Skip to content

feat(trading): add atomic batch swaps and quotes - #1129

Open
damilare0813 wants to merge 4 commits into
accesslayerorg:mainfrom
damilare0813:fix/issue-1094
Open

damilare0813 wants to merge 4 commits into
accesslayerorg:mainfrom
damilare0813:fix/issue-1094

Conversation

@damilare0813

Copy link
Copy Markdown

Summary

Add atomic batch_swap(trader, items) for up to 15 buys and sells, with each item's existing spot-price slippage convention. A later failure rolls back earlier fills, balances, fees and events. get_batch_quote prices items in order with virtual supplies, including repeated keys, and the execution receipt reports per-item output, price impact and summed fees.

The batch authorizes its trader once and reuses the existing buy core and a shared sell core. Public batch_sell retains its authorization and behavior. See docs/batch-swaps.md for API, quote and fee semantics.

Closes #1094.

Validation

  • 4 new batch-swap tests passed: mixed directions, quote and receipt agreement, repeated-key pricing, event payload, input limits and rollback on a later slippage failure.
  • All 11 existing batch-sell regression tests passed after extracting the shared core.
  • Targeted Clippy with -D warnings, formatting and diff checks passed.
  • Branch includes the current upstream main.

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

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

@Chucks1093

Copy link
Copy Markdown
Member

✅ PR Ready for Review

Due to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging.

This PR has passed all automated checks:

  • ✅ Security scan — no malicious code detected
  • ✅ No merge conflicts
  • ✅ CI checks passed

Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514

1 similar comment
@Chucks1093

Copy link
Copy Markdown
Member

✅ PR Ready for Review

Due to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging.

This PR has passed all automated checks:

  • ✅ Security scan — no malicious code detected
  • ✅ No merge conflicts
  • ✅ CI checks passed

Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514

@damilare0813

Copy link
Copy Markdown
Author

Note for maintainers: I merged origin/main into this branch and fixed batch_trade.rs to match main's signatures for compute_trade_fee and compute_sell_proceeds (commit b278b81). The batch tests have NOT been run, because creator-keys does not compile on main: ContractError assigns discriminant 148 twice (NoRetirementProposed and CircuitBreakerActive). That is a main bug outside this PR and needs fixing on main first. No reviewer requests were on the PR.

@zeemscript

Copy link
Copy Markdown
Contributor

@Chucks1093 Synced this PR with the latest main, which resolves the duplicate Soroban error-code conflict (NoRetirementProposed now uses 142 and CircuitBreakerActive uses 148). Local validation: cargo check -p creator-keys passed. Fresh GitHub verify check is queued; please review once it completes.

@Chucks1093

Copy link
Copy Markdown
Member

✅ PR Ready for Review

Due to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging.

This PR has passed all automated checks:

  • ✅ Security scan — no malicious code detected
  • ✅ No merge conflicts
  • ✅ CI checks passed

Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514

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.

Implement batch trade contract for executing multiple swaps in one call

3 participants