Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Rewards on curve #376

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
359 changes: 244 additions & 115 deletions contracts/staking/stakeManager/StakeManager.sol

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions contracts/staking/stakeManager/StakeManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ contract StakeManagerStorage is GovernanceLockable, RootChainable {
struct State {
uint256 amount;
uint256 stakerCount;
uint256 shares;
}

struct StateChange {
int256 amount;
int256 stakerCount;
int256 shares;
}

struct Validator {
Expand All @@ -43,12 +45,14 @@ contract StakeManagerStorage is GovernanceLockable, RootChainable {
uint256 lastCommissionUpdate;
uint256 delegatorsReward;
uint256 delegatedAmount;
uint256 initialRewardPerStake;
uint256 initialRewardPerShare;
}

uint256 constant MAX_COMMISION_RATE = 100;
uint256 constant MAX_PROPOSER_BONUS = 100;
uint256 constant CHK_REWARD_PRECISION = 100;
uint256 constant REWARD_PRECISION = 10**25;

uint256 internal constant INCORRECT_VALIDATOR_ID = 2**256 - 1;
uint256 internal constant INITIALIZED_AMOUNT = 1;

Expand All @@ -68,7 +72,7 @@ contract StakeManagerStorage is GovernanceLockable, RootChainable {
uint256 public checkPointBlockInterval;
uint256 public signerUpdateLimit;

uint256 public validatorThreshold; //128
uint256 public validatorThreshold; // 128
uint256 public totalStaked;
uint256 public NFTCounter;
uint256 public totalRewards;
Expand Down
15 changes: 13 additions & 2 deletions contracts/staking/stakeManager/StakeManagerStorageExtension.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
pragma solidity 0.5.17;

contract StakeManagerStorageExtension {
uint256 public constant SHARES_PRECISION = 10**12; // will cause and overflow if ALL tokens will be staked at once, which will won't matter at this point anyway

struct StakeSharesState {
uint256 sharesPool;
uint256 stakePool;
uint256 shares;
}

address public eventsHub;
uint256 public rewardPerStake;
uint256 public rewardPerShare;
address public extensionCode;
address[] public signers;

uint256 constant CHK_REWARD_PRECISION = 100;
uint256 public prevBlockInterval;
// how much less reward per skipped checkpoint, 0 - 100%
uint256 public rewardDecreasePerCheckpoint;
// how many checkpoints to reward
uint256 public maxRewardedCheckpoints;
// increase / decrease value for faster or slower checkpoints, 0 - 100%
uint256 public checkpointRewardDelta;
// constant for stake shares curve
uint256 public sharesCurvature;
// validator Id => state
mapping(uint256 => StakeSharesState) public sharesState;
}
Loading