Skip to main content

TRSRYv1

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

Methods

INIT

function INIT() external nonpayable

Initialization function for the module

This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.

KEYCODE

function KEYCODE() external pure returns (Keycode)

5 byte identifier for a module.

Returns

NameTypeDescription
_0Keycodeundefined

VERSION

function VERSION() external pure returns (uint8 major, uint8 minor)

Returns which semantic version of a module is being implemented.

Returns

NameTypeDescription
majoruint8- Major version upgrade indicates breaking change to the interface.
minoruint8- Minor version change retains backward-compatible interface.

activate

function activate() external nonpayable

Re-activate withdrawals after shutdown.

active

function active() external view returns (bool)

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

Returns

NameTypeDescription
_0boolundefined

changeKernel

function changeKernel(contract Kernel newKernel_) external nonpayable

Function used by kernel when migrating to a new kernel.

Parameters

NameTypeDescription
newKernel_contract Kernelundefined

deactivate

function deactivate() external nonpayable

Emergency shutdown of withdrawals.

debtApproval

function debtApproval(address, contract ERC20) external view returns (uint256)

Mapping of who is approved to incur debt.

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

Parameters

NameTypeDescription
_0addressundefined
_1contract ERC20undefined

Returns

NameTypeDescription
_0uint256undefined

decreaseDebtorApproval

function decreaseDebtorApproval(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable

Decrease approval for someone to withdraw reserves as debt.

Parameters

NameTypeDescription
debtor_addressundefined
token_contract ERC20undefined
amount_uint256undefined

decreaseWithdrawApproval

function decreaseWithdrawApproval(address withdrawer_, contract ERC20 token_, uint256 amount_) external nonpayable

Decrease approval for specific withdrawer addresses

Parameters

NameTypeDescription
withdrawer_addressundefined
token_contract ERC20undefined
amount_uint256undefined

getReserveBalance

function getReserveBalance(contract ERC20 token_) external view returns (uint256)

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

Parameters

NameTypeDescription
token_contract ERC20undefined

Returns

NameTypeDescription
_0uint256undefined

increaseDebtorApproval

function increaseDebtorApproval(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable

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.

Parameters

NameTypeDescription
debtor_addressundefined
token_contract ERC20undefined
amount_uint256undefined

increaseWithdrawApproval

function increaseWithdrawApproval(address withdrawer_, contract ERC20 token_, uint256 amount_) external nonpayable

Increase approval for specific withdrawer addresses

Parameters

NameTypeDescription
withdrawer_addressundefined
token_contract ERC20undefined
amount_uint256undefined

incurDebt

function incurDebt(contract ERC20 token_, uint256 amount_) external nonpayable

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

Parameters

NameTypeDescription
token_contract ERC20undefined
amount_uint256undefined

kernel

function kernel() external view returns (contract Kernel)

Returns

NameTypeDescription
_0contract Kernelundefined

repayDebt

function repayDebt(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable

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.

Parameters

NameTypeDescription
debtor_addressundefined
token_contract ERC20undefined
amount_uint256undefined

reserveDebt

function reserveDebt(contract ERC20, address) external view returns (uint256)

Debt for particular token and debtor address

Parameters

NameTypeDescription
_0contract ERC20undefined
_1addressundefined

Returns

NameTypeDescription
_0uint256undefined

setDebt

function setDebt(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable

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

Parameters

NameTypeDescription
debtor_addressundefined
token_contract ERC20undefined
amount_uint256undefined

totalDebt

function totalDebt(contract ERC20) external view returns (uint256)

Total debt for token across all withdrawals.

Parameters

NameTypeDescription
_0contract ERC20undefined

Returns

NameTypeDescription
_0uint256undefined

withdrawApproval

function withdrawApproval(address, contract ERC20) external view returns (uint256)

Mapping of who is approved for withdrawal.

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

Parameters

NameTypeDescription
_0addressundefined
_1contract ERC20undefined

Returns

NameTypeDescription
_0uint256undefined

withdrawReserves

function withdrawReserves(address to_, contract ERC20 token_, uint256 amount_) external nonpayable

Allow withdrawal of reserve funds from pre-approved addresses.

Parameters

NameTypeDescription
to_addressundefined
token_contract ERC20undefined
amount_uint256undefined

Events

DebtIncurred

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

Parameters

NameTypeDescription
token_ indexedcontract ERC20undefined
policy_ indexedaddressundefined
amount_uint256undefined

DebtRepaid

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

Parameters

NameTypeDescription
token_ indexedcontract ERC20undefined
policy_ indexedaddressundefined
amount_uint256undefined

DebtSet

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

Parameters

NameTypeDescription
token_ indexedcontract ERC20undefined
policy_ indexedaddressundefined
amount_uint256undefined

DecreaseDebtorApproval

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

Parameters

NameTypeDescription
debtor_ indexedaddressundefined
token_ indexedcontract ERC20undefined
newAmount_uint256undefined

DecreaseWithdrawApproval

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

Parameters

NameTypeDescription
withdrawer_ indexedaddressundefined
token_ indexedcontract ERC20undefined
newAmount_uint256undefined

IncreaseDebtorApproval

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

Parameters

NameTypeDescription
debtor_ indexedaddressundefined
token_ indexedcontract ERC20undefined
newAmount_uint256undefined

IncreaseWithdrawApproval

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

Parameters

NameTypeDescription
withdrawer_ indexedaddressundefined
token_ indexedcontract ERC20undefined
newAmount_uint256undefined

Withdrawal

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

Parameters

NameTypeDescription
policy_ indexedaddressundefined
withdrawer_ indexedaddressundefined
token_ indexedcontract ERC20undefined
amount_uint256undefined

Errors

KernelAdapter_OnlyKernel

error KernelAdapter_OnlyKernel(address caller_)

Parameters

NameTypeDescription
caller_addressundefined

Module_PolicyNotPermitted

error Module_PolicyNotPermitted(address policy_)

Parameters

NameTypeDescription
policy_addressundefined

TRSRY_NoDebtOutstanding

error TRSRY_NoDebtOutstanding()

TRSRY_NotActive

error TRSRY_NotActive()