The affiliates field allows you to specify fee recipients who will receive a portion of the swap output as an affiliate fee. Fees are specified in basis points (1 basis point = 0.01%, 100 basis points = 1%) and are calculated on the swap output amount.
JSON Example
Multi-Hop Swaps
The routes field allows for multi-hop swaps through multiple pools. The swap will execute through each pool in sequence.
Slippage Protection
The token_out_min_amount field ensures that the user receives at least the specified amount of output tokens, protecting against price slippage.
Swap Fees
Each pool in the swap route charges a swap fee, which is deducted from the input amount before the swap is executed.
Affiliate Fees
The affiliates field allows you to specify fee recipients who will receive a portion of the swap output. Affiliate fees are:
Optional: If not specified, no affiliate fees are deducted
Calculated on output: Fees are calculated on the swap output amount
Multiple affiliates: You can specify multiple affiliates, each receiving their specified fee
Basis points: Fees are specified in basis points (1 basis point = 0.01%)
Example: If a swap outputs 1,000,000 tokens and you specify an affiliate with 10 basis points (0.1%):