Swap Aggregator
Get Swap Router
WARNING: amountOut
FROM QUOTE WHEN USE WITH COMMISSION ONLY FOR DISPLAY, NOT FOR CALCULATE ONCHAIN.
To find best route for swap
Build Transaction for aggregator swap
Normal case if you want fast swap
Return coin for later use
Commission
The Commission
class represents a commission configuration for transactions, defining the partner, commission type, and value. It includes methods for computing the commission amount based on the specified type.
if CommissionType.PERCENTAGE
then value
should be input 1/100 * 1e6
it is example of 1% if CommissionType.FLAT
then value
should be the amount of token you want to fee include decimals Then you should pass commission
variable to both tradeBuilder
and getRoutes
for exact values
if directTransfer
= true
then commission will transfer directly to partner address, else you need go to contract and claim partner fee later
The coin
pass in commission that mean coin you want collect fee in transaction, for example, if you pass SUI is coin collect fee, when you swap SUI -> USDC or USDC->SUI you will collect SUI is a fee, but if you swap FLX->USDC and USDC->FLX you receive nothing and coin is SUI, then you SHOULD NOT pass commission to TradeBuilder
Usage
If const routes = await quoter.getRoutes(params)
include commssion then amount will return amount that include commission
if trade = tradeBuilder.commission(commission)
then the transaction will include commission, if not pass commission in tradeBuilder then transaction will execute without commission
Last updated