File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -206,20 +206,25 @@ abstract contract HorizonStakingBase is
206206 return 0 ;
207207 }
208208
209- uint256 tokens = 0 ;
209+ uint256 thawedTokens = 0 ;
210210 Provision storage prov = _provisions[serviceProvider][verifier];
211+ uint256 tokensThawing = prov.tokensThawing;
212+ uint256 sharesThawing = prov.sharesThawing;
211213
212214 bytes32 thawRequestId = thawRequestList.head;
213215 while (thawRequestId != bytes32 (0 )) {
214216 ThawRequest storage thawRequest = _getThawRequest (requestType, thawRequestId);
215217 if (thawRequest.thawingUntil <= block .timestamp ) {
216- tokens += (thawRequest.shares * prov.tokensThawing) / prov.sharesThawing;
218+ uint256 tokens = (thawRequest.shares * tokensThawing) / sharesThawing;
219+ tokensThawing = tokensThawing - tokens;
220+ sharesThawing = sharesThawing - thawRequest.shares;
221+ thawedTokens = thawedTokens + tokens;
217222 } else {
218223 break ;
219224 }
220225 thawRequestId = thawRequest.next;
221226 }
222- return tokens ;
227+ return thawedTokens ;
223228 }
224229
225230 /**
Original file line number Diff line number Diff line change @@ -139,4 +139,28 @@ contract HorizonStakingThawTest is HorizonStakingTest {
139139 resetPrank (users.indexer);
140140 _thaw (users.indexer, subgraphDataServiceAddress, thawAmount);
141141 }
142+
143+ function testThaw_GetThawedTokens (
144+ uint256 amount ,
145+ uint64 thawingPeriod ,
146+ uint256 thawSteps
147+ ) public useIndexer useProvision (amount, 0 , thawingPeriod) {
148+ thawSteps = bound (thawSteps, 1 , 10 );
149+
150+ uint256 thawAmount = amount / thawSteps;
151+ vm.assume (thawAmount > 0 );
152+ for (uint256 i = 0 ; i < thawSteps; i++ ) {
153+ _thaw (users.indexer, subgraphDataServiceAddress, thawAmount);
154+ }
155+
156+ skip (thawingPeriod + 1 );
157+
158+ uint256 thawedTokens = staking.getThawedTokens (
159+ ThawRequestType.Provision,
160+ users.indexer,
161+ subgraphDataServiceAddress,
162+ users.indexer
163+ );
164+ vm.assertEq (thawedTokens, thawAmount * thawSteps);
165+ }
142166}
You can’t perform that action at this time.
0 commit comments