Consol
Inherits: IConsol, MultiTokenVault, ReentrancyGuard
Title: Consol
Author: @SocksNFlops
A rebasing ERC20 token that is backed by a pool of tokens, notably usdx and a forfeited assets pool. Include a redemption pool for withdrawing usdx.
State Variables
forfeitedAssetsPool
Get the address of the forfeited assets pool.
address public forfeitedAssetsPool
Functions
constructor
Constructor
constructor(
string memory name_,
string memory symbol_,
uint8 decimalsOffset_,
address admin_,
address forfeitedAssetsPool_
) 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 |
forfeitedAssetsPool_ | address | The address of the forfeited assets pool |
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);
setForfeitedAssetsPool
Set the address of the forfeited assets pool.
function setForfeitedAssetsPool(address forfeitedAssetsPool_) external override onlyRole(Roles.SUPPORTED_TOKEN_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
forfeitedAssetsPool_ | address | The address of the forfeited assets pool |
withdraw
Withdraw tokens from the MultiTokenVault and burn an equivalent amount of the MultiTokenVault token.
function withdraw(address token, uint256 amount)
public
virtual
override(IMultiTokenVault, MultiTokenVault)
onlyRole(Roles.WITHDRAW_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token to withdraw |
amount | uint256 | The amount of tokens to withdraw |
flashSwap
Flash swap tokens. Caller must implement the IConsolFlashSwap interface.
function flashSwap(address inputToken, address outputToken, uint256 amount, bytes calldata data)
external
override
onlyRole(Roles.WITHDRAW_ROLE)
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
inputToken | address | The address of the input token |
outputToken | address | The address of the output token |
amount | uint256 | The amount of tokens to swap |
data | bytes | The data to pass into the callback |
_totalSupply
Checks that the forfeited assets pool is set before returning the total supply
function _totalSupply() internal view virtual override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The total supply of the Consol token |