The Pool smart contract extends from ERC-20, which represents the underlying token of the Pool (the LP token / shares). The total capital available in the Pool is represented in the totalCapital variable.

mapping(uint256=>mapping(address=>uint256)) public standByCapitals

This mapping stores for each cycle and Oracle, the commited stand by capital (in BRZ).

mapping(uint256=>mapping(address=>CapitalAssigned)) public capitalsAssigned

This mapping stores for each cycle and Oracle, the capital assigned, which stores the original assigned amount (after voting), the amount accepted by the Oracle, how much he still has available to spend in this cycle (only if we are inside of the cycle, this amount gets reduced every time a loan is funded and increased every time there was a repayment) and if the Oracle sent the confirmation to accept an amount or not.

mapping(uint256=>mapping(address=>uint256)) public costsOfCapital

This mapping stores for each cycle and Oracle, the cost of capital required by the Pool (in BRZ).

mapping(address=>mapping(address=>uint256)) public defaultVotings

This mapping stores for each Staker and Oracle, the token percentage assigned by default during voting (in Kona Tokens).

mapping(uint256=>mapping(address=>uint256)) public totalVotesToOracles

This mapping stores for each cycle and Oracle, the total votes accumulated (in Kona Tokens).

mapping(uint256=>mapping(address=>Vote[])) public votesToOracles

This mapping stores for each cycle and Oracle, the list of Votes (which has a Staker address and the total Kona Tokens voted).

mapping(uint256=>mapping(address=>uint256)) internal votesByStakers

This mapping stores for each cycle and Staker, the total Kona Tokens used already to vote (in this Pool).

mapping(uint256=>uint256) internal cycleVotes

This mapping stores for each cycle, the total amount of Kona Tokens used to vote.

function changeOracleStatus(address _oracle, bool _status) public onlyOwner

This function can be used to enable a new Oracle (must has been enabled by the Oracle Manager contract as well) or disable one.

function changeLoanStatus(address _loan, bool _status) public onlyOwner

This function is used to approve a loan so that it can be funded (the maturity must be before the end of the cycle) or disapprove one (must not be funded already). It is meant to be called after an Oracle manager informs the Pool that there is a new loan to be approved.

function isDateInsideCurrentCycle(uint256 _date) public view returns(bool)

This function returns True if we are inside a cycle and the date is before the end of the cycle.

function getCurrentCycleNumber() public view returns(uint256)

This function returns the current cycle number. All the Pools share the same cycle number and start timestamp.

function isJoinOrLeavePeriod() public view returns(bool)

This function returns True if we are inside the Join/Leave period.

function addFundsAfterDistribution(uint256 _cycleNumber, address _oracle, uint256 _total) external

This function can be called by the PoolManager to add back the capital used by the Oracles plus the the cost of capital (or less or nothing) to the Pool during distribution, at the end of each cycle.

function processLPsRequests(address user) external onlyOwner

This function can be called to process the requests by liquidity providers to deposit or withdraw funds.

function calculateCostsOfCapital(address _oracle) public onlyOwner

This function calculate the cost of capital to request from each Oracle. It is meant to be called before every cycle.

function getCostOfCapitalParams(address _oracle, uint256 _cycle) public view returns(uint256, uint256, uint256)

This internal function is used to gather all the parameters needed to calculate the cost of capital for an Oracle and a cycle.

function assignCapitalAfterVoting(address _oracle) public onlyOwner

This function is used to assign the capital that can be accepted by each Oracle before each cycle.

function commitStandByCapital(uint256 _total) external onlyOracle

This function can be called by Oracles to commit their stand by capital, before voting.

function acceptCapitalAssigned(uint256 _totalAccepted) external

This function can be called by Oracles to accept totally or partially the capital assigned to them before each cycle. The amount accepted is deducted from the Pool's total capital (which represents the BRZ that the Pool has available for investments).

function requestRemove() external onlyOracle

This function can be called by Oracles to request to be removed from the Pool.

function requestFunding(address _loan) external onlyOracle

This function can be called by Oracles to request the Pool to fund a loan. The loan must be approved and its amount must be equal or less than the funds still available for this Oracle during this cycle. The BRZ is directly sent to the borrower.

function repay(address _loan, uint256 _total) external onlyOracle

This function can be called by Oracles to repay a loan (it is called when the Oracle calls the repay function from the loan itself). The total BRZ is added to the total amount still available for this Oracle to spend during this cycle.

function setDefaultVoting(address _oracle, uint256 _percentage) public

This function can be called by stakers to set the default voting percentage for an Oracle.

function vote(address _oracle, uint256 _totalVotes) public

This function can be called by stakers to vote a certain amount of Kona Tokens for an Oracle before a cycle.

function requestDeposit(uint256 _total) external

This function can be called by liquidity providers to request to deposit funds to the Pool. Their BRZ is taken from them immediately and the request will be processed in the next Join/Leave period.

function requestWithdraw(uint256 _total) external

This function can be called by liquidity providers to request to withdraw funds from the Pool (they send a total of LP tokens, the UI can calculate how many shares are needed to get a certain amount of BRZ). Their tokens are taken from them immediately and the request will be processed in the next Join/Leave period.

function requestCreateRewardDeposit(address _beneficiary, uint256 _total) external onlyPoolManager

This function can be called by the Pool Manager to give shares in the Pool to the stakers (if the Oracles they supported made profit). The BRZ is already in the Pool so just a request is created, to be processed in the next Join/Leave period (which comes immediately after the Distribution).

function getShares(uint _brzAmount) public view returns(uint)

This function returns how many shares represent a total amount of BRZ at the moment.

function getBRZForShares(uint shares) public view returns(uint)

This function returns how much BRZ correspond to a certain number of shares.

function getBRZForMyShares() public view returns(uint)

This function returns how much BRZ could potentially a liquidity provider withdraw at the moment.

function getFundsAvailableToSpend(address _oracle, uint256 _cycleNumber) external view returns(uint256)

This function returns how much BRZ a certain Oracle can still spend during a specific cycle.

function getCommittedStandByCapital(address _oracle, uint256 _cycleNumber) external view returns(uint256)

This function returns the commited stand by capital by an Oracle during a specific cycle.

function getOriginalCapitalAssigned(address _oracle, uint256 _cycleNumber) external view returns(uint256)

This function returns the original capital assigned to an Oracle during a specific cycle.

function getAcceptedCapitalAssigned(address _oracle, uint256 _cycleNumber) external view returns(uint256)

This function returns the accepted capital by an Oracle during a specific cycle.

function getCostOfCapital(address _oracle, uint256 _cycleNumber) external view returns(uint256)

This function returns the cost of capital assigned to an Oracle during a specific cycle.

function getTotalVotesToOracles(address _oracle, uint256 _cycleNumber) external view returns(uint256)

This function returns the total votes an Oracle received in a specific cycle.

function getVotesToOracles(address _oracle, uint256 _cycleNumber) external view returns(Vote[] memory)

This function returns the list of Votes received by an Oracle in a specific cycle.

function getCycleVotes(uint256 _cycleNumber) external view returns(uint256)

This function returns the total votes given in a specific cycle.

function getOracles() external view returns(address[] memory)

This function returns the list of Oracles enabled in the Pool at the moment.

function hasOracles() external view returns(bool)

This function returns True if there are enabled Oracles in the Pool at the moment.