Profile
Back to NewsBack
Dev.to 14 min
Reader Mode
Jupiter's AMM test kit only checks the swaps you register. What to prepare before a Solana AMM audit and integration review

Jupiter's AMM test kit only checks the swaps you register. What to prepare before a Solana AMM audit and integration review

2 days ago

We broke the fee math in a local copy of Jupiter's own reference test suite. One function changed, so the SDK folded the trade fee and the owner fee into one rate and floored it once instead of twice. The two swaps the suite registers still passed. A swap of 333 base units of USDC failed, and so did one of 123,456,789.

That's jupiter-amm-test-kit doing exactly its job. It funds a fresh user with the swap amount, calls your Amm::quote, runs your program's native swap instruction in LiteSVM and compares one number: quote.out_amount against what actually landed in the destination token account (parity.rs, lines 129 to 195). One unit off and it fails. But it only knows about the swaps you register.

If you're building an AMM on Solana and want Jupiter's router to send flow to it, you're heading into two reviews: your security audit and Jupiter's integration review. Jupiter asks for the audit and for a green parity run. If the audit report points at one commit and the parity suite ran against a .so built from another, the submission tells two stories about one program. This post keeps Jupiter's published requirements apart from what I'd add on top, so the auditor and the integration reviewer end up looking at the same artifact.

Nothing here is endorsed by Jupiter or the Solana Foundation. Their guide is the source of truth, so read it again before you submit. For the program-level checks (signers, owners, PDAs, CPIs) I already wrote a Solana security checklist. This is only what an AMM needs on top of that before an aggregator routes to it.

What Jupiter publishes

From the integration guide and its Market Listing page, paraphrased closely. Follow the links for the exact wording.

Area What Jupiter's guide says Section
What it weighs Code health, a security audit, traction, and the team and backers. Integration Prerequisites
Interface Implement the Amm trait from the jupiter-amm-interface crate. The jup-ag/jupiter-amm-interface repo is the source of truth for the trait. Step 1
Forkable SDK Jupiter must be able to fork your SDK, so it can maintain it and fix integration bugs. Step 1
Scope of the implementation Limit the Amm implementation to deserializing state and quoting. Keep the detailed math in your SDK. Heavy deserialization and precomputation go in update, not quote. Step 1
No network calls Accounts named by get_accounts_to_update are fetched, batched and cached by Jupiter and delivered through update. quote may run many times on the same cache, so "we do not allow any network calls" anywhere in the implementation. Step 1
Quote parity Before submitting, prove with jupiter-amm-test-kit that your quotes match what the on-chain program executes, down to the exact token deltas. Step 2
What the kit covers ExactIn swaps that run as a single top-level instruction with one signer. If a documented limitation blocks you, open an issue on the repo instead of working around it. Step 2
Submission Through the AMM integrators support form, with the SDK repo (parity suite and committed fixtures included, fork access granted), your security audit, traction metrics and the team and backers. Step 3
After integration Every 30 minutes each market is re-checked and must pass one of two tests: less than 30% price difference on a $500 round trip, or less than 20% price impact between a $1000 buy and a $500 buy. Markets that fail are removed from routing. Market Listing
Frontend flow (optional) Swaps from the Jupiter frontend carry a signature from sighWH8KaiT7QhtV4w29ReVF8kG6D5yG3EQP1KYyGVF. If you price that flow differently, check that it signed, not just that the address is there. More

The guide doesn't say which auditors it accepts, what the audit must cover, or whether the SDK has to be in scope. I don't know either, so the sheet at the end asks you to state it instead of leaving the reviewer to guess.

What the test kit checks, read from its code

All of this is from jup-ag/jupiter-amm-interface at commit 70f56e0 (22 Oct 2026), still the head of main on 16 November. On 9 November we ran the reference suite, cargo test -p jupiter-amm-test-kit --test spl_token_swap, offline from the committed fixtures, and it passed.

Funding. create_funded_ata creates each user token account through the Associated Token Account program, then writes the swap amount straight into the source account's data (svm.rs, lines 82 to 126). The source holds exactly amount, so a program that pulls more than the input fails the transaction.

The assertion. There's one assert_eq!, between quote.out_amount and the destination balance change (parity.rs, lines 190 to 195). quote.in_amount, fee_amount and fee_mint are never compared. A program that takes less than the quoted input still passes.

The instruction. Your encoder closure turns the Swap::Placeholder your Amm returned, plus the amount, into native instruction data. The kit sends it as the only instruction after a compute budget instruction that sets the limit to 1,400,000 units (parity.rs, lines 173 to 187). Compute usage isn't measured.

Minimum out. The reference encoder for SPL Token Swap writes minimum_amount_out as 0, and its comment says asserting the exact output is the kit's job (spl_token_swap.rs, lines 47 to 65). Copy that pattern and the parity run tells you nothing about your on-chain slippage check.

