Skip to main content

USDX

Git Source

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

NameTypeDescription
name_stringThe name of the token
symbol_stringThe symbol of the token
decimalsOffset_uint8The number of decimals to pad the internal shares with to avoid precision loss
admin_addressThe 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

NameTypeDescription
tokenaddressThe 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

NameTypeDescription
tokenaddressThe address of the token to add
scalarNumeratoruint256The scalar numerator for the token
scalarDenominatoruint256The 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

NameTypeDescription
tokenaddressThe 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

NameTypeDescription
tokenaddressThe address of the token to deposit/withdraw
amountuint256The amount of tokens to deposit/withdraw

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
tokenaddressThe address of the token to deposit/withdraw
amountuint256The amount of tokens minted/burned as a result of the deposit/withdraw operation

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
totalSupplyuint256The 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

NameTypeDescription
amountuint256The amount of USDX to burn