Swap APIs & SDKs

PancakeSwap quote expiry and order deadline are different

Track gateway acceptance expiry and PancakeSwap X settlement deadline as separate fields with separate recovery rules.

A quote can become unacceptable to the gateway before your application has finished its workflow, while an already accepted order has its own settlement deadline. Store these as different concepts.

The PancakeSwap integration notes distinguish expiresAt from pcsx.orderInfo.deadline. The endpoint reference documents quote-expiry errors and order-status handling. Read the actual returned values rather than assuming a fixed relationship between them.

Apply each clock at the right boundary

ClockApplication decision
Gateway quote expiryWhether to consume the candidate in a new build or submit request
Order settlement deadlineHow to reason about an accepted order remaining fillable

A local timeout waiting for an HTTP response is a third clock. It expresses the client's patience, not the provider's acceptance state or the contract's fillability rule.

Choose recovery from state

If an unsigned candidate expires, fetch a replacement and review its terms. If submission may have succeeded but its response was lost, reconcile by order hash before making a new order. If an accepted order remains pending, continue its status workflow rather than discarding it because the original review countdown reached zero.

Keep Unix seconds and milliseconds explicit in type names or conversion helpers. Recompute countdowns after a suspended browser tab resumes.

Fixtures should place the two deadlines in different orders and include clock skew. The application must use semantic roles rather than whichever numeric value is smaller. This prevents a future provider change from turning a hardcoded timing assumption into premature success or failure.

Sources & verification (2)

Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.

  1. TypeScript examples

    Different approval and execution paths for agg and pcsx candidates

    https://developer.pancakeswap.finance/contracts/unified-swap-api/typescript
  2. Endpoints

    Quote, calldata, submit and status contracts

    https://developer.pancakeswap.finance/contracts/unified-swap-api/endpoints

Continue reading

Swap API integration: quote, approve, simulate, submit