SubConsol
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
| Name | Type | Description |
|---|---|---|
name_ | string | The name of the token |
symbol_ | string | The symbol of the token |
admin_ | address | The address of the admin |
collateral_ | address | The 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
| Name | Type | Description |
|---|---|---|
yieldStrategy_ | address | The 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
| Name | Type | Description |
|---|---|---|
collateralAmount | uint256 | The amount of collateral to deposit |
mintAmount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
to | address | The address to send the collateral to |
collateralAmount | uint256 | The amount of collateral to withdraw |
burnAmount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
to | address | The address to send the collateral to |
collateralAmount | uint256 | The amount of collateral to withdraw |
burnAmount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
to | address | The address to send the collateral to |
collateralAmount | uint256 | The amount of collateral to withdraw |
burnAmount | uint256 | The amount of SubConsol to burn |
depositToYieldStrategy
Deposit collateral into the yield strategy
function depositToYieldStrategy(uint256 collateralAmount) external override onlyRole(Roles.PORTFOLIO_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
collateralAmount | uint256 | The amount of collateral to deposit |
withdrawFromYieldStrategy
Withdraw collateral from the yield strategy
function withdrawFromYieldStrategy(uint256 collateralAmount) external override onlyRole(Roles.PORTFOLIO_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
collateralAmount | uint256 | The amount of collateral to withdraw |