KonaStaking
This is a Staking smart contract in which users can lock their KonaTokens to participate in the system and be able to vote for Oracles so that they can receive funds.
Furthermore it keeps track of the votes/the staking and the slashing after distribution by saving the ratios in mappings.
mapping(address => uint256) public stakedBalance;
This mapping keeps track of the staked balance of each user.
function stake(uint256 _total)
This function allows users to stake a certain amount of tokens.
function unstake(uint256 _total)
This function allows users to unstake a certain amount of tokens.
.
Voting related mappings
We decided to have those mappings to avoid looping over arrays to get certain values.
mapping(uint => mapping(address => mapping(address => mapping(address => uint)))) public votesCyleUserPoolOracle;
This mapping tracks the total votes per oracle - cycle -> user -> pool -> oracle -> votes
mapping(uint => mapping(address => mapping(address => address[]))) public votesCycleUserPoolOracles;
This mapping tacks a list of oracles in a pool that a user voted for in a cycle - cycle -> user -> pool -> oracles
mapping(uint => mapping(address => address[])) public votesCycleUserPools;
This mapping tacks a list of pools that a user voted for in a cycle - cycle -> user -> pools
mapping(uint => mapping(address => mapping(address => uint))) public userCyclePoolVotedAmount;
This mapping tracks the total amount of votes used by the user per pool in the cycle
mapping(uint => mapping(address => uint)) public totalVotedPoolPerCycle;
This mapping tracks the global total amount of votes a pool received in the cycle
mapping(uint => mapping(address => mapping(address => uint))) public totalVotedPoolOraclePerCycle;
This mapping tracks the global total amount of votes an oracle in a pool received in the cycle
mapping(uint => uint) public totalVotesPerCycle;
This mapping tracks the global total amount of votes in the cycle
Reward Mappings
mapping(uint => mapping(address => mapping(address => int))) public rewardPerOracleRate;
This mapping tracks the rewardrate per balance of pools - cycle -> pool -> oracle -> rate - 1e18 base.
This rate can be positive as well as negative. A negative value would indicate that the oracle lost and the users will get slashed
mapping(uint => uint) public inflationRewardRateCycle
This mapping tracks the InflationRewardsRate with the accuracy base of 1e18.
User Mappings
mapping(address => uint) public userLastUpdated;
This mapping tracks the last cycle the user stake was updated
mapping(address => uint) public userLastUpdatedLPReward;
This mapping tracks the last cycle the user lpReward was updated
Updated 10 months ago