Token Quantity Conversion
You are referring to the Legacy
version of KyberSwap docs.
For the most updated information, please refer to:
Token Amount Conversion
Since getExpectedRate
returns a rate, not the amount, the following code snippets show how to convert to both source and destination token amounts, taking their decimals into account.
calcSrcQty
calcSrcQty
Returns: ERC20 source token amount in its decimals.
Javascript
Solidity
Refer to the Utils contract.
calcDstQty
calcDstQty
Returns: ERC20 destination token amount in its decimals.
Javascript
Solidity
Refer to the Utils contract.
calcRateFromQty
calcRateFromQty
Returns: Token conversion rate independent of token decimals
Javascript
Solidity
Refer to the Utils2 contract.
Last updated