Skip to content

feat: add per-holder accrual snapshot query - #708

Merged
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
Glam26:feat/accrual-snapshot-query
Jul 30, 2026
Merged

feat: add per-holder accrual snapshot query#708
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
Glam26:feat/accrual-snapshot-query

Conversation

@Glam26

@Glam26 Glam26 commented Jul 29, 2026

Copy link
Copy Markdown

Here's a summary of all changes made across 3 files (258 additions, 8 deletions):
──────────────────────────────────────────────────────────────────────

  1. src/lib.rs — New get_holder_accrued_unclaimed function (+113 lines)
    Event constant ( EVENT_ACC_SNAP ):
  • New debug tracing event emitted on every call to the new query, giving integrators a computation breakdown in simulation responses.
    New public function get_holder_accrued_unclaimed(env, issuer, namespace, token, holder) -> i128 :
  • Pure read-only — no state mutation, no auth required
  • Returns 0 immediately for blacklisted holders
  • Computes total unclaimed dividends by:
  1. Loading the holder's HolderAccrualState (frozen accrued_owed + last_settled_idx )
  2. Computing additional accrual from last_settled_idx → matured end via find_matured_claim_end_idx + compute_holder_payout_for_range
  3. Adding any AccrualAnchor.claimable_sum (compressed share-schedule entries)
  4. Emitting EVENT_ACC_SNAP with the full breakdown
  • Gas bounded per-holder — scales with share-schedule entries (naturally bounded by checkpoint compression at 1,000 entries)
  • Inserted after get_claimable_chunk , before the Time-delayed claim configuration section
    ──────────────────────────────────────────────────────────────────────
  1. src/test_accrual_ledger.rs — 8 new tests (+144 lines)
    ┌───────────────────────────────────────┬──────────────────────────────┐
    │ Test │ What it checks │
    ├───────────────────────────────────────┼──────────────────────────────┤
    │ accrued_unclaimed_returns_zero_for_bl │ Fast-path guard works │
    │ acklisted_holder │ │
    │ accrued_unclaimed_matches_claimable_f │ 50% share → accrued == │
    │ or_single_period │ claimable == 50k │
    │ accrued_unclaimed_matches_claimable_a │ 50% → 25% share: accrued == │
    │ fter_share_change │ claimable == 75k │
    │ accrued_unclaimed_returns_zero_for_ho │ Never had share → 0 │
    │ lder_with_no_share │ │
    │ accrued_unclaimed_respects_partial_cl │ Claimed 1 of 2 periods → │
    │ aim │ remaining = 50k │
    │ accrued_unclaimed_after_full_claim_re │ All periods claimed → 0 │
    │ turns_zero │ │
    │ accrued_unclaimed_zero_share_does_not │ Had 50% share then set to 0 │
    │ _erase_past_accrual │ → past accrual (50k) │
    │ │ preserved │
    │ accrued_unclaimed_matches_claimable_a │ Combination: share changes + │
    │ fter_partial_claim_with_share_change │ partial claim → matches │
    └───────────────────────────────────────┴──────────────────────────────┘
    Every test asserts accrued == claimable when both are meaningful.
    ──────────────────────────────────────────────────────────────────────
  2. tools/storage_layout_schema.rs — Pre-existing drift fix (-8, +1 lines)
  • Added: DataKey2::FaucetSeedCount(OfferingId) — was missing from the registry
  • Removed: 8 stale variants no longer in the DataKey2 enum ( EmitV2Compat , GlobalFreezeReason , AdminRotationDelay , JurisdictionGracePeriod , JurisdictionMigration , RedemptionRequest , RedemptionFeeConfig , LockupSchedule )

closes #529

- Add get_holder_accrued_unclaimed public query that walks the
  accrual ledger and returns total unclaimed dividend balance
- Add EVENT_ACC_SNAP debug tracing event for simulation visibility
- Add 8 comprehensive tests covering blacklist, partial claims,
  share changes, zero shares, and full-claim scenarios
- Fix pre-existing storage layout registry drift in schema tool
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Glam26 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

- Fix missing newline after RedemptionWindowClosed enum variant
- Fix module list ordering in test module declarations
- Fix long tuple expression formatting in emit_v2_event
- Fix assertion and method call formatting in test_transfer_cooldown
- Fix let+match binding formatting in vesting.rs
- Additional minor whitespace adjustments in test files
@thlpkee20-wq
thlpkee20-wq merged commit 835c346 into RevoraOrg:master Jul 30, 2026
3 of 4 checks passed
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.

Add per-holder accrual snapshot query returning currently-owed but unclaimed balance

3 participants