File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
packages/horizon/contracts/staking Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -783,9 +783,10 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
783783
784784 // Calculate shares to issue
785785 // Thawing pool is reset/initialized when the pool is empty: prov.tokensThawing == 0
786+ // Round thawing shares up to ensure fairness and avoid undervaluing the shares due to rounding down.
786787 uint256 thawingShares = prov.tokensThawing == 0
787788 ? _tokens
788- : ((prov.sharesThawing * _tokens) / prov.tokensThawing);
789+ : ((prov.sharesThawing * _tokens + prov.tokensThawing - 1 ) / prov.tokensThawing);
789790 uint64 thawingUntil = uint64 (block .timestamp + uint256 (prov.thawingPeriod));
790791
791792 prov.sharesThawing = prov.sharesThawing + thawingShares;
@@ -907,6 +908,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
907908 // delegation pool shares -> delegation pool tokens -> thawing pool shares
908909 // Thawing pool is reset/initialized when the pool is empty: prov.tokensThawing == 0
909910 uint256 tokens = (_shares * (pool.tokens - pool.tokensThawing)) / pool.shares;
911+ // Thawing shares are rounded down to protect the pool and avoid taking extra tokens from other participants.
910912 uint256 thawingShares = pool.tokensThawing == 0 ? tokens : ((tokens * pool.sharesThawing) / pool.tokensThawing);
911913 uint64 thawingUntil = uint64 (block .timestamp + uint256 (_provisions[_serviceProvider][_verifier].thawingPeriod));
912914
You can’t perform that action at this time.
0 commit comments