> ## Documentation Index
> Fetch the complete documentation index at: https://digraphsas-docs-pricing.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Parallel aggregator routing prompt

> Prompt an AI agent to wire Velora as a parallel quote source and route per-quote.

## Outcome

A backend service that **fans out a single user swap intent** to Velora and one other aggregator, compares the quotes, and returns the winner. Velora is queried either as two parallel calls (`mode=DELTA` and `mode=MARKET`) to compare paths head-to-head, or as a single `mode=ALL` call where Velora has already picked the winner server-side and the client checks which block is present: `delta` or `market`.

## Prompt

<CodeGroup>
  ```text Claude Code theme={null}
  You are extending an existing TypeScript backend that already wires one DEX aggregator (assume 1inch or 0x). Add Velora as a parallel quote source.

  Requirements:
  - Velora endpoint: `GET https://api.velora.xyz/v2/quote` with `mode=ALL` and `partner` set to the host app's partner identifier (`my-app-name` is only a placeholder). The `mode=ALL` response contains exactly one of `delta` or `market` (server-picked winner). To compare Delta vs Market head-to-head before competing against the other aggregator, issue two requests in parallel (`mode=DELTA` and `mode=MARKET`), then pick the better Velora result.
  - Compare on `destUSD` (or `destAmount` normalized to a common token) net of `gasCostUSD` and `partnerFee`.
  - Fan out in parallel; respect a hard 800ms budget per quote source; fall back gracefully if one source times out.
  - For the Velora native-ETH placeholder use `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` (mixed case).
  - If Velora wins via Delta, return both the `delta` block and `hmac` to the caller so they can sign and submit. If via Market, return the `market` block (same shape as `/prices`'s `priceRoute`).

  Reference these docs and follow them exactly:
  - https://velora.xyz/docs/overview/why-velora
  - https://velora.xyz/docs/api-reference/market/prices
  - https://velora.xyz/docs/api-reference/market/quote

  Do NOT race-update shared state across the two aggregators' callbacks. Do NOT fall back silently to the slower source if the budget is exceeded; surface a clear error.
  ```

  ```text Cursor theme={null}
  [Same prompt body as Claude Code above.]
  ```

  ```text Codex theme={null}
  [Same prompt body as Claude Code above.]
  ```
</CodeGroup>

## End-state check

* A side-by-side comparison log shows both aggregators quoting the same trade within the 800ms budget.
* When Velora's Delta path wins on a large trade, the response carries the `delta` block + `hmac` ready to sign.
