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). 1001.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 swap

  • net_in = amount_in * (1 - p)

  • The quote computes amount_out from net_in.

  • fee_amount = amount_in − net_in (deducted in input token).

EXACT_OUT

  • min_amount_in is increased based on fee

  • Apply 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 for EXACT_OUT fees will be deducted from amount_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 calculates amount_out from net_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 least 505,000 units of the input token.

  • Fee: fee_amount = 5,000 (in input token)

Last updated