AbstractTokenConverter
AbstractTokenConverter
This contract provides every feature to configure and convert the desired assets.
Solidity API
MAX_INCENTIVE
Maximum incentive allowed
minAmountToConvert
Min amount to convert for private conversions. Defined in USD, with 18 decimals
priceOracle
Venus price oracle contract
conversionConfigurations
Conversion configurations for the existing pairs
destinationAddress
Address that all incoming tokens are transferred to
conversionPaused
Boolean for if conversion is paused
converterNetwork
Address of the converterNetwork contract
pauseConversion
Pause conversion of tokens
📅 Events
Emits ConversionPaused on success
⛔️ Access Requirements
Restricted by ACM
❌ Errors
ConversionTokensPaused thrown when conversion is already paused
resumeConversion
Resume conversion of tokens.
📅 Events
Emits ConversionResumed on success
⛔️ Access Requirements
Restricted by ACM
❌ Errors
ConversionTokensActive thrown when conversion is already active
setPriceOracle
Sets a new price oracle
Parameters
⛔️ Access Requirements
Only Governance
setDestination
Sets a new destination address
Parameters
⛔️ Access Requirements
Only Governance
setConverterNetwork
Sets a converter network contract address
Parameters
⛔️ Access Requirements
Only Governance
setMinAmountToConvert
Min amount to convert setter
Parameters
⛔️ Access Requirements
Only Governance
setConversionConfigs
Batch sets the conversion configurations
Parameters
❌ Errors
InputLengthMisMatch is thrown when tokenAddressesOut and conversionConfigs array length mismatches
convertExactTokens
Converts exact amount of tokenAddressIn for tokenAddressOut if there is enough tokens held by the contract
Parameters
Return Values
📅 Events
Emits ConvertedExactTokens event on success
❌ Errors
ZeroAddressNotAllowed is thrown when to address is zero
InvalidToAddress error is thrown when address(to) is same as tokenAddressIn or tokenAddressOut
AmountOutLowerThanMinRequired error is thrown when amount of output tokenAddressOut is less than amountOutMinMantissa
AmountInMismatched error is thrown when amount of output tokenAddressOut is less than amountOutMinMantissa
convertForExactTokens
Converts tokens for tokenAddressIn for exact amount of tokenAddressOut if there are enough tokens held by the contract. otherwise the amount is adjusted
Parameters
Return Values
📅 Events
Emits ConvertedForExactTokens event on success
❌ Errors
ZeroAddressNotAllowed is thrown when to address is zero
InvalidToAddress error is thrown when address(to) is same as tokenAddressIn or tokenAddressOut
AmountInHigherThanMax error is thrown when amount of tokenAddressIn is higher than amountInMaxMantissa
AmountOutMismatched error is thrown when actualAmountOut is does not match amountOutMantissa
convertExactTokensSupportingFeeOnTransferTokens
Converts exact amount of tokenAddressIn for tokenAddressOut if there is enough tokens held by the contract
Parameters
Return Values
📅 Events
Emits ConvertedExactTokensSupportingFeeOnTransferTokens event on success
❌ Errors
ZeroAddressNotAllowed is thrown when to address is zero
InvalidToAddress error is thrown when address(to) is same as tokenAddressIn or tokenAddressOut
AmountOutLowerThanMinRequired error is thrown when amount of output tokenAddressOut is less than amountOutMinMantissa
convertForExactTokensSupportingFeeOnTransferTokens
Converts tokens for tokenAddressIn for amount of tokenAddressOut calculated on the basis of amount of tokenAddressIn received by the contract, if there is enough tokens held by the contract, otherwise the amount is adjusted. The user will be responsible for bearing any fees associated with token transfers, whether pulling in or pushing out tokens
Parameters
Return Values
📅 Events
Emits ConvertedForExactTokensSupportingFeeOnTransferTokens event on success
❌ Errors
ZeroAddressNotAllowed is thrown when to address is zero
InvalidToAddress error is thrown when address(to) is same as tokenAddressIn or tokenAddressOut
AmountInHigherThanMax error is thrown when amount of tokenAddressIn is higher than amountInMaxMantissa
sweepToken
To sweep ERC20 tokens and transfer them to user(to address)
Parameters
📅 Events
Emits SweepToken event on success
⛔️ Access Requirements
Only Governance
❌ Errors
ZeroAddressNotAllowed is thrown when tokenAddress/to address is zero
getAmountOut
To get the amount of tokenAddressOut tokens sender could receive on providing amountInMantissa tokens of tokenAddressIn. This function does not account for potential token transfer fees(in case of deflationary tokens)
Parameters
Return Values
❌ Errors
InsufficientInputAmount error is thrown when given input amount is zero
ConversionConfigNotEnabled is thrown when conversion is disabled or config does not exist for given pair
ConversionEnabledOnlyForPrivateConversions is thrown when conversion is only enabled for private conversion
getAmountIn
To get the amount of tokenAddressIn tokens sender would send on receiving amountOutMantissa tokens of tokenAddressOut. This function does not account for potential token transfer fees(in case of deflationary tokens)
Parameters
Return Values
❌ Errors
InsufficientInputAmount error is thrown when given input amount is zero
ConversionConfigNotEnabled is thrown when conversion is disabled or config does not exist for given pair
ConversionEnabledOnlyForPrivateConversions is thrown when conversion is only enabled for private conversion
getUpdatedAmountOut
To get the amount of tokenAddressOut tokens sender could receive on providing amountInMantissa tokens of tokenAddressIn
Parameters
Return Values
❌ Errors
InsufficientInputAmount error is thrown when given input amount is zero
ConversionConfigNotEnabled is thrown when conversion is disabled or config does not exist for given pair
getUpdatedAmountIn
To get the amount of tokenAddressIn tokens sender would send on receiving amountOutMantissa tokens of tokenAddressOut
Parameters
Return Values
❌ Errors
InsufficientInputAmount error is thrown when given input amount is zero
ConversionConfigNotEnabled is thrown when conversion is disabled or config does not exist for given pair
updateAssetsState
This method updates the states of this contract after getting funds from PSR after settling the amount(if any) through privateConversion between converters
Parameters
setConversionConfig
Set the configuration for new or existing conversion pair
Parameters
📅 Events
Emits ConversionConfigUpdated event on success
⛔️ Access Requirements
Controlled by AccessControlManager
❌ Errors
Unauthorized error is thrown when the call is not authorized by AccessControlManager
ZeroAddressNotAllowed is thrown when pool registry address is zero
NonZeroIncentiveForPrivateConversion is thrown when incentive is non zero for private conversion
balanceOf
Get the balance for specific token
Parameters
Return Values
Last updated