[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FXHG6CKTAFNJD4QF9D4D6Z":3,"skill-same:01M6FXHG6CKTAFNJD4QF9D4D6Z":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":39,"install":40,"resources":53},"01M6FXHG6CKTAFNJD4QF9D4D6Z","jb-protocol-fees",null,"Juicebox V5 and Revnet protocol fee structures and UI integration patterns.\nUse when: (1) implementing payout limits with fee calculations, (2) building cash out\u002Fredeem UIs,\n(3) building loan interfaces for revnets, (4) displaying fee breakdowns to users,\n(5) calculating net amounts after fees, (6) adding custom UI fees on top of protocol fees.\nCovers the 2.5% NANA fee, 2.5% Revnet cash out fee, 1% REV loan fee, and variable loan fees.","kbarbel640-del\u002Fskills","kbarbel640-del","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F255315490?v=4","01M6CJPPQGCCESXMG3K7BBGQ5J","01M6CJPPX2PB2BCZERFVM2C2B3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fmejango\u002Fjuicy\u002Fjb-protocol-fees\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27],"protocol","fees","jb protocol fees","ui","integration","use","patterns","users","with","juicebox v5","2026-11-10 10:12:30",false,"---\nname: jb-protocol-fees\ndescription: |\n  Juicebox V5 and Revnet protocol fee structures and UI integration patterns.\n  Use when: (1) implementing payout limits with fee calculations, (2) building cash out\u002Fredeem UIs,\n  (3) building loan interfaces for revnets, (4) displaying fee breakdowns to users,\n  (5) calculating net amounts after fees, (6) adding custom UI fees on top of protocol fees.\n  Covers the 2.5% NANA fee, 2.5% Revnet cash out fee, 1% REV loan fee, and variable loan fees.\n---\n\n# Juicebox V5 & Revnet Protocol Fees\n\nComplete guide to protocol fees and how UIs should handle them.\n\n## Problem\n\nJuicebox V5 and Revnet have multiple fee layers that UIs must correctly calculate and display:\n- NANA 2.5% fee on payouts\n- Revnet 2.5% fee on cash outs\n- Revnet 1% + 2.5% fees on loans\n- Variable loan fees over time\n\nUIs need to show users accurate net amounts and provide transparent fee breakdowns.\n\n## Fee Structure Overview\n\n| Fee | Rate | Source Contract | Recipient |\n|-----|------|-----------------|-----------|\n| NANA payout fee | 2.5% | `JBMultiTerminal.sol:86` | Project #1 (JBX) |\n| Revnet cash out fee | 2.5% | `REVDeployer.sol:95` | REV revnet |\n| REV loan fee | 1% | `REVLoans.sol:89` | REV revnet |\n| Source loan fee | 2.5%-50% | `REVLoans.sol:92` | Source revnet |\n| Variable loan fee | 0-100% | `REVLoans.sol:377-403` | Source revnet |\n\n---\n\n## 1. NANA Fee (2.5%)\n\n### Contract Definition\n\n**File:** `nana-core-v5\u002Fsrc\u002FJBMultiTerminal.sol:86`\n```solidity\nuint256 public constant override FEE = 25; \u002F\u002F 2.5% (out of MAX_FEE = 1000)\n```\n\n### When Applied\n\n- Payouts to wallet addresses (not Juicebox projects)\n- Payouts to split hooks\n- Surplus allowance usage\n- Cash outs when `cashOutTaxRate > 0`\n\n### When NOT Applied\n\n- Payouts to other Juicebox projects (inter-project transfers are fee-free)\n- Feeless addresses (managed by `JBFeelessAddresses` contract)\n- Cash outs with 100% redemption rate (`cashOutTaxRate == 0`)\n\n### Fee Calculation Library\n\n**File:** `nana-core-v5\u002Fsrc\u002Flibraries\u002FJBFees.sol`\n\n```solidity\n\u002F\u002F Calculate fee from gross amount: fee = amount * 25 \u002F 1000\nfunction feeAmountFrom(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {\n    return mulDiv(amountBeforeFee, feePercent, JBConstants.MAX_FEE);\n}\n\n\u002F\u002F Calculate fee needed to achieve specific net amount\nfunction feeAmountResultingIn(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {\n    return mulDiv(amountAfterFee, JBConstants.MAX_FEE, JBConstants.MAX_FEE - feePercent) - amountAfterFee;\n}\n```\n\n### UI Implementation (juice-interface)\n\n**File:** `juice-interface\u002Fsrc\u002Fpackages\u002Fv4\u002Futils\u002Fdistributions.ts`\n\n```typescript\nexport const JB_FEE = 0.025\n\n\u002F\u002F Subtract fee from gross amount\nexport function deriveAmountAfterFee(amount: number) {\n  return amount - amount * JB_FEE  \u002F\u002F amount * 0.975\n}\n\n\u002F\u002F Calculate gross amount needed to achieve net\nexport function deriveAmountBeforeFee(amount: number) {\n  return amount \u002F (1 - JB_FEE)  \u002F\u002F amount \u002F 0.975\n}\n\n\u002F\u002F Apply fee conditionally based on split type\nexport function derivePayoutAmount({ payoutSplit, distributionLimit, dontApplyFee }) {\n  const amountBeforeFee = payoutSplit.percent.toFloat() * distributionLimit\n  if (isJuiceboxProjectSplit(payoutSplit) || dontApplyFee)\n    return amountBeforeFee  \u002F\u002F No fee for project splits\n  return deriveAmountAfterFee(amountBeforeFee)\n}\n```\n\n### UI Display Pattern\n\nShow fee tooltip on payout amounts:\n```\nAmount: 100 ETH\n→ \"97.5 ETH after 2.5% JBX membership fee\"\n```\n\nTooltip explanation:\n> \"Payouts to Ethereum addresses incur a 2.5% fee. Your project will receive JBX in return.\"\n\n---\n\n## 2. Revnet Cash Out Fee (2.5%)\n\n### Contract Definition\n\n**File:** `revnet-core-v5\u002Fsrc\u002FREVDeployer.sol:95`\n```solidity\nuint256 public constant override FEE = 25; \u002F\u002F 2.5%\n```\n\n### How It Works\n\n1. User initiates cash out of X tokens\n2. 2.5% of tokens (X * 0.025) are redirected to pay the REV revnet\n3. User receives REV tokens in return for the fee portion\n4. Remaining 97.5% of tokens are cashed out for the underlying asset\n\n### Exemptions\n\n- **Suckers** (cross-chain bridge contracts) do NOT pay cash out fees\n- Check at `REVDeployer.sol:282-283`\n\n### UI Implementation (revnet-app)\n\n**File:** `revnet-app\u002Fsrc\u002Flib\u002FfeeHelpers.ts`\n\n```typescript\nimport { REVNET_CASHOUT_FEE_PERCENT } from \"@\u002Fapp\u002Fconstants\"; \u002F\u002F 0.025\n\nexport function applyRevFee(tokenAmount: bigint) {\n  return (tokenAmount * BigInt((1 - REVNET_CASHOUT_FEE_PERCENT) * 1000)) \u002F 1000n;\n}\n\nexport function applyNanaFee(reclaimableAmount: bigint) {\n  return (reclaimableAmount * BigInt((1 - JBDAO_CASHOUT_FEE_PERCENT) * 1000)) \u002F 1000n;\n}\n```\n\n### Layered Fee Application\n\nFor cash outs, apply BOTH fees:\n```typescript\n\u002F\u002F In reclaimableSurplus.ts\nconst afterRevFee = applyRevFee(tokenAmountWei)    \u002F\u002F 2.5% Revnet fee\nconst afterAllFees = applyNanaFee(afterRevFee)     \u002F\u002F 2.5% NANA fee on remainder\n```\n\n### UI Display Pattern\n\nShow net amount directly:\n```\nCash out: 1000 tokens\n→ \"You'll get ~X ETH\"\n```\n\nThe displayed amount should have both fees pre-applied.\n\n---\n\n## 3. Revnet Loan Fees\n\n### Contract Definitions\n\n**File:** `revnet-core-v5\u002Fsrc\u002FREVLoans.sol:83-92`\n\n```solidity\nuint256 public constant override LOAN_LIQUIDATION_DURATION = 3650 days;  \u002F\u002F 10 years\nuint256 public constant override MAX_PREPAID_FEE_PERCENT = 500;          \u002F\u002F 50% max\nuint256 public constant override REV_PREPAID_FEE_PERCENT = 10;           \u002F\u002F 1% REV fee\nuint256 public constant override MIN_PREPAID_FEE_PERCENT = 25;           \u002F\u002F 2.5% min source fee\n```\n\n### Fee Components\n\n| Fee | Rate | When Charged | Recipient |\n|-----|------|--------------|-----------|\n| REV fee | 1% | At borrow time | REV revnet |\n| Source fee | 2.5%-50% | At borrow time (prepaid) | Source revnet |\n| Variable fee | 0-100% | After prepaid period expires | Source revnet |\n\n### Prepaid Fee Mechanics\n\n- User chooses prepaid percentage (2.5% to 50%)\n- Higher prepaid = longer fee-free period\n- Prepaid period = `(prepaidPercent \u002F 50%) * 10 years`\n\nExamples:\n- 2.5% prepaid → 6 months fee-free\n- 25% prepaid → 5 years fee-free\n- 50% prepaid → 10 years fee-free (no variable fees ever)\n\n### Variable Fee Calculation\n\n**File:** `revnet-core-v5\u002Fsrc\u002FREVLoans.sol:377-403`\n\nAfter prepaid period expires:\n```\nvariableFee = (elapsedAfterPrepaid \u002F remainingTime) * amountAfterFixedFees\n```\n\nThe fee increases linearly from 0% to 100% over the remaining time until 10 years.\n\n### UI Implementation (revnet-app)\n\n**File:** `revnet-app\u002Fsrc\u002Flib\u002FfeeHelpers.ts`\n\n```typescript\nexport function generateFeeData({\n  grossBorrowedEth,\n  prepaidPercent,\n  fixedLoanFee = 0.035,  \u002F\u002F 3.5% = 1% REV + 2.5% source\n}: {\n  grossBorrowedEth: number;\n  prepaidPercent: string;\n  fixedLoanFee?: number;\n}) {\n  const MAX_YEARS = 10;\n  const monthsToPrepay = (parseFloat(prepaidPercent) \u002F 50) * 120;\n  const prepaidDuration = monthsToPrepay \u002F 12;\n\n  \u002F\u002F Fixed fees come off immediately\n  const fixedFee = grossBorrowedEth * fixedLoanFee;\n\n  \u002F\u002F Prepaid fee calculation\n  const feeBpsBigInt = calcPrepaidFee(Math.round(monthsToPrepay));\n  const prepaidFee = (grossBorrowedEth * Number(feeBpsBigInt)) \u002F 10000;\n\n  \u002F\u002F Amount user actually receives\n  const amountUserReceives = grossBorrowedEth - fixedFee - prepaidFee;\n\n  \u002F\u002F Generate fee curve data points\n  const data = [];\n  for (let year = 0; year \u003C= MAX_YEARS; year += 0.25) {\n    let variableFee = 0;\n    if (year > prepaidDuration) {\n      const elapsedAfterPrepaid = year - prepaidDuration;\n      const remainingTime = MAX_YEARS - prepaidDuration;\n      variableFee = amountUserReceives * (elapsedAfterPrepaid \u002F remainingTime);\n    }\n    const totalCostToUnlock = grossBorrowedEth + variableFee;\n    data.push({ year, totalCost: totalCostToUnlock });\n  }\n  return data;\n}\n```\n\n### UI Display Pattern\n\n**SimulatedLoanCard** shows inline breakdown:\n```\nAmount borrowed: 1.0 ETH\nTo beneficiary after fees: 0.945 ETH\n\n[Tooltip]\n- Collateral used: 1000 REVNET\n- Protocol & project fees: 0.055 ETH (5.5%)\n- Max cost to unlock before 10 years: 1.945 ETH\n```\n\n**LoanFeeChart** visualizes the fee curve:\n- X-axis: Years (0-10)\n- Y-axis: Total cost to unlock collateral\n- Slider: Prepaid percentage (2.5%-50%)\n\n---\n\n## 4. Adding Custom UI Fees\n\nUIs are welcome to add fees on top of protocol fees. Pattern:\n\n```typescript\nconst UI_FEE = 0.005 \u002F\u002F 0.5% UI operator fee\n\nfunction applyAllFees(amount: bigint, includeUIFee = true) {\n  \u002F\u002F Apply protocol fees first\n  let result = applyNanaFee(amount)  \u002F\u002F 2.5%\n\n  \u002F\u002F Optionally apply UI fee\n  if (includeUIFee) {\n    result = result - (result * BigInt(UI_FEE * 10000)) \u002F 10000n\n  }\n\n  return result\n}\n```\n\n**Best practices:**\n1. Be transparent - show users the full breakdown\n2. Apply UI fee after protocol fees (on the remainder)\n3. Route UI fee to your operator address\n4. Display separately: \"Protocol fee: 2.5% | Platform fee: 0.5%\"\n\n---\n\n## 5. Fee Display Best Practices\n\n### Payout Tables (juice-interface pattern)\n\n```\nSub-total:           100.00 ETH\nOwner remainder:      10.00 ETH\nFees (2.5%):           2.75 ETH\n─────────────────────────────\nTotal:               112.75 ETH\n```\n\n### Cash Out Preview\n\n```\nCashing out: 1,000 tokens\nYou'll receive: ~0.95 ETH\n  └─ After 2.5% Revnet fee + 2.5% JBX fee\n```\n\n### Loan Summary\n\n```\nBorrowing: 1.0 ETH\nYou'll receive: 0.945 ETH\nFees paid now:\n  - REV fee (1%): 0.01 ETH\n  - Prepaid fee (4.5%): 0.045 ETH\nTo unlock collateral: 1.0 ETH (+ variable fees after 1 year)\n```\n\n---\n\n## Key Source Files\n\n### Contracts\n| File | Purpose |\n|------|---------|\n| `nana-core-v5\u002Fsrc\u002FJBMultiTerminal.sol` | NANA fee logic (lines 86, 555, 587, 1129, 2028) |\n| `nana-core-v5\u002Fsrc\u002Flibraries\u002FJBFees.sol` | Fee calculation library |\n| `nana-core-v5\u002Fsrc\u002FJBFeelessAddresses.sol` | Feeless address management |\n| `revnet-core-v5\u002Fsrc\u002FREVDeployer.sol` | Cash out fee (lines 95, 270-333, 567-624) |\n| `revnet-core-v5\u002Fsrc\u002FREVLoans.sol` | Loan fees (lines 83-92, 377-403, 821-851) |\n\n### UI Implementations\n| File | Purpose |\n|------|---------|\n| `juice-interface\u002Fsrc\u002Fpackages\u002Fv4\u002Futils\u002Fdistributions.ts` | Payout fee calculations |\n| `juice-interface\u002Fsrc\u002Fpackages\u002Fv4\u002Fcomponents\u002FFeeTooltipLabel.tsx` | Fee display component |\n| `revnet-app\u002Fsrc\u002Flib\u002FfeeHelpers.ts` | Revnet fee helpers |\n| `revnet-app\u002Fsrc\u002Fapp\u002F[slug]\u002Fcomponents\u002FValue\u002FSimulatedLoanCard.tsx` | Loan fee display |\n| `revnet-app\u002Fsrc\u002Fapp\u002F[slug]\u002Fcomponents\u002FValue\u002FLoanFeeChart.tsx` | Fee curve visualization |\n\n---\n\n## Common Mistakes to Avoid\n\n1. **Forgetting project splits are fee-free**: Always check `isJuiceboxProjectSplit()` before applying fees\n2. **Double-applying fees**: Protocol fees are applied on-chain; UI should only display, not re-apply\n3. **Ignoring the NANA fee on cash outs**: Cash outs have BOTH Revnet (2.5%) and NANA (2.5%) fees\n4. **Showing gross instead of net**: Users care about what they receive, not what they send\n5. **Missing the variable loan fee**: Loan costs increase over time after prepaid period\n\n## Verification\n\nTo verify fee calculations match on-chain behavior:\n1. Compare UI-calculated amounts with actual transaction results\n2. Test with feeless addresses to confirm exemptions work\n3. Verify loan fee curves match contract's `_determineSourceFeeAmount()` logic\n","# Juicebox V5 & Revnet Protocol Fees\n\nComplete guide to protocol fees and how UIs should handle them.\n\n## Problem\n\nJuicebox V5 and Revnet have multiple fee layers that UIs must correctly calculate and display:\n- NANA 2.5% fee on payouts\n- Revnet 2.5% fee on cash outs\n- Revnet 1% + 2.5% fees on loans\n- Variable loan fees over time\n\nUIs need to show users accurate net amounts and provide transparent fee breakdowns.\n\n## Fee Structure Overview\n\n| Fee | Rate | Source Contract | Recipient |\n|-----|------|-----------------|-----------|\n| NANA payout fee | 2.5% | `JBMultiTerminal.sol:86` | Project #1 (JBX) |\n| Revnet cash out fee | 2.5% | `REVDeployer.sol:95` | REV revnet |\n| REV loan fee | 1% | `REVLoans.sol:89` | REV revnet |\n| Source loan fee | 2.5%-50% | `REVLoans.sol:92` | Source revnet |\n| Variable loan fee | 0-100% | `REVLoans.sol:377-403` | Source revnet |\n\n---\n\n## 1. NANA Fee (2.5%)\n\n### Contract Definition\n\n**File:** `nana-core-v5\u002Fsrc\u002FJBMultiTerminal.sol:86`\n```solidity\nuint256 public constant override FEE = 25; \u002F\u002F 2.5% (out of MAX_FEE = 1000)\n```\n\n### When Applied\n\n- Payouts to wallet addresses (not Juicebox projects)\n- Payouts to split hooks\n- Surplus allowance usage\n- Cash outs when `cashOutTaxRate > 0`\n\n### When NOT Applied\n\n- Payouts to other Juicebox projects (inter-project transfers are fee-free)\n- Feeless addresses (managed by `JBFeelessAddresses` contract)\n- Cash outs with 100% redemption rate (`cashOutTaxRate == 0`)\n\n### Fee Calculation Library\n\n**File:** `nana-core-v5\u002Fsrc\u002Flibraries\u002FJBFees.sol`\n\n```solidity\n\u002F\u002F Calculate fee from gross amount: fee = amount * 25 \u002F 1000\nfunction feeAmountFrom(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {\n    return mulDiv(amountBeforeFee, feePercent, JBConstants.MAX_FEE);\n}\n\n\u002F\u002F Calculate fee needed to achieve specific net amount\nfunction feeAmountResultingIn(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {\n    return mulDiv(amountAfterFee, JBConstants.MAX_FEE, JBConstants.MAX_FEE - feePercent) - amountAfterFee;\n}\n```\n\n### UI Implementation (juice-interface)\n\n**File:** `juice-interface\u002Fsrc\u002Fpackages\u002Fv4\u002Futils\u002Fdistributions.ts`\n\n```typescript\nexport const JB_FEE = 0.025\n\n\u002F\u002F Subtract fee from gross amount\nexport function deriveAmountAfterFee(amount: number) {\n  return amount - amount * JB_FEE  \u002F\u002F amount * 0.975\n}\n\n\u002F\u002F Calculate gross amount needed to achieve net\nexport function deriveAmountBeforeFee(amount: number) {\n  return amount \u002F (1 - JB_FEE)  \u002F\u002F amount \u002F 0.975\n}\n\n\u002F\u002F Apply fee conditionally based on split type\nexport function derivePayoutAmount({ payoutSplit, distributionLimit, dontApplyFee }) {\n  const amountBeforeFee = payoutSplit.percent.toFloat() * distributionLimit\n  if (isJuiceboxProjectSplit(payoutSplit) || dontApplyFee)\n    return amountBeforeFee  \u002F\u002F No fee for project splits\n  return deriveAmountAfterFee(amountBeforeFee)\n}\n```\n\n### UI Display Pattern\n\nShow fee tooltip on payout amounts:\n```\nAmount: 100 ETH\n→ \"97.5 ETH after 2.5% JBX membership fee\"\n```\n\nTooltip explanation:\n> \"Payouts to Ethereum addresses incur a 2.5% fee. Your project will receive JBX in return.\"\n\n---\n\n## 2. Revnet Cash Out Fee (2.5%)\n\n### Contract Definition\n\n**File:** `revnet-core-v5\u002Fsrc\u002FREVDeployer.sol:95`\n```solidity\nuint256 public constant override FEE = 25; \u002F\u002F 2.5%\n```\n\n### How It Works\n\n1. User initiates cash out of X tokens\n2. 2.5% of tokens (X * 0.025) are redirected to pay the REV revnet\n3. User receives REV tokens in return for the fee portion\n4. Remaining 97.5% of tokens are cashed out for the underlying asset\n\n### Exemptions\n\n- **Suckers** (cross-chain bridge contracts) do NOT pay cash out fees\n- Check at `REVDeployer.sol:282-283`\n\n### UI Implementation (revnet-app)\n\n**File:** `revnet-app\u002Fsrc\u002Flib\u002FfeeHelpers.ts`\n\n```typescript\nimport { REVNET_CASHOUT_FEE_PERCENT } from \"@\u002Fapp\u002Fconstants\"; \u002F\u002F 0.025\n\nexport function applyRevFee(tokenAmount: bigint) {\n  return (tokenAmount * BigInt((1 - REVNET_CASHOUT_FEE_PERCENT) * 1000)) \u002F 1000n;\n}\n\nexport function applyNanaFee(reclaimableAmount: bigint) {\n  return (reclaimableAmount * BigInt((1 - JBDAO_CASHOUT_FEE_PERCENT) * 1000)) \u002F 1000n;\n}\n```\n\n### Layered Fee Application\n\nFor cash outs, apply BOTH fees:\n```typescript\n\u002F\u002F In reclaimableSurplus.ts\nconst afterRevFee = applyRevFee(tokenAmountWei)    \u002F\u002F 2.5% Revnet fee\nconst afterAllFees = applyNanaFee(afterRevFee)     \u002F\u002F 2.5% NANA fee on remainder\n```\n\n### UI Display Pattern\n\nShow net amount directly:\n```\nCash out: 1000 tokens\n→ \"You'll get ~X ETH\"\n```\n\nThe displayed amount should have both fees pre-applied.\n\n---\n\n## 3. Revnet Loan Fees\n\n### Contract Definitions\n\n**File:** `revnet-core-v5\u002Fsrc\u002FREVLoans.sol:83-92`\n\n```solidity\nuint256 public constant override LOAN_LIQUIDATION_DURATION = 3650 days;  \u002F\u002F 10 years\nuint256 public constant override MAX_PREPAID_FEE_PERCENT = 500;          \u002F\u002F 50% max\nuint256 public constant override REV_PREPAID_FEE_PERCENT = 10;           \u002F\u002F 1% REV fee\nuint256 public constant override MIN_PREPAID_FEE_PERCENT = 25;           \u002F\u002F 2.5% min source fee\n```\n\n### Fee Components\n\n| Fee | Rate | When Charged | Recipient |\n|-----|------|--------------|-----------|\n| REV fee | 1% | At borrow time | REV revnet |\n| Source fee | 2.5%-50% | At borrow time (prepaid) | Source revnet |\n| Variable fee | 0-100% | After prepaid period expires | Source revnet |\n\n### Prepaid Fee Mechanics\n\n- User chooses prepaid percentage (2.5% to 50%)\n- Higher prepaid = longer fee-free period\n- Prepaid period = `(prepaidPercent \u002F 50%) * 10 years`\n\nExamples:\n- 2.5% prepaid → 6 months fee-free\n- 25% prepaid → 5 years fee-free\n- 50% prepaid → 10 years fee-free (no variable fees ever)\n\n### Variable Fee Calculation\n\n**File:** `revnet-core-v5\u002Fsrc\u002FREVLoans.sol:377-403`\n\nAfter prepaid period expires:\n```\nvariableFee = (elapsedAfterPrepaid \u002F remainingTime) * amountAfterFixedFees\n```\n\nThe fee increases linearly from 0% to 100% over the remaining time until 10 years.\n\n### UI Implementation (revnet-app)\n\n**File:** `revnet-app\u002Fsrc\u002Flib\u002FfeeHelpers.ts`\n\n```typescript\nexport function generateFeeData({\n  grossBorrowedEth,\n  prepaidPercent,\n  fixedLoanFee = 0.035,  \u002F\u002F 3.5% = 1% REV + 2.5% source\n}: {\n  grossBorrowedEth: number;\n  prepaidPercent: string;\n  fixedLoanFee?: number;\n}) {\n  const MAX_YEARS = 10;\n  const monthsToPrepay = (parseFloat(prepaidPercent) \u002F 50) * 120;\n  const prepaidDuration = monthsToPrepay \u002F 12;\n\n  \u002F\u002F Fixed fees come off immediately\n  const fixedFee = grossBorrowedEth * fixedLoanFee;\n\n  \u002F\u002F Prepaid fee calculation\n  const feeBpsBigInt = calcPrepaidFee(Math.round(monthsToPrepay));\n  const prepaidFee = (grossBorrowedEth * Number(feeBpsBigInt)) \u002F 10000;\n\n  \u002F\u002F Amount user actually receives\n  const amountUserReceives = grossBorrowedEth - fixedFee - prepaidFee;\n\n  \u002F\u002F Generate fee curve data points\n  const data = [];\n  for (let year = 0; year \u003C= MAX_YEARS; year += 0.25) {\n    let variableFee = 0;\n    if (year > prepaidDuration) {\n      const elapsedAfterPrepaid = year - prepaidDuration;\n      const remainingTime = MAX_YEARS - prepaidDuration;\n      variableFee = amountUserReceives * (elapsedAfterPrepaid \u002F remainingTime);\n    }\n    const totalCostToUnlock = grossBorrowedEth + variableFee;\n    data.push({ year, totalCost: totalCostToUnlock });\n  }\n  return data;\n}\n```\n\n### UI Display Pattern\n\n**SimulatedLoanCard** shows inline breakdown:\n```\nAmount borrowed: 1.0 ETH\nTo beneficiary after fees: 0.945 ETH\n\n[Tooltip]\n- Collateral used: 1000 REVNET\n- Protocol & project fees: 0.055 ETH (5.5%)\n- Max cost to unlock before 10 years: 1.945 ETH\n```\n\n**LoanFeeChart** visualizes the fee curve:\n- X-axis: Years (0-10)\n- Y-axis: Total cost to unlock collateral\n- Slider: Prepaid percentage (2.5%-50%)\n\n---\n\n## 4. Adding Custom UI Fees\n\nUIs are welcome to add fees on top of protocol fees. Pattern:\n\n```typescript\nconst UI_FEE = 0.005 \u002F\u002F 0.5% UI operator fee\n\nfunction applyAllFees(amount: bigint, includeUIFee = true) {\n  \u002F\u002F Apply protocol fees first\n  let result = applyNanaFee(amount)  \u002F\u002F 2.5%\n\n  \u002F\u002F Optionally apply UI fee\n  if (includeUIFee) {\n    result = result - (result * BigInt(UI_FEE * 10000)) \u002F 10000n\n  }\n\n  return result\n}\n```\n\n**Best practices:**\n1. Be transparent - show users the full breakdown\n2. Apply UI fee after protocol fees (on the remainder)\n3. Route UI fee to your operator address\n4. Display separately: \"Protocol fee: 2.5% | Platform fee: 0.5%\"\n\n---\n\n## 5. Fee Display Best Practices\n\n### Payout Tables (juice-interface pattern)\n\n```\nSub-total:           100.00 ETH\nOwner remainder:      10.00 ETH\nFees (2.5%):           2.75 ETH\n─────────────────────────────\nTotal:               112.75 ETH\n```\n\n### Cash Out Preview\n\n```\nCashing out: 1,000 tokens\nYou'll receive: ~0.95 ETH\n  └─ After 2.5% Revnet fee + 2.5% JBX fee\n```\n\n### Loan Summary\n\n```\nBorrowing: 1.0 ETH\nYou'll receive: 0.945 ETH\nFees paid now:\n  - REV fee (1%): 0.01 ETH\n  - Prepaid fee (4.5%): 0.045 ETH\nTo unlock collateral: 1.0 ETH (+ variable fees after 1 year)\n```\n\n---\n\n## Key Source Files\n\n### Contracts\n| File | Purpose |\n|------|---------|\n| `nana-core-v5\u002Fsrc\u002FJBMultiTerminal.sol` | NANA fee logic (lines 86, 555, 587, 1129, 2028) |\n| `nana-core-v5\u002Fsrc\u002Flibraries\u002FJBFees.sol` | Fee calculation library |\n| `nana-core-v5\u002Fsrc\u002FJBFeelessAddresses.sol` | Feeless address management |\n| `revnet-core-v5\u002Fsrc\u002FREVDeployer.sol` | Cash out fee (lines 95, 270-333, 567-624) |\n| `revnet-core-v5\u002Fsrc\u002FREVLoans.sol` | Loan fees (lines 83-92, 377-403, 821-851) |\n\n### UI Implementations\n| File | Purpose |\n|------|---------|\n| `juice-interface\u002Fsrc\u002Fpackages\u002Fv4\u002Futils\u002Fdistributions.ts` | Payout fee calculations |\n| `juice-interface\u002Fsrc\u002Fpackages\u002Fv4\u002Fcomponents\u002FFeeTooltipLabel.tsx` | Fee display component |\n| `revnet-app\u002Fsrc\u002Flib\u002FfeeHelpers.ts` | Revnet fee helpers |\n| `revnet-app\u002Fsrc\u002Fapp\u002F[slug]\u002Fcomponents\u002FValue\u002FSimulatedLoanCard.tsx` | Loan fee display |\n| `revnet-app\u002Fsrc\u002Fapp\u002F[slug]\u002Fcomponents\u002FValue\u002FLoanFeeChart.tsx` | Fee curve visualization |\n\n---\n\n## Common Mistakes to Avoid\n\n1. **Forgetting project splits are fee-free**: Always check `isJuiceboxProjectSplit()` before applying fees\n2. **Double-applying fees**: Protocol fees are applied on-chain; UI should only display, not re-apply\n3. **Ignoring the NANA fee on cash outs**: Cash outs have BOTH Revnet (2.5%) and NANA (2.5%) fees\n4. **Showing gross instead of net**: Users care about what they receive, not what they send\n5. **Missing the variable loan fee**: Loan costs increase over time after prepaid period\n\n## Verification\n\nTo verify fee calculations match on-chain behavior:\n1. Compare UI-calculated amounts with actual transaction results\n2. Test with feeless addresses to confirm exemptions work\n3. Verify loan fee curves match contract's `_determineSourceFeeAmount()` logic\n",{"name":5,"description":7},"main","e7e336ac628c3e3bd771aff1aaa469c93778f94a","skills\u002Fmejango\u002Fjuicy\u002Fjb-protocol-fees",0,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del","2026-08-23 22:39:37",{"source":8,"skillName":5,"commands":41,"prompt":51,"zipAvailable":52},[42,45,48],{"tool":43,"command":44},"npx","npx skills add kbarbel640-del\u002Fskills --skill jb-protocol-fees",{"tool":46,"command":47},"bunx","bunx skills add kbarbel640-del\u002Fskills --skill jb-protocol-fees",{"tool":49,"command":50},"pnpm","pnpm dlx skills add kbarbel640-del\u002Fskills --skill jb-protocol-fees","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fmejango\u002Fjuicy\u002Fjb-protocol-fees\u002FSKILL.md",true,[],[55,85,113,134,140,160],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":66,"publishedAt":28},"01M6G8J55967D6281ACMKAKTEQ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[61],{"categoryNo":62,"categoryName":63,"taxonomyType":64,"taxonomyTypeDesc":65},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[67,68,69,26,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84],"crowd prompting","prompting","api","tokens","domain","world","prompts","operations","instructions","text","tool","system","improve","productivity","marketplace","https","content","ai agents",{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":96,"publishedAt":28},"01M6G8J0PKPAYVET6BWE8W4C26","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[91],{"categoryNo":92,"categoryName":93,"taxonomyType":94,"taxonomyTypeDesc":95},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[97,69,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,73,23],"dilemm ai","arena","analyze","browser","openclaw agent","create","automation","browser automation","bot","openclaw","design","strategy","headless","compete","submit","matchmaking",{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":122,"publishedAt":28},"01M6G8HWAF3K9SW7NP3Z83CPJ6","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, or submitting paper reviews via API at http:\u002F\u002F150.158.152.82:8000.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Fweak-accept\u002FSKILL.md",[119],{"categoryNo":120,"categoryName":121,"taxonomyType":94,"taxonomyTypeDesc":95},"01JBSEEDCAT000000000000021","资料检索与研究",[123,124,125,126,127,128,129,26,130,111,23,131,69,132,133],"arxiv paper reviews","reviews","arxiv","paper","crawler","papers","comments","fetch","read","http","via",{"skillNo":135,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":139,"publishedAt":28},"01M6G8HQJ7N7WMY6YV7D7SSJ16","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[138],{"categoryNo":120,"categoryName":121,"taxonomyType":94,"taxonomyTypeDesc":95},[126,125,124,123,133,128,129,26,127,111,23,130,131,69,132],{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":28},"01M6G8HM95Y64JNVFC2HN4E2BG","git-summary","Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzweack\u002Fgit-summary\u002FSKILL.md",[],[147,148,149,150,151,152,153,154,155,156,157,158,159],"git","summary","git summary","commits","repository","win32","status","linux","contributors","true","quick","get","branches",{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":164,"categories":165,"keywords":170,"publishedAt":28},"01M6G8HGEGF05CNEJCGVYFSC4R","agent-constitution","Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fztsalexey\u002Fagent-constitution\u002FSKILL.md",[166,167],{"categoryNo":92,"categoryName":93,"taxonomyType":94,"taxonomyTypeDesc":95},{"categoryNo":168,"categoryName":169,"taxonomyType":64,"taxonomyTypeDesc":65},"01JBSEEDCAT000000000000037","律师与法务",[171,172,173,174,26,175,176,33,177,131,178,179,180,181,182,82,183,184,185],"agent constitution","constitution","contracts","tree","query","base","log","check","Rules","projects","compliance","actions","state","governance","github"]