Affiliate Fee Integration
Partners can earn a commission on swap transactions by passing affiliate fee parameters in API calls.
How it works
The affiliate fee is deducted from amountIn before the swap calculation. The pool receives the remainder.
affiliateFeeAmount = floor((amountIn × partnerFeeBps) / 1,000,000)
poolAmountIn = amountIn - affiliateFeeAmountRequest example
{
"type": "SWAP",
"params": {
"tokens": ["2584333:39", "0:0"],
"amountIn": "1000000",
"amountOut": "100000",
"feeRates": [3000],
"isExactIn": true,
"partnerFeeBps": 10000,
"partnerFeeRecipient": "bc1q..."
}
}Rules
partnerFeeBpsandpartnerFeeRecipientmust always be provided togetherRUNE → BTC swaps: affiliate receives RUNE. Minimum fee: 1 RUNE
BTC → RUNE swaps: affiliate receives BTC. Minimum fee: 546 sats (auto-adjusted if lower)
partnerFeeRecipientcannot be the pool address or the user's trading address
Fee calculation examples
1% fee on a RUNE → BTC swap:
0.5% fee on a BTC → RUNE swap:
Common errors
Missing recipient
partnerFeeBps provided without partnerFeeRecipient
Always provide both together
Invalid recipient
Recipient is pool or user address
Use a different recipient address
Fee too small
Calculated fee < 1 RUNE
Increase partnerFeeBps or amountIn
Fee too large
poolAmountIn would be 0
Reduce partnerFeeBps