Skip to content

Commit 6d3068f

Browse files
committed
Removed rank on both staker and node.
1 parent 3bdedb1 commit 6d3068f

6 files changed

+2
-248
lines changed

generated/schema.ts

-80
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ export class Staker extends Entity {
143143
this.set("rETHBalance", Value.fromBigInt(BigInt.zero()));
144144
this.set("ethBalance", Value.fromBigInt(BigInt.zero()));
145145
this.set("totalETHRewards", Value.fromBigInt(BigInt.zero()));
146-
this.set("totalETHRewardsRank", Value.fromBigInt(BigInt.zero()));
147146
this.set("hasAccruedETHRewardsDuringLifecycle", Value.fromBoolean(false));
148147
this.set("block", Value.fromBigInt(BigInt.zero()));
149148
this.set("blockTime", Value.fromBigInt(BigInt.zero()));
@@ -202,15 +201,6 @@ export class Staker extends Entity {
202201
this.set("totalETHRewards", Value.fromBigInt(value));
203202
}
204203

205-
get totalETHRewardsRank(): BigInt {
206-
let value = this.get("totalETHRewardsRank");
207-
return value!.toBigInt();
208-
}
209-
210-
set totalETHRewardsRank(value: BigInt) {
211-
this.set("totalETHRewardsRank", Value.fromBigInt(value));
212-
}
213-
214204
get hasAccruedETHRewardsDuringLifecycle(): boolean {
215205
let value = this.get("hasAccruedETHRewardsDuringLifecycle");
216206
return value!.toBoolean();
@@ -499,26 +489,6 @@ export class NetworkStakerBalanceCheckpoint extends Entity {
499489
this.set("averageStakerETHRewards", Value.fromBigInt(value));
500490
}
501491

502-
get checkpointWithHighestRewardsRank(): string | null {
503-
let value = this.get("checkpointWithHighestRewardsRank");
504-
if (!value || value.kind == ValueKind.NULL) {
505-
return null;
506-
} else {
507-
return value.toString();
508-
}
509-
}
510-
511-
set checkpointWithHighestRewardsRank(value: string | null) {
512-
if (!value) {
513-
this.unset("checkpointWithHighestRewardsRank");
514-
} else {
515-
this.set(
516-
"checkpointWithHighestRewardsRank",
517-
Value.fromString(<string>value)
518-
);
519-
}
520-
}
521-
522492
get stakersWithAnRETHBalance(): BigInt {
523493
let value = this.get("stakersWithAnRETHBalance");
524494
return value!.toBigInt();
@@ -575,7 +545,6 @@ export class StakerBalanceCheckpoint extends Entity {
575545
this.set("ethBalance", Value.fromBigInt(BigInt.zero()));
576546
this.set("rETHBalance", Value.fromBigInt(BigInt.zero()));
577547
this.set("totalETHRewards", Value.fromBigInt(BigInt.zero()));
578-
this.set("totalETHRewardsRank", Value.fromBigInt(BigInt.zero()));
579548
this.set("block", Value.fromBigInt(BigInt.zero()));
580549
this.set("blockTime", Value.fromBigInt(BigInt.zero()));
581550
}
@@ -656,15 +625,6 @@ export class StakerBalanceCheckpoint extends Entity {
656625
this.set("totalETHRewards", Value.fromBigInt(value));
657626
}
658627

659-
get totalETHRewardsRank(): BigInt {
660-
let value = this.get("totalETHRewardsRank");
661-
return value!.toBigInt();
662-
}
663-
664-
set totalETHRewardsRank(value: BigInt) {
665-
this.set("totalETHRewardsRank", Value.fromBigInt(value));
666-
}
667-
668628
get block(): BigInt {
669629
let value = this.get("block");
670630
return value!.toBigInt();
@@ -694,7 +654,6 @@ export class Node extends Entity {
694654
this.set("effectiveRPLStaked", Value.fromBigInt(BigInt.zero()));
695655
this.set("totalRPLSlashed", Value.fromBigInt(BigInt.zero()));
696656
this.set("totalClaimedRPLRewards", Value.fromBigInt(BigInt.zero()));
697-
this.set("totalRPLClaimedRewardsRank", Value.fromBigInt(BigInt.zero()));
698657
this.set("minimumEffectiveRPL", Value.fromBigInt(BigInt.zero()));
699658
this.set("maximumEffectiveRPL", Value.fromBigInt(BigInt.zero()));
700659
this.set("queuedMinipools", Value.fromBigInt(BigInt.zero()));
@@ -779,15 +738,6 @@ export class Node extends Entity {
779738
this.set("totalClaimedRPLRewards", Value.fromBigInt(value));
780739
}
781740

782-
get totalRPLClaimedRewardsRank(): BigInt {
783-
let value = this.get("totalRPLClaimedRewardsRank");
784-
return value!.toBigInt();
785-
}
786-
787-
set totalRPLClaimedRewardsRank(value: BigInt) {
788-
this.set("totalRPLClaimedRewardsRank", Value.fromBigInt(value));
789-
}
790-
791741
get minimumEffectiveRPL(): BigInt {
792742
let value = this.get("minimumEffectiveRPL");
793743
return value!.toBigInt();
@@ -1530,26 +1480,6 @@ export class NetworkNodeBalanceCheckpoint extends Entity {
15301480
this.set("totalClaimedRPLRewards", Value.fromBigInt(value));
15311481
}
15321482

1533-
get checkpointWithHighestRPLRewardsRank(): string | null {
1534-
let value = this.get("checkpointWithHighestRPLRewardsRank");
1535-
if (!value || value.kind == ValueKind.NULL) {
1536-
return null;
1537-
} else {
1538-
return value.toString();
1539-
}
1540-
}
1541-
1542-
set checkpointWithHighestRPLRewardsRank(value: string | null) {
1543-
if (!value) {
1544-
this.unset("checkpointWithHighestRPLRewardsRank");
1545-
} else {
1546-
this.set(
1547-
"checkpointWithHighestRPLRewardsRank",
1548-
Value.fromString(<string>value)
1549-
);
1550-
}
1551-
}
1552-
15531483
get rplPriceInETH(): BigInt {
15541484
let value = this.get("rplPriceInETH");
15551485
return value!.toBigInt();
@@ -1654,7 +1584,6 @@ export class NodeBalanceCheckpoint extends Entity {
16541584
this.set("maximumEffectiveRPL", Value.fromBigInt(BigInt.zero()));
16551585
this.set("totalRPLSlashed", Value.fromBigInt(BigInt.zero()));
16561586
this.set("totalClaimedRPLRewards", Value.fromBigInt(BigInt.zero()));
1657-
this.set("totalRPLClaimedRewardsRank", Value.fromBigInt(BigInt.zero()));
16581587
this.set("queuedMinipools", Value.fromBigInt(BigInt.zero()));
16591588
this.set("stakingMinipools", Value.fromBigInt(BigInt.zero()));
16601589
this.set("stakingUnbondedMinipools", Value.fromBigInt(BigInt.zero()));
@@ -1768,15 +1697,6 @@ export class NodeBalanceCheckpoint extends Entity {
17681697
this.set("totalClaimedRPLRewards", Value.fromBigInt(value));
17691698
}
17701699

1771-
get totalRPLClaimedRewardsRank(): BigInt {
1772-
let value = this.get("totalRPLClaimedRewardsRank");
1773-
return value!.toBigInt();
1774-
}
1775-
1776-
set totalRPLClaimedRewardsRank(value: BigInt) {
1777-
this.set("totalRPLClaimedRewardsRank", Value.fromBigInt(value));
1778-
}
1779-
17801700
get queuedMinipools(): BigInt {
17811701
let value = this.get("queuedMinipools");
17821702
return value!.toBigInt();

schema.graphql

-18
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ type Staker @entity {
3636
# Total ETH rewards (in WEI) accrued during the lifecycle of the staker.
3737
totalETHRewards: BigInt!
3838

39-
# Current ETH reward rank of the staker based on his current total ETH rewards in comparison to the other stakers on the protocol.
40-
totalETHRewardsRank: BigInt!
41-
4239
# Indicates if this staker has accrued ETH rewards at some point in time during its lifetime.
4340
hasAccruedETHRewardsDuringLifecycle: Boolean!
4441

@@ -108,9 +105,6 @@ type NetworkStakerBalanceCheckpoint @entity {
108105
# Average staker ETH rewards (+/-) (in WEI) up to this checkpoint.
109106
averageStakerETHRewards: BigInt!
110107

111-
# Staker checkpoint that had the highest total ETH reward rank at this checkpoint.
112-
checkpointWithHighestRewardsRank: StakerBalanceCheckpoint
113-
114108
# Total unique stakers that have an rETH balance (in WEI) greater than 0 at this checkpoint.
115109
stakersWithAnRETHBalance: BigInt!
116110

@@ -147,9 +141,6 @@ type StakerBalanceCheckpoint @entity {
147141
# Total ETH rewards (in WEI) up to this checkpoint.
148142
totalETHRewards: BigInt!
149143

150-
# ETH reward rank of the staker based on his total ETH rewards at this checkpoint in comparison to the other stakers on the protocol.
151-
totalETHRewardsRank: BigInt!
152-
153144
# Block Number of this checkpoint.
154145
block: BigInt!
155146

@@ -177,9 +168,6 @@ type Node @entity {
177168
# Total claimed RPL rewards since this node was registered with RocketPool.
178169
totalClaimedRPLRewards: BigInt!
179170

180-
# Current RPL reward rank of the node based on his total RPL rewards in comparison to the other nodes on the protocol.
181-
totalRPLClaimedRewardsRank: BigInt!
182-
183171
# Current minimum RPL needed to collateralize all staking minipools of this node by the bare minimum.
184172
minimumEffectiveRPL: BigInt!
185173

@@ -377,9 +365,6 @@ type NetworkNodeBalanceCheckpoint @entity {
377365
# Total Claimed RPL rewards from all previous checkpoints up to this checkpoint.
378366
totalClaimedRPLRewards: BigInt!
379367

380-
# Node balance checkpoint that had the highest total RPL reward rank at this checkpoint.
381-
checkpointWithHighestRPLRewardsRank: NodeBalanceCheckpoint
382-
383368
# The RPL price in ETH at this checkpoint.
384369
rplPriceInETH: BigInt!
385370

@@ -440,9 +425,6 @@ type NodeBalanceCheckpoint @entity {
440425
# Total Claimed RPL rewards up to this checkpoint.
441426
totalClaimedRPLRewards: BigInt!
442427

443-
# RPL reward rank of the node based on his total RPL rewards at this checkpoint in comparison to the other nodes on the protocol.
444-
totalRPLClaimedRewardsRank: BigInt!
445-
446428
# Queued minipools for this node at this checkpoint.
447429
queuedMinipools: BigInt!
448430

src/entityfactory.ts

+1-12
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class RocketPoolEntityFactory {
9393
networkBalance.stakerETHInProtocol = event.params.totalEth;
9494
networkBalance.totalRETHSupply = event.params.rethSupply;
9595
networkBalance.averageStakerETHRewards = BigInt.fromI32(0);
96-
networkBalance.checkpointWithHighestRewardsRank = null;
9796
networkBalance.rETHExchangeRate = rEthExchangeRate;
9897
networkBalance.block = event.block.number;
9998
networkBalance.blockTime = event.block.timestamp;
@@ -115,7 +114,6 @@ class RocketPoolEntityFactory {
115114
staker.rETHBalance = BigInt.fromI32(0);
116115
staker.ethBalance = BigInt.fromI32(0);
117116
staker.totalETHRewards = BigInt.fromI32(0);
118-
staker.totalETHRewardsRank = BigInt.fromI32(0);
119117
staker.lastBalanceCheckpoint = null;
120118
staker.hasAccruedETHRewardsDuringLifecycle = false;
121119
staker.block = blockNumber;
@@ -154,10 +152,7 @@ class RocketPoolEntityFactory {
154152
stakerBalanceCheckpoint.rETHBalance = rEthBalance;
155153
stakerBalanceCheckpoint.totalETHRewards = totalETHRewards;
156154
stakerBalanceCheckpoint.block = blockNumber;
157-
stakerBalanceCheckpoint.blockTime = blockTime;
158-
159-
// Set later based on other staker balance checkpoints in the same network checkpoint.
160-
stakerBalanceCheckpoint.totalETHRewardsRank = BigInt.fromI32(0);
155+
stakerBalanceCheckpoint.blockTime = blockTime;
161156

162157
return stakerBalanceCheckpoint;
163158
}
@@ -190,7 +185,6 @@ class RocketPoolEntityFactory {
190185
node.maximumEffectiveRPL = BigInt.fromI32(0);
191186
node.totalRPLSlashed = BigInt.fromI32(0);
192187
node.totalClaimedRPLRewards = BigInt.fromI32(0);
193-
node.totalRPLClaimedRewardsRank = BigInt.fromI32(0);
194188
node.queuedMinipools = BigInt.fromI32(0);
195189
node.stakingMinipools = BigInt.fromI32(0);
196190
node.stakingUnbondedMinipools = BigInt.fromI32(0);
@@ -320,7 +314,6 @@ class RocketPoolEntityFactory {
320314
checkpoint.maximumEffectiveRPL = BigInt.fromI32(0); // Will be calculated.
321315
checkpoint.totalRPLSlashed = BigInt.fromI32(0); // Will be calculated.
322316
checkpoint.totalClaimedRPLRewards = BigInt.fromI32(0); // Will be calculated.
323-
checkpoint.checkpointWithHighestRPLRewardsRank = null; // Should be determined later.
324317
checkpoint.rplPriceInETH = newRplPriceInETH; // From the associated price update.
325318
checkpoint.queuedMinipools = BigInt.fromI32(0); // Will be calculated.
326319
checkpoint.stakingMinipools = BigInt.fromI32(0); // Will be calculated.
@@ -365,10 +358,6 @@ class RocketPoolEntityFactory {
365358
checkpoint.block = blockNumber;
366359
checkpoint.blockTime = blockTime;
367360

368-
// Unlike the staker total ETH rewards rank, the RPL rewards rank it kept up to date by the ETH1 chain every time rewards are claimed.
369-
// That means we can just copy the state over from the node.
370-
checkpoint.totalRPLClaimedRewardsRank = node.totalRPLClaimedRewardsRank;
371-
372361
return checkpoint;
373362
}
374363

src/mappings/rocketNetworkBalancesMapping.ts

-71
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ function generateStakerBalanceCheckpoints(
138138
return
139139
}
140140

141-
let generatedStakerBalanceCheckpoints = new Array<StakerBalanceCheckpoint>()
142-
let stakerBalanceCheckpointToStakerMap = new Map<string, Staker>()
143-
144141
// Loop through all the staker id's in the protocol.
145142
for (let index = 0; index < stakerIds.length; index++) {
146143
// Determine current staker ID.
@@ -201,74 +198,6 @@ function generateStakerBalanceCheckpoints(
201198
// Index both the updated staker & the new staker balance checkpoint.
202199
stakerBalanceCheckpoint.save()
203200
staker.save()
204-
205-
// Keep track of all generated staker balance checkpoints.
206-
generatedStakerBalanceCheckpoints.push(
207-
<StakerBalanceCheckpoint>stakerBalanceCheckpoint,
208-
)
209-
210-
// Keep track of the staker object that belongs to the node.
211-
stakerBalanceCheckpointToStakerMap.set(
212-
stakerBalanceCheckpoint.id,
213-
<Staker>staker,
214-
)
215-
}
216-
217-
// If there were any staker balance checkpoints generated..
218-
if (generatedStakerBalanceCheckpoints.length > 0) {
219-
let sortedStakerBalanceCheckpointsByRank = generatedStakerBalanceCheckpoints.sort(
220-
function (a, b) {
221-
if(b.totalETHRewards > a.totalETHRewards) return 1;
222-
else if(b.totalETHRewards < a.totalETHRewards) return -1;
223-
else return 0;
224-
},
225-
)
226-
227-
// Set the rank of each staker balance checkpoint & store the checkpoint with the highest rank on the network checkpoint.
228-
let rankIndex = 1
229-
for (
230-
let index = 0;
231-
index < sortedStakerBalanceCheckpointsByRank.length;
232-
index++
233-
) {
234-
// Get the current staker balance checkpoint for this iteration.
235-
let currentStakerBalanceCheckpoint =
236-
sortedStakerBalanceCheckpointsByRank[index]
237-
if (
238-
currentStakerBalanceCheckpoint === null &&
239-
stakerBalanceCheckpointToStakerMap.has(
240-
currentStakerBalanceCheckpoint.id,
241-
)
242-
)
243-
continue
244-
245-
// The rank of the staker in this checkpoint is the current index.
246-
currentStakerBalanceCheckpoint.totalETHRewardsRank = BigInt.fromI32(
247-
rankIndex,
248-
)
249-
currentStakerBalanceCheckpoint.save()
250-
251-
// Determine the associated staker
252-
let associatedStaker = <Staker>(
253-
stakerBalanceCheckpointToStakerMap.get(
254-
currentStakerBalanceCheckpoint.id,
255-
)
256-
)
257-
if (associatedStaker !== null) {
258-
associatedStaker.totalETHRewardsRank =
259-
currentStakerBalanceCheckpoint.totalETHRewardsRank
260-
associatedStaker.save()
261-
}
262-
263-
// If this was the first staker checkpoint, it has the highest rank and should be stored that way on the network staker balance checkpoint.
264-
if (rankIndex === 1) {
265-
networkCheckpoint.checkpointWithHighestRewardsRank =
266-
currentStakerBalanceCheckpoint.id
267-
}
268-
269-
// Update the rank index for the next staker(balance checkpoint).
270-
rankIndex = rankIndex + 1
271-
}
272201
}
273202
}
274203

src/mappings/rocketNetworkPricesMapping.ts

-6
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ function generateNodeBalanceCheckpoints(
160160
if (nodeBalanceCheckpoint == null) continue
161161
node.lastNodeBalanceCheckpoint = nodeBalanceCheckpoint.id
162162

163-
// Keep track of the highest RPL rewards claimed rank for this checkpoint.
164-
if (node.totalRPLClaimedRewardsRank == BigInt.fromI32(1)) {
165-
networkCheckpoint.checkpointWithHighestRPLRewardsRank =
166-
nodeBalanceCheckpoint.id
167-
}
168-
169163
// Index both the updated node & the new node balance checkpoint.
170164
nodeBalanceCheckpoint.save()
171165
node.save()

0 commit comments

Comments
 (0)