Skip to main content

SubConsol

Git Source

Inherits: Context, ERC165, AccessControl, ERC20, ISubConsol

Title: SubConsol

Author: SocksNFlops

SubConsol is a contract that allows users to deposit collateral and mint an input into Consol

State Variables

collateral

Get the collateral token

address public immutable override collateral

yieldStrategy

Get the yield strategy

address public override yieldStrategy

yieldAmount

Get the amount of yield in the yield strategy

uint256 public override yieldAmount

Functions

constructor

Constructor

constructor(string memory name_, string memory symbol_, address admin_, address collateral_) ERC20(name_, symbol_);

Parameters

NameTypeDescription
name_stringThe name of the token
symbol_stringThe symbol of the token
admin_addressThe address of the admin
collateral_addressThe address of the collateral

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(AccessControl, ERC165) returns (bool);

setYieldStrategy

Set the yield strategy

function setYieldStrategy(address yieldStrategy_) external override onlyRole(Roles.DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
yieldStrategy_addressThe address of the yield strategy

depositCollateral

Deposit collateral into the Consol contract while minting a specified amount of SubConsol

function depositCollateral(uint256 collateralAmount, uint256 mintAmount)
external
override
onlyRole(Roles.ACCOUNTING_ROLE);

Parameters

NameTypeDescription
collateralAmountuint256The amount of collateral to deposit
mintAmountuint256The amount of SubConsol to mint

_withdrawCollateral

Internal function to withdraw collateral from the contract

function _withdrawCollateral(address to, uint256 collateralAmount, uint256 burnAmount)
internal
onlyRole(Roles.ACCOUNTING_ROLE);

Parameters

NameTypeDescription
toaddressThe address to send the collateral to
collateralAmountuint256The amount of collateral to withdraw
burnAmountuint256The amount of tokens to burn

withdrawCollateral

Withdraw collateral from the Consol contract while burning a specified amount of SubConsol

function withdrawCollateral(address to, uint256 collateralAmount, uint256 burnAmount) public override;

Parameters

NameTypeDescription
toaddressThe address to send the collateral to
collateralAmountuint256The amount of collateral to withdraw
burnAmountuint256The amount of SubConsol to burn

withdrawCollateralAsync

Withdraw collateral from the SubConsol contract asynchronously (from the yield strategy if necessary)

function withdrawCollateralAsync(address to, uint256 collateralAmount, uint256 burnAmount) external override;

Parameters

NameTypeDescription
toaddressThe address to send the collateral to
collateralAmountuint256The amount of collateral to withdraw
burnAmountuint256The amount of SubConsol to burn

depositToYieldStrategy

Deposit collateral into the yield strategy

function depositToYieldStrategy(uint256 collateralAmount) external override onlyRole(Roles.PORTFOLIO_ROLE);

Parameters

NameTypeDescription
collateralAmountuint256The amount of collateral to deposit

withdrawFromYieldStrategy

Withdraw collateral from the yield strategy

function withdrawFromYieldStrategy(uint256 collateralAmount) external override onlyRole(Roles.PORTFOLIO_ROLE);

Parameters

NameTypeDescription
collateralAmountuint256The amount of collateral to withdraw