KonaCycleManager

function changePoolStatus(address _pool, bool _status)

This function is used by the Kona Admin to add or remove a Pool from the protocol. It receives the Pool smart contract address and a boolean expressing if it should be enabled or disabled.

function canStartDistribution()

This function returns True if the protocol is ready to move to the "Distribution" status. It will only be True if the current status is "Cycle" and it has been at least 90 days since the cycle started.

function canStartJoinLeave()

This function returns True if the protocol is ready to move to the "Join Leave" status.

function canStartVoting()

This function returns True if the protocol is ready to move to the "Voting" status.

function canStartNewCycle()

This function returns True if the protocol is ready to move to the "Cycle" status.

function startNewCycle()

This function starts a new cycle by setting the status to "Cycle" and storing the current timestamp. It can be called by anyone as long as the protocol is ready to change its status.

function startDistribution()

This function starts the "Distribution" period. It can be called by anyone as long as the protocol is ready to change its status.

function startJoinLeave()

This function starts the "Join Leave" period. It can be called by anyone as long as the protocol is ready to change its status.

function startVoting()

This function starts the "Voting" period. It can be called by anyone as long as the protocol is ready to change its status.

function isDateInsideCurrentCycle(uint256 _maturity)  returns(bool)

This function receives a timestamp and returns True only if that date will be reached before finishing the current cycle. It is meant to be used to disallow loans with a maturity outside the cycle.

function getCycleStatus()  returns(uint256, uint256, Status)

This function returns the current cycle number, the timestamp in which the current status was set and the current status.

function distributeFunds(address _pool)

This function receives a Pool address and distributes funds for it. It can be called by anyone as long as the protocol is ready to distribute funds and it was not called before for this Pool. It will be check the results of the Pool (including all Oracles) and distribute excess (if any), claim stand by capital (if applicable), slash and reward stakers (minting new Kona tokens).

function getOracleResultsForCycle(address _pool, address _oracle)

This internal function receives a Pool and an Oracle addresses and returns some variables about that Oracle status (how much was the cost of capital, how much fund it accumulated, how much was its stand by capital, etc).

function getOracleResults(address _pool, address _oracle)

This function receives a Pool and an Oracle addresses and returns some variables informing how that Oracle did in the last cycle (if it generated excess, if it covered the cost of capital, etc).

function distributeToWinningOracles(address _pool, uint256 _excessForStakers, address[] memory _oracles, OracleResult[] memory _oraclesResults) 

This internal function iterates over each Pool's Oracles and distributes the excess generated by each to itself and its voters (stakers).

function slashAndDistribute(address _pool, uint256 _alpha, uint256 _s, OracleResult[] memory _oraclesResults, address[] memory oracles, uint256[] memory _newWeights)

This internal function iterates over each Pool's Oracles and if the Oracle generates a loss, it slashes the voter's stakes and use them to reward the voters from the winning Oracles.

function distributeSlashInflation(address _pool, uint256 _totalCapitalRecovered, uint256 _totalOriginalCapital, OracleResult[] memory _oraclesResults)

This internal function receives a Pool address and its results in this cycle and it is in charge of distributing excess (if any), reward Oracles, slash tokens and reward Stakers (by minting new Kona tokens).

function mintTokensForStakers(address _pool, address _oracle, uint256 _totalTokens)

This internal function is in charge of minting new Kona tokens and add them to the stakes of the stakers that supported winning Oracles.

function calculateS()

This internal function calculates the parameter S used in some equations.

function calculateWeights(uint256 _totalVotes, OracleResult[] memory _oraclesResults)

This internal function calculates the weights for all the Oracles that belong to a Pool, plus the new weights after discarding loosing Oracles.

function getAdjustment(uint256 _alpha, uint256 _s) 

This internal function calculates te Unit At Risk and Slash Rate and uses them to calculate the adjustment that will be used to calculate how many tokens to slash.

function getPools()

This function returns the list of Pools that belong to the Protocol.