KlimaTreasury

Git Source

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

NameTypeDescription
_amountuint256uint
_tokenaddressaddress
_profituint256uint

Returns

NameTypeDescription
send_uint256uint

withdraw

allow approved address to burn KLIMA for reserves

function withdraw(uint256 _amount, address _token) external;

Parameters

NameTypeDescription
_amountuint256uint
_tokenaddressaddress

incurDebt

allow approved address to borrow reserves

function incurDebt(uint256 _amount, address _token) external;

Parameters

NameTypeDescription
_amountuint256uint
_tokenaddressaddress

repayDebtWithReserve

allow approved address to repay borrowed reserves with reserves

function repayDebtWithReserve(uint256 _amount, address _token) external;

Parameters

NameTypeDescription
_amountuint256uint
_tokenaddressaddress

repayDebtWithKLIMA

allow approved address to repay borrowed reserves with KLIMA

function repayDebtWithKLIMA(uint256 _amount) external;

Parameters

NameTypeDescription
_amountuint256uint

manage

allow approved address to withdraw assets

function manage(address _token, uint256 _amount) external;

Parameters

NameTypeDescription
_tokenaddressaddress
_amountuint256uint

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

NameTypeDescription
<none>uint256uint

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

NameTypeDescription
_tokenaddressaddress
_amountuint256uint

Returns

NameTypeDescription
value_uint256uint

queue

queue address to change boolean in mapping

function queue(MANAGING _managing, address _address) external onlyManager returns (bool);

Parameters

NameTypeDescription
_managingMANAGINGMANAGING
_addressaddressaddress

Returns

NameTypeDescription
<none>boolbool

toggle

verify queue then set boolean in mapping

function toggle(MANAGING _managing, address _address, address _calculator) external onlyManager returns (bool);

Parameters

NameTypeDescription
_managingMANAGINGMANAGING
_addressaddressaddress
_calculatoraddressaddress

Returns

NameTypeDescription
<none>boolbool

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

NameTypeDescription
queue_mapping(address => uint256)mapping( address => uint )
status_mapping(address => bool)mapping( address => bool )
_addressaddressaddress

Returns

NameTypeDescription
<none>boolbool

listContains

checks array to ensure against duplicate

function listContains(address[] storage _list, address _token) internal view returns (bool);

Parameters

NameTypeDescription
_listaddress[]address[]
_tokenaddressaddress

Returns

NameTypeDescription
<none>boolbool

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
}