技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
jb-cash-out-hook【数据与研究】Generate custom Juicebox V5 cash out hooks from natural language specifications. Creates Solidity contracts implementing IJBCashOutHook and/or IJBRulesetDataHook with Foundry tests. First evaluates if off-the-shelf solutions (721 hook, Revnet) fit the use case.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Generate custom cash out hooks for Juicebox V5 projects based on natural language specifications.
Always evaluate if an off-the-shelf solution fits the user's needs:
| User Need | Recommended Solution |
|---|---|
| Burn NFTs to reclaim funds | Deploy nana-721-hook-v5 directly |
| Fee extraction on cash outs | Deploy a Revnet (extracts 2.5% fees) |
| Autonomous treasury with cash out rules | Use revnet-core-v5 |
If off-the-shelf solutions fit, guide the user to deploy them instead of generating custom code.
Cash out hooks in V5 follow a two-stage pattern:
IJBRulesetDataHookIJBCashOutHookstruct JBAfterCashOutRecordedContext {
address holder; // Token holder cashing out
uint256 projectId; // Project ID
uint256 rulesetId; // Current ruleset ID
uint256 cashOutCount; // Tokens being cashed out
JBTokenAmount reclaimedAmount; // Amount reclaimed by holder
JBTokenAmount forwardedAmount; // Amount forwarded to hook
uint256 cashOutTaxRate; // Tax rate (0-10000)
address payable beneficiary; // Receives reclaimed funds
bytes hookMetadata; // Data from data hook
bytes cashOutMetadata; // Data from cash out initiator
}
Use when you only need to execute logic after cash out without modifying calculations.
contract SimpleCashOutHook is IJBCashOutHook, ERC165 {
function afterCashOutRecordedWith(JBAfterCashOutRecordedContext calldata context) external payable {
// Validate caller is a project terminal
// Execute custom logic with forwarded funds
}
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return interfaceId == type(IJBCashOutHook).interfaceId || super.supportsInterface(interfaceId);
}
}
Use when you need to modify tax rate, supply calculations, or intercept funds.
contract FullCashOutHook is IJBRulesetDataHook, IJBCashOutHook, ERC165 {
function beforeCashOutRecordedWith(JBBeforeCashOutRecordedContext calldata context)
external view returns (
uint256 cashOutTaxRate,
uint256 cashOutCount,
uint256 totalSupply,
JBCashOutHookSpecification[] memory hookSpecifications
)
{
// Calculate custom tax rate or modify supply
// Specify hooks and forwarded amounts
}
function afterCashOutRecordedWith(JBAfterCashOutRecordedContext calldata context) external payable {
// Execute with forwarded funds
// Handle fee extraction, burning, etc.
}
function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
external view returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications)
{
// Pass through if not handling payments
return (context.weight, new JBPayHookSpecification[](0));
}
function hasMintPermissionFor(uint256) external pure returns (bool) {
return false;
}
}
Route a percentage of cash outs to a fee beneficiary.
function afterCashOutRecordedWith(JBAfterCashOutRecordedContext calldata context) external payable {
// Forward fee to beneficiary
uint256 feeAmount = context.forwardedAmount.value;
if (feeAmount > 0) {
// Process fee payment
}
}
Burn NFTs when cashing out to reclaim proportional funds.
function afterCashOutRecordedWith(JBAfterCashOutRecordedContext calldata context) external payable {
// Decode token IDs from metadata
uint256[] memory tokenIds = abi.decode(context.cashOutMetadata, (uint256[]));
// Verify ownership and burn
for (uint256 i; i < tokenIds.length; i++) {
_burn(tokenIds[i]);
}
}
Generate:
src/src/interfaces/ if neededtest/script/ if requestedUse Foundry project structure with forge-std.