Before swapping. you should obtain the estimated amount of the other token and ths swap routes.
There are two functions for this preperation.
sdk.Swap.estFromAmount
sdk.Swap.estToAmount
Swap
use sdk.Swap.swapTransactionPayload method.
Example
constcurrencyAAmount=Math.pow(10,7)const{amountOut:currencyBAmount,path:poolRoute}=awaitsdk.Swap.estToAmount({amount:currencyAAmount,from:"0xa",to:"0xc5bcdea4d8a9f5809c5c945a3ff5698a347afb982c7389a335100e1b0043d115", // safeMode // if safeMode is true, only few swap token pairs will return path route // default: true. support from (v0.0.12)safeMode:false})/*{ "amountOut": "10000000", // This is for toAmount "amountIn": "1279371", // This is for fromAmount // swap path route "path": [ "0x0d21c2f5628db619957703e90ab07bcb2b13ad6983da2b5d721f24523cae29ff" ]}*/constparams={ // here must be fa typecurrencyA:'0xa',currencyB:"0xc5bcdea4d8a9f5809c5c945a3ff5698a347afb982c7389a335100e1b0043d115",currencyAAmount,currencyBAmount,slippage:0.1,poolRoute,recipient:'',}constpayload=awaitsdk.Swap.swapTransactionPayload(params)console.log(payload)
Swap with Partnership
use sdk.Swap.swapWithPartnershipTransactionPayload method.
(from v0.0.17)
Example
Swap via Aggregator
(from v0.0.24)
The White Paper is for informational purposes only. Nothing in the White Paper constitutes legal, financial or tax advice. Its content may be updated from time to time without express notice. You should seek your own professional advice before engaging in any activity in connection with Hyperion. See Legal Disclaimer.