Skip to content

Commit d5a05c3

Browse files
committed
chore: fixes after review
1 parent 0a45d61 commit d5a05c3

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/providers/execution/contracts/lazy_oracle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def get_vaults(self, offset: int, limit: int, block_identifier: BlockIdentifier
5959
for vault in response:
6060
out.append(VaultInfo(
6161
vault=vault.vault,
62-
aggregated_balance=vault.aggregateBalance,
62+
aggregated_balance=vault.aggregatedBalance,
6363
in_out_delta=vault.inOutDelta,
6464
withdrawal_credentials=Web3.to_hex(vault.withdrawalCredentials),
6565
liability_shares=vault.liabilityShares,

src/services/staking_vaults.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from web3.types import BlockIdentifier, Wei
1111

1212
from src.constants import (
13-
FAR_FUTURE_EPOCH,
1413
MIN_DEPOSIT_AMOUNT,
1514
TOTAL_BASIS_POINTS,
1615
)
@@ -79,18 +78,20 @@ def get_vaults_total_values(
7978
8079
A validator is included in the TV calculation if EITHER of the following conditions is true:
8180
82-
1. Already passed activation eligibility: validator.activation_eligibility_epoch != FAR_FUTURE_EPOCH
83-
2. If not yet passed activation eligibility, the validator then is checked over the lazy oracle stages:
81+
1. It has already passed activation eligibility: validator.activation_eligibility_epoch != FAR_FUTURE_EPOCH
82+
- add full balance + pending deposits are added to TV, as the validator is for sure will be activated
83+
2. If not-yet-eligible, then validator is checked over the registered PDG validator stages:
8484
- PREDEPOSITED: add 1 ETH to TV, as only the predeposit is counted and not the validator balance
85-
- ACTIVATED: add full balance + pending deposits to TV, as the validator is for sure will be activated
86-
87-
# NB: In the PDG validator proving flow, a validator initially receives 1 ETH on the consensus layer as a
88-
# predeposit. After the proof is submitted, an additional 31 ETH immediately appears on the consensus layer
89-
# as a pending deposit. If we ignore these pending deposits, vault's TV would appear to drop by 32 ETH
90-
# until the pending deposit is finalized and the validator is activated. To avoid this misleading drop,
91-
# the calculation of a validator's total balance must include all pending deposits, but only for those
92-
# validators that passed PDG flow. All side-deposited validators will appear in the TV as soon as the
93-
# validator becomes eligible for activation.
85+
- ACTIVATED: count as `already passed activation`, thus add full balance + pending deposits to TV
86+
- all other stages are skipped as not related to the non-eligible for activation validators
87+
88+
NB: In the PDG validator proving flow, a validator initially receives 1 ETH on the consensus layer as a
89+
predeposit. After the proof is submitted, an additional 31 ETH immediately appears on the consensus layer
90+
as a pending deposit. If we ignore these pending deposits, vault's TV would appear to drop by 32 ETH
91+
until the pending deposit is finalized and the validator is activated. To avoid this misleading drop,
92+
the calculation of a validator's total balance must include all pending deposits, but only for those
93+
validators that passed PDG flow. All side-deposited validators will appear in the TV as soon as the
94+
validator becomes eligible for activation.
9495
"""
9596
validators_by_vault = self._get_validators_by_vault(validators, vaults)
9697
total_pending_amount_by_pubkey = self._get_total_pending_amount_by_pubkey(pending_deposits)
@@ -105,12 +106,12 @@ def get_vaults_total_values(
105106
validator_pending_amount = total_pending_amount_by_pubkey.get(validator_pubkey, Gwei(0))
106107
total_validator_balance = gwei_to_wei(Gwei(validator.balance + validator_pending_amount))
107108

108-
# NB: Include validator balance and all pending deposits in TV when validator is eligible for activation
109-
# or has already passed activation: activation_eligibility_epoch stays unchanged != FAR_FUTURE_EPOCH
110-
if validator.validator.activation_eligibility_epoch != FAR_FUTURE_EPOCH:
109+
# Include validator balance and all pending deposits in TV when validator is eligible for activation or
110+
# has already passed activation
111+
if not has_far_future_activation_eligibility_epoch(validator.validator):
111112
vault_total += int(total_validator_balance)
112113

113-
# For not-yet-eligible validators, use lazy oracle stages:
114+
# For not-yet-eligible validators, use PDG stages:
114115
# - PREDEPOSITED: add 1 ETH (guaranteed)
115116
# - ACTIVATED: add full balance + pending deposits
116117
# All other stages are skipped as not related to the non-eligible for activation validators
@@ -136,7 +137,7 @@ def _get_non_activated_validator_stages(
136137
block_identifier: BlockIdentifier = 'latest',
137138
) -> dict[str, ValidatorStage]:
138139
"""
139-
Get validator stages for non-activated validators for connected vaults from the lazy oracle.
140+
Get PDG validator stages for non-activated validators for connected vaults from the lazy oracle.
140141
"""
141142

142143
vault_wcs = {v.withdrawal_credentials for v in vaults.values()}

0 commit comments

Comments
 (0)