IStabilityFeeTreasury

Git Source

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

NameTypeDescription
_accountaddressThe account to query

Returns

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

NameTypeDescription
_accountaddressThe account to query

Returns

NameTypeDescription
_totaluint256Total allowance for the given account
_perHouruint256Per 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

NameTypeDescription
_accountaddressThe approved address
_raduint256The 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

NameTypeDescription
_accountaddressThe approved address
_raduint256The per hour approved amount of SF to withdraw [rad]

giveFunds

Governance transfers SF to an address

function giveFunds(address _account, uint256 _rad) external;

Parameters

NameTypeDescription
_accountaddressAddress to transfer SF to
_raduint256Amount of internal system coins to transfer [rad]

takeFunds

Governance takes funds from an address

function takeFunds(address _account, uint256 _rad) external;

Parameters

NameTypeDescription
_accountaddressAddress to take system coins from
_raduint256Amount 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

NameTypeDescription
_dstAccountaddressAddress to transfer funds to
_waduint256Amount 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

NameTypeDescription
_coinBalanceuint256Amount of internal system coins that this contract has after settling debt
_debtBalanceuint256Amount 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

NameTypeDescription
_accountaddressThe account to query
_blockHouruint256The block hour to query

Returns

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

NameTypeDescription
_sfTreasuryParamsStabilityFeeTreasuryParamsStabilityFee parameters struct

_params

Getter for the unpacked contract parameters struct

function _params()
  external
  view
  returns (uint256 _treasuryCapacity, uint256 _pullFundsMinThreshold, uint256 _surplusTransferDelay);

Returns

NameTypeDescription
_treasuryCapacityuint256Maximum amount of internal coins that the treasury can hold [rad]
_pullFundsMinThresholduint256Minimum amount of internal coins that the treasury must hold in order to allow pulling funds [rad]
_surplusTransferDelayuint256Minimum 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

NameTypeDescription
_accountaddressThe account whose allowance was modified
_raduint256The new total allowance [rad]

SetPerHourAllowance

Emitted when an account's per hour allowance is modified

event SetPerHourAllowance(address indexed _account, uint256 _rad);

Parameters

NameTypeDescription
_accountaddressThe account whose allowance was modified
_raduint256The new per hour allowance [rad]

GiveFunds

Emitted when governance gives funds to an account

event GiveFunds(address indexed _account, uint256 _rad);

Parameters

NameTypeDescription
_accountaddressThe account that received funds
_raduint256The amount of funds that were given [rad]

TakeFunds

Emitted when governance takes funds from an account

event TakeFunds(address indexed _account, uint256 _rad);

Parameters

NameTypeDescription
_accountaddressThe account from which the funds are taken
_raduint256The 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

NameTypeDescription
_senderaddressThe account that triggered the pull
_dstAccountaddressThe account that received funds
_raduint256The amount of funds that were pulled [rad]

TransferSurplusFunds

Emitted when surplus funds are transferred to the extraSurplusReceiver

event TransferSurplusFunds(address _extraSurplusReceiver, uint256 _fundsToTransfer);

Parameters

NameTypeDescription
_extraSurplusReceiveraddressThe account that received the surplus funds
_fundsToTransferuint256The amount of funds that were transferred [rad]

JoinCoins

Emitted when ERC20 coins are joined into the system

event JoinCoins(uint256 _wad);

Parameters

NameTypeDescription
_waduint256The amount of ERC20 coins that were joined [wad]

SettleDebt

Emitted when treasury coins are used to settle debt

event SettleDebt(uint256 _rad);

Parameters

NameTypeDescription
_raduint256The 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;
}