The clock. The SVM takes its clock from the snapshot's clock sysvar, and the AmmContext handed to from_keyed_account is built from the same snapshot (parity.rs, lines 94 to 96). Every swap in a run sees one moment in time.

The program under test. Your program loads from tests/fixtures/<label>.so, where the label is Amm::label() lowercased with spaces turned into underscores. Programs you CPI into come from Amm::program_dependencies() (svm.rs, lines 30 to 56). When you regenerate fixtures with RPC set, a missing .so is dumped from chain but an existing one is kept, so a local build is never replaced by the deployed program (rpc.rs, lines 128 to 137).

State discovery. The snapshotter asks get_accounts_to_update again after each of three update rounds, so accounts that only show up once the pool state is read (tick arrays, for example) get captured (rpc.rs, lines 45 to 52). Before quoting, update runs three times over the snapshot.

The README's limitations list the rest: ExactIn only, one native instruction per swap, a plain top-level instruction (no instructions-sysvar gate that only accepts CPIs from approved callers), account metas used verbatim in on-chain order, one signer, and freshly created token accounts, where transfer logic that needs extra per-account state such as transfer-hook side accounts may not work. The README frames these as the common case covered first, not hard design limits.

So a green run shows one thing. For the swaps you registered, against that snapshot and that .so, the output matched.

One rounding rule, two results

The SPL Token Swap math the reference suite vendors floors the trade fee and the owner fee separately, and charges at least one unit for any non-zero fee rate (calculate_fee, spl_token_swap.rs, lines 77 to 84):

fn calculate_fee(amount: u128, numerator: u128, denominator: u128) -> Option<u128> {
    if numerator == 0 || amount == 0 {
        Some(0)
    } else {
        let fee = amount.checked_mul(numerator)?.checked_div(denominator)?;
        Some(if fee == 0 { 1 } else { fee })
    }
}

An SDK that folds both fees into one rate and floors once is right for most inputs and wrong for some. Here's a synthetic pool with reserves of 1,000,000,000 and 2,000,000,000 base units, a 0.25% trade fee and a 0.05% owner fee, run through that math:

Input On-chain fees (trade + owner) SDK fee (combined 0.30%) On-chain output SDK quote
333 1 + 1 0 661 665
1,999 4 + 1 5 3,987 3,987
1,000,000 2,500 + 500 3,000 1,992,013 1,992,013
123,456,789 308,641 + 61,728 370,370 219,193,140 219,193,139

At 333 the minimum-one rule charges two units on chain and the combined floor charges none. At 123,456,789 the two separate floors drop more than the single one, so the SDK charges one unit too many.

Then we put the same mistake through the real kit. In a local copy of spl_token_swap.rs we replaced only the SDK's fee arithmetic with the combined version and registered six single-swap tests against the kit's committed SOL/USDC fixture. Both reference swaps (0.1 SOL in, 50 USDC in) passed, and so did 333 and 123,456,789 lamports of SOL in. The two USDC-side swaps failed, exactly:

Swap (base units in) SDK quote On-chain output Result
333 USDC to SOL 4,506 4,479 failed
123,456,789 USDC to SOL 1,662,262,210 1,662,262,223 failed

The kit caught both, and only because those amounts were registered.

What I'd add before either review

None of this section is in Jupiter's guide. It's what I'd want to see as the auditor, and what I'd want ready if I were the one submitting.

Quote parity beyond the default run

  • Register swaps in both directions at dust sizes, at the amounts where your fee and price rounding changes, and close to the largest trade the pool can fill. Cover every pool type and fee mode you ship. The kit's own crate docs ask for as many pool types and swap paths as possible (lib.rs, lines 12 to 13).
  • Write one test of your own, outside the kit, that checks the input side: the source account ends at amount - quote.in_amount and the pool vaults move by what your quote implies.
  • Test the minimum-out check on its own. The same swap with minimum_amount_out set to quote.out_amount + 1 must fail on chain.
  • If price or fees depend on time (dynamic fees, decaying volatility, oracle staleness windows), commit snapshots taken at more than one moment and point extra PoolTests at them through fixtures_dir.
  • If either mint has a TransferFeeConfig, the amount that arrives is reduced by the fee (Solana docs, transfer fees). The kit reads the destination's raw balance, so your quote has to be net of that fee. Transfer hooks need their own review.
  • Record the compute units each swap path uses. And implement get_accounts_len: the trait's default returns 32, and the comment next to it says that default is there to penalize AMMs that don't implement it (interface lib.rs, lines 250 to 252).

The SDK itself

  • No network calls is Jupiter's rule. I'd extend it to anything else that makes quote or update non-deterministic: no host system time, no randomness, no file reads. Take time from the ClockRef the interface passes in AmmContext.
  • quote returns Result<Quote, AmmError>. Return an error for empty reserves or overflow instead of panicking.
  • Pin the interface version. At 70f56e0 the repo's interface crate is 0.7.0, QuoteParams carries flow_type, Amm requires Clone, and Swap::Placeholder exists. The newest releases on crates.io, 0.6.1 and 1.0.0-beta.0, still have fee_mode and a clone_amm method, and neither has Swap::Placeholder. The test kit isn't on crates.io at all, and its Cargo.toml takes the interface by path. Build the SDK and the parity suite against one git revision of the repo and name that revision in your submission.
  • Keep the committed Cargo.lock. The kit's README warns against running cargo update on solana-clock and the related sysvar crates past 3.2.0 without moving LiteSVM too.
  • Make the fork boring: a licence file, a build that works from a clean clone, no private git dependencies, and fixtures committed so the suite runs offline.

