constructor(address dataFeed, address dpos) public
uint256 maxValidatorStakeCapacity
uint256 nodeCount
address[] nodesList
mapping(address => struct IApyOracle.NodeData) nodes
modifier OnlyDataFeed()
function getNodeCount() external view returns (uint256)
function getNodesForDelegation(uint256 amount) external view returns (struct IApyOracle.TentativeDelegation[])
Returns the list of nodes that can be delegated to, along with the amount that can be delegated to each node.
Name | Type | Description |
---|---|---|
amount | uint256 | The amount to be delegated |
function updateNodeCount(uint256 count) external
function getDataFeedAddress() external view returns (address)
function getNodeData(address node) external view returns (struct IApyOracle.NodeData)
function updateNodeData(address node, struct IApyOracle.NodeData data) external
uint256 protocolStartTimestamp
uint256 epochDuration
uint256 maxValidatorStakeCapacity
uint256 minStakeAmount
contract IstTara stTaraToken
contract DposInterface dposContract
contract IApyOracle apyOracle
address[] delegators
address[] validators
mapping(address => uint256) protocolTotalStakeAtValidator
mapping(address => bool) isCompounding
mapping(address => uint256) stakedAmounts
mapping(address => uint256) delegatedAmounts
mapping(address => uint256) claimableRewards
mapping(address => uint256) undelegated
uint256 lastEpochTotalDelegatedAmount
bool isEpochRunning
constructor(address _sttaraToken, address _dposContract, address _apyOracle) public
fallback() external payable
receive() external payable
modifier onlyUser(address user)
function getDelegatorAtIndex(uint256 index) public view returns (address)
Getter for a certain delegator at a certain index
Name | Type | Description |
---|---|---|
index | uint256 | the index of the delegator |
function isValidatorRegistered(address validator) public view returns (bool)
Checks if a validator is registered in the protocol
Name | Type | Description |
---|---|---|
validator | address | the validator address |
function setEpochDuration(uint256 _epochDuration) public
Setter for epochDuration
Name | Type | Description |
---|---|---|
_epochDuration | uint256 | new epoch duration (in seconds) |
function setCompound(address user, bool value) public
Setter for compounding
Name | Type | Description |
---|---|---|
user | address | the user for which to set compounding |
value | bool | the new value for compounding(T/F) |
function setMaxValidatorStakeCapacity(uint256 _maxValidatorStakeCapacity) external
onlyOwner Setter for maxValidatorStakeCapacity
Name | Type | Description |
---|---|---|
_maxValidatorStakeCapacity | uint256 | new maxValidatorStakeCapacity |
function setMinStakeAmount(uint256 _minStakeAmount) external
onlyOwner Setter for minStakeAmount
Name | Type | Description |
---|---|---|
_minStakeAmount | uint256 | the new minStakeAmount |
function stake(uint256 amount) public payable
Stake function In the stake function, the user sends the amount of TARA tokens he wants to stake. This method takes the payment and mints the stTARA tokens to the user. The tokens are not DELEGATED INSTANTLY, but on the next epoch.
Name | Type | Description |
---|---|---|
amount | uint256 | the amount to stake |
function reDelegate(address from, address to, uint256 amount) public
ReDelegate method to move stake from one validator to another inside the protocol. The method is intended to be called by the protocol owner on a need basis. In this V0 there is no on-chain trigger or management function for this, will be triggere from outside.
Name | Type | Description |
---|---|---|
from | address | the validator from which to move stake |
to | address | the validator to which to move stake |
amount | uint256 | the amount to move |
function confirmUndelegate(address validator, uint256 amount) public
Confirm undelegate method to confirm the undelegation of a user from a certain validator. Will fail if called before the undelegation period is over. msg.sender is the delegator
Name | Type | Description |
---|---|---|
validator | address | the validator from which to undelegate |
amount | uint256 | the amount to undelegate |
function cancelUndelegate(address validator, uint256 amount) public
Cancel undelegate method to cancel the undelegation of a user from a certain validator. The undelegated value will be returned to the origin validator.
Name | Type | Description |
---|---|---|
validator | address | the validator from which to undelegate |
amount | uint256 | the amount to undelegate |
function removeStake(uint256 amount) public
Removes the stake of a user from the protocol. reverts on missing approval for the amount. The user needs to provide the amount of stTARA tokens he wants to get back as TARA
Name | Type | Description |
---|---|---|
amount | uint256 | the amount of stTARA tokens to remove |
function requestUndelegate(uint256 amount) public
Undelegates the amount from one or more validators. The user needs to provide the amount of stTARA tokens he wants to undelegate. The protocol will burn them. reverts on missing approval for the amount.
Name | Type | Description |
---|---|---|
amount | uint256 | the amount of tokens to undelegate |
function claimRewards() public
Public method for claiming rewards. The user can claim his rewards at any time but if there is an epoch running, he will only get the rewards from the last epoch. Pays rewards in TARA.
function startEpoch() external
OnlyOwner method for starting a staking epoch.
function endEpoch() public
OnlyOwner method for ending a staking epoch.
function delegateToValidators(uint256 amount) internal returns (uint256 remainingAmount)
error NotAuthorized()
It is returned if the caller is not authorized
error RewardClaimFailed()
It is returned if reward claim from DPOS fails
error StakeAmountTooLow(uint256 amount, uint256 minAmount)
error StakeValueTooLow(uint256 sentAmount, uint256 targetAmount)
error DelegationFailed(address validator, address delegator, uint256 amount)
It is returned if the delegation to a certain validator fails.
struct NodeData {
address account;
uint16 rank;
uint256 rating;
uint16 apy;
uint64 fromBlock;
uint64 toBlock;
}
struct TentativeDelegation {
address validator;
uint256 amount;
}
event NodeDataUpdated(address node, uint16 apy, uint256 pbftCount)
function getNodeCount() external view returns (uint256)
function getNodesForDelegation(uint256 amount) external view returns (struct IApyOracle.TentativeDelegation[])
function updateNodeCount(uint256 count) external
function getNodeData(address node) external view returns (struct IApyOracle.NodeData)
function updateNodeData(address node, struct IApyOracle.NodeData data) external
function getDataFeedAddress() external view returns (address)
event Delegated(address delegator, address validator, uint256 amount)
event Undelegated(address delegator, address validator, uint256 amount)
event UndelegateConfirmed(address delegator, address validator, uint256 amount)
event UndelegateCanceled(address delegator, address validator, uint256 amount)
event Redelegated(address delegator, address from, address to, uint256 amount)
event RewardsClaimed(address account, address validator, uint256 amount)
event CommissionRewardsClaimed(address account, address validator, uint256 amount)
event CommissionSet(address validator, uint16 commission)
event ValidatorRegistered(address validator)
event ValidatorInfoSet(address validator)
struct ValidatorBasicInfo {
uint256 total_stake;
uint256 commission_reward;
uint16 commission;
uint64 last_commission_change;
address owner;
string description;
string endpoint;
}
struct ValidatorData {
address account;
struct DposInterface.ValidatorBasicInfo info;
}
struct UndelegateRequest {
uint256 eligible_block_num;
uint256 amount;
}
struct DelegatorInfo {
uint256 stake;
uint256 rewards;
}
struct DelegationData {
address account;
struct DposInterface.DelegatorInfo delegation;
}
struct UndelegationData {
uint256 stake;
uint64 block;
address validator;
bool validator_exists;
}
function delegate(address validator) external payable
function undelegate(address validator, uint256 amount) external
function confirmUndelegate(address validator) external
function cancelUndelegate(address validator) external
function reDelegate(address validator_from, address validator_to, uint256 amount) external
function claimRewards(address validator) external
function claimAllRewards(uint32 batch) external returns (bool end)
Claims staking rewards from all validators (limited by batch) that caller has delegated to
Name | Type | Description |
---|---|---|
batch | uint32 | Batch number - there is a limit of 10 validators per batch that delegator can claim rewards from in single tranaction |
Name | Type | Description |
---|---|---|
end | bool | Flag if there are no more validators left that delegator can claim rewards from |
function claimCommissionRewards(address validator) external
function registerValidator(address validator, bytes proof, bytes vrf_key, uint16 commission, string description, string endpoint) external payable
function setValidatorInfo(address validator, string description, string endpoint) external
Sets some of the static validator details.
Name | Type | Description |
---|---|---|
validator | address | |
description | string | New description (e.g name, short purpose description, etc…) |
endpoint | string | New endpoint, might be a validator’s website |
function setCommission(address validator, uint16 commission) external
function isValidatorEligible(address validator) external view returns (bool)
function getTotalEligibleVotesCount() external view returns (uint64)
function getValidatorEligibleVotesCount(address validator) external view returns (uint64)
function getValidator(address validator) external view returns (struct DposInterface.ValidatorBasicInfo validator_info)
function getValidators(uint32 batch) external view returns (struct DposInterface.ValidatorData[] validators, bool end)
function getValidatorsFor(address owner, uint32 batch) external view returns (struct DposInterface.ValidatorData[] validators, bool end)
Returns list of validators owned by an address
Name | Type | Description |
---|---|---|
owner | address | Owner address |
batch | uint32 | Batch number to be fetched. If the list is too big it cannot return all validators in one call. Instead, users are fetching batches of 100 account at a time |
Name | Type | Description |
---|---|---|
validators | struct DposInterface.ValidatorData[] | Batch of N validators basic info |
end | bool | Flag if there are no more accounts left. To get all accounts, caller should fetch all batches until he sees end == true |
function getTotalDelegation(address delegator) external view returns (uint256 total_delegation)
Name | Type | Description |
---|---|---|
delegator | address | delegator account address |
function getDelegations(address delegator, uint32 batch) external view returns (struct DposInterface.DelegationData[] delegations, bool end)
Returns list of delegations for specified delegator - which validators delegator delegated to
Name | Type | Description |
---|---|---|
delegator | address | delegator account address |
batch | uint32 | Batch number to be fetched. If the list is too big it cannot return all delegations in one call. Instead, users are fetching batches of 50 delegations at a time |
Name | Type | Description |
---|---|---|
delegations | struct DposInterface.DelegationData[] | Batch of N delegations |
end | bool | Flag if there are no more delegations left. To get all delegations, caller should fetch all batches until he sees end == true |
function getUndelegations(address delegator, uint32 batch) external view returns (struct DposInterface.UndelegationData[] undelegations, bool end)
Returns list of undelegations for specified delegator
Name | Type | Description |
---|---|---|
delegator | address | delegator account address |
batch | uint32 | Batch number to be fetched. If the list is too big it cannot return all undelegations in one call. Instead, users are fetching batches of 50 undelegations at a time |
Name | Type | Description |
---|---|---|
undelegations | struct DposInterface.UndelegationData[] | Batch of N undelegations |
end | bool | Flag if there are no more undelegations left. To get all undelegations, caller should fetch all batches until he sees end == true |
event Staked(address user, uint256 amount)
event Delegated(address user, uint256 amount)
event EpochStarted(uint256 totalEpochDelegation, uint256 timestamp)
event RewardsClaimed(address user, uint256 amount, uint256 timestamp)
event EpochEnded(uint256 totalEpochDelegation, uint256 totalEpochReward, uint256 timestamp)
event Undelegated(address user, address validator, uint256 amount)
event TaraSent(address user, uint256 amount, uint256 blockNumber)
event StakeRemoved(address user, uint256 amount)
function getDelegatorAtIndex(uint256 index) external view returns (address)
function isValidatorRegistered(address validator) external view returns (bool)
function setEpochDuration(uint256 _epochDuration) external
function setCompound(address user, bool value) external
function setMaxValidatorStakeCapacity(uint256 _maxValidatorStakeCapacity) external
function setMinStakeAmount(uint256 _minStakeAmount) external
function stake(uint256 amount) external payable
function removeStake(uint256 amount) external
function reDelegate(address from, address to, uint256 amount) external
function confirmUndelegate(address validator, uint256 amount) external
function cancelUndelegate(address validator, uint256 amount) external
function requestUndelegate(uint256 amount) external
function claimRewards() external
function startEpoch() external
function endEpoch() external
struct NodeStats {
uint64 dagsCount;
uint64 lastDagTimestamp;
uint64 lastPbftTimestamp;
uint64 lastTransactionTimestamp;
uint64 pbftCount;
uint64 transactionsCount;
}
event NodeDataUpdated(address node, uint64 timestamp, uint256 pbftCount)
function getNodeUpdateTimestamps(address node) external view returns (uint64[] timestamps)
function getNodeStatsFrom(uint64 timestamp) external view returns (struct INodeContinuityOracle.NodeStats)
function updateNodeStats(address node, uint64 timestamp, struct INodeContinuityOracle.NodeStats stats) external
function getDataFeedAddress() external view returns (address)
function mint(address recipient, uint256 amount) external payable
function burn(address user, uint256 amount) external
struct Undelegation {
address delegator;
uint256 amount;
uint256 blockNumberClaimable;
}
mapping(address => struct MockIDPOS.ValidatorData) validators
struct MockIDPOS.ValidatorData[] validatorDatas
mapping(address => struct MockDpos.Undelegation) undelegations
uint256 UNDELEGATION_DELAY_BLOCKS
constructor(address[] _internalValidators) public payable
function isValidatorRegistered(address validator) external view returns (bool)
function getValidator(address validator) external view returns (struct MockIDPOS.ValidatorBasicInfo)
function getValidators(uint32 batch) external view returns (struct MockIDPOS.ValidatorData[] validatorsOut, bool end)
function getValidatorsFor(address owner, uint32 batch) external view returns (struct MockIDPOS.ValidatorData[] validatorsOut, bool end)
function delegate(address validator) external payable
function registerValidator(address validator, bytes proof, bytes vrf_key, uint16 commission, string description, string endpoint) external payable
function undelegate(address validator, uint256 amount) external
event DelegationRewards(uint256 totalStakes, uint256 totalRewards)
function claimAllRewards(uint32 batch) external returns (bool end)
function reDelegate(address validator_from, address validator_to, uint256 amount) external
function confirmUndelegate(address validator) external
event CallerCheck(address CallerCheck)
function cancelUndelegate(address validator) external
event Delegated(address delegator, address validator, uint256 amount)
event Undelegated(address delegator, address validator, uint256 amount)
event UndelegateConfirmed(address delegator, address validator, uint256 amount)
event UndelegateCanceled(address delegator, address validator, uint256 amount)
event RewardsClaimed(address account, address validator)
event CommissionRewardsClaimed(address account, address validator)
event CommissionSet(address validator, uint16 comission)
event ValidatorRegistered(address validator)
event ValidatorInfoSet(address validator)
event Redelegated(address delegator, address from, address to, uint256 amount)
struct ValidatorBasicInfo {
uint256 total_stake;
uint256 commission_reward;
uint16 commission;
uint64 last_commission_change;
address owner;
string description;
string endpoint;
}
struct ValidatorData {
address account;
struct MockIDPOS.ValidatorBasicInfo info;
}
struct UndelegateRequest {
uint256 eligible_block_num;
uint256 amount;
}
struct DelegatorInfo {
uint256 stake;
uint256 rewards;
}
struct DelegationData {
address account;
struct MockIDPOS.DelegatorInfo delegation;
}
struct UndelegationData {
uint256 stake;
uint64 block;
address validator;
bool validator_exists;
}
function delegate(address validator) external payable
function registerValidator(address validator, bytes proof, bytes vrf_key, uint16 commission, string description, string endpoint) external payable
function getValidator(address validator) external view returns (struct MockIDPOS.ValidatorBasicInfo validator_info)
function undelegate(address validator, uint256 amount) external
function getValidators(uint32 batch) external view returns (struct MockIDPOS.ValidatorData[] validators, bool end)
function getValidatorsFor(address owner, uint32 batch) external view returns (struct MockIDPOS.ValidatorData[] validators, bool end)
function claimAllRewards(uint32 batch) external returns (bool end)
function reDelegate(address validator_from, address validator_to, uint256 amount) external
function confirmUndelegate(address validator) external
function cancelUndelegate(address validator) external
error DepositAmountTooLow(uint256 amount, uint256 minAmount)
error MintValueTooLow(uint256 sentAmount, uint256 minAmount)
error WrongBurnAddress(address wrongAddress)
error InsufficientUserAllowanceForBurn(uint256 amount, uint256 senderBalance, uint256 protocolBalance)
error InsufficientProtocolBalanceForBurn(uint256 amount, uint256 protocolBalance)
event Minted(address user, uint256 amount)
event Burned(address user, uint256 amount)
uint256 minDepositAmount
address lara
constructor() public
modifier onlyLara()
function setMinDepositAmount(uint256 _minDepositAmount) external
function setLaraAddress(address _lara) external
function mint(address recipient, uint256 amount) external
function burn(address user, uint256 amount) external
address staker0
address staker1
address staker2
uint256 MAX_VALIDATOR_STAKE_CAPACITY
function setUp() public
function getTotalDposStake() public view returns (uint256)
function testFuzz_testStakeToSingleValidator(uint256 amount) public
function testStakeToMultipleValidators() public
function calculateExpectedRewardForUser(address staker) public view returns (uint256)
function test_launchNextEpoch() public
function setUp() public
function testGetNodesForDelegation() public
function testFuzz_GetNodesForDelegation(uint256 amount) public
function testFailStakeAmountTooLow() public
function testFailStakeValueTooLow() public
uint256 firstAmountToStake
function testFuzz_testStakeToSingleValidator(uint256 amount) public
event DelegationReward(uint256 totalStakes, uint256 totalRewards)
function testStakeToMultipleValidators() public
function testFailValidatorsFull() public
function setUp() public
function testGetLotsOfNodesForDelegation() public
function testFuzz_GetLotsOfNodesForDelegation(uint256 amount) public
function setUp() public
function testFuzz_testRedelegateStakeToSingleValidator(uint256 amount) public
function testFuzz_testRedelegateStakeToMultipleValidators(uint256 amount) public
contract Lara lara
contract ApyOracle mockApyOracle
contract MockDpos mockDpos
contract stTARA stTaraToken
uint16 numValidators
address[] validators
function setupValidators() public
function setupApyOracle() public
function setupLara() public
function checkValidatorTotalStakesAreZero() public
function findValidatorWithStake(uint256 stake) public view returns (address)
contract Lara lara
contract ApyOracle mockApyOracle
contract MockDpos mockDpos
contract stTARA stTaraToken
uint16 numValidators
address[] validators
event UpToThis(uint256 value)
function setupValidators() public
function setupApyOracle() public
function setupLara() public
function checkValidatorTotalStakesAreZero() public
function findValidatorWithStake(uint256 stake) public view returns (address)
address[] delegators
function setUp() public
function testFuzz_setMaxValdiatorStakeCapacity(address setter) public
function testFuzz_setMinStakeAmount(address setter) public
function setUp() public
fallback() external payable
receive() external payable
function testFuzz_testStakeAndRemoveStake(uint256 amount) public
function invariant_testStakeAndRemoveStake() public
function testFuzz_failsToUndelegateDuringEpoch(uint256 amount) public
function testFuzz_failsToUndelegateWithoutApproval(uint256 amount) public
function testFuzz_failsToUndelegateForSomeoneElse(uint256 amount) public
function testFuzz_singleStakeAndUnstake(uint256 amount) public
function invariant_testFuzz_singleStakeAndUnstake() public
constructor(address dataFeed) public
mapping(address => uint64[]) nodeStatsUpdateTimestamps
mapping(uint64 => struct INodeContinuityOracle.NodeStats) nodeStats
modifier OnlyDataFeed()
function getDataFeedAddress() external view returns (address)
function updateNodeStats(address node, uint64 timestamp, struct INodeContinuityOracle.NodeStats data) external
function getNodeUpdateTimestamps(address node) external view returns (uint64[] timestamps)
function getNodeStatsFrom(uint64 timestamp) external view returns (struct INodeContinuityOracle.NodeStats)