IStabilityFeeTreasury
Inherits: IAuthorizable, IDisableable, IModifiable
Functions
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 |
_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
function _allowance(address _account) external view returns (uint256 _total, uint256 _perHour);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The account to query |
Returns
Name | Type | Description |
---|---|---|
_total | uint256 | Total allowance for the given account |
_perHour | uint256 | Per hour allowance for the given account |
setTotalAllowance
Modify an address' total allowance in order to withdraw SF from the treasury
function setTotalAllowance(address _account, uint256 _rad) external;
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;
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;
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;
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;
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 |
safeEngine
Address of the SAFEEngine contract
function safeEngine() external view returns (ISAFEEngine _safeEngine);
coinJoin
Address of the CoinJoin contract
function coinJoin() external view returns (ICoinJoin _coinJoin);
extraSurplusReceiver
Address that receives surplus funds when treasury exceeds capacity (or is disabled)
function extraSurplusReceiver() external view returns (address _extraSurplusReceiver);
systemCoin
Address of the SystemCoin contract
function systemCoin() external view returns (ISystemCoin _systemCoin);
latestSurplusTransferTime
Timestamp of the last time that surplus funds were transferred
function latestSurplusTransferTime() external view returns (uint256 _latestSurplusTransferTime);
pulledPerHour
Amount of internal coins a given account has pulled from the treasury in a given block hour
function pulledPerHour(address _account, uint256 _blockHour) external view returns (uint256 _pulledPerHour);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The account to query |
_blockHour | uint256 | The block hour to query |
Returns
Name | Type | Description |
---|---|---|
_pulledPerHour | uint256 | Amount of coins pulled from the treasury by the account in the given block hour [rad] |
params
Getter for the contract parameters struct
function params() external view returns (StabilityFeeTreasuryParams memory _sfTreasuryParams);
Returns
Name | Type | Description |
---|---|---|
_sfTreasuryParams | StabilityFeeTreasuryParams | StabilityFee parameters struct |
_params
Getter for the unpacked contract parameters struct
function _params()
external
view
returns (uint256 _treasuryCapacity, uint256 _pullFundsMinThreshold, uint256 _surplusTransferDelay);
Returns
Name | Type | Description |
---|---|---|
_treasuryCapacity | uint256 | Maximum amount of internal coins that the treasury can hold [rad] |
_pullFundsMinThreshold | uint256 | Minimum amount of internal coins that the treasury must hold in order to allow pulling funds [rad] |
_surplusTransferDelay | uint256 | Minimum amount of time that must pass between surplus transfers [seconds] |
Events
SetTotalAllowance
Emitted when an account's total allowance is modified
event SetTotalAllowance(address indexed _account, uint256 _rad);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The account whose allowance was modified |
_rad | uint256 | The new total allowance [rad] |
SetPerHourAllowance
Emitted when an account's per hour allowance is modified
event SetPerHourAllowance(address indexed _account, uint256 _rad);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The account whose allowance was modified |
_rad | uint256 | The new per hour allowance [rad] |
GiveFunds
Emitted when governance gives funds to an account
event GiveFunds(address indexed _account, uint256 _rad);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The account that received funds |
_rad | uint256 | The amount of funds that were given [rad] |
TakeFunds
Emitted when governance takes funds from an account
event TakeFunds(address indexed _account, uint256 _rad);
Parameters
Name | Type | Description |
---|---|---|
_account | address | The account from which the funds are taken |
_rad | uint256 | The amount of funds that were taken [rad] |
PullFunds
Emitted when an account pulls funds from the treasury
event PullFunds(address indexed _sender, address indexed _dstAccount, uint256 _rad);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The account that triggered the pull |
_dstAccount | address | The account that received funds |
_rad | uint256 | The amount of funds that were pulled [rad] |
TransferSurplusFunds
Emitted when surplus funds are transferred to the extraSurplusReceiver
event TransferSurplusFunds(address _extraSurplusReceiver, uint256 _fundsToTransfer);
Parameters
Name | Type | Description |
---|---|---|
_extraSurplusReceiver | address | The account that received the surplus funds |
_fundsToTransfer | uint256 | The amount of funds that were transferred [rad] |
JoinCoins
Emitted when ERC20 coins are joined into the system
event JoinCoins(uint256 _wad);
Parameters
Name | Type | Description |
---|---|---|
_wad | uint256 | The amount of ERC20 coins that were joined [wad] |
SettleDebt
Emitted when treasury coins are used to settle debt
event SettleDebt(uint256 _rad);
Parameters
Name | Type | Description |
---|---|---|
_rad | uint256 | The amount of internal system coins and debt that were destroyed [rad] |
Errors
SFTreasury_AccountCannotBeTreasury
Throws when trying to pull/give/take funds from/to the treasury itself
error SFTreasury_AccountCannotBeTreasury();
SFTreasury_OutstandingBadDebt
Throws when trying to transfer surplus funds without having settled all debt
error SFTreasury_OutstandingBadDebt();
SFTreasury_NotEnoughFunds
Throws when trying to transfer more funds than the treasury has
error SFTreasury_NotEnoughFunds();
SFTreasury_NotAllowed
Throws when trying to pull funds above the account's total allowance
error SFTreasury_NotAllowed();
SFTreasury_PerHourLimitExceeded
Throws when trying to pull funds above the account's per hour allowance
error SFTreasury_PerHourLimitExceeded();
SFTreasury_DstCannotBeAccounting
Throws when trying to pull funds to the accounting contract
error SFTreasury_DstCannotBeAccounting();
SFTreasury_NullTransferAmount
Throws when trying to transfer a null amount of funds
error SFTreasury_NullTransferAmount();
SFTreasury_BelowPullFundsMinThreshold
Throws when trying to pull funds while the coin balance is below the minimum threshold
error SFTreasury_BelowPullFundsMinThreshold();
SFTreasury_TransferCooldownNotPassed
Throws when trying to transfer surplus funds before the cooldown period has passed
error SFTreasury_TransferCooldownNotPassed();
SFTreasury_NotEnoughSurplus
Throws when trying to transfer surplus funds while the treasury is below capacity
error SFTreasury_NotEnoughSurplus();
Structs
StabilityFeeTreasuryParams
struct StabilityFeeTreasuryParams {
uint256 treasuryCapacity;
uint256 pullFundsMinThreshold;
uint256 surplusTransferDelay;
}
Allowance
struct Allowance {
uint256 total;
uint256 perHour;
}