--- tags: azur-mayors --- # Staking contract documentation ## Data structures ### StakingConfig ``` solidity struct StakingConfig { address voteAddress; address voucherAddress; } ``` ### Stake ``` solidity struct Stake { uint256 startDate; uint256 amount; } ``` ## Events ### VotesStaked ``` solidity event ConfigUpdated(); ``` ### VotesStaked ``` solidity event VotesStaked( uint256 startDate, uint256 amount ); ``` ### VotesUnstaked ``` solidity event VotesUnstaked( address staker, uint256 votesAmount, uint256 vouchersAmount ); ``` ### VouchersMinted ``` solidity event VouchersMinted( address staker, uint256 amount ); ``` ### StakeAdded ``` solidity event StakeAdded( address staker, uint256 startDate, uint256 amount ); ``` ### StakeRemoved ``` solidity event StakeRemoved( address staker, uint256 startDate, uint256 amount ); ``` ### StakerAdded ``` solidity event StakerAdded( address staker ); ``` ### StakerRemoved ``` solidity event StakerRemoved( address staker ); ``` ## Get functions ### getThreshold Returns the current threshold. ``` solidity function getThreshold() external view returns (uint256); ``` ### getStakesNumber Returns the number of stakes by user. ``` solidity function getStakesNumber( address staker ) external view returns (uint256); ``` ### getStakersNumber Returns the number of stakers. ``` solidity function getStakersNumber() external view returns (uint256); ``` ### getVotesAmount Returns the number of Votes by user. ``` solidity function getVotesAmount( uint256 startIndex, // stake index uint256 number // number of stakes ) external view returns (uint256 totalAmount); ``` ### getVouchersAmount Returns the number of BVouchers by user which have not been withdrawn yet. ``` solidity function getVouchersAmount( uint256 startIndex, // stake index uint256 number // number of stakes ) external view returns (uint256 totalAmount); ``` ## Set functions ### [OWNER] setThreshold Sets the minimam thershold of Votes which a user can stake at the first time. ``` solidity function setThreshold( uint256 threshold ) external; ``` ### stakeVotes Stakes the votes by user. The user can do the next one stake after 24 hours. A stake must be a multiple of 100 Votes. The first stake does not allow to be less than votes threshold(see getThreshold() and setThreshold()) Requires an allowance for Votes transfer. Emits `VotesStaked` event. Emits `StakerAdded` event. Emits `StakeAdded` event. ``` solidity function stakeVotes( uint256 votesNumber ) external; ``` ### [OWNER] withdrawVouchers Once a week, the owner can withdraw the accumulated BVouchers to the user's wallet. Emits `VouchersMinted` event. ``` solidity function withdrawVouchers( address staker, uint256 startIndex, // stake index uint256 number // number of stakes ) external; ``` ### unstakeVotes Users can unstake them Votes. All of the user's Votes and the accumulated BVouchers be withdrawn to the user's wallet. Emits `VotesUnstaked` event. Emits `StakeRemoved` event. Emits `StakerRemoved` event. ``` solidity function unstakeVotes( uint256 startIndex, // stake index uint256 numberr // number of stakes ) external; ```