Conversion
Swaps happen according to the provided conversion path and can involve one or multiple liquidity pools.
Conversion Path
conversionPath returns the conversion path between two tokens in the network. Please note that this method is quite expensive in terms of gas and should generally be called off-chain. Moreover, the function returns the shortest path, not necessarily the one with the best rate.
Arguments
_sourceToken
IERC20Token
source token address
_targetToken
IERC20Token
target token address
Returns
The conversion path between the two tokens. Format:
Conversion Rate
rateByPath returns the expected target amount of converting a given amount on a given path.
Arguments
_path
IERC20Token[]
conversion path (see conversion path format above)
_amount
uint256
amount of _path[0] tokens received from the sender
Returns
The expected target amount.
Conversion
convertByPath converts the token to any other token in the Sovryn swap network by following a predefined conversion path and transfers the result tokens to a target account. Affiliate account/fee can also be passed in to receive a conversion fee (on top of the liquidity provider fees). Please note that the network should already have been given allowance of the source token.
Arguments
_path
IERC20Token[]
conversion path, see conversion path format above
_amount
uint256
amount to convert from, in the source token
_minReturn
uint256
if the conversion results in an amount smaller than the minimum return - it is cancelled, must be greater than zero
_beneficiary
address
account that will receive the conversion result or 0x0 to send the result to the sender account
_affiliateAccount
address
wallet address to receive the affiliate fee or 0x0 to disable affiliate fee
_affiliateFee
uint256
affiliate fee in PPM or 0 to disable affiliate fee *
Returns
The amount of tokens to receive from the conversion.
Last updated