StakingManager

StakingManager__IsNotApprovedAgent

error StakingManager__IsNotApprovedAgent(address)

StakingManager__AgentIsNotActive

error StakingManager__AgentIsNotActive(address)

StakingManager__RewardsAlreadyClaimed

error StakingManager__RewardsAlreadyClaimed()

StakingManager__InvalidAmount

error StakingManager__InvalidAmount(uint256)

StakingManager__InvalidFeeRate

error StakingManager__InvalidFeeRate(uint256)

StakingManager__InvalidRoundCondition

error StakingManager__InvalidRoundCondition()

StakingManager__NoWithdrawRequested

error StakingManager__NoWithdrawRequested()

StakingManager__WithdrawingPended

error StakingManager__WithdrawingPended()

StakingManager__InvalidInputLength

error StakingManager__InvalidInputLength()

ADMIN

bytes32 ADMIN

ROUND_MANAGER

bytes32 ROUND_MANAGER

STAKE_MANAGER

bytes32 STAKE_MANAGER

Delegate

event Delegate(address delegator, address agent, uint256 round, uint256 amount)

Withdraw

event Withdraw(address delegator, address agent, uint256 round, uint256 amount)

RewardClaimed

event RewardClaimed(address delegator, address agent, address rewardCollector, uint256 amount)

AgentRewardClaimed

event AgentRewardClaimed(address agent, address rewardCollector, uint256 amount)

UpdateFee

event UpdateFee(address agent, uint256 round, uint256 fee)

DepositPersonalStake

event DepositPersonalStake(address agent, uint256 round, uint256 amount)

RequestWithdrawPersonalStake

event RequestWithdrawPersonalStake(address agent, uint256 round, uint256 amount)

WithdrawPersonalStake

event WithdrawPersonalStake(address agent, uint256 round, uint256 amount)

Slashed

event Slashed(address agent, uint256 round, uint256 amount)

Reward

struct Reward {
  uint256 agentReward;
  uint256 delegateReward;
  uint256 totalDelegate;
  bool slashed;
}

Delegator

struct Delegator {
  uint256 stake;
  uint256 lastStakeUnstakeRound;
  uint256 lastClaimRound;
}

AgentInfo

struct AgentInfo {
  uint256 realtimeStake;
  uint256 activeRoundStake;
  uint256 realtimeFee;
  uint256 activeRoundFee;
  uint256 personalStake;
  uint256 withdrawRequestRound;
  uint256 withdrawRequestAmount;
  uint256 lastClaimRound;
  uint256 lastSlashRound;
  mapping(uint256 => struct StakingManager.Reward) rewards;
  mapping(address => struct StakingManager.Delegator) delegators;
}

isInit

bool isInit

setContracts init marker

agentManager

contract AgentManager agentManager

ngl

contract IERC20 ngl

globalConfig

contract GlobalConfig globalConfig

round

uint256 round

Current round number

rewardCollectors

mapping(address => mapping(address => address)) rewardCollectors

reward collector addresses for delegators

agentInfo

mapping(address => struct StakingManager.AgentInfo) agentInfo

agent info structs

initialize

function initialize(address[1] initAddr) public

Initialize

Parameters

Name
Type
Description

initAddr

address[1]

isApprovedAgent

function isApprovedAgent(address _agent) internal view returns (bool)

onlyApprovedAgent

modifier onlyApprovedAgent()

setContracts

function setContracts(address[5] initAddr) external

Set contracts addresses

Parameters

Name
Type
Description

initAddr

address[5]

_authorizeUpgrade

function _authorizeUpgrade(address) internal

_claimRewards

function _claimRewards(address _agent) internal returns (uint256)

This methods should also be called before each delegator action (stake/unstake) to keep track of only recent rewards

Parameters

Name
Type
Description

_agent

address

- agent address

setRewardCollector

function setRewardCollector(address agent, address rewardCollector) external

Set reward collector address for delegator

Parameters

Name
Type
Description

agent

address

rewardCollector

address

- reward collector address

getRewardCollector

function getRewardCollector(address delegator, address agent) public view returns (address rc)

Get reward collector for delegator

Parameters

Name
Type
Description

delegator

address

- delegator address

agent

address

delegate

function delegate(address _agent, uint256 _amount) external

Delegate NGL to agent

Parameters

Name
Type
Description

_agent

address

- agent address

_amount

uint256

- amount of NGL to delegate

withdraw

function withdraw(address _agent, uint256 _amount) external

Withdraw delegation

Parameters

Name
Type
Description

_agent

address

- agent address

_amount

uint256

- amount of NGL to withdraw

claimRewards

function claimRewards(address _agent) external returns (uint256)

Claim delegator rewards from last claim round to current round

Parameters

Name
Type
Description

_agent

address

- agent address

distributeRewards

function distributeRewards(address[] agents, uint256[] amounts) external

Distribute rewards at the turn of a round

Parameters

Name
Type
Description

agents

address[]

- agents addresses

amounts

uint256[]

- reward amounts

turnRound

function turnRound() external

Execute turning of a round

lockAgentStake

function lockAgentStake(address _agent, uint256 _amount) external

Lock agent stake for bet

Parameters

Name
Type
Description

_agent

address

- agent address

_amount

uint256

- amount of NGL to lock

unlockAgentStake

function unlockAgentStake(address _agent, uint256 _amount) external

Unlock agent stake when bet is released

Parameters

Name
Type
Description

_agent

address

- agent address

_amount

uint256

- amount of NGL to unlock

slash

function slash(address _agent, uint256 _amount) external

Slash agent personal stake

Parameters

Name
Type
Description

_agent

address

- agent address

_amount

uint256

- amount of NGL to slash

claimAgentRewards

function claimAgentRewards() external

Claim agent rewards from last claim round to current round

updateFee

function updateFee(uint256 newFee) external

Update agent fee (reflected only on next round)

Parameters

Name
Type
Description

newFee

uint256

- new fee

depositPersonalStake

function depositPersonalStake(uint256 _amount) external

Deposit to personal stake of agent

Parameters

Name
Type
Description

_amount

uint256

- amount of NGL to deposit

requestWithdrawPersonalStake

function requestWithdrawPersonalStake(uint256 _amount) external

Request withdrawal from personal stake of agent (available to withdraw on next round)

Parameters

Name
Type
Description

_amount

uint256

- amount of NGL to withdraw

withdrawPersonalStake

function withdrawPersonalStake() external

Withdraw personal stake (requested on previous rounds)

getAgentActiveDelegation

function getAgentActiveDelegation(address _agent) external view returns (uint256)

Get actual total delegation (recorded at the start of round)

Parameters

Name
Type
Description

_agent

address

- agent address

getAgentRealtimeDelegation

function getAgentRealtimeDelegation(address _agent) external view returns (uint256)

Get current total delegation (reflected on the next round)

Parameters

Name
Type
Description

_agent

address

- agent address

getAgentPersonalStake

function getAgentPersonalStake(address _agent) external view returns (uint256)

Get personal stake of agent

Parameters

Name
Type
Description

_agent

address

- agent address

Last updated