feat(contracts): add batch_deposit entrypoint for multi-user relayer …#687
Merged
Junirezz merged 1 commit intoJun 2, 2026
Merged
Conversation
…submissions (Junirezz#564) Adds a new �atch_deposit function to YieldVault that allows whitelisted relayers to process multiple user deposits atomically in a single Soroban transaction. ## New public interface - �atch_deposit(relayer, entries) -> Result<BatchDepositResult, VaultError> Processes a Vec<DepositEntry> in one tx. Per-entry failures are recorded in the result; valid entries succeed regardless. Paused-vault and relayer auth checks gate the entire call. - set_relayer(relayer, approved) Admin: register/remove relayer whitelist - is_relayer(relayer) -> bool Query relayer registration - set_max_batch_size(size) Admin: set per-call entry limit (default 50) - max_batch_size() -> u32 Query current limit ## New types - DepositEntry { user: Address, amount: i128 } input element - DepositResult { user, shares_minted, success, error_code } per-entry result - BatchDepositResult { results, total_shares_minted, success_count, failure_count } ## New error codes - VaultError::BatchTooLarge (16) entries.len() exceeds max_batch_size - VaultError::RelayerNotAuthorized (17) caller not in relayer whitelist ## New DataKey variants - DataKey::RelayerWhitelist(Address) per-relayer approval flag - DataKey::MaxBatchSize configurable batch size cap ## Security - Checks-Effects-Interactions pattern maintained: all validation runs before token transfers; in-memory VaultState is updated incrementally per entry and persisted once after the loop. - Each user's equire_auth() is called before their token.transfer(). - Relayer whitelist requires explicit admin approval. - Batch size cap prevents unbounded-loop DOS. ## Tests (contracts/vault/src/test.rs) 11 new tests covering: - Happy path: 3-user batch, 1:1 and diluted share price - Partial failures: invalid amount, min_deposit, per-user cap - Guard rails: paused vault, unregistered relayer, oversized batch - Edge: empty batch, share price consistency across entries, state invariant
|
@Whiznificent 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! 🚀 |
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.
…submissions (#564)
Adds a new �atch_deposit function to YieldVault that allows whitelisted relayers to process multiple user deposits atomically in a single Soroban transaction.
New public interface
�atch_deposit(relayer, entries) -> Result<BatchDepositResult, VaultError> Processes a Vec in one tx. Per-entry failures are recorded in the result; valid entries succeed regardless. Paused-vault and relayer auth checks gate the entire call.
set_relayer(relayer, approved) Admin: register/remove relayer whitelist
is_relayer(relayer) -> bool Query relayer registration
set_max_batch_size(size) Admin: set per-call entry limit (default 50)
max_batch_size() -> u32 Query current limit
New types
New error codes
New DataKey variants
Security
equire_auth() is called before their token.transfer().
Tests (contracts/vault/src/test.rs)
11 new tests covering:
Pull Request Template
📋 Description
Add a complete environment variable matrix (
docs/ENV_VARIABLE_MATRIX.md) covering every env var consumed across the backend and frontend, with defaults, required flags, and production recommendations. UpdateREADME.mdandENV_QUICK_REFERENCE.mdto link to the new document.🔗 Type of Change
🔒 SECURITY REVIEW (⭐ MANDATORY FOR SMART CONTRACT CHANGES)
For all smart contract code changes, complete the following checklist.
See
docs/SECURITY_CHECKLIST.mdfor detailed guidance.Required: Security Checklist Sign-Off
I have reviewed this PR against the Internal Security Checklist (
docs/SECURITY_CHECKLIST.md)onlyOwner,onlyRole(), etc.)require(success, ...))If any checkbox cannot be verified, explain below:
Slither Static Analysis Results
Ran Slither locally:
slither . --config-file slither.config.jsonGitHub Actions Slither workflow passed:
If this PR has security findings, document them below:
Handling Security Findings
Option A: Fixed in This PR ✅
Option B: False Positive 🟡
contracts/.false-positives.mdwith:Option C: Accepted Risk⚠️
📝 Testing
Functional Testing
Security Testing
For state-changing functions:
For external integrations:
Test Coverage
N/A — documentation only, no executable code added🚀 Deployment Notes
No deployment steps required. This PR adds a Markdown file and updates two existing Markdown files only.
Mainnet Readiness
Breaking Changes
If this PR introduces breaking changes:
[timeframe]📊 Automated Scan Results
Slither Analysis
Related Documentation
✅ Reviewer Checklist
For code reviewers (use this to guide your security-focused review):
📞 Questions or Issues?
docs/SECURITY_CHECKLIST.mddocs/FALSE_POSITIVE_HANDLING.md@security-teamin comments📋 Pre-Submit Checklist
Before marking PR as ready for review:
npm testnpm run lintslither . --config-file slither.config.json✅ Ready for Review? Ensure all items above are checked before requesting review.
closes #564