Skip to content

feat(stellar): add buildStellarSwapAndStealth helper#96

Merged
truthixify merged 1 commit into
wraith-protocol:developfrom
Mathew2k-hash:feat/stellar-swap-and-stealth
Jun 25, 2026
Merged

feat(stellar): add buildStellarSwapAndStealth helper#96
truthixify merged 1 commit into
wraith-protocol:developfrom
Mathew2k-hash:feat/stellar-swap-and-stealth

Conversation

@Mathew2k-hash

Copy link
Copy Markdown
Contributor

feat(stellar): atomic swap + stealth payment helper

Adds buildStellarSwapAndStealth — a single-envelope Stellar transaction that swaps one asset
for another via the AMM and delivers the output to a one-time stealth address, with a Wraith
announcement, all atomically.

What's in the transaction

  • Native XLM as toAsset (2 ops): pathPaymentStrictReceive delivers XLM directly to the stealth
    address (creating the account if needed) + invokeHostFunction announcement.
  • Non-native toAsset e.g. USDC (3 ops): pathPaymentStrictReceive → sender,
    createClaimableBalance claimable by the stealth address (no trustline required), +
    announcement.

Slippage protection

sendMax caps the maximum spend. If the AMM path costs more, Stellar rejects the transaction
before any funds move. The docs include a snippet for deriving sendMax from a Horizon
/paths/strict-receive quote with a configurable basis-point tolerance.

Files changed

  • src/chains/stellar/swap.ts — implementation
  • src/chains/stellar/index.ts — exports buildStellarSwapAndStealth,
    BuildStellarSwapAndStealthOptions, SwapAndStealthResult
  • test/chains/stellar/swap.test.ts — 7 unit tests (native path, non-native path, slippage
    encoding, determinism, announcement always present)
  • test/chains/stellar/swap.integration.test.ts — 3 testnet tests against live Horizon/AMM pools
    (skipped unless INTEGRATION=1)
  • docs/guides/stellar-swap-and-stealth.mdx — full guide with API reference, worked examples,
    slippage calculation, and recipient claim flow

Testing

pnpm test test/chains/stellar/swap.test.ts # 7/7 passing
INTEGRATION=1 pnpm exec vitest run test/chains/stellar/swap.integration.test.ts

closes #85

Atomic transaction that swaps fromAsset → toAsset via pathPaymentStrictReceive
and delivers the output to a one-time stealth address, with an on-chain
announcement in the same envelope.

- Native XLM toAsset: 2 ops (pathPayment directly to stealth + announce)
- Non-native toAsset: 3 ops (pathPayment to sender + claimableBalance + announce)
- sendMax provides configurable slippage protection
- Exports: buildStellarSwapAndStealth, BuildStellarSwapAndStealthOptions, SwapAndStealthResult
- Unit tests (7) and integration tests (3, INTEGRATION=1 gated)
- Docs: docs/guides/stellar-swap-and-stealth.mdx
@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@Mathew2k-hash 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

@truthixify

Copy link
Copy Markdown
Contributor

Clean merge. buildStellarSwapAndStealth (DEX swap then send to stealth address atomically) is exactly the helper the demo's swap-and-pay flow needs. Tests cover the integration path. Thanks @Mathew2k-hash.

@truthixify truthixify merged commit 01d066c into wraith-protocol:develop Jun 25, 2026
emarkees pushed a commit to emarkees/sdk that referenced this pull request Jun 26, 2026
Atomic transaction that swaps fromAsset → toAsset via pathPaymentStrictReceive
and delivers the output to a one-time stealth address, with an on-chain
announcement in the same envelope.

- Native XLM toAsset: 2 ops (pathPayment directly to stealth + announce)
- Non-native toAsset: 3 ops (pathPayment to sender + claimableBalance + announce)
- sendMax provides configurable slippage protection
- Exports: buildStellarSwapAndStealth, BuildStellarSwapAndStealthOptions, SwapAndStealthResult
- Unit tests (7) and integration tests (3, INTEGRATION=1 gated)
- Docs: docs/guides/stellar-swap-and-stealth.mdx
emarkees pushed a commit to emarkees/sdk that referenced this pull request Jun 26, 2026
Atomic transaction that swaps fromAsset → toAsset via pathPaymentStrictReceive
and delivers the output to a one-time stealth address, with an on-chain
announcement in the same envelope.

- Native XLM toAsset: 2 ops (pathPayment directly to stealth + announce)
- Non-native toAsset: 3 ops (pathPayment to sender + claimableBalance + announce)
- sendMax provides configurable slippage protection
- Exports: buildStellarSwapAndStealth, BuildStellarSwapAndStealthOptions, SwapAndStealthResult
- Unit tests (7) and integration tests (3, INTEGRATION=1 gated)
- Docs: docs/guides/stellar-swap-and-stealth.mdx
emarkees pushed a commit to emarkees/sdk that referenced this pull request Jun 26, 2026
Atomic transaction that swaps fromAsset → toAsset via pathPaymentStrictReceive
and delivers the output to a one-time stealth address, with an on-chain
announcement in the same envelope.

- Native XLM toAsset: 2 ops (pathPayment directly to stealth + announce)
- Non-native toAsset: 3 ops (pathPayment to sender + claimableBalance + announce)
- sendMax provides configurable slippage protection
- Exports: buildStellarSwapAndStealth, BuildStellarSwapAndStealthOptions, SwapAndStealthResult
- Unit tests (7) and integration tests (3, INTEGRATION=1 gated)
- Docs: docs/guides/stellar-swap-and-stealth.mdx
truthixify pushed a commit that referenced this pull request Jun 26, 2026
* feat(stellar): buildStellarSwapAndStealth helper (#96)

Atomic transaction that swaps fromAsset → toAsset via pathPaymentStrictReceive
and delivers the output to a one-time stealth address, with an on-chain
announcement in the same envelope.

- Native XLM toAsset: 2 ops (pathPayment directly to stealth + announce)
- Non-native toAsset: 3 ops (pathPayment to sender + claimableBalance + announce)
- sendMax provides configurable slippage protection
- Exports: buildStellarSwapAndStealth, BuildStellarSwapAndStealthOptions, SwapAndStealthResult
- Unit tests (7) and integration tests (3, INTEGRATION=1 gated)
- Docs: docs/guides/stellar-swap-and-stealth.mdx

* style: apply consistent code formatting and downgrade expo-crypto version

---------

Co-authored-by: Mathew2k-hash <ochoalaurie74@gmail.com>
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.

Stellar Liquidity Pool swap-then-stealth helper

2 participants