Skip to content

refine monad staking lens scan#4

Draft
0xh3rman wants to merge 1 commit intomainfrom
codex/refine-monad-staking-lens-scan
Draft

refine monad staking lens scan#4
0xh3rman wants to merge 1 commit intomainfrom
codex/refine-monad-staking-lens-scan

Conversation

@0xh3rman
Copy link
Copy Markdown
Collaborator

What changed

  • refactored StakingLens.getDelegations() into an explicit hybrid scan path
  • full-scan withdrawal ids 0..255 for active validators and Gem Wallet's curated validators
  • keep shallow 0..7 scanning for validator-set fallback validators
  • prioritize curated validators ahead of active validators so they are not crowded out by MAX_DELEGATIONS
  • added src/monad/README.md documenting the trade-off and accepted blind spot
  • expanded tests to cover high withdraw ids, all curated validators, and the delegation-cap regression case

Why

Monad withdrawal ids are scoped per (validator, delegator) and may use the full 0..255 range. The previous lens only scanned 0..7, which could miss valid withdrawals. After adding the deeper scan, the next risk was ordering: curated validators could still be squeezed out when a user had enough active delegations to hit MAX_DELEGATIONS.

This change keeps the common Gem Wallet path accurate without paying the cost of a full all validators x 256 withdraw ids sweep on every call.

Impact

  • better visibility for high withdraw ids on active and curated validators
  • curated validators keep priority even when the delegator has many active positions
  • no client ABI change for getDelegations(address)
  • unknown fully-undelegated validators with only withdrawId > 7 remain an intentional blind spot, now documented

Validation

  • forge fmt src/monad/StakingLens.sol test/monad/StakingLens.t.sol
  • forge lint src/monad/StakingLens.sol test/monad/StakingLens.t.sol
  • forge test --match-path test/monad/StakingLens.t.sol

@0xh3rman 0xh3rman changed the title [codex] refine monad staking lens scan refine monad staking lens scan Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant