feat(vault): per-depositor lifetime cumulative deposit tracker for compliance reports (#444)#599
Merged
greatest0fallt1me merged 2 commits intoJun 29, 2026
Conversation
…aOrg#444) Add LifetimeDeposit(Address) persistent storage and LifetimeDepositorIndex instance storage to record cumulative USDC ever deposited per address. - StorageKey::LifetimeDeposit(Address): persistent, TTL ~1 year, never decremented by withdrawals or deducts - StorageKey::LifetimeDepositorIndex: instance Vec<Address> tracking insertion-ordered depositor list for pagination - get_lifetime_deposit(addr): returns 0 for unknown addresses - list_lifetime_deposits(cursor, limit): paginated view, hard cap at 100 - Overflow protected via checked_add on both meta.balance and lifetime total - 10 new tests covering: zero default, accumulation, multi-depositor, withdraw/deduct invariance, pagination, cap enforcement, overflow, dedup - STORAGE.md updated with new keys and version 1.3 entry
|
@frankrichard99 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! 🚀 |
Contributor
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #444
Summary
Adds a compliance-facing lifetime deposit tracker to the Callora Vault contract.
Compliance systems can now query the total USDC ever deposited by any allowed
depositor without replaying transaction history.
Changes
contracts/vault/src/lib.rsStorageKey::LifetimeDeposit(Address)— persistent storage, TTLthreshold ~30 days / bump to ~1 year. Stores a running
i128total perdepositor. Never written by
withdraw,withdraw_to, ordeduct.StorageKey::LifetimeDepositorIndex— instanceVec<Address>maintaining insertion-ordered list of every address that has deposited at
least once; deduplicated on append.
LIFETIME_DEPOSIT_BUMP_THRESHOLD,LIFETIME_DEPOSIT_BUMP_AMOUNT,MAX_LIST_LIFETIME_LIMIT(= 100).deposit()updated — after updatingmeta.balance, accumulatesamountinto
LifetimeDeposit(caller)usingchecked_add(returnsVaultError::Overflowon overflow) and appends caller to the index if absent.get_lifetime_deposit(addr: Address) -> i128— view; returns0foraddresses that have never deposited.
list_lifetime_deposits(cursor: u32, limit: u32) -> Vec<(Address, i128)>— paginated view ordered by first-deposit time; limit silently capped at 100.
contracts/vault/src/test.rsTen new tests appended:
lifetime_deposit_zero_for_new_addresslifetime_deposit_single_depositlifetime_deposit_accumulates_across_multiple_depositslifetime_deposit_not_decremented_by_withdrawlifetime_deposit_not_decremented_by_deductlifetime_deposit_multi_depositor_accumulationlist_lifetime_deposits_empty_before_any_depositlist_lifetime_deposits_returns_entrieslist_lifetime_deposits_paginationlist_lifetime_deposits_limit_capped_at_100lifetime_deposit_overflow_protectedlifetime_deposit_index_no_duplicatescontracts/vault/STORAGE.mdLifetimeDeposit(Address)andLifetimeDepositorIndexin thestorage keys table.
Acceptance Criteria Checklist
checked_add→VaultError::Overflow)