# almm:quote-swap — Ammora SDK 0.3.8 Check the source for arguments and transaction requirements. [Read in Docs](https://docs.ammora.org/examples?command=almm%3Aquote-swap) · [Detailed guide](https://docs.ammora.org/guides/src-almm-readme) · [Local setup](https://docs.ammora.org/guides/example-setup) ## Context and execution GIWA Sepolia 91342. Public SDK 0.3.8, Math 0.3.0. Source revision: `a9b3fd798fa51495e8defec99a25de59e4d70672`. Install the SDK in your app, or prepare the example project using the local setup guide for its npm commands. Review the entry source and guide for required arguments, roles and deployment selection. `AMMORA_SEND=0` does not turn send-only commands into previews. Never put CLI keys in a browser or resend an uncertain transaction. Command: `npm run almm:quote-swap -- ` (`tsx src/almm/quote-swap.ts`). Omit `--` and arguments when the source accepts none. ## Entry file: `src/almm/quote-swap.ts` ```typescript import { tokenAmount } from "../shared/input.js"; /** * Quote a swap on a bin (ALMM) pool. Reads only, so no key is required. * * npm run almm:quote-swap -- [base-for-quote] * * Start here: it shows what the SDK will price a swap at, and what slippage bound the * swap example would send, without putting anything on chain. */ import { ALMMClient, minOutFromSlippage } from "@ammora-protocol/sdk"; import { clientOptions, address, deployment, reader } from "../shared/env.js"; import { amount, main, requireContract, tokenInfo } from "../shared/run.js"; main(async () => { const [poolArgument, amountArgument, directionArgument] = process.argv.slice(2); const pool = address("ALMM_POOL", poolArgument); if (!amountArgument) { throw new Error("pass an input amount: npm run almm:quote-swap -- [base-for-quote]"); } const baseForQuote = directionArgument === "base-for-quote"; const client = await reader(); const contracts = deployment().contracts.liquidityMarketMaker; await requireContract(client, "pool", pool); const sdk = new ALMMClient(client, pool, contracts.positionManager, contracts.binLens, clientOptions()); // Reads do not move value, so the SDK's provenance check does not run on this path. // A contract that is not a bin pool simply fails to answer; say which read broke. const state = await sdk.getPoolState().catch(() => { throw new Error( `${pool} does not answer as a bin pool. Check the address, or use almm:swap, which ` + "proves the pool against the reviewed factory before planning", ); }); const [base, quote] = await Promise.all([ tokenInfo(client, state.baseToken), tokenInfo(client, state.quoteToken), ]); const input = baseForQuote ? base : quote; const output = baseForQuote ? quote : base; const includedAmountIn = tokenAmount(amountArgument, input.decimals); const quoted = await sdk.quoteExactInput(includedAmountIn, baseForQuote); console.log(`pool ${pool}`); console.log(`pair ${base.symbol} / ${quote.symbol} (bin step ${state.binStepBps} bps)`); console.log(`active id ${state.activeId}, current fee ${state.currentFeeBps} bps`); console.log(""); console.log(`in ${amount(includedAmountIn, input.decimals, input.symbol)}`); console.log(`out ${amount(quoted.amountOut, output.decimals, output.symbol)}`); const consumed = includedAmountIn - quoted.amountInLeft; console.log(`consumed ${amount(consumed, input.decimals, input.symbol)}`); if (quoted.amountInLeft > 0n) { // The pool ran out of liquidity in range before the whole input was used. console.log(`unfilled ${amount(quoted.amountInLeft, input.decimals, input.symbol)}`); console.log("\nthe pool cannot fill this size in range, so the swap example would need partial fill"); } // What the swap example would send as its floor. The SDK never plans a zero minimum. for (const bps of [10, 50, 100]) { const minimum = minOutFromSlippage(quoted.amountOut, BigInt(bps)); console.log(`min out @ ${String(bps).padStart(3)} bps ${amount(minimum, output.decimals, output.symbol)}`); } }); ``` ## Supporting files Keep relative paths intact. Local imports are listed recursively; JSON templates are choices to review, not approved inputs. Runtime-selected files and wallet/environment setup still follow the detailed guide. - [src/shared/env.ts](https://docs.ammora.org/examples/source/src/shared/env.ts.txt) - [src/shared/input.ts](https://docs.ammora.org/examples/source/src/shared/input.ts.txt) - [src/shared/retry.ts](https://docs.ammora.org/examples/source/src/shared/retry.ts.txt) - [src/shared/rpc.ts](https://docs.ammora.org/examples/source/src/shared/rpc.ts.txt) - [src/shared/run.ts](https://docs.ammora.org/examples/source/src/shared/run.ts.txt) - [src/almm/rebalance.example.json](https://docs.ammora.org/examples/source/src/almm/rebalance.example.json.txt) - [package.json](https://docs.ammora.org/examples/source/package.json.txt) - [package-lock.json](https://docs.ammora.org/examples/source/package-lock.json.txt) - [tsconfig.json](https://docs.ammora.org/examples/source/tsconfig.json.txt) - [.env.giwa.example](https://docs.ammora.org/examples/source/file.env.giwa.example.txt) - [.nvmrc](https://docs.ammora.org/examples/source/file.nvmrc.txt) ## AI implementation checklist Use the actual SDK exports and parameter types in the linked files. Start with reads and unsigned plans where supported. Use a connected wallet for browser signing. Preserve raw integer units, exact approvals, caller authority, deadlines and receipt reconciliation. Report local checks separately from live-chain verification.