Skip to content

Commit 241b09d

Browse files
authored
indexer: align with v0.15.0 ValidatorPodManager events (#131)
Share-pool refactor in ValidatorPodManager changed three event signatures and added one. Mirror those in the indexer config + handlers so the ingest pipeline doesn't silently drop or misread the new fields. - SharesUpdated: gained `totalAssets` and `totalSharesPool`. `newShares` also moved from int256 to uint256. - WithdrawalQueued / WithdrawalCompleted: gained a trailing `assets` (snapshot at queue time; live-min-snapshot payout at completion). - BeaconRebase (new event): tracks beacon rewards/slashes that move totalAssets without changing share balances. Stored in a separate entity so analytics can distinguish principal mints from pool-price moves. Schema entity `ValidatorPodShareEvent` gains nullable `totalAssets` / `totalSharesPool`; `ValidatorPodWithdrawal` gains nullable `queuedAssets` / `completedAssets`. New `ValidatorPodBeaconRebase` entity. Codegen succeeds, tsc --build clean, unit suite 5/5.
1 parent d3db884 commit 241b09d

3 files changed

Lines changed: 49 additions & 3 deletions

File tree

indexer/config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ networks:
114114
- event: PodCreated(address indexed owner, address indexed pod)
115115
- event: Delegated(address indexed delegator, address indexed operator, uint256 amount)
116116
- event: Undelegated(address indexed delegator, address indexed operator, uint256 amount)
117-
- event: SharesUpdated(address indexed owner, int256 sharesDelta, int256 newShares)
117+
- event: SharesUpdated(address indexed owner, int256 sharesDelta, uint256 newShares, uint256 totalAssets, uint256 totalSharesPool)
118+
- event: BeaconRebase(address indexed owner, int256 assetsDelta, uint256 newTotalAssets, uint256 totalSharesPool)
118119
- event: OperatorRegistered(address indexed operator)
119120
- event: OperatorDeregistered(address indexed operator)
120121
- event: DelegatorSlashed(address indexed delegator, address indexed operator, uint256 amount)
121-
- event: WithdrawalQueued(bytes32 indexed withdrawalRoot, address indexed staker, uint256 shares)
122-
- event: WithdrawalCompleted(bytes32 indexed withdrawalRoot, address indexed staker, uint256 shares)
122+
- event: WithdrawalQueued(bytes32 indexed withdrawalRoot, address indexed staker, uint256 shares, uint256 assets)
123+
- event: WithdrawalCompleted(bytes32 indexed withdrawalRoot, address indexed staker, uint256 shares, uint256 assets)
123124
- name: LiquidDelegationFactory
124125
address: []
125126
handler: src/EventHandlers.ts

indexer/schema.graphql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,25 @@ type ValidatorPodShareEvent {
167167
owner: String!
168168
sharesDelta: BigInt!
169169
newShares: BigInt!
170+
"Pool totalAssets at the emit instant. Null on legacy events emitted before the share-pool refactor."
171+
totalAssets: BigInt
172+
"Pool totalShares at the emit instant. Null on legacy events emitted before the share-pool refactor."
173+
totalSharesPool: BigInt
174+
timestamp: BigInt!
175+
txHash: String!
176+
}
177+
178+
"""
179+
Beacon-chain rebase. Distinct from ValidatorPodShareEvent — share events fire on
180+
principal deposits (mint), rebases fire on rewards/slashes (totalAssets-only;
181+
share balances are invariant).
182+
"""
183+
type ValidatorPodBeaconRebase {
184+
id: ID!
185+
owner: String!
186+
assetsDelta: BigInt!
187+
newTotalAssets: BigInt!
188+
totalSharesPool: BigInt!
170189
timestamp: BigInt!
171190
txHash: String!
172191
}
@@ -176,6 +195,10 @@ type ValidatorPodWithdrawal {
176195
withdrawalRoot: String!
177196
staker: String!
178197
shares: BigInt!
198+
"Asset snapshot at queue time. Completion pays out min(snapshot, live)."
199+
queuedAssets: BigInt
200+
"Asset amount actually transferred on completion (≤ queuedAssets when the pool slashed in-between)."
201+
completedAssets: BigInt
179202
status: RequestStatus!
180203
queuedAt: BigInt!
181204
completedAt: BigInt

indexer/src/handlers/validatorPods.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {
33
Operator,
44
ValidatorPod,
55
ValidatorPodShareEvent,
6+
ValidatorPodBeaconRebase,
67
ValidatorPodWithdrawal,
78
ValidatorPodSlash,
89
NativeOperator,
@@ -77,12 +78,31 @@ export function registerValidatorPodHandlers() {
7778
owner: normalizeAddress(event.params.owner),
7879
sharesDelta: toBigInt(event.params.sharesDelta),
7980
newShares: toBigInt(event.params.newShares),
81+
totalAssets: toBigInt(event.params.totalAssets),
82+
totalSharesPool: toBigInt(event.params.totalSharesPool),
8083
timestamp,
8184
txHash: getTxHash(event),
8285
} as ValidatorPodShareEvent;
8386
context.ValidatorPodShareEvent.set(entity);
8487
});
8588

89+
// Beacon rebases (rewards / slashes) move totalAssets only; shares are invariant.
90+
// Tracked separately from SharesUpdated so analytics can distinguish principal
91+
// mints from pool-price moves.
92+
ValidatorPodManager.BeaconRebase.handler(async ({ event, context }) => {
93+
const timestamp = getTimestamp(event);
94+
const entity: ValidatorPodBeaconRebase = {
95+
id: `rebase-${getTxHash(event)}-${event.logIndex}`,
96+
owner: normalizeAddress(event.params.owner),
97+
assetsDelta: toBigInt(event.params.assetsDelta),
98+
newTotalAssets: toBigInt(event.params.newTotalAssets),
99+
totalSharesPool: toBigInt(event.params.totalSharesPool),
100+
timestamp,
101+
txHash: getTxHash(event),
102+
} as ValidatorPodBeaconRebase;
103+
context.ValidatorPodBeaconRebase.set(entity);
104+
});
105+
86106
ValidatorPodManager.OperatorRegistered.handler(async ({ event, context }) => {
87107
const timestamp = getTimestamp(event);
88108
const operator = await ensureNativeOperator(context, event.params.operator, timestamp);
@@ -129,6 +149,7 @@ export function registerValidatorPodHandlers() {
129149
withdrawalRoot: root,
130150
staker: normalizeAddress(event.params.staker),
131151
shares: toBigInt(event.params.shares),
152+
queuedAssets: toBigInt(event.params.assets),
132153
status: "PENDING",
133154
queuedAt: timestamp,
134155
txHash: getTxHash(event),
@@ -143,6 +164,7 @@ export function registerValidatorPodHandlers() {
143164
if (!existing) return;
144165
const updated: ValidatorPodWithdrawal = {
145166
...existing,
167+
completedAssets: toBigInt(event.params.assets),
146168
status: "EXECUTED",
147169
completedAt: timestamp,
148170
txHash: getTxHash(event),

0 commit comments

Comments
 (0)