Accounts and authority in the swap instruction

  • SwapParams::token_transfer_authority is documented as either the user or a program authority over the source token account (interface lib.rs, lines 108 to 109). Don't write the on-chain swap as if the signer were always the end user.
  • Validate every pool-side account the instruction receives: pool state, vaults, mints, fee accounts, token program. In Anchor, has_one ties a key stored in the pool state to the account passed in, address = pins a known key, owner = checks the owning program, and Signer<'info> requires a signature (Anchor account constraints).
  • If the program only accepts CPIs from approved callers, the kit can't drive it yet. Say so in the submission and open the issue Jupiter asks for.
  • If you quote the Jupiter frontend flow tighter, give the better price only on a path where the frontend address comes in as a Signer<'info> with an address = constraint, never because the key is present. Anyone can add the address to a transaction. Only Jupiter can sign for it.

Upgrade authority and which program was tested

Record the program ID and upgrade authority, and match the deployed program to a reproducible build (Solana docs, verified builds). For an AMM, add the fixture .so to that comparison:

solana program show <PROGRAM_ID>                              # authority, ProgramData address, last deployed slot
solana-verify get-program-hash -u <RPC_URL> <PROGRAM_ID>      # what is deployed
solana-verify get-executable-hash tests/fixtures/<label>.so   # what the parity suite ran
solana-verify get-executable-hash target/deploy/<lib>.so      # built from the audited commit with solana-verify build

solana-verify strips trailing zero bytes before it hashes (get_binary_hash), so a padded ELF dumped from chain and a local build compare cleanly. If the hashes disagree, the parity suite tested a different program from the one deployed or the one audited, and your submission should say which.

Note who holds the upgrade authority and what happens after an upgrade: delete the stale .so, refresh the fixtures with REFRESH=1 RPC=<url>, rerun parity and tell the integrator. Once solana program set-upgrade-authority --final makes a program immutable, it can never be updated or closed (Solana docs, deploying programs).

The audit evidence

Jupiter asks for your security audit and doesn't define its scope. Tie the report to the same revision as everything above: the reviewed commit, the hash of the build from that commit, the deployed hash and the SDK commit used for parity. And say whether the SDK's quote code was in the audit's scope. If it wasn't, the quote math has only been checked by your own tests, the parity swaps you registered among them.

A one-page sheet for both reviews

This isn't a Jupiter form or a certificate. The tags in brackets show where each line comes from. Fill it with public material only, never keys or secret config, and keep it in the repo (as INTEGRATION.md, say) so the auditor and the integrator read the same file.

# <AMM name>: audit and integration sheet
Last updated: YYYY-MM-DD   Owner: <name, role>

## Target [not required by Jupiter]
- Program ID(s) and network:
- Audited commit:
- Deployed hash (solana-verify get-program-hash):
- Audited build hash (solana-verify get-executable-hash):
- Fixture .so hash (tests/fixtures/<label>.so):
- All equal? yes / no, and why:

## Authority [not required by Jupiter]
- Upgrade authority (solana program show): keypair / multisig / none
- Other privileged roles and what each can change:
- After an upgrade we: refresh fixtures, rerun parity, notify integrators

## SDK [Jupiter: Amm trait, forkable, no network calls]
- Repository and commit:
- jupiter-amm-interface git revision:
- Fork access granted to Jupiter: yes / no
- Network calls in the Amm implementation: none (evidence):
- Work done in update vs quote:

## Parity [Jupiter: test kit, committed fixtures]
| Pool | Direction | Amount | Why this amount | Passed at commit |
|------|-----------|--------|-----------------|------------------|
|      |           |        |                 |                  |
- Own tests beyond the kit [not required by Jupiter]:
  input side / min-out fails at quote + 1 / compute units per path / snapshots at other times
- Kit limitations that apply to us:
- Issues opened on jup-ag/jupiter-amm-interface:

## Audit [Jupiter: security audit]
- Report link, auditor, reviewed commit:
- SDK quote code in scope: yes / no
- Findings fixed, and fix-review evidence:
- Changes since the reviewed commit:

## Project [Jupiter: traction, team and backers]
- Traction metrics, with dates and source:
- Team and backers (publicly verifiable):

## Open questions
- Question / owner / internal target date (not an agreed date):

Adapted from a guide our team published on zealynx.io, with the FAQ and sources list.

I wrote this with help from AI for drafting and editing. The opinions and the audit experience are mine.

Chat with me