TRSRYv1
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;
decreaseWithdrawApproval
Decrease approval for specific withdrawer addresses
function decreaseWithdrawApproval(address withdrawer_, ERC20 token_, uint256 amount_) external virtual;
withdrawReserves
Allow withdrawal of reserve funds from pre-approved addresses.
function withdrawReserves(address to_, ERC20 token_, uint256 amount_) external virtual;
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;
decreaseDebtorApproval
Decrease approval for someone to withdraw reserves as debt.
function decreaseDebtorApproval(address debtor_, ERC20 token_, uint256 amount_) external virtual;
incurDebt
Pre-approved policies can get a loan to perform operations with treasury assets.
function incurDebt(ERC20 token_, uint256 amount_) external virtual;
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;
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;
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);
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_);
DecreaseWithdrawApproval
event DecreaseWithdrawApproval(address indexed withdrawer_, ERC20 indexed token_, uint256 newAmount_);
Withdrawal
event Withdrawal(address indexed policy_, address indexed withdrawer_, ERC20 indexed token_, uint256 amount_);
IncreaseDebtorApproval
event IncreaseDebtorApproval(address indexed debtor_, ERC20 indexed token_, uint256 newAmount_);
DecreaseDebtorApproval
event DecreaseDebtorApproval(address indexed debtor_, ERC20 indexed token_, uint256 newAmount_);
DebtIncurred
event DebtIncurred(ERC20 indexed token_, address indexed policy_, uint256 amount_);
DebtRepaid
event DebtRepaid(ERC20 indexed token_, address indexed policy_, uint256 amount_);
DebtSet
event DebtSet(ERC20 indexed token_, address indexed policy_, uint256 amount_);
Errors
TRSRY_NoDebtOutstanding
error TRSRY_NoDebtOutstanding();
TRSRY_NotActive
error TRSRY_NotActive();