Skip to main content

TRSRYv1

Git Source

Inherits: Module

Treasury holds all other assets under the control of the protocol.

State Variables​

active​

Status of the treasury. If false, no withdrawals or debt can be incurred.

bool public active;

withdrawApproval​

Mapping of who is approved for withdrawal.

withdrawer -> token -> amount. Infinite approval is max(uint256).

mapping(address => mapping(ERC20 => uint256)) public withdrawApproval;

debtApproval​

Mapping of who is approved to incur debt.

debtor -> token -> amount. Infinite approval is max(uint256).

mapping(address => mapping(ERC20 => uint256)) public debtApproval;

totalDebt​

Total debt for token across all withdrawals.

mapping(ERC20 => uint256) public totalDebt;

reserveDebt​

Debt for particular token and debtor address

mapping(ERC20 => mapping(address => uint256)) public reserveDebt;

Functions​

onlyWhileActive​

modifier onlyWhileActive();

increaseWithdrawApproval​

Increase approval for specific withdrawer addresses

function increaseWithdrawApproval(
address withdrawer_,
ERC20 token_,
uint256 amount_
) external virtual;

Parameters

NameTypeDescription
withdrawer_address
token_ERC20
amount_uint256

decreaseWithdrawApproval​

Decrease approval for specific withdrawer addresses

function decreaseWithdrawApproval(
address withdrawer_,
ERC20 token_,
uint256 amount_
) external virtual;

Parameters

NameTypeDescription
withdrawer_address
token_ERC20
amount_uint256

withdrawReserves​

Allow withdrawal of reserve funds from pre-approved addresses.

function withdrawReserves(address to_, ERC20 token_, uint256 amount_) external virtual;

Parameters

NameTypeDescription
to_address
token_ERC20
amount_uint256

increaseDebtorApproval​

Increase approval for someone to accrue debt in order to withdraw reserves.

Debt will generally be taken by contracts to allocate treasury funds in yield sources.

function increaseDebtorApproval(
address debtor_,
ERC20 token_,
uint256 amount_
) external virtual;

Parameters

NameTypeDescription
debtor_address
token_ERC20
amount_uint256

decreaseDebtorApproval​

Decrease approval for someone to withdraw reserves as debt.

function decreaseDebtorApproval(
address debtor_,
ERC20 token_,
uint256 amount_
) external virtual;

Parameters

NameTypeDescription
debtor_address
token_ERC20
amount_uint256

incurDebt​

Pre-approved policies can get a loan to perform operations with treasury assets.

function incurDebt(ERC20 token_, uint256 amount_) external virtual;

Parameters

NameTypeDescription
token_ERC20
amount_uint256

repayDebt​

Repay a debtor debt.

Only confirmed to safely handle standard and non-standard ERC20s.

Can have unforeseen consequences with ERC777. Be careful with ERC777 as reserve.

function repayDebt(address debtor_, ERC20 token_, uint256 amount_) external virtual;

Parameters

NameTypeDescription
debtor_address
token_ERC20
amount_uint256

setDebt​

An escape hatch for setting debt in special cases, like swapping reserves to another token.

function setDebt(address debtor_, ERC20 token_, uint256 amount_) external virtual;

Parameters

NameTypeDescription
debtor_address
token_ERC20
amount_uint256

getReserveBalance​

Get total balance of assets inside the treasury + any debt taken out against those assets.

function getReserveBalance(ERC20 token_) external view virtual returns (uint256);

Parameters

NameTypeDescription
token_ERC20

Returns

NameTypeDescription
<none>uint256

deactivate​

Emergency shutdown of withdrawals.

function deactivate() external virtual;

activate​

Re-activate withdrawals after shutdown.

function activate() external virtual;

Events​

IncreaseWithdrawApproval​

event IncreaseWithdrawApproval(
address indexed withdrawer_,
ERC20 indexed token_,
uint256 newAmount_
);

Parameters

NameTypeDescription
withdrawer_address
token_ERC20
newAmount_uint256

DecreaseWithdrawApproval​

event DecreaseWithdrawApproval(
address indexed withdrawer_,
ERC20 indexed token_,
uint256 newAmount_
);

Parameters

NameTypeDescription
withdrawer_address
token_ERC20
newAmount_uint256

Withdrawal​

event Withdrawal(
address indexed policy_,
address indexed withdrawer_,
ERC20 indexed token_,
uint256 amount_
);

Parameters

NameTypeDescription
policy_address
withdrawer_address
token_ERC20
amount_uint256

IncreaseDebtorApproval​

event IncreaseDebtorApproval(address indexed debtor_, ERC20 indexed token_, uint256 newAmount_);

Parameters

NameTypeDescription
debtor_address
token_ERC20
newAmount_uint256

DecreaseDebtorApproval​

event DecreaseDebtorApproval(address indexed debtor_, ERC20 indexed token_, uint256 newAmount_);

Parameters

NameTypeDescription
debtor_address
token_ERC20
newAmount_uint256

DebtIncurred​

event DebtIncurred(ERC20 indexed token_, address indexed policy_, uint256 amount_);

Parameters

NameTypeDescription
token_ERC20
policy_address
amount_uint256

DebtRepaid​

event DebtRepaid(ERC20 indexed token_, address indexed policy_, uint256 amount_);

Parameters

NameTypeDescription
token_ERC20
policy_address
amount_uint256

DebtSet​

event DebtSet(ERC20 indexed token_, address indexed policy_, uint256 amount_);

Parameters

NameTypeDescription
token_ERC20
policy_address
amount_uint256

Errors​

TRSRY_NoDebtOutstanding​

error TRSRY_NoDebtOutstanding();

TRSRY_NotActive​

error TRSRY_NotActive();