Skip to main content

AbstractTokenConverter

The AbstractTokenConverter is the base contract for all token converter implementations in the Rheofi Protocol. It provides the core logic for converting protocol-held tokens into desired target tokens through permissionless swap operations, enabling efficient protocol revenue management.

Overview

Token converters facilitate the conversion of accumulated protocol revenue tokens into target assets needed by various protocol components (e.g., converting diverse fee tokens into stablecoins for the Risk Fund). The AbstractTokenConverter defines the standard interface and shared logic, including conversion execution, price validation via the ResilientOracle, and access control integration.

Converters incentivize external participants to execute conversions by offering a configurable incentive on each swap.

Key Functions

convertExactTokens

Converts an exact amount of input tokens into the maximum possible output tokens.

function convertExactTokens(
uint256 amountInMantissa,
uint256 amountOutMinMantissa,
address tokenAddressIn,
address tokenAddressOut,
address to
) external returns (uint256 actualAmountIn, uint256 actualAmountOut);

convertForExactTokens

Converts the minimum necessary input tokens to receive an exact amount of output tokens.

function convertForExactTokens(
uint256 amountInMaxMantissa,
uint256 amountOutMantissa,
address tokenAddressIn,
address tokenAddressOut,
address to
) external returns (uint256 actualAmountIn, uint256 actualAmountOut);

setConversionConfig

Configures conversion parameters including the incentive and enabled token pairs.

function setConversionConfig(
address tokenAddressIn,
address tokenAddressOut,
ConversionConfig calldata conversionConfig
) external;

getAmountOut / getAmountIn

Preview functions that return the expected output or required input for a conversion.

function getAmountOut(uint256 amountInMantissa, address tokenAddressIn, address tokenAddressOut) external view returns (uint256);
function getAmountIn(uint256 amountOutMantissa, address tokenAddressIn, address tokenAddressOut) external view returns (uint256);

See Also