Fee Parameters
Include these parameters in theappFees object when requesting a quote:
| Parameter | Type | Description |
|---|---|---|
recipient | string | Any NEAR-supported address (named account like alice.near, implicit account, or EVM-like address) |
fee_bps | number | Fee in basis points. 100 = 1.00%. Fee is charged from the input token. |
Conversion formula:
percentage = fee_bps / 10,000For example, fee_bps: 50 equals 0.5% fee.Constraints
- Fee range:
0to10,000(where10,000= 100%)
How Fees Are Applied
Fees are calculated differently depending on the swap type:- EXACT_IN
- EXACT_OUT
For EXACT_IN swaps, the fee is deducted from your input amount before the swap:
net_in = amount_in * (1 - p)wherep = fee_bps / 10,000- The quote calculates
amount_outfromnet_in fee_amount = amount_in - net_in(deducted in input token)
- Input:
amount_in = 1,000,000,fee_bps = 100(1%) - Calculation:
net_in = 1,000,000 * (1 - 0.01) = 990,000 - User deposits
1,000,000and quote calculates output from990,000 - Fee:
10,000units (in input token)
Example Quote Request
Fee Aggregation
For high-volume integrations that collect fees in multiple tokens, you can aggregate all fees into a single destination asset using the ANY_INPUT feature. This automatically converts incoming fees and withdraws them when reaching a threshold.Overview
When you collect fees from swaps, you may receive them in many different tokens. Fee aggregation:- Accepts deposits in any supported token
- Automatically swaps all deposits to your chosen
destinationAsset - Withdraws to your specified address when the pool reaches $1,000 USD
Setup
Create an ANY_INPUT quote
Request a quote with
originAsset: "1cs:any" to get a dedicated deposit address for fee collection.Use the deposit address for app fees
Use the
depositAddress from the quote response as the appFees.recipient in your user quotes.How It Works
- Use
originAsset: "1cs:any"withamount: "0" - A background job continuously polls, swaps all deposits to
destinationAsset, and withdraws when the threshold is reached - Failed swap attempts retry every 5 minutes
Authentication
You must include an
Authorization: Bearer YOUR_JWT_TOKEN header to receive the quote and deposit address. Get your API key from the Partner Dashboard.Example ANY_INPUT Request
Create an ANY_INPUT quote to get your fee collection address:Key Fields
| Field | Description |
|---|---|
originAsset | Must be "1cs:any" for fee aggregation |
destinationAsset | Token you want to collect fees in |
recipient | Address where converted fees will be withdrawn |
recipientType | "DESTINATION_CHAIN" or "INTENTS" |
refundTo | Set to an address you control |
Checking Withdrawals
Use the/v0/any-input/withdrawals endpoint to retrieve withdrawal records for your deposit address.
Request:
| Field | Description |
|---|---|
status | Withdrawal status (e.g., SUCCESS) |
amountOut | Raw amount withdrawn |
amountOutFormatted | Human-readable amount |
amountOutUsd | USD value at time of withdrawal |
withdrawFee | Fee charged for withdrawal |
timestamp | When the withdrawal occurred |
hash | Transaction hash |
Each response contains up to 50 records, ordered by timestamp descending.