Skip to main content

Consol

Git Source

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

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
forfeitedAssetsPool_addressThe 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

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

NameTypeDescription
tokenaddressThe address of the token to withdraw
amountuint256The 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

NameTypeDescription
inputTokenaddressThe address of the input token
outputTokenaddressThe address of the output token
amountuint256The amount of tokens to swap
databytesThe 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

NameTypeDescription
<none>uint256The total supply of the Consol token