StabilityFeeTreasury
Inherits: Authorizable, Modifiable, Disableable, IStabilityFeeTreasury
This contract is in charge of distributing the accrued stability fees to allowed addresses
State Variables
safeEngine
Address of the SAFEEngine contract
ISAFEEngine public safeEngine;
systemCoin
Address of the SystemCoin contract
ISystemCoin public systemCoin;
coinJoin
Address of the CoinJoin contract
ICoinJoin public coinJoin;
extraSurplusReceiver
Address that receives surplus funds when treasury exceeds capacity (or is disabled)
address public extraSurplusReceiver;
_params
Getter for the unpacked contract parameters struct
StabilityFeeTreasuryParams public _params;
_allowance
Getter for the unpacked allowance struct of a given account
A null per hour allowance means that the account has no per hour limit
mapping(address _account => Allowance) public _allowance;
pulledPerHour
Amount of internal coins a given account has pulled from the treasury in a given block hour
mapping(address _account => mapping(uint256 _blockHour => uint256 _rad)) public pulledPerHour;
latestSurplusTransferTime
Timestamp of the last time that surplus funds were transferred
uint256 public latestSurplusTransferTime;
Functions
params
Getter for the contract parameters struct
function params() external view returns (StabilityFeeTreasuryParams memory _sfTreasuryParams);
Returns
Name | Type | Description |
---|---|---|
_sfTreasuryParams | StabilityFeeTreasuryParams | StabilityFee parameters struct |
allowance
Getter for the allowance struct of a given account
function allowance(address _account) external view returns (Allowance memory __allowance);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The account to query |
Returns
Name | Type | Description |
---|---|---|
__allowance | Allowance | Data structure containing total and per hour allowance for the given account |
accountNotTreasury
Modifier to check if an account is not the treasury (this contract)
This modifier is used to prevent the treasury from giving funds to itself
modifier accountNotTreasury(address _account);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The account to check whether it's the treasury or not |
constructor
constructor(
address _safeEngine,
address _extraSurplusReceiver,
address _coinJoin,
StabilityFeeTreasuryParams memory _sfTreasuryParams
) Authorizable(msg.sender) validParams;
Parameters
Name | Type | Description |
---|---|---|
_safeEngine | address | Address of the SAFEEngine contract |
_extraSurplusReceiver | address | Address that receives surplus funds when treasury exceeds capacity |
_coinJoin | address | Address of the CoinJoin contract |
_sfTreasuryParams | StabilityFeeTreasuryParams | Initial valid StabilityFeeTreasury parameters struct |
_onContractDisable
Disable this contract (normally called by GlobalSettlement)
This method is virtual and should be overriden to implement
function _onContractDisable() internal override;
_joinAllCoins
Join all ERC20 system coins that the treasury has inside the SAFEEngine
Converts all ERC20 system coins to internal system coins
function _joinAllCoins() internal;
settleDebt
Settle as much bad debt as possible (if this contract has any)
function settleDebt() external returns (uint256 _coinBalance, uint256 _debtBalance);
Returns
Name | Type | Description |
---|---|---|
_coinBalance | uint256 | Amount of internal system coins that this contract has after settling debt |
_debtBalance | uint256 | Amount of bad debt that this contract has after settling debt |
_settleDebt
Settle as much bad debt as possible (if this contract has any)
function _settleDebt() internal returns (uint256 _coinBalance, uint256 _debtBalance);
Returns
Name | Type | Description |
---|---|---|
_coinBalance | uint256 | Amount of internal system coins that this contract has after settling debt |
_debtBalance | uint256 | Amount of bad debt that this contract has after settling debt |
setTotalAllowance
Modify an address' total allowance in order to withdraw SF from the treasury
function setTotalAllowance(address _account, uint256 _rad) external isAuthorized accountNotTreasury(_account);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The approved address |
_rad | uint256 | The total approved amount of SF to withdraw [rad] |
setPerHourAllowance
Modify an address' per hour allowance in order to withdraw SF from the treasury
function setPerHourAllowance(address _account, uint256 _rad) external isAuthorized accountNotTreasury(_account);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The approved address |
_rad | uint256 | The per hour approved amount of SF to withdraw [rad] |
giveFunds
Governance transfers SF to an address
function giveFunds(address _account, uint256 _rad) external isAuthorized accountNotTreasury(_account);
Parameters
Name | Type | Description |
---|---|---|
_account | address | Address to transfer SF to |
_rad | uint256 | Amount of internal system coins to transfer [rad] |
takeFunds
Governance takes funds from an address
function takeFunds(address _account, uint256 _rad) external isAuthorized accountNotTreasury(_account);
Parameters
Name | Type | Description |
---|---|---|
_account | address | Address to take system coins from |
_rad | uint256 | Amount of internal system coins to take from the account [rad] |
pullFunds
Pull stability fees from the treasury
The caller of this method needs to have enough allowance in order to pull funds
function pullFunds(address _dstAccount, uint256 _wad) external;
Parameters
Name | Type | Description |
---|---|---|
_dstAccount | address | Address to transfer funds to |
_wad | uint256 | Amount of system coins (SF) to transfer [wad] |
transferSurplusFunds
Transfer surplus stability fees to the extraSurplusReceiver. This is here to make sure that the treasury doesn't accumulate fees that it doesn't even need in order to pay for allowances. It ensures that there are enough funds left in the treasury to account for posterior expenses
function transferSurplusFunds() external;
_modifyParameters
Internal function to be overriden with custom logic to modify parameters
This function is set to revert if not overriden
function _modifyParameters(bytes32 _param, bytes memory _data) internal override;
_validateParameters
Internal function to be overriden with custom logic to validate parameters
function _validateParameters() internal view override;