USDX
Inherits: IUSDX, MultiTokenVault
Title: USDX
Author: SocksNFlops
USDX is a wrapper token for USD-pegged tokens.
State Variables
tokenScalars
mapping(address token => TokenScalars scalars) public override tokenScalars
Functions
constructor
Constructor
constructor(string memory name_, string memory symbol_, uint8 decimalsOffset_, address admin_)
MultiTokenVault(name_, symbol_, decimalsOffset_, admin_);
Parameters
| Name | Type | Description |
|---|---|---|
name_ | string | The name of the token |
symbol_ | string | The symbol of the token |
decimalsOffset_ | uint8 | The number of decimals to pad the internal shares with to avoid precision loss |
admin_ | address | The address of the admin |
supportsInterface
Returns true if this contract implements the interface defined by
interfaceId. See the corresponding
https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(MultiTokenVault) returns (bool);
addSupportedToken
Add a supported token to the MultiTokenVault
function addSupportedToken(address token)
public
override(MultiTokenVault, IMultiTokenVault)
onlyRole(Roles.SUPPORTED_TOKEN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token to add |
addSupportedToken
Add a supported token to the MultiTokenVault with specified scalar values
function addSupportedToken(address token, uint256 scalarNumerator, uint256 scalarDenominator)
external
override
onlyRole(Roles.SUPPORTED_TOKEN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token to add |
scalarNumerator | uint256 | The scalar numerator for the token |
scalarDenominator | uint256 | The scalar denominator for the token |
removeSupportedToken
Remove a supported token from the MultiTokenVault
function removeSupportedToken(address token)
public
override(MultiTokenVault, IMultiTokenVault)
onlyRole(Roles.SUPPORTED_TOKEN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token to remove |
convertAmount
Calculates the amount of tokens minted/burned in a deposit/withdraw operation
function convertAmount(address token, uint256 amount)
public
view
virtual
override(MultiTokenVault, IMultiTokenVault)
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token to deposit/withdraw |
amount | uint256 | The amount of tokens to deposit/withdraw |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The mint/burn amount |
convertUnderlying
Calculates the amount of underlying tokens required to deposit/withdraw a given amount of tokens
function convertUnderlying(address token, uint256 amount)
public
view
virtual
override(MultiTokenVault, IMultiTokenVault)
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token to deposit/withdraw |
amount | uint256 | The amount of tokens minted/burned as a result of the deposit/withdraw operation |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of underlying tokens required to deposit/withdraw the given amount of tokens |
_totalSupply
Internal function to get the total supply of the token. Calculated by summing up the balances of all supported tokens and scaling them by the token scalars.
function _totalSupply() internal view virtual override returns (uint256 totalSupply);
Returns
| Name | Type | Description |
|---|---|---|
totalSupply | uint256 | The total supply of the token |
burn
Burn a specified amount of USDX for a proportional amount of each supported token
function burn(uint256 amount) public;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of USDX to burn |