Skip to content

Commit 53f6cf6

Browse files
authored
staking: emit the effective allocation when settling (#201)
1 parent 0f5c5bf commit 53f6cf6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

contracts/Staking.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ contract Staking is Governed {
123123
address channelID,
124124
address from,
125125
uint256 curationFees,
126-
uint256 rebateFees
126+
uint256 rebateFees,
127+
uint256 effectiveAllocation
127128
);
128129

129130
/**
@@ -514,8 +515,7 @@ contract Staking is Governed {
514515
) private {
515516
address indexer = channels[_channelID].indexer;
516517
bytes32 subgraphID = channels[_channelID].subgraphID;
517-
Stakes.Indexer storage indexerStake = stakes[indexer];
518-
Stakes.Allocation storage alloc = indexerStake.allocations[subgraphID];
518+
Stakes.Allocation storage alloc = stakes[indexer].allocations[subgraphID];
519519

520520
require(alloc.hasChannel(), "Channel: Must be active for settlement");
521521

@@ -530,16 +530,15 @@ contract Staking is Governed {
530530

531531
// Set apart fees into a rebate pool
532532
uint256 rebateFees = _tokens.sub(curationFees);
533-
rebates[currentEpoch].add(
534-
indexer,
535-
subgraphID,
536-
rebateFees,
537-
alloc.getTokensEffectiveAllocation(epochs, maxAllocationEpochs)
533+
uint256 effectiveAllocation = alloc.getTokensEffectiveAllocation(
534+
epochs,
535+
maxAllocationEpochs
538536
);
537+
rebates[currentEpoch].add(indexer, subgraphID, rebateFees, effectiveAllocation);
539538

540539
// Close channel
541540
// NOTE: Channels used are never deleted from state tracked in `channels` var
542-
indexerStake.unallocateTokens(subgraphID, alloc.tokens);
541+
stakes[indexer].unallocateTokens(subgraphID, alloc.tokens);
543542
alloc.channelID = address(0);
544543
alloc.createdAtEpoch = 0;
545544
// TODO: send multisig one-shot invalidation
@@ -560,7 +559,8 @@ contract Staking is Governed {
560559
_channelID,
561560
_from,
562561
rebateFees,
563-
curationFees
562+
curationFees,
563+
effectiveAllocation
564564
);
565565
}
566566

0 commit comments

Comments
 (0)