Skip to content

fix(vault): add slippage protection for deposit and withdraw#277

Merged
0xDeon merged 1 commit intoSuncrest-Labs:mainfrom
wheval:liquid_reserves
Apr 23, 2026
Merged

fix(vault): add slippage protection for deposit and withdraw#277
0xDeon merged 1 commit intoSuncrest-Labs:mainfrom
wheval:liquid_reserves

Conversation

@wheval
Copy link
Copy Markdown
Contributor

@wheval wheval commented Apr 23, 2026

Summary

  • add slippage-safe vault entrypoints by introducing min_shares_out for deposit and min_assets_out for withdraw
  • revert with ContractError::SlippageExceeded when output falls below caller-specified minimums
  • add preview_deposit / preview_withdraw views and update vault + integration tests to pass explicit slippage params

Test plan

  • Updated unit/integration call sites to new signatures
  • Added slippage regression tests for deposit and withdraw revert paths
  • Run cargo test -p vault-contract in CI environment with vault_token.wasm artifact available

Closes #248

@wheval wheval requested a review from 0xDeon as a code owner April 23, 2026 11:54
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

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

@0xDeon
Copy link
Copy Markdown
Contributor

0xDeon commented Apr 23, 2026

@wheval Fix conflicts please

Add min output parameters to vault deposit/withdraw flows and revert when execution would return worse-than-expected terms. Also expose preview methods and update tests/callers to enforce slippage-safe behavior.

Closes Suncrest-Labs#248

Made-with: Cursor
Copy link
Copy Markdown
Contributor

@0xDeon 0xDeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@0xDeon 0xDeon merged commit 3c7726a into Suncrest-Labs:main Apr 23, 2026
6 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.

[Vault] No slippage protection on deposit and withdrawal — users exposed to unexpected losses without recourse

2 participants