# portable:curve-exact-output — Ammora SDK 0.3.8 portable:curve-exact-output -- [deadlineUnix]. [Read in Docs](https://docs.ammora.org/examples?command=portable%3Acurve-exact-output) · [Detailed guide](https://docs.ammora.org/guides/src-portable-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 portable:curve-exact-output -- ` (`tsx src/portable/curve-exact-output.ts`). Omit `--` and arguments when the source accepts none. ## Entry file: `src/portable/curve-exact-output.ts` ```typescript /** portable:curve-exact-output -- [deadlineUnix]. */ import { readFile } from "node:fs/promises"; import { AmmoraPortableLifecyclePlanner, verifyAmmoraPortableDeploymentAtBlock, assertAmmoraPortableBlockCanonical, type AmmoraPortableDeployment, type AmmoraPortableLifecycleTargets } from "@ammora-protocol/sdk"; import { caller, deadline, execute, natural } from "../shared/actions.js"; import { address, reader, readBlock } from "../shared/env.js"; import { printJson } from "../shared/input.js"; import { requireHelper } from "../arl/optional-guards.js"; import { requirePortableLifecycleAsset } from "./asset-model.js"; import { main } from "../shared/run.js"; main(async () => { const [deploymentFile, targetsFile, curveArg, side, amountOut, maximumIn, maxFee, expiry] = process.argv.slice(2); if (!deploymentFile || !targetsFile || !["buy", "sell"].includes(side ?? "")) throw new Error("Supply reviewed deployment/targets, curve, buy|sell, output, maximum input and max fee"); const deployment = JSON.parse(await readFile(deploymentFile, "utf8")) as AmmoraPortableDeployment; const targets = JSON.parse(await readFile(targetsFile, "utf8")) as AmmoraPortableLifecycleTargets; requireHelper(targets.exactOutputRouter, "exactOutputRouter"); requirePortableLifecycleAsset(deployment.nativeAsset); const client = await reader(), block = await readBlock(client), account = caller(); const context = await verifyAmmoraPortableDeploymentAtBlock(client, deployment, block.number); const plan = await new AmmoraPortableLifecyclePlanner(context, targets).planCurveExactOutput({ curve: address("CURVE", curveArg), account, recipient: account, baseForQuote: side === "sell", amountOutRaw: natural(amountOut, "outputRaw", true), maximumAmountInRaw: natural(maximumIn, "maximumInputRaw", true), deadline: expiry ? natural(expiry, "deadlineUnix", true) : deadline(), allowancePolicy: "prepare-approval", gas: { maxFeePerGasNativeRaw: natural(maxFee, "maxFeePerGasWei", true), safetyMarginBps: 2000n } }); await assertAmmoraPortableBlockCanonical(context); printJson(plan); // Approval is one transaction, never an automatic follow-up swap. Re-run to obtain a fresh verified context and quote. const target = plan.status === "APPROVAL_REQUIRED" ? plan.quote.inputToken : targets.exactOutputRouter; await execute(plan.status === "APPROVAL_REQUIRED" ? "approve exact-output input; replan required" : "portable curve exact output", { client, caller: account, allowedTargets: [target] }, plan.transaction); }); ``` ## 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/arl/optional-guards.ts](https://docs.ammora.org/examples/source/src/arl/optional-guards.ts.txt) - [src/portable/asset-model.ts](https://docs.ammora.org/examples/source/src/portable/asset-model.ts.txt) - [src/shared/actions.ts](https://docs.ammora.org/examples/source/src/shared/actions.ts.txt) - [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/portable/fixtures/synthetic-9-6.json](https://docs.ammora.org/examples/source/src/portable/fixtures/synthetic-9-6.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.