TokenAmtResolver ​
Inherits:Error
Title: TokenAmtResolver
Utility for converting between token amounts and USD values using the FluidUsdOracle. All USD values are in 1e27 precision (1 USD = 1e27). Inheritable by auth contracts, limit handlers, resolvers, or any consumer that needs token <-> USD conversions.
Constants ​
ORACLE_PRECISION ​
solidity
uint256 private constant ORACLE_PRECISION = 1e27Functions ​
_getUsdValueForTokenAmount ​
Converts a token amount to its USD value using the oracle's getPriceRawForMode.
solidity
function _getUsdValueForTokenAmount(address usdOracle_, address token_, uint256 amount_, uint8 priceMode_)
internal
view
returns (uint256 usdValue_);Parameters
| Name | Type | Description |
|---|---|---|
usdOracle_ | address | Address of the FluidUsdOracle. |
token_ | address | The token address. |
amount_ | uint256 | The token amount in token decimals. |
priceMode_ | uint8 | The price mode (PRICE_MODE_MARKET = 1, PRICE_MODE_PEG = 2). |
Returns
| Name | Type | Description |
|---|---|---|
usdValue_ | uint256 | The USD value in 1e27 precision. |
_getTokenAmountForUsdValue ​
Converts a USD value to a token amount using the oracle's getPriceRawForMode.
solidity
function _getTokenAmountForUsdValue(address usdOracle_, address token_, uint256 usdValue_, uint8 priceMode_)
internal
view
returns (uint256 amount_);Parameters
| Name | Type | Description |
|---|---|---|
usdOracle_ | address | Address of the FluidUsdOracle. |
token_ | address | The token address. |
usdValue_ | uint256 | The USD value in 1e27 precision. |
priceMode_ | uint8 | The price mode (PRICE_MODE_MARKET = 1, PRICE_MODE_PEG = 2). |
Returns
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The token amount in token decimals. |