Skip to content

feat(wrapper): [Storage] Define VaultState struct (#715) - #831

Open
TochukwuJustice wants to merge 1 commit into
BCPathway:mainfrom
TochukwuJustice:vault-state
Open

feat(wrapper): [Storage] Define VaultState struct (#715)#831
TochukwuJustice wants to merge 1 commit into
BCPathway:mainfrom
TochukwuJustice:vault-state

Conversation

@TochukwuJustice

Copy link
Copy Markdown

closes #715

Summary of Changes

This pull request implements Issue #715: [Storage] Define VaultState struct under the Yield-Bearing Fee Vaults epic:

  • Struct Definition (VaultState): Encapsulates fee_rate_bps (u32), fee_receiver (Address), min_deposit (i128), max_deposit (i128), exchange_rate (i128), accumulated_fees (i128), and last_update_timestamp (u64).
  • Storage Safety: Added DataKey::VaultState strictly as the last discriminant in the DataKey enum, preserving upgrade compatibility and preventing storage slot collision.
  • Contract Functions: Implemented set_vault_state (admin-gated with parameter bounds checks) and get_vault_state public view method on WrapperContract.
  • Events: Added emit_vault_state_set event ("v_state" topic).
  • TypeScript SDK: Added VaultState interface, getVaultState(), and setVaultState() methods to WrapperClient in @bc-forge/sdk.
  • Unit Tests: Added 8 comprehensive test cases in contracts/wrapper/src/test.rs covering happy path configuration, unauthorized caller rejection, invariant validation (fee rate bounds, limit ranges, positive exchange rate, non-negative fees), and storage slot isolation.

Reason for Changes

Yield-bearing fee vaults require persistent storage of global vault parameters, deposit thresholds, exchange pricing, and fee accumulation to enable fee distribution, capital tracking, and yield accrual mechanisms without breaking existing token wrapping features.

… fee vaults

- Define VaultState struct storing fee rates, limits, exchange rate, and fee accumulation metrics

- Add DataKey::VaultState preserving storage discriminant ordering

- Implement set_vault_state and get_vault_state contract entrypoints with strict invariant validation

- Add emit_vault_state_set contract event

- Add comprehensive unit test suite covering happy paths and error states

- Extend TypeScript SDK WrapperClient with VaultState interface, getter, and setter methods
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@TochukwuJustice 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

@p3ris0n

p3ris0n commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@TochukwuJustice please fix CI and conflicts

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.

[Storage] Define VaultState struct

2 participants