Repository navigation
fix(vault): enforce reserve cap on deposit - #1444
Draft
Madubuezejoshua wants to merge 1 commit into
Draft
Madubuezejoshua wants to merge 1 commit into
Madubuezejoshua wants to merge 1 commit into
Conversation
|
@Madubuezejoshua 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
|
This PR is still marked as a draft, so it can't be reviewed or merged yet. When it's ready, please rebase onto the latest default branch, make sure CI passes, and click Ready for review. Note: PRs that change |
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 #1394
Enforce the inclusive reserve cap against the tracked USDC balance before deposit writes or transfers, preserve validation order, remove the duplicate pause lookup, and return Overflow for unrepresentable finite-cap sums. Unset/MAX caps retain the arithmetic-free fast path. Lowering a cap below balance blocks deposits while withdrawals/deducts keep their existing rules. Reject non-USDC cap tokens with typed code 59; legacy numeric errors are unchanged (a separate setter error enum avoids the existing 50-case XDR limit).
Regression: unchanged production baseline f4ab47e incorrectly accepts 900 + 101 under cap 1000: actual assertion output
unexpected result: Ok(Ok(())), expected code 43. The same regression now passes with storage, token-balance and event atomicity checks. Final base is 87fba99; its vault production sources match the baseline.Validation:
cargo test -p callora-vault reserve_cap -- --nocapture: 20 passed, none failed/ignored.cargo fmt -p callora-vault -- --checkand required release WASM build for vault, settlement and revenue-pool: passed.Coverage:
cargo llvm-cov --lib -p callora-vault --json --output-path coverage.json -- reserve_cap(cargo-llvm-cov 0.9.1, LLVM 22.1.8): deposit 38/38 lines (100%); limits::check 18/18 lines (100%). Individual function report; 18 instrumented tests passed.Previously stored USDC caps become effective when adopted. Rust callers explicitly typing the setter result as VaultError need a source update. No storage/dependency/CI changes or deployment. See docs/RESERVE_CAP_1394_VALIDATION.md for evidence, commands and limitations.
CI verified: run 39308249244 failed at formatting because unchanged
contracts/yield/src/lib.rs:26places an inner attribute after an outer doc comment. Workspace-test and WASM CI steps were skipped. This is the same inherited failure reproduced locally; the PR stays draft.