executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
jb-protocol-feesJuicebox V5 and Revnet protocol fee structures and UI integration patterns. Use when: (1) implementing payout limits with fee calculations, (2) building cash out/redeem UIs, (3) building loan interfaces for revnets, (4) displaying fee breakdowns to users, (5) calculating net amounts after fees, (6) adding custom UI fees on top of protocol fees. Covers the 2…
Independent GitHub snapshot · Automated classification · Original documentation governs
Complete guide to protocol fees and how UIs should handle them.
Juicebox V5 and Revnet have multiple fee layers that UIs must correctly calculate and display:
UIs need to show users accurate net amounts and provide transparent fee breakdowns.
| Fee | Rate | Source Contract | Recipient |
|---|---|---|---|
| NANA payout fee | 2.5% | JBMultiTerminal.sol:86 | Project #1 (JBX) |
| Revnet cash out fee | 2.5% | REVDeployer.sol:95 | REV revnet |
| REV loan fee | 1% | REVLoans.sol:89 | REV revnet |
| Source loan fee | 2.5%-50% | REVLoans.sol:92 | Source revnet |
| Variable loan fee | 0-100% | REVLoans.sol:377-403 | Source revnet |
File: nana-core-v5/src/JBMultiTerminal.sol:86
uint256 public constant override FEE = 25; // 2.5% (out of MAX_FEE = 1000)
cashOutTaxRate > 0JBFeelessAddresses contract)cashOutTaxRate == 0)File: nana-core-v5/src/libraries/JBFees.sol
// Calculate fee from gross amount: fee = amount * 25 / 1000
function feeAmountFrom(uint256 amountBeforeFee, uint256 feePercent) internal pure returns (uint256) {
return mulDiv(amountBeforeFee, feePercent, JBConstants.MAX_FEE);
}
// Calculate fee needed to achieve specific net amount
function feeAmountResultingIn(uint256 amountAfterFee, uint256 feePercent) internal pure returns (uint256) {
return mulDiv(amountAfterFee, JBConstants.MAX_FEE, JBConstants.MAX_FEE - feePercent) - amountAfterFee;
}
File: juice-interface/src/packages/v4/utils/distributions.ts
export const JB_FEE = 0.025
// Subtract fee from gross amount
export function deriveAmountAfterFee(amount: number) {
return amount - amount * JB_FEE // amount * 0.975
}
// Calculate gross amount needed to achieve net
export function deriveAmountBeforeFee(amount: number) {
return amount / (1 - JB_FEE) // amount / 0.975
}
// Apply fee conditionally based on split type
export function derivePayoutAmount({ payoutSplit, distributionLimit, dontApplyFee }) {
const amountBeforeFee = payoutSplit.percent.toFloat() * distributionLimit
if (isJuiceboxProjectSplit(payoutSplit) || dontApplyFee)
return amountBeforeFee // No fee for project splits
return deriveAmountAfterFee(amountBeforeFee)
}
Show fee tooltip on payout amounts:
Amount: 100 ETH
→ "97.5 ETH after 2.5% JBX membership fee"
Tooltip explanation:
"Payouts to Ethereum addresses incur a 2.5% fee. Your project will receive JBX in return."
File: revnet-core-v5/src/REVDeployer.sol:95
uint256 public constant override FEE = 25; // 2.5%
REVDeployer.sol:282-283File: revnet-app/src/lib/feeHelpers.ts
import { REVNET_CASHOUT_FEE_PERCENT } from "@/app/constants"; // 0.025
export function applyRevFee(tokenAmount: bigint) {
return (tokenAmount * BigInt((1 - REVNET_CASHOUT_FEE_PERCENT) * 1000)) / 1000n;
}
export function applyNanaFee(reclaimableAmount: bigint) {
return (reclaimableAmount * BigInt((1 - JBDAO_CASHOUT_FEE_PERCENT) * 1000)) / 1000n;
}
For cash outs, apply BOTH fees:
// In reclaimableSurplus.ts
const afterRevFee = applyRevFee(tokenAmountWei) // 2.5% Revnet fee
const afterAllFees = applyNanaFee(afterRevFee) // 2.5% NANA fee on remainder
Show net amount directly:
Cash out: 1000 tokens
→ "You'll get ~X ETH"
The displayed amount should have both fees pre-applied.
File: revnet-core-v5/src/REVLoans.sol:83-92
uint256 public constant override LOAN_LIQUIDATION_DURATION = 3650 days; // 10 years
uint256 public constant override MAX_PREPAID_FEE_PERCENT = 500; // 50% max
uint256 public constant override REV_PREPAID_FEE_PERCENT = 10; // 1% REV fee
uint256 public constant override MIN_PREPAID_FEE_PERCENT = 25; // 2.5% min source fee
| Fee | Rate | When Charged | Recipient |
|---|---|---|---|
| REV fee | 1% | At borrow time | REV revnet |
| Source fee | 2.5%-50% | At borrow time (prepaid) | Source revnet |
| Variable fee | 0-100% | After prepaid period expires | Source revnet |
(prepaidPercent / 50%) * 10 yearsExamples:
File: revnet-core-v5/src/REVLoans.sol:377-403
After prepaid period expires:
variableFee = (elapsedAfterPrepaid / remainingTime) * amountAfterFixedFees
The fee increases linearly from 0% to 100% over the remaining time until 10 years.
File: revnet-app/src/lib/feeHelpers.ts
export function generateFeeData({
grossBorrowedEth,
prepaidPercent,
fixedLoanFee = 0.035, // 3.5% = 1% REV + 2.5% source
}: {
grossBorrowedEth: number;
prepaidPercent: string;
fixedLoanFee?: number;
}) {
const MAX_YEARS = 10;
const monthsToPrepay = (parseFloat(prepaidPercent) / 50) * 120;
const prepaidDuration = monthsToPrepay / 12;
// Fixed fees come off immediately
const fixedFee = grossBorrowedEth * fixedLoanFee;
// Prepaid fee calculation
const feeBpsBigInt = calcPrepaidFee(Math.round(monthsToPrepay));
const prepaidFee = (grossBorrowedEth * Number(feeBpsBigInt)) / 10000;
// Amount user actually receives
const amountUserReceives = grossBorrowedEth - fixedFee - prepaidFee;
// Generate fee curve data points
const data = [];
for (let year = 0; year <= MAX_YEARS; year += 0.25) {
let variableFee = 0;
if (year > prepaidDuration) {
const elapsedAfterPrepaid = year - prepaidDuration;
const remainingTime = MAX_YEARS - prepaidDuration;
variableFee = amountUserReceives * (elapsedAfterPrepaid / remainingTime);
}
const totalCostToUnlock = grossBorrowedEth + variableFee;
data.push({ year, totalCost: totalCostToUnlock });
}
return data;
}
SimulatedLoanCard shows inline breakdown:
Amount borrowed: 1.0 ETH
To beneficiary after fees: 0.945 ETH
[Tooltip]
- Collateral used: 1000 REVNET
- Protocol & project fees: 0.055 ETH (5.5%)
- Max cost to unlock before 10 years: 1.945 ETH
LoanFeeChart visualizes the fee curve:
UIs are welcome to add fees on top of protocol fees. Pattern:
const UI_FEE = 0.005 // 0.5% UI operator fee
function applyAllFees(amount: bigint, includeUIFee = true) {
// Apply protocol fees first
let result = applyNanaFee(amount) // 2.5%
// Optionally apply UI fee
if (includeUIFee) {
result = result - (result * BigInt(UI_FEE * 10000)) / 10000n
}
return result
}
Best practices:
Sub-total: 100.00 ETH
Owner remainder: 10.00 ETH
Fees (2.5%): 2.75 ETH
─────────────────────────────
Total: 112.75 ETH
Cashing out: 1,000 tokens
You'll receive: ~0.95 ETH
└─ After 2.5% Revnet fee + 2.5% JBX fee
Borrowing: 1.0 ETH
You'll receive: 0.945 ETH
Fees paid now:
- REV fee (1%): 0.01 ETH
- Prepaid fee (4.5%): 0.045 ETH
To unlock collateral: 1.0 ETH (+ variable fees after 1 year)
| File | Purpose |
|---|---|
nana-core-v5/src/JBMultiTerminal.sol | NANA fee logic (lines 86, 555, 587, 1129, 2028) |
nana-core-v5/src/libraries/JBFees.sol | Fee calculation library |
nana-core-v5/src/JBFeelessAddresses.sol | Feeless address management |
revnet-core-v5/src/REVDeployer.sol | Cash out fee (lines 95, 270-333, 567-624) |
revnet-core-v5/src/REVLoans.sol | Loan fees (lines 83-92, 377-403, 821-851) |
| File | Purpose |
|---|---|
juice-interface/src/packages/v4/utils/distributions.ts | Payout fee calculations |
juice-interface/src/packages/v4/components/FeeTooltipLabel.tsx | Fee display component |
revnet-app/src/lib/feeHelpers.ts | Revnet fee helpers |
revnet-app/src/app/[slug]/components/Value/SimulatedLoanCard.tsx | Loan fee display |
revnet-app/src/app/[slug]/components/Value/LoanFeeChart.tsx | Fee curve visualization |
isJuiceboxProjectSplit() before applying feesTo verify fee calculations match on-chain behavior:
_determineSourceFeeAmount() logic