Skip to content

docs: executeSwapQuote README uses step="deposit" (should be "swap"); getSwapQuote example missing route object #267

@Nexory

Description

@Nexory

Summary

Two copy-paste errors in the SDK docs cause every new integrator to write broken code. The executeSwapQuote README example checks for progress.step === "deposit", but the SwapTransactionProgress union type (executeSwapQuote.ts) defines steps "approve", "swap", and "fill" — there is no "deposit" step in the swap flow. Separately, the getSwapQuote JSDoc example (which propagates to docs/classes/AcrossClient.md) passes route fields (originChainId, destinationChainId, inputToken, outputToken) at the top level, but GetSwapQuoteParams requires them nested inside a route sub-object.

What I observed

Bug 1 — packages/sdk/README.md L104

// README example for executeSwapQuote onProgress callback
if (progress.step === "deposit" && progress.status === "txSuccess") {
  // once deposit is successful you have access to depositId and the receipt
  const { depositId, txReceipt } = progress;
}

SwapTransactionProgress (src/actions/executeSwapQuote.ts) defines steps "approve", "swap", and "fill" only. The branch above can never match; the correct step is "swap". The destructured txReceipt is also wrong for this step — the "swap" | txSuccess variant exposes txReceipt and depositId, but txReceipt alone is not listed at the top level.

Bug 2 — src/client.ts JSDoc for executeSwapQuote (L398–405), reflected in docs/classes/AcrossClient.md L100–107

// JSDoc example
const quote = await client.getSwapQuote({
  originChainId: 1,
  destinationChainId: 10,
  inputToken: "0x...",
  outputToken: "0x...",
  amount: "10",
  depositor: "0x...",
});

GetSwapQuoteParams (src/actions/getSwapQuote.ts L13–33) omits the flat chain/token fields from the top level and requires them inside a route sub-object:

export type GetSwapQuoteParams = Omit<BaseSwapQueryParams,
  "amount" | "inputToken" | "outputToken" | "originChainId" | "destinationChainId" | ...
> & {
  amount: Amount;
  route: {
    originChainId: number;
    inputToken: AnyChainAddress;
    destinationChainId: number;
    outputToken: AnyChainAddress;
  };
  ...
};

The example call passes originChainId etc. at the top level, which TypeScript rejects at compile time.

Impact

  • Bug 1: Any integrator following the README writes an onProgress handler that silently never fires on the swap step. If they depend on depositId being set before proceeding, their code hangs or throws a runtime error.
  • Bug 2: Any integrator copy-pasting the documented getSwapQuote example gets an immediate TypeScript type error (or silent undefined at runtime if transpiling loose), blocking them from getting a quote at all.

Both errors appear in the primary onboarding surface (README + generated API docs), so impact is highest for new users.

Suggested fix

Fix 1 — packages/sdk/README.md L104: change "deposit" to "swap".

Fix 2 — packages/sdk/src/client.ts JSDoc example (~L398–405): wrap the route fields in a route object. The generated docs will update on the next doc build.

// corrected JSDoc example
const quote = await client.getSwapQuote({
  route: {
    originChainId: 1,
    destinationChainId: 10,
    inputToken: "0x...",
    outputToken: "0x...",
  },
  amount: "10",
  depositor: "0x...",
});

Notes

The executeQuote flow (non-swap) correctly uses step: "deposit" (src/actions/executeQuote.ts), so the README example appears to have been copied from the non-swap path without updating the step name. The fix is independent of any runtime changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions