Skip to content

Commit 5e58c8e

Browse files
committed
chore: changes to horizon events
1 parent 7db331d commit 5e58c8e

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

packages/horizon/contracts/interfaces/internal/IHorizonStakingMain.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,14 @@ interface IHorizonStakingMain {
169169
* @param verifier The address of the verifier
170170
* @param delegator The address of the delegator
171171
* @param tokens The amount of tokens delegated
172+
* @param shares The amount of shares delegated
172173
*/
173174
event TokensDelegated(
174175
address indexed serviceProvider,
175176
address indexed verifier,
176177
address indexed delegator,
177-
uint256 tokens
178+
uint256 tokens,
179+
uint256 shares
178180
);
179181

180182
/**

packages/horizon/contracts/staking/HorizonStaking.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
866866

867867
delegation.shares = delegation.shares + shares;
868868

869-
emit TokensDelegated(_serviceProvider, _verifier, msg.sender, _tokens);
869+
emit TokensDelegated(_serviceProvider, _verifier, msg.sender, _tokens, shares);
870870
}
871871

872872
/**
@@ -978,10 +978,9 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
978978
_delegate(_newServiceProvider, _newVerifier, tokensThawed, _minSharesForNewProvider);
979979
} else {
980980
_graphToken().pushTokens(msg.sender, tokensThawed);
981+
emit DelegatedTokensWithdrawn(_serviceProvider, _verifier, msg.sender, tokensThawed);
981982
}
982983
}
983-
984-
emit DelegatedTokensWithdrawn(_serviceProvider, _verifier, msg.sender, tokensThawed);
985984
}
986985

987986
/**

packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest {
864864
// delegate
865865
token.approve(address(staking), tokens);
866866
vm.expectEmit();
867-
emit IHorizonStakingMain.TokensDelegated(serviceProvider, verifier, delegator, tokens);
867+
emit IHorizonStakingMain.TokensDelegated(serviceProvider, verifier, delegator, tokens, calcShares);
868868
if (legacy) {
869869
staking.delegate(serviceProvider, tokens);
870870
} else {
@@ -1141,20 +1141,22 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest {
11411141
params.newServiceProvider,
11421142
params.newVerifier,
11431143
msgSender,
1144-
calcValues.tokensThawed
1144+
calcValues.tokensThawed,
1145+
calcValues.sharesThawed
11451146
);
11461147
} else {
11471148
emit Transfer(address(staking), msgSender, calcValues.tokensThawed);
1149+
1150+
vm.expectEmit();
1151+
emit IHorizonStakingMain.DelegatedTokensWithdrawn(
1152+
params.serviceProvider,
1153+
params.verifier,
1154+
msgSender,
1155+
calcValues.tokensThawed
1156+
);
11481157
}
11491158
}
1150-
vm.expectEmit();
11511159

1152-
emit IHorizonStakingMain.DelegatedTokensWithdrawn(
1153-
params.serviceProvider,
1154-
params.verifier,
1155-
msgSender,
1156-
calcValues.tokensThawed
1157-
);
11581160
if (reDelegate) {
11591161
staking.redelegate(
11601162
params.serviceProvider,
@@ -2226,6 +2228,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest {
22262228
struct CalcValues_ThawRequestData {
22272229
uint256 tokensThawed;
22282230
uint256 tokensThawing;
2231+
uint256 sharesThawed;
22292232
uint256 sharesThawing;
22302233
ThawRequest[] thawRequestsFulfilledList;
22312234
bytes32[] thawRequestsFulfilledListIds;
@@ -2256,13 +2259,14 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest {
22562259
params.owner
22572260
);
22582261
if (thawRequestList.count == 0) {
2259-
return CalcValues_ThawRequestData(0, 0, 0, new ThawRequest[](0), new bytes32[](0), new uint256[](0));
2262+
return CalcValues_ThawRequestData(0, 0, 0, 0, new ThawRequest[](0), new bytes32[](0), new uint256[](0));
22602263
}
22612264

22622265
Provision memory prov = staking.getProvision(params.serviceProvider, params.verifier);
22632266
DelegationPool memory pool = staking.getDelegationPool(params.serviceProvider, params.verifier);
22642267

22652268
uint256 tokensThawed = 0;
2269+
uint256 sharesThawed = 0;
22662270
uint256 tokensThawing = params.delegation ? pool.tokensThawing : prov.tokensThawing;
22672271
uint256 sharesThawing = params.delegation ? pool.sharesThawing : prov.sharesThawing;
22682272
uint256 thawRequestsFulfilled = 0;
@@ -2279,6 +2283,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest {
22792283
: (thawRequest.shares * prov.tokensThawing) / prov.sharesThawing;
22802284
tokensThawed += tokens;
22812285
tokensThawing -= tokens;
2286+
sharesThawed += thawRequest.shares;
22822287
sharesThawing -= thawRequest.shares;
22832288
}
22842289
} else {
@@ -2291,6 +2296,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest {
22912296
CalcValues_ThawRequestData memory thawRequestData;
22922297
thawRequestData.tokensThawed = tokensThawed;
22932298
thawRequestData.tokensThawing = tokensThawing;
2299+
thawRequestData.sharesThawed = sharesThawed;
22942300
thawRequestData.sharesThawing = sharesThawing;
22952301
thawRequestData.thawRequestsFulfilledList = new ThawRequest[](thawRequestsFulfilled);
22962302
thawRequestData.thawRequestsFulfilledListIds = new bytes32[](thawRequestsFulfilled);

0 commit comments

Comments
 (0)