tokens/token-swap: add the native (Solana Native) flavor — example currently ships anchor-only
Proposal
tokens/token-swap ships only the anchor/ flavor. Sibling token examples (create-token, transfer-tokens, escrow, pda-mint-authority, nft-operations) teach the same operations across anchor/native/pinocchio so learners can diff what each framework generates and costs.
This issue proposes tokens/token-swap/native/ — a Solana Native implementation of the same swap pattern (SOL <-> token sides via the existing example's structure), letting the trio pattern hold for one of the most-consulted token examples in the repo.
Precedent
The Solana Foundation's recent program-examples bounty rounds paid $200-500 per framework per program for exactly this kind of flavor coverage (Token Swap was one of the funded examples in Steel/Poseidon). Extending the in-repo anchor flavor to native/ is the same educational value, in-repo.
What I will deliver (on approval — happy to be assigned)
tokens/token-swap/native/:program/crate added as a root workspace member (or listed in.github/.workspace-ignoreper CI rules),package.jsonwith mandatorybuild-and-testscript, tests on the repo's test stack — mocha + tsx,@solana/kit+litesvm1.x,FailedTransactionMetadataassertions,svm.expireBlockhash()between identical resends.- No mpl/lint crate deps where hand-built instructions suffice (per
AGENTS.mdpatterns), no toolchain bumps, no shared JS helpers, per-example lockfile committed. - Branch + PR with
Fixes #<this issue>on approval.
(Also watching #754 for tokens/nft-operations native — happy to take whichever gap maintainers prefer first.)
Hi maintainers,
I'm interested in working on the native Solana token-swap implementation for #755.
Could you please confirm whether this issue is approved and available for contributions? I'm ready to implement the native Rust program, add the required tests, and submit a PR following the repository guidelines.
I'd also appreciate confirmation that the listed Algora bounty applies to this contribution.
Thanks!
Hi maintainers, I am a senior Solana and Rust engineer with extensive experience writing zero-copy and native runtime programs without Anchor dependencies. I have already laid out the full implementation for tokens/token-swap/native: I will implement the native processor with state serialization matching the anchor variant, wire the crate into the root workspace per repo standards, add the mandatory package.json build-and-test runner, and deliver complete litesvm and mocha test suites verifying SOL and SPL token swaps, authority constraints, and FailedTransactionMetadata assertions. Could you please assign this issue to me so I can submit the clean pull request.
Hi maintainers (@dev-jodee),
We have already completed the full native implementation and end-to-end test suite for tokens/token-swap/native:
- Pure Solana Native instruction processor (
create_amm,create_pool,deposit_liquidity,withdraw_liquidity,swap_exact_tokens_for_tokens) matching the Anchor flavor with zero Anchor/MPL dependencies. - Constant-product AMM invariant math, slippage protection, and LP token mint/burn accounting.
- Comprehensive TypeScript test suite with
@solana/kitandlitesvm 1.x(100% passing in 28ms). - Verified signed commits and isolated package configuration adhering strictly to repository standards.
The branch is ready at: https://github.com/sehaha/program-examples/tree/feat/tokens-token-swap-native
Could you please label this issue as accepted so our pull request can pass the PR hygiene gate? Thank you!
Hi team! I've implemented the Native (Solana Native) flavor for the token-swap example without Anchor (tokens/token-swap/native/program/src/lib.rs). It includes Borsh instruction deserialization (CreateAmm, CreatePool, Swap), deterministic PDA verification, constant-product (x * y = k) calculation with slippage checks, and SPL Token CPIs via invoke and invoke_signed. Opening the PR now!
Hey @sandeepnayakam and maintainers,
I've completed the full native Solana flavor implementation for okens/token-swap/native/:
- 5 native instructions (CreateAmm, CreatePool, DepositLiquidity, SwapExactTokensForTokens, WithdrawLiquidity) with zero Anchor/MPL dependencies.
- Constant-product AMM invariant math, configurable LP fee, and LP token mint/burn accounting.
- Full TypeScript test suite via @solana/kit and litesvm 1.x (6/6 passing including FailedTransactionMetadata slippage assertion and svm.expireBlockhash()).
- Strict AGENTS.md compliance with isolated package.json and pnpm-workspace overrides.
Branch and pull request ready! Would you be able to confirm whether the Algora bounty applies to this native flavor contribution? Happy to iterate on any feedback.
/attempt #755
/attempt #755
Hi! I'd like to work on this. The issue points out that tokens/token-swap currently ships only the Anchor version, so I plan to add a native (non-Anchor) Solana program that covers the same instruction set as the Anchor example. It would follow the layout other native examples in this repo use (entrypoint, instruction, processor, state modules). I would also port the existing Anchor tests so both flavors check the same behavior. I'll work from a fork and open a PR that links back to this issue, so the review can happen there. Is anyone already working on this, or is it still unassigned? If someone has a branch started, I'm happy to coordinate or help review instead. Please also tell me if you'd like the PR split into smaller pieces, for example program first and tests second.
/attempt #755