Skip to main content
Configure how fees are collected and distributed when using the 1Click Swap API. As a distribution channel, you can add your own fees on top of the base platform fees.
This guide covers distribution channel fees (fees you collect). For an overview of all platform fees including protocol fees and API fees, see Fees.

Fee Parameters

Include these parameters in the appFees array when requesting a quote:
ParameterTypeDescription
recipientstringAny NEAR-supported address (named account like alice.near, implicit account, or EVM-like address)
feenumberFee in basis points. 100 = 1.00%. Fee is charged from the input token.
  • Conversion formula: percentage = fee / 10,000 (e.g. fee: 50 equals 0.5% fee)
  • Constraints: Fee range: 0 to 500 (where 500 = 5%)
A 50/50 revenue share applies by default — half of the fee amount goes to your recipient address and half goes to the 1Click protocol address. For example, "fee": 10 means 5 bps to you and 5 bps to 1Click.

How Fees Are Applied

Fees are calculated differently depending on the swap type:
For EXACT_IN swaps, the fee is deducted from your input amount before the swap:
  1. net_in = amount_in * (1 - p) where p = fee / 10,000
  2. The quote calculates amount_out from net_in
  3. fee_amount = amount_in - net_in (deducted in input token)
Example:
  • Input: amount_in = 1,000,000, fee = 100 (1%)
  • Calculation: net_in = 1,000,000 * (1 - 0.01) = 990,000
  • User deposits 1,000,000 and quote calculates output from 990,000
  • Fee: 10,000 units (in input token)

{
  "dry": false,
  "swapType": "EXACT_IN",
  "originAsset": "nep141:wrap.near",
  "destinationAsset": "nep141:usdt.tether-token.near",
  "amount": "1000000000000000000000000",
  "recipient": "user.near",
  "recipientType": "INTENTS",
  "refundTo": "user.near",
  "refundType": "INTENTS",
  "appFees": [{
    "recipient": "your-fee-wallet.near",
    "fee": 50
  }]
}

Fee Aggregation

For high-volume integrations that collect fees in many different tokens, the ANY_INPUT swap type aggregates them all into a single destination asset and withdraws automatically.
To compare ANY_INPUT with the other swap types, see the Swap Types page.

How it works

  • Deposits in any supported token are sent to one dedicated depositAddress and accumulate there.
  • A background job continuously swaps everything to your chosen destinationAsset and withdraws it to recipient once the pool reaches $1,000 USD.
  • The deadline is checked only when the quote is created — after that the quote runs indefinitely, so a single quote keeps collecting and withdrawing without being refreshed.
  • Failed swaps retry every 5 minutes.
No refunds. If a swap fails it retries automatically rather than returning funds — set refundTo to an address you control as a safety measure.

Set it up

Every request must include an Authorization: Bearer YOUR_JWT_TOKEN header to receive the quote and its depositAddress. Get your API key from the Partner Dashboard.
1

Create an ANY_INPUT quote

Request a quote with originAsset: "1cs_v1:any" and amount: "0" to get a dedicated depositAddress for fee collection.
{
  "dry": false,
  "swapType": "ANY_INPUT",
  "slippageTolerance": 0,
  "originAsset": "1cs_v1:any",
  "depositType": "INTENTS",
  "destinationAsset": "nep141:eth-0xdac17f958d2ee523a2206206994597c13d831ec7.omft.near",
  "amount": "0",
  "refundTo": "your-wallet.near",
  "refundType": "INTENTS",
  "recipient": "0x1ddA60d784483FBB54304c68830d42A706327C6d",
  "recipientType": "DESTINATION_CHAIN",
  "deadline": "2025-01-01T00:00:00.000Z",
  "referral": "YOUR_REFERRAL",
  "quoteWaitingTimeMs": 10000
}
FieldDescription
originAssetMust be "1cs_v1:any" for fee aggregation
destinationAssetToken you want to collect fees in
recipientAddress where converted fees will be withdrawn
recipientType"DESTINATION_CHAIN" or "INTENTS"
refundToSet to an address you control
Set quoteWaitingTimeMs to 5000–10000ms for optimal performance (3–4s is often enough).
2

Wire the deposit address into your fees

Use the depositAddress from the quote response as the appFees.recipient in your user quotes (see Fee Parameters). Collected fees now flow to the aggregation address and convert automatically.

Track withdrawals

Use the /v0/any-input/withdrawals endpoint to retrieve withdrawal records for your deposit address. Request:
GET /v0/any-input/withdrawals?depositAddress=YOUR_DEPOSIT_ADDRESS
Records are filtered by depositAddress and sorted by timestamp (newest first). Page through results with these query parameters:
ParameterDescription
depositAddressRequired. The deposit address whose withdrawals you’re fetching
depositMemoMemo, if the deposit address requires one
timestampFromOnly return withdrawals from this ISO timestamp onward
pagePage number (default 1)
limitRecords per page (max and default 50)
sortOrderasc or desc by timestamp (default desc)
Response:
{
  "recipient": "0x88b9da55b59a59751424b357cf8aea239770944c",
  "affiliateRecipient": "2fd5aba4dc4729dcaec040242fc3b0b1faf8c81f74831c7c7843c6a96ad28add",
  "asset": "nep141:base-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913.omft.near",
  "withdrawals": [
    {
      "status": "SUCCESS",
      "amountOut": "140735",
      "amountOutFormatted": "0.140735",
      "amountOutUsd": "0.140693483175",
      "withdrawFee": "2400",
      "withdrawFeeFormatted": "0.0024",
      "withdrawFeeUsd": "0.0023992919999999995",
      "timestamp": "2025-10-07T10:16:19.702Z",
      "hash": "0xcc005d3e3340c61b1240905c4e383d8b8ecb114a827bef3e0394293997406621"
    }
  ]
}
Response Fields:
FieldDescription
statusWithdrawal status (e.g., SUCCESS)
amountOutRaw amount withdrawn
amountOutFormattedHuman-readable amount
amountOutUsdUSD value at time of withdrawal
withdrawFeeFee charged for withdrawal
timestampWhen the withdrawal occurred
hashTransaction hash