← All posts
INTEGRATIONS

Earn from your swap flow with Tirio partner fees

TE
Tirio Engineering · 6 min read

Add a fee of up to 10 % to swaps and orders you route through Tirio, paid to your address in the same transaction. How to set it and verify it.

If you run a wallet, a trading bot, a community dashboard or a website with a swap widget, you can earn from the swaps you bring to Tirio. A partner fee is set per request, charged by Tirio's Router inside the swap transaction and paid straight to your address. There is no sign-up, no invoice and no monthly settlement. The money arrives in the same block as the trade.

This guide covers the rules, the API parameters, a worked example from the live API and how to check your earnings on chain.

The rules

  • You choose the fee, from 0 to 1000 basis points (10 %), on every request.
  • It is paid to the partner address you name, in the same transaction as the swap.
  • The Router keeps 10 % of the partner fee. You receive the other 90 %. The contract caps that share at 20 %.
  • A share of positive slippage. On sales of an exact amount whose output token has no transfer tax, the Router keeps any output above the quote up to 1 % of it. With a partner on the swap, 20 % of what it keeps goes to the partner.
  • Your users see it. The quote reports your fee, and on tirio.io a partner link shows a Partner fee line with your address.
  • API quotes carry no Tirio fee of their own, so your partner fee is the only fee added on top of pool fees and gas.

Adding a partner fee to a quote

Pass partner and partnerFeeBps to /quote, and the same pair to /price so the indicative price matches (partner is required whenever partnerFeeBps is set). Using the tirio helper, the clients and the Quote type from our integration guide, with your own address in place of 0x…:

const PARTNER: Address = "0x…";
 
type Fees = { token: Address; partner: Address | null; partnerBps: number; partnerAmount: string; surplusCapBps: number };
 
const quote = await tirio<Quote & { fees: Fees }>("quote", {
  tokenIn: NATIVE,
  tokenOut: USDT,
  amountIn: "1000000000000000000",
  slippageBps: "50",
  recipient: account,
  sender: account,
  partner: PARTNER,
  partnerFeeBps: "50",
});

The response's fees block tells you exactly what the swap will pay:

FieldMeaning
fees.tokenThe token the partner fee is taken from
fees.partnerYour address, or null without a partner
fees.partnerBpsThe fee you asked for, in basis points
fees.partnerAmountWhat you receive, after the Router's 10 %
fees.surplusCapBpsThe positive slippage cap, 100 (1 %)

A real example

On 2026-10-01 we asked the live API for a 1 BNB to USDT quote with partnerFeeBps set to 50. The fees block came back with token as the native coin, partnerBps 50 and partnerAmount 4500000000000000, which is 0.0045 BNB. That is 50 bps of 1 BNB (0.005 BNB) minus the Router's 10 % (0.0005 BNB). The calldata carried the partner address and the fee of 50, exactly as requested.

Which side the fee comes from

By default the partner fee is taken from the token the user pays, as in the example. Pass feeToken=tokenOut to take it from the token they receive instead. Two cases move it back to the input automatically: an output token with a transfer tax, and exact-out quotes, where the output is fixed. fees.token always reports the side actually used.

Check the calldata before signing

As with any quote, decode the transaction and make sure it says what you asked for. With the Router ABI from the integration guide:

const { args } = decodeFunctionData({ abi: routerAbi, data: quote.tx.data });
const [params] = args;
if (params.partner.toLowerCase() !== PARTNER.toLowerCase()) throw new Error("unexpected partner");
if (params.partnerFeeBps !== 50) throw new Error("unexpected partner fee");

Make sure your address can receive the fee

When the fee is taken in BNB, which happens when users pay with BNB and the fee is on the input, the Router sends it to your address as native BNB within the swap. If that address is a contract that cannot accept BNB, the transfer fails and so does the swap. An ordinary wallet address works. A contract needs a receive function. The same applies to tokens: the partner address has to be one the token will transfer to.

Tracking what you earned

Every swap emits a Swap event from the Router, and partner is one of its indexed fields, so you can find every swap that paid you with a single filtered query. The Router was deployed at block 124,724,236, so there is nothing to find before it:

import { parseAbiItem } from "viem";
 
const swapEvent = parseAbiItem(
  "event Swap(address indexed sender, address indexed partner, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut, address recipient, uint256 protocolTake, uint256 partnerTake, uint256 surplus)",
);
 
const logs = await publicClient.getLogs({
  address: ROUTER,
  event: swapEvent,
  args: { partner: PARTNER },
  fromBlock: 124724236n,
  toBlock: "latest",
});
 
for (const log of logs) console.log(log.transactionHash, log.args.tokenIn, log.args.tokenOut, log.args.amountIn);

For exact amounts, the token transfers into your address in those transactions are the authoritative record, and you can see them on BscScan like any other incoming transfer. Node providers often limit how many blocks a single log query may cover, so split long ranges into smaller windows.

Partner fees on orders

Limit, stop and DCA orders placed through the API accept partner and partnerFeeBps too. The fee is taken from the output of every fill and paid to you in the fill transaction, minus the Orders contract's protocol share (10 %, capped at 20 %). Our guide to orders through the API shows the request.

Partner links on tirio.io

If you do not want to build a swap interface at all, you can still earn. A link to tirio.io of the form

https://tirio.io/swap?partner=<your address>&partnerFeeBps=<1 to 1000>

opens the swap card with your fee applied to every swap made from it, and orders placed from it carry your fee as well. On a partner link the 3 bps Tirio fee is replaced by your fee, and the card shows your fee and your shortened address. If either parameter is missing or invalid, both are ignored and the normal Tirio fee applies.

Setting a fair fee

The fee is yours to choose, and your users will compare it with what they can get elsewhere. Keeping it modest and showing it clearly in your interface builds trust. Whatever you choose, it appears in the quote and in the transaction, so there is nothing hidden to explain later.

The full parameter reference is in the API documentation, and the contract-level fee rules are on the contracts page.

KEEP READING