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_in
is decreased based on fee during swapnet_in = amount_in * (1 - p)
The quote computes
amount_out
fromnet_in
.fee_amount = amount_in − net_in
(deducted in input token).
EXACT_OUT
min_amount_in
is 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_in
forEXACT_OUT
fees will be deducted fromamount_in
field.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,000
User deposits
1,000,000
and the quote calculatesamount_out
fromnet_in = 990,000
Fee:
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,000
User have to deposit
505,000
and the quote require at least505,000
units of the input token.Fee:
fee_amount = 5,000
(in input token)
Last updated