@@ -68,6 +68,7 @@ pub contract FlowIDTableStaking {
68
68
pub event NewDelegatorCutPercentage (newCutPercentage : UFix64 )
69
69
pub event NewWeeklyPayout (newPayout : UFix64 )
70
70
pub event NewStakingMinimums (newMinimums : {UInt8 : UFix64 })
71
+ pub event NewDelegatorStakingMinimum (newMinimum : UFix64 )
71
72
72
73
/// Holds the identity table for all the nodes in the network.
73
74
/// Includes nodes that aren't actively participating
@@ -78,7 +79,6 @@ pub contract FlowIDTableStaking {
78
79
/// The minimum amount of tokens that each staker type has to stake
79
80
/// in order to be considered valid
80
81
/// Keys:
81
- /// 0 - Delegators
82
82
/// 1 - Collector Nodes
83
83
/// 2 - Consensus Nodes
84
84
/// 3 - Execution Nodes
@@ -853,17 +853,25 @@ pub contract FlowIDTableStaking {
853
853
/// at the end of the staking auction, and pay rewards to nodes at the end of an epoch
854
854
pub resource Admin : EpochOperations {
855
855
856
- /// Sets a new set of minimum staking requirements for all the nodes and delegators
857
- /// Delegator minimum is at index 0, other nodes ' indexes are their role numbers
856
+ /// Sets a new set of minimum staking requirements for all the nodes
857
+ /// Nodes ' indexes are their role numbers
858
858
pub fun setMinimumStakeRequirements (_ newRequirements : {UInt8 : UFix64 }) {
859
859
pre {
860
- newRequirements.keys.length == 6 :
861
- " There must be six entries for minimum stake requirements (one for delegators and 5 for nodes) "
860
+ newRequirements.keys.length == 5 :
861
+ " There must be six entries for node minimum stake requirements"
862
862
}
863
863
FlowIDTableStaking.minimumStakeRequired = newRequirements
864
864
emit NewStakingMinimums (newMinimums : newRequirements)
865
865
}
866
866
867
+ /// Sets a new set of minimum staking requirements for all the delegators
868
+ pub fun setDelegatorMinimumStakeRequirement (_ newRequirement : UFix64 ) {
869
+ FlowIDTableStaking.account.load< UFix64> (from : / storage/ delegatorStakingMinimum)
870
+ FlowIDTableStaking.account.save (newRequirement, to : / storage/ delegatorStakingMinimum)
871
+
872
+ emit NewDelegatorStakingMinimum (newMinimum : newRequirement)
873
+ }
874
+
867
875
/// Changes the total weekly payout to a new value
868
876
pub fun setEpochTokenPayout (_ newPayout : UFix64 ) {
869
877
if newPayout ! = FlowIDTableStaking.epochTokenPayout {
@@ -1441,9 +1449,9 @@ pub contract FlowIDTableStaking {
1441
1449
let delRecord = nodeRecord.borrowDelegatorRecord (delegator)
1442
1450
1443
1451
// If the delegator's committed tokens for the next epoch
1444
- // Is less than the delegator minimum, unstake all their tokens
1452
+ // is less than the delegator minimum, unstake all their tokens
1445
1453
let actualCommittedForNextEpoch = delRecord.tokensCommitted.balance + delRecord.tokensStaked.balance - delRecord.tokensRequestedToUnstake
1446
- if ! FlowIDTableStaking. isGreaterThanMinimumForRole ( numTokens : actualCommittedForNextEpoch, role : UInt8 ( 0 ) ) {
1454
+ if actualCommittedForNextEpoch < FlowIDTableStaking. getDelegatorMinimumStakeRequirement ( ) {
1447
1455
delRecord.tokensUnstaked.deposit (from : <- delRecord.tokensCommitted.withdraw (amount : delRecord.tokensCommitted.balance))
1448
1456
delRecord.tokensRequestedToUnstake = delRecord.tokensStaked.balance
1449
1457
}
@@ -1548,9 +1556,9 @@ pub contract FlowIDTableStaking {
1548
1556
message : " Cannot register a delegator for an access node"
1549
1557
)
1550
1558
1551
- let minimum = self .minimumStakeRequired[ UInt8 ( 0 )] !
1559
+ let minimum = self .getDelegatorMinimumStakeRequirement ()
1552
1560
assert (
1553
- self . isGreaterThanMinimumForRole ( numTokens : tokensCommitted.balance, role : 0 ) ,
1561
+ tokensCommitted.balance > = minimum ,
1554
1562
message : " Tokens committed for delegator registration is not above the minimum (" .concat (minimum.toString ()).concat (" )" )
1555
1563
)
1556
1564
@@ -1810,10 +1818,10 @@ pub contract FlowIDTableStaking {
1810
1818
}
1811
1819
1812
1820
/// Checks if the amount of tokens is greater than the minimum staking requirement
1813
- /// for the specified staker role (including role == 0 for delegators)
1821
+ /// for the specified node role
1814
1822
pub fun isGreaterThanMinimumForRole (numTokens : UFix64 , role : UInt8 ): Bool {
1815
1823
let minimumStake = self .minimumStakeRequired[role]
1816
- ?? panic (" Incorrect role provided for minimum stake. Must be 0, 1, 2, 3, 4, or 5" )
1824
+ ?? panic (" Incorrect role provided for minimum stake. Must be 1, 2, 3, 4, or 5" )
1817
1825
1818
1826
return numTokens > = minimumStake
1819
1827
}
@@ -1851,11 +1859,17 @@ pub contract FlowIDTableStaking {
1851
1859
?? panic (" could not get non-operational node list" )
1852
1860
}
1853
1861
1854
- /// Gets the minimum stake requirements for all the staker types
1862
+ /// Gets the minimum stake requirements for all the node types
1855
1863
pub fun getMinimumStakeRequirements (): {UInt8 : UFix64 } {
1856
1864
return self .minimumStakeRequired
1857
1865
}
1858
1866
1867
+ /// Gets the minimum stake requirement for delegators
1868
+ pub fun getDelegatorMinimumStakeRequirement (): UFix64 {
1869
+ return self .account.copy< UFix64> (from : / storage/ delegatorStakingMinimum)
1870
+ ?? 0 .0
1871
+ }
1872
+
1859
1873
/// Gets a dictionary that indicates the current number of tokens staked
1860
1874
/// by all the nodes of each type
1861
1875
pub fun getTotalTokensStakedByNodeType (): {UInt8 : UFix64 } {
@@ -1906,7 +1920,8 @@ pub contract FlowIDTableStaking {
1906
1920
self .StakingAdminStoragePath = / storage/ flowStakingAdmin
1907
1921
self .DelegatorStoragePath = / storage/ flowStakingDelegator
1908
1922
1909
- self .minimumStakeRequired = {UInt8 (0 ): 50 .0 , UInt8 (1 ): 250000 .0 , UInt8 (2 ): 500000 .0 , UInt8 (3 ): 1250000 .0 , UInt8 (4 ): 135000 .0 , UInt8 (5 ): 100 .0 }
1923
+ self .minimumStakeRequired = {UInt8 (1 ): 250000 .0 , UInt8 (2 ): 500000 .0 , UInt8 (3 ): 1250000 .0 , UInt8 (4 ): 135000 .0 , UInt8 (5 ): 100 .0 }
1924
+ self .account.save (50 .0 as UFix64, to : / storage/ delegatorStakingMinimum)
1910
1925
self .totalTokensStakedByNodeType = {UInt8 (1 ): 0 .0 , UInt8 (2 ): 0 .0 , UInt8 (3 ): 0 .0 , UInt8 (4 ): 0 .0 , UInt8 (5 ): 0 .0 }
1911
1926
self .epochTokenPayout = epochTokenPayout
1912
1927
self .nodeDelegatingRewardCut = rewardCut
0 commit comments