feat(yield-vault): implement guards and tests (#732–#735) - #871
Open
damilareojetunde wants to merge 9 commits into
Open
feat(yield-vault): implement guards and tests (#732–#735)#871damilareojetunde wants to merge 9 commits into
damilareojetunde wants to merge 9 commits into
Conversation
|
@damilareojetunde 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! 🚀 |
…y#735) Add three guard layers and comprehensive tests to the yield vault contract: - BCPathway#732: rate_limit_deposits — integrates with bc_forge_rate_limit module to throttle deposit frequency and prevent whale manipulation. - BCPathway#733: pause_vault_deposits — adds require_not_paused to deposit while keeping withdraw always active so users can exit. - BCPathway#734: rescue_tokens — admin-only function to recover non-underlying tokens; reverts if the requested token matches the vault's core underlying asset. - BCPathway#735: deposit-to-mint ratio tests — verifies share calculation across initial deposits, secondary deposits, reward distributions, and multi-user pro-rata scenarios. Also removes yield_vault from workspace exclude list and adds dependencies on bc-forge-admin, bc-forge-lifecycle, bc-forge-rate-limit, and bc-forge-ttl. Co-Authored-By: Samuel Ojetunde <samjay8@users.noreply.github.com>
Apply rustfmt formatting to events.rs, lib.rs, and test.rs to pass the CI formatting check. Co-Authored-By: Samuel Ojetunde <samjay8@users.noreply.github.com>
Co-Authored-By: Samuel Ojetunde <samjay8@users.noreply.github.com>
…ignature) Co-Authored-By: Samuel Ojetunde <samjay8@users.noreply.github.com>
- Remove & from numeric literals in assert_eq! (E0277: can't compare i128 with &{integer})
- Fix tuple destructuring: setup_and_fund returns 5 values, setup returns 4 (E0308: mismatched types)
Co-Authored-By: Samuel Ojetunde <samjay8@users.noreply.github.com>
- Soroban client auto-unwraps Result return types, so vault.supply(), vault.underlying_token(), vault.share_balance() return values directly - Remove unused import soroban_sdk::testutils::Ledger - Prefix unused variable underlying with underscore Co-Authored-By: Samuel Ojetunde <samjay8@users.noreply.github.com>
freebuff-web
Bot
force-pushed
the
feat/yield-vault-guards-732-735
branch
from
August 31, 2026 10:34
e32e771 to
da91224
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
feat(yield-vault): Implement guard layers and tests (#732–#735)
Epic: Yield-Bearing Fee Vaults
Closes #732
Closes #733
Closes #734
Closes #735
This PR implements three guard functions and comprehensive tests for the
yield_vaultcontract, closing issues #732, #733, #734, and #735.Changes
#732 —
rate_limit_depositsintegrationrate_limit_depositsguard that hooks into the existingbc_forge_rate_limitmodule."deposit"operation type.VaultError::RateLimitedwhen the limit is hit.#733 —
pause_vault_depositsfunctionensure_not_pausedguard to thedepositfunction that checksbc_forge_lifecycle::is_paused.VaultError::ContractPausedwhen the vault is paused.bc_forge_lifecyclemodule.#734 —
rescue_stuck_fundsfunctionrescue_tokens(admin, token, to, amount)— admin-only.VaultError::CannotRescueUnderlyingif the requested token matches the vault's core underlying asset (those tokens belong to depositors).amount > 0.rescueevent for auditability.#735 — Deposit to mint ratio tests
Comprehensive test coverage verifying the share calculation formula:
test_deposit_to_mint_ratio_initial_deposit_1_to_1test_deposit_to_mint_ratio_secondary_deposit_matches_formulashares = assets × total_shares / total_assetstest_deposit_to_mint_ratio_after_reward_distributiontest_deposit_to_mint_ratio_inexact_division_floorstest_deposit_to_mint_ratio_three_users_pro_rataAdditional Changes
yield_vaultfrom workspaceexcludein rootCargo.tomlso it compiles as a workspace member.yield_vault/Cargo.tomlwith dependencies:bc-forge-admin,bc-forge-lifecycle,bc-forge-rate-limit,bc-forge-ttl.cdylibcrate type for WASM deployment.events.rsmodule with structured event emission forinit,deposit,withdraw, andrescue.Test Coverage
RateLimitedContractPausedwhen pausedCannotRescueUnderlyingfor underlying token; reverts for zero/negative amount; non-admin rejectedmin_shares_out/min_tokens_outrespectedInvalidAmount,InsufficientBalance,NotInitializedFiles Changed
Cargo.tomlyield_vaultfrom workspace excludecontracts/yield_vault/Cargo.tomlcontracts/yield_vault/src/lib.rscontracts/yield_vault/src/events.rscontracts/yield_vault/src/test.rs