Token Quantity Conversion
Last updated
Was this helpful?
Last updated
Was this helpful?
You are referring to the Legacy
version of KyberSwap docs.
For the most updated information, please refer to:
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
dstQty
ERC20 destination token amount in its decimals
srcDecimals
ERC20 source token decimals
dstDecimals
ERC20 destination token decimals
rate
src -> dst conversion rate, independent of token decimals
Returns: ERC20 source token amount in its decimals.
Javascript
srcQty
ERC20 source token amount in its decimals
srcDecimals
ERC20 source token decimals
dstDecimals
ERC20 destination token decimals
rate
src -> dst conversion rate, independent of token decimals
Returns: ERC20 destination token amount in its decimals.
srcAmount
Number
ERC20 source token amount in its decimals
destAmount
Number
ERC20 destination token amount in its decimals
srcDecimals
Number
ERC20 source token decimals
dstDecimals
Number
ERC20 destination token decimals
Returns: Token conversion rate independent of token decimals
Solidity
Refer to the .
Javascript
Solidity
Refer to the .
Javascript
Solidity
Refer to the .