KlimaTreasury
Inherits: Ownable
State Variables
KLIMA
address public KLIMA;
blocksNeededForQueue
uint256 public blocksNeededForQueue;
reserveTokens
address[] public reserveTokens;
isReserveToken
mapping(address => bool) public isReserveToken;
reserveTokenQueue
mapping(address => uint256) public reserveTokenQueue;
reserveDepositors
address[] public reserveDepositors;
isReserveDepositor
mapping(address => bool) public isReserveDepositor;
reserveDepositorQueue
mapping(address => uint256) public reserveDepositorQueue;
reserveSpenders
address[] public reserveSpenders;
isReserveSpender
mapping(address => bool) public isReserveSpender;
reserveSpenderQueue
mapping(address => uint256) public reserveSpenderQueue;
liquidityTokens
address[] public liquidityTokens;
isLiquidityToken
mapping(address => bool) public isLiquidityToken;
LiquidityTokenQueue
mapping(address => uint256) public LiquidityTokenQueue;
liquidityDepositors
address[] public liquidityDepositors;
isLiquidityDepositor
mapping(address => bool) public isLiquidityDepositor;
LiquidityDepositorQueue
mapping(address => uint256) public LiquidityDepositorQueue;
bondCalculator
mapping(address => address) public bondCalculator;
reserveManagers
address[] public reserveManagers;
isReserveManager
mapping(address => bool) public isReserveManager;
ReserveManagerQueue
mapping(address => uint256) public ReserveManagerQueue;
liquidityManagers
address[] public liquidityManagers;
isLiquidityManager
mapping(address => bool) public isLiquidityManager;
LiquidityManagerQueue
mapping(address => uint256) public LiquidityManagerQueue;
debtors
address[] public debtors;
isDebtor
mapping(address => bool) public isDebtor;
debtorQueue
mapping(address => uint256) public debtorQueue;
debtorBalance
mapping(address => uint256) public debtorBalance;
rewardManagers
address[] public rewardManagers;
isRewardManager
mapping(address => bool) public isRewardManager;
rewardManagerQueue
mapping(address => uint256) public rewardManagerQueue;
sKLIMA
address public sKLIMA;
sKLIMAQueue
uint256 public sKLIMAQueue;
totalReserves
uint256 public totalReserves;
totalDebt
uint256 public totalDebt;
Functions
constructor
constructor(address _KLIMA, address _BCT, uint256 _blocksNeededForQueue);
deposit
allow approved address to deposit an asset for KLIMA
function deposit(uint256 _amount, address _token, uint256 _profit) external returns (uint256 send_);
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_token | address | address |
_profit | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
send_ | uint256 | uint |
withdraw
allow approved address to burn KLIMA for reserves
function withdraw(uint256 _amount, address _token) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_token | address | address |
incurDebt
allow approved address to borrow reserves
function incurDebt(uint256 _amount, address _token) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_token | address | address |
repayDebtWithReserve
allow approved address to repay borrowed reserves with reserves
function repayDebtWithReserve(uint256 _amount, address _token) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_token | address | address |
repayDebtWithKLIMA
allow approved address to repay borrowed reserves with KLIMA
function repayDebtWithKLIMA(uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
manage
allow approved address to withdraw assets
function manage(address _token, uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_token | address | address |
_amount | uint256 | uint |
mintRewards
send epoch reward to staking contract
function mintRewards(address _recipient, uint256 _amount) external;
excessReserves
returns excess reserves not backing tokens
function excessReserves() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
auditReserves
takes inventory of all tracked assets
always consolidate to recognized reserves before audit
function auditReserves() external onlyManager;
valueOf
returns KLIMA valuation of asset
function valueOf(address _token, uint256 _amount) public view returns (uint256 value_);
Parameters
Name | Type | Description |
---|---|---|
_token | address | address |
_amount | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
value_ | uint256 | uint |
queue
queue address to change boolean in mapping
function queue(MANAGING _managing, address _address) external onlyManager returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_managing | MANAGING | MANAGING |
_address | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
toggle
verify queue then set boolean in mapping
function toggle(MANAGING _managing, address _address, address _calculator) external onlyManager returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_managing | MANAGING | MANAGING |
_address | address | address |
_calculator | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
requirements
checks requirements and returns altered structs
function requirements(
mapping(address => uint256) storage queue_,
mapping(address => bool) storage status_,
address _address
) internal view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
queue_ | mapping(address => uint256) | mapping( address => uint ) |
status_ | mapping(address => bool) | mapping( address => bool ) |
_address | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
listContains
checks array to ensure against duplicate
function listContains(address[] storage _list, address _token) internal view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_list | address[] | address[] |
_token | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
Events
Deposit
event Deposit(address indexed token, uint256 amount, uint256 value);
Withdrawal
event Withdrawal(address indexed token, uint256 amount, uint256 value);
CreateDebt
event CreateDebt(address indexed debtor, address indexed token, uint256 amount, uint256 value);
RepayDebt
event RepayDebt(address indexed debtor, address indexed token, uint256 amount, uint256 value);
ReservesManaged
event ReservesManaged(address indexed token, uint256 amount);
ReservesUpdated
event ReservesUpdated(uint256 indexed totalReserves);
ReservesAudited
event ReservesAudited(uint256 indexed totalReserves);
RewardsMinted
event RewardsMinted(address indexed caller, address indexed recipient, uint256 amount);
ChangeQueued
event ChangeQueued(MANAGING indexed managing, address queued);
ChangeActivated
event ChangeActivated(MANAGING indexed managing, address activated, bool result);
Enums
MANAGING
enum MANAGING {
RESERVEDEPOSITOR,
RESERVESPENDER,
RESERVETOKEN,
RESERVEMANAGER,
LIQUIDITYDEPOSITOR,
LIQUIDITYTOKEN,
LIQUIDITYMANAGER,
DEBTOR,
REWARDMANAGER,
SKLIMA
}