SDK
Swap SDK is meant to provide simple interfaces for calculating all parameters needed for token swaps: slippage, price impact, exact supply/target, etc.
Before making any swap there needed to few calls to check liquidity and to calculate some basic parameters to make swaps safer and to avoid malicious operations as front-running or sandwich-attacks.
First, you need to create an instance of either SwapPromise or SwapRx:
After setup arguments of swap:
And make calculate parameters with next interface:
type
defines whether the swap should be with exact supply or exact target.
You can find the full code sample here: swapWithSDK.ts
Last updated