Comment on page
Execute An Elastic Swap
Trade Directly Against An Elastic Pool
It is necessary to specify which pools are to be used for the token swap. Read more about fetching pool addresses before proceeding.
Elastic SDK
KyberSwap has created an Elastic SDK to make interacting with our Elastic smart contracts easier. You can refer to our Elastic SDK Developer Guides for step-by-step walkthroughs on how to achieve various Elastic operations in a TypeScript environment.
Swap token0 -> token1, or vice versa. Note that swaps will either fully use up the specified swap quantity, or swap up to the specified price limit, depending on whichever condition is satisfied first.
Field | Type | Explanation |
---|---|---|
recipient | address | address to receive the swap output |
swapQty | int256 | swap quantity, which implicitly configures the swap as exact input (>0), or exact output (<0) |
isToken0 | bool | whether the swapQty is specified in token0 (true) or token1 (false) |
limitSqrtP | uint160 | sqrt price limit to reach |
data | bytes | Data, if any, to be passed into the callback function |
To specify an unlimited price limit for a swap, use the following values.
isToken0 | swapQty | Value |
true | > 0 | MIN_SQRT_RATIO + 1 |
true | < 0 | MAX_SQRT_RATIO - 1 |
false | > 0 | MAX_SQRT_RATIO - 1 |
false | < 0 | MIN_SQRT_RATIO + 1 |
Field | Type | Explanation |
---|---|---|
qty0 | int256 | exact token0 qty sent to recipient if < 0. Minimally received quantity if > 0 |
qty1 | int256 | exact token1 qty sent to recipient if < 0. Minimally received quantity if > 0 |
Last modified 1mo ago