1Click App Fees Calculation
A concise guide on how to setup 1Click Swap API app fees distribution during quoting and execution. As a distribution channel while asking for quote, you can specify the distribution of fees that come from the swap being executed.
Parameters
recipient — any NEAR‑supported address (named account ID like
alice.near, implicit based account or EVM-like).fee_bps — fee in basis points (bps).
100→1.00%. The fee is charged from the input token.
Conversion: p = fee_bps / 10_000.
Constraints
0 ≤ fee_bps ≤ 10_000(10_000= 100%).
How fees are applied
EXACT_IN
amount_inis decreased based on fee during swapnet_in = amount_in * (1 - p)The quote computes
amount_outfromnet_in.fee_amount = amount_in − net_in(deducted in input token).
EXACT_OUT
min_amount_inis increased based on feeApply the fee to the required input:
net_in = min_amount_in × (1 + p).fee_amount = net_in − min_amount_in(deducted in input token).If user deposit more than
min_amount_inforEXACT_OUTfees will be deducted fromamount_infield.fee_amount = net_in − amount_in
Examples
Example 1 — EXACT_IN
Inputs:
amount_in = 1,000,000,fee_bps = 100(p = 0.01)Computation:
net_in = 1,000,000 × (1 − 0.01) = 990,000User deposits
1,000,000and the quote calculatesamount_outfromnet_in = 990,000Fee:
fee_amount = 10,000(in input token)
Example 2 — EXACT_OUT
Inputs:
min_amount_in = 500,000,fee_bps = 100(p = 0.01)Computation:
net_in = 500,000 × (1 + 0.01) = 505,000User have to deposit
505,000and the quote require at least505,000units of the input token.Fee:
fee_amount = 5,000(in input token)
Last updated