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

# Quote a swap

> Returns the best route and estimated output for a token swap. On EVM chains, `evm_routing` has the full route details, including the block the quote was priced at. Use `from_pool_id` to force the first hop through a pool and `to_pool_id` to force the last hop; leave them out to let us pick. If no route uses a pool you forced, the request fails. Any transaction returned by the trading endpoints is signed by your own wallet.

```bash theme={null}
curl -X POST "https://staging-api.struct.to/v1/trading/swap?fields=short" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"chain_id":4663,"wallet_address":"0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51","token_in":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","token_out":"0x39dBED3a2bd333467115dE45665cC57F813C4571","amount":"100","slippage_bps":100,"direction":"exact_in","only_protocols":["PonsV2"],"to_pool_id":"0xEd50bDeeA8aDC232f159486192a4157281D722ff"}'
```

```json Response (Long) theme={null}
{
  "request_id": "7c4a8d09-ca37-62af-61d5-3583ec55ad30",
  "chain_id": "4663",
  "chain": "evm",
  "token_in": {
    "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "symbol": "USDC",
    "name": "USD Coin",
    "decimals": 6,
    "image_url": "https://cdn.example.com/usdc.png"
  },
  "token_out": {
    "address": "0x39dBED3a2bd333467115dE45665cC57F813C4571",
    "symbol": "PONS",
    "name": "Pons",
    "decimals": 18,
    "image_url": "https://cdn.example.com/pons.png"
  },
  "amount": "100",
  "amount_raw": "100000000",
  "estimated_amount_out_raw": "1034821991840221184",
  "minimum_amount_out_raw": "1024473771921818972",
  "slippage_bps": 100,
  "pool_fee_bps": 100,
  "warnings": [
    "Quote expires at the supplied expires_at time."
  ],
  "route": {
    "hop_count": 1,
    "total_fee_bps": 100,
    "steps": [
      {
        "protocol": "PonsV2",
        "pool_address": "0xEd50bDeeA8aDC232f159486192a4157281D722ff",
        "token_in": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "token_out": "0x39dBED3a2bd333467115dE45665cC57F813C4571",
        "amount_in": "100000000",
        "estimated_amount_out": "1034821991840221184",
        "fee_bps": 100
      }
    ]
  },
  "evm": {
    "to": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
    "from": "0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51",
    "data": "0x12aa3caf",
    "value": "0",
    "chain_id": 4663,
    "approval_address": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
    "approvals": [
      {
        "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "spender": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
        "amount": "100000000"
      }
    ]
  },
  "expires_at": "2026-09-21T13:10:00Z"
}
```

```jsonc Response (Short) theme={null}
{
  "id": "7c4a8d09-ca37-62af-61d5-3583ec55ad30",
  "ci": "4663",
  "ch": "evm",
  "ti": {
    "a": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "s": "USDC",
    "n": "USD Coin",
    "d": 6,
    "i": "https://cdn.example.com/usdc.png"
  },
  "to": {
    "a": "0x39dBED3a2bd333467115dE45665cC57F813C4571",
    "s": "PONS",
    "n": "Pons",
    "d": 18,
    "i": "https://cdn.example.com/pons.png"
  },
  "a": "100",
  "ar": "100000000",
  "er": "1034821991840221184",
  "mr": "1024473771921818972",
  "sl": 100,
  "pfb": 100,
  "w": [
    "Quote expires at the supplied expires_at time."
  ],
  "rt": {
    "hc": 1,
    "tfb": 100,
    "st": [
      {
        "pr": "PonsV2",
        "pa": "0xEd50bDeeA8aDC232f159486192a4157281D722ff",
        "ti": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "to": "0x39dBED3a2bd333467115dE45665cC57F813C4571",
        "ai": "100000000",
        "eo": "1034821991840221184",
        "fb": 100
      }
    ]
  },
  "evm": {
    "to": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
    "fr": "0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51",
    "d": "0x12aa3caf",
    "v": "0",
    "ci": 4663,
    "aa": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
    "ap": [
      {
        "tk": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "sp": "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
        "a": "100000000"
      }
    ]
  },
  "ea": "2026-09-21T13:10:00Z"
}
```


## OpenAPI

````yaml onchain-openapi.json POST /trading/swap
openapi: 3.1.0
info:
  title: Struct On-chain API
  description: >-
    RESTful API for token market data, discovery, holders, audits, and trader
    analytics across supported chains. Pass `fields=short` or header
    `x-field-names: short` for abbreviated keys. HTTP defaults to `long`. Token
    candlesticks, token trades and wallet batch trades also support
    `fields=array` for typed positional rows.
  version: 1.0.0
servers:
  - url: https://staging-api.struct.to/v1
    description: Staging
security:
  - ApiKey: []
paths:
  /trading/swap:
    post:
      tags:
        - DEX Trading
      summary: Quote a swap
      description: >-
        Returns the best route and estimated output for a token swap. On EVM
        chains, `evm_routing` has the full route details, including the block
        the quote was priced at. Use `from_pool_id` to force the first hop
        through a pool and `to_pool_id` to force the last hop; leave them out to
        let us pick. If no route uses a pool you forced, the request fails. Any
        transaction returned by the trading endpoints is signed by your own
        wallet.
      operationId: post_dex_trading_swap
      parameters:
        - name: x-field-names
          in: header
          required: false
          description: >-
            Select long (full) or short (abbreviated) field names. HTTP defaults
            to `long`. Takes precedence over `fields`. See [Response
            Format](/api-reference/response-format#long-and-short-field-names).
          schema:
            type: string
            enum:
              - long
              - short
            default: long
          example: short
        - name: fields
          in: query
          required: false
          description: >-
            Same as `x-field-names`. Use `long` or `short`. HTTP defaults to
            `long`. Ignored when the header is set. `field_names` is accepted as
            an alias.
          schema:
            type: string
            enum:
              - long
              - short
            default: long
          example: short
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TradeIntentRequest'
            example:
              chain_id: 4663
              wallet_address: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
              token_in: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
              token_out: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
              amount: '100'
              slippage_bps: 100
              direction: exact_in
              only_protocols:
                - PonsV2
              to_pool_id: '0xEd50bDeeA8aDC232f159486192a4157281D722ff'
        required: true
      responses:
        '200':
          description: Swap quote
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuoteResponse'
              examples:
                long:
                  summary: Response (Long)
                  value:
                    request_id: 7c4a8d09-ca37-62af-61d5-3583ec55ad30
                    chain_id: '4663'
                    chain: evm
                    token_in:
                      address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                      symbol: USDC
                      name: USD Coin
                      decimals: 6
                      image_url: https://cdn.example.com/usdc.png
                    token_out:
                      address: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
                      symbol: PONS
                      name: Pons
                      decimals: 18
                      image_url: https://cdn.example.com/pons.png
                    amount: '100'
                    amount_raw: '100000000'
                    estimated_amount_out_raw: '1034821991840221184'
                    minimum_amount_out_raw: '1024473771921818972'
                    slippage_bps: 100
                    pool_fee_bps: 100
                    warnings:
                      - Quote expires at the supplied expires_at time.
                    route:
                      hop_count: 1
                      total_fee_bps: 100
                      steps:
                        - protocol: PonsV2
                          pool_address: '0xEd50bDeeA8aDC232f159486192a4157281D722ff'
                          token_in: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                          token_out: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
                          amount_in: '100000000'
                          estimated_amount_out: '1034821991840221184'
                          fee_bps: 100
                    evm:
                      to: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                      from: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
                      data: '0x12aa3caf'
                      value: '0'
                      chain_id: 4663
                      approval_address: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                      approvals:
                        - token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                          spender: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                          amount: '100000000'
                    expires_at: '2026-09-21T13:10:00Z'
                short:
                  summary: Response (Short)
                  value:
                    id: 7c4a8d09-ca37-62af-61d5-3583ec55ad30
                    ci: '4663'
                    ch: evm
                    ti:
                      a: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                      s: USDC
                      'n': USD Coin
                      d: 6
                      i: https://cdn.example.com/usdc.png
                    to:
                      a: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
                      s: PONS
                      'n': Pons
                      d: 18
                      i: https://cdn.example.com/pons.png
                    a: '100'
                    ar: '100000000'
                    er: '1034821991840221184'
                    mr: '1024473771921818972'
                    sl: 100
                    pfb: 100
                    w:
                      - Quote expires at the supplied expires_at time.
                    rt:
                      hc: 1
                      tfb: 100
                      st:
                        - pr: PonsV2
                          pa: '0xEd50bDeeA8aDC232f159486192a4157281D722ff'
                          ti: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                          to: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
                          ai: '100000000'
                          eo: '1034821991840221184'
                          fb: 100
                    evm:
                      to: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                      fr: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
                      d: '0x12aa3caf'
                      v: '0'
                      ci: 4663
                      aa: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                      ap:
                        - tk: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
                          sp: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
                          a: '100000000'
                    ea: '2026-09-21T13:10:00Z'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DexTradingErrorEnvelope'
        '501':
          description: No route found for this swap
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DexTradingErrorEnvelope'
components:
  schemas:
    TradeIntentRequest:
      type: object
      required:
        - chain_id
        - token_in
        - token_out
      properties:
        chain_id:
          $ref: '#/components/schemas/TradingChainId'
          description: Chain id. Use `-1` for Solana or an EVM chain id such as `4663`.
        wallet_address:
          type:
            - string
            - 'null'
          description: >-
            Wallet that supplies the sell token and signs the returned
            transaction.
        recipient_address:
          type:
            - string
            - 'null'
          description: >-
            Optional wallet that receives the buy token. Defaults to
            `wallet_address`.
        token_in:
          type: string
          description: >-
            Sell token address. Use the chain's native token identifier for
            native swaps.
        token_out:
          type: string
          description: >-
            Buy token address. Use the chain's native token identifier for
            native swaps.
        amount:
          type:
            - string
            - 'null'
          description: >-
            Amount in normal token units, for example `1.5`. For `exact_in` it
            is

            the amount you sell; for `exact_out` it is the amount you buy. Use

            exactly one of `amount`, `amount_raw` or `amount_usd`.
        amount_raw:
          type:
            - string
            - 'null'
          description: >-
            Amount in the token's smallest unit (no decimals). For `exact_in` it
            is

            the amount you sell; for `exact_out` it is the amount you buy. Use

            exactly one of `amount`, `amount_raw` or `amount_usd`.
        amount_usd:
          type:
            - string
            - 'null'
          description: |-
            Solana only: USD value of `token_in` to sell. On EVM chains use
            `amount` or `amount_raw`.
        minimum_amount_out_raw:
          type:
            - string
            - 'null'
          description: >-
            Optional minimum amount to receive, in the buy token's smallest
            unit.

            The stricter of this and the slippage-based minimum is used. On EVM,

            taxes charged by the buy token itself may still reduce what arrives.
        maximum_amount_in_raw:
          type:
            - string
            - 'null'
          description: >-
            `exact_out` only: maximum amount to spend, in the sell token's
            smallest

            unit. Can only make the slippage protection stricter.
        slippage_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: Slippage tolerance in basis points. `100` means 1%.
          minimum: 0
        direction:
          $ref: '#/components/schemas/TradeDirection'
          description: >-
            `exact_in` (default): you set how much you sell. `exact_out`: you
            set

            how much you want to receive.
        excluded_protocols:
          type: array
          items:
            type: string
          description: Protocols to exclude when selecting a route.
        only_protocols:
          type: array
          items:
            type: string
          description: Protocols to allow when selecting a route. Leave empty to allow any.
        only_routers:
          type: array
          items:
            type: string
          description: >-
            Solana only: limit which routing providers may be used. Leave empty
            on

            EVM chains.
        from_pool_id:
          type:
            - string
            - 'null'
          description: |-
            Force the first hop to use this pool. The rest of the route is found
            for you. If no route uses this pool, the request fails.
        to_pool_id:
          type:
            - string
            - 'null'
          description: >-
            Force the last hop to use this pool. The rest of the route is found
            for

            you. Can be combined with `from_pool_id`.
        use_rpc:
          type: boolean
          description: |-
            Solana only: price the swap from the very latest on-chain pool data.
            Slower. Try it if a swap fails because pool data changed. Default
            `false`.
        split_steps:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Controls splitting a trade across several routes for a better price.

            Omit to let us split large trades automatically. `0` disables

            splitting. `2`-`20` sets how finely the split is searched (higher is

            finer). All splits run in one transaction and are listed in

            `route.splits`. A value other than `0` is not allowed with
            `exact_out`,

            `from_pool_id`/`to_pool_id`, or some single-protocol trades.
          minimum: 0
        restrict_intermediate_tokens:
          type:
            - boolean
            - 'null'
          description: >-
            When true (default), routes only pass through major tokens such as
            the

            native token, its wrapped form, stablecoins, and the main trading
            pair

            of the tokens you're swapping. Set false to allow any token in the

            middle of the route.
        max_accounts:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Solana only: maximum number of accounts the transaction may use,
            from

            `24` to `64` (default `64`). Lower it if you add your own
            instructions

            to the same transaction.
          minimum: 0
        max_market_impact_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: |-
            Optional price impact limit in basis points (`100` = 1%). Not
            available on EVM chains.
          minimum: 0
        sell_entire_balance:
          type:
            - boolean
            - 'null'
          description: >-
            Sell the wallet's whole balance of `token_in` at the moment the
            trade

            executes. Not available on EVM chains or with `exact_out`.
        fee_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: |-
            Optional referral fee in basis points, paid to `fee_wallet`. Not
            available on EVM chains or with `exact_out`.
          minimum: 0
        fee_wallet:
          type:
            - string
            - 'null'
          description: Wallet that receives referral fees when `fee_bps` is set.
        prioritization_fee_lamports:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SolanaPriorityFeeLamports'
              description: Solana priority fee budget.
        dynamic_compute_unit_limit:
          type:
            - boolean
            - 'null'
          description: |-
            Solana only: add a compute unit limit sized for this swap to the
            transaction. Default `true`.
        jito_tip_lamports:
          type:
            - string
            - 'null'
          description: Solana Jito tip in lamports.
        multi_lander:
          type:
            - boolean
            - 'null'
          description: |-
            Solana only: prepare the transaction for sending through several
            landing services. Use with `lander_tip_lamports`.
        lander_tip_lamports:
          type:
            - string
            - 'null'
          description: Solana per-lander tip in lamports.
        payer_address:
          type:
            - string
            - 'null'
          description: >-
            Solana fee payer. When different from `wallet_address`, it also
            signs.
        close_authority:
          type:
            - string
            - 'null'
          description: Solana close authority for token accounts created during the swap.
        destination_wallet:
          type:
            - string
            - 'null'
          description: Solana token output recipient.
        swap_recipient_address:
          type:
            - string
            - 'null'
          description: >-
            Solana only: wallet that must receive the final output. The swap
            fails

            if the output goes elsewhere.
        deadline_unix_seconds:
          type:
            - integer
            - 'null'
          format: int64
          description: Optional execution deadline in Unix seconds.
          minimum: 0
        idempotency_key:
          type:
            - string
            - 'null'
          description: Caller-supplied key used to make repeated requests safe.
        metadata:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TradeRequestMetadata'
              description: Caller metadata echoed in trade tracking records.
      additionalProperties: false
      example:
        chain_id: 4663
        wallet_address: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
        token_in: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
        token_out: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
        amount: '100'
        slippage_bps: 100
        direction: exact_in
        only_protocols:
          - PonsV2
        to_pool_id: '0xEd50bDeeA8aDC232f159486192a4157281D722ff'
    QuoteResponse:
      type: object
      required:
        - request_id
        - chain_id
        - chain
        - token_in
        - token_out
        - route
        - expires_at
        - warnings
      properties:
        direction:
          $ref: '#/components/schemas/TradeDirection'
        request_id:
          type: string
          format: uuid
        chain_id:
          type: string
        chain:
          $ref: '#/components/schemas/TradingChainFamily'
        token_in:
          $ref: '#/components/schemas/TokenSummary'
        token_out:
          $ref: '#/components/schemas/TokenSummary'
        amount:
          type:
            - string
            - 'null'
          description: |-
            Amount you sell, in normal token units. Exact for `exact_in`; an
            estimate for `exact_out`.
        amount_raw:
          type:
            - string
            - 'null'
          description: |-
            Amount you sell, in the sell token's smallest unit. For `exact_out`
            the most you can spend is in `maximum_amount_in_raw`.
        amount_usd:
          type:
            - number
            - 'null'
          format: double
        estimated_amount_out:
          type:
            - string
            - 'null'
        estimated_amount_out_raw:
          type:
            - string
            - 'null'
        estimated_amount_out_usd:
          type:
            - number
            - 'null'
          format: double
        price_impact_pct:
          type:
            - number
            - 'null'
          format: double
          description: |-
            How much worse your rate is than the current market price because of
            the size of your trade, in percent. Fees are not included.
        value_change_pct:
          type:
            - number
            - 'null'
          format: double
          description: >-
            USD value you receive compared with the USD value you pay, in
            percent,

            including fees and price impact. Negative means you receive less
            value

            than you pay.
        minimum_amount_out_raw:
          type:
            - string
            - 'null'
        maximum_amount_in_raw:
          type:
            - string
            - 'null'
        slippage_bps:
          type:
            - integer
            - 'null'
          format: int32
          minimum: 0
        pool_fee_bps:
          type:
            - integer
            - 'null'
          format: int32
          minimum: 0
        route:
          $ref: '#/components/schemas/RouteDetails'
        fee:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ReferralFee'
        evm:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/EvmTransactionRequest'
        solana:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SolanaTransactionRequest'
        expires_at:
          type: string
          format: date-time
        warnings:
          type: array
          items:
            type: string
        context_slot:
          type:
            - integer
            - 'null'
          format: int64
          description: 'Solana only: the slot the quote was priced at.'
          minimum: 0
        evm_routing:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/EvmRoutingDetails'
              description: |-
                EVM only: full route details and the simulation result, when
                available.
        compute_ms:
          type:
            - number
            - 'null'
          format: double
          description: Time taken to find the route, in milliseconds.
      example:
        request_id: 7c4a8d09-ca37-62af-61d5-3583ec55ad30
        chain_id: '4663'
        chain: evm
        token_in:
          address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
          symbol: USDC
          name: USD Coin
          decimals: 6
          image_url: https://cdn.example.com/usdc.png
        token_out:
          address: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
          symbol: PONS
          name: Pons
          decimals: 18
          image_url: https://cdn.example.com/pons.png
        amount: '100'
        amount_raw: '100000000'
        estimated_amount_out_raw: '1034821991840221184'
        minimum_amount_out_raw: '1024473771921818972'
        slippage_bps: 100
        pool_fee_bps: 100
        warnings:
          - Quote expires at the supplied expires_at time.
        route:
          hop_count: 1
          total_fee_bps: 100
          steps:
            - protocol: PonsV2
              pool_address: '0xEd50bDeeA8aDC232f159486192a4157281D722ff'
              token_in: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
              token_out: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
              amount_in: '100000000'
              estimated_amount_out: '1034821991840221184'
              fee_bps: 100
        evm:
          to: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
          from: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
          data: '0x12aa3caf'
          value: '0'
          chain_id: 4663
          approval_address: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
          approvals:
            - token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
              spender: '0x1f7d7550B1b028f7571E69A784071F0205FD2EfA'
              amount: '100000000'
        expires_at: '2026-09-21T13:10:00Z'
    DexTradingErrorEnvelope:
      type: object
      required:
        - success
        - message
        - error_code
        - category
        - retryable
        - data
        - info
      properties:
        success:
          type: boolean
        message:
          type: string
        error_code:
          type: string
        category:
          type: string
        retryable:
          type: boolean
        data:
          type: 'null'
          description: Errors have no response data; this field is always null.
        info:
          $ref: '#/components/schemas/DexTradingErrorInfo'
    TradingChainId:
      type: integer
      format: int64
      example: 4663
    TradeDirection:
      type: string
      enum:
        - exact_in
        - exact_out
    SolanaPriorityFeeLamports:
      oneOf:
        - type: string
          description: Use automatic priority fee selection.
        - type: integer
          format: int64
          description: Fixed priority fee budget in lamports.
          minimum: 0
        - $ref: '#/components/schemas/SolanaPriorityFeeBudget'
          description: Priority level with an upper lamport budget.
    TradeRequestMetadata:
      type: object
      properties:
        reference_id:
          type:
            - string
            - 'null'
          description: Caller-side order, quote, or request identifier.
        source:
          type:
            - string
            - 'null'
          description: Client application or integration label.
        user_id:
          type:
            - string
            - 'null'
          description: Caller-side user identifier.
        account_id:
          type:
            - string
            - 'null'
          description: Caller-side wallet or account grouping identifier.
        attributes:
          type:
            - object
            - 'null'
          description: Additional caller-defined string attributes.
          additionalProperties:
            type: string
          propertyNames:
            type: string
    TradingChainFamily:
      type: string
      enum:
        - evm
        - solana
    TokenSummary:
      type: object
      description: Basic token details. Fields we don't know are null.
      required:
        - address
      properties:
        address:
          type: string
        symbol:
          type:
            - string
            - 'null'
        name:
          type:
            - string
            - 'null'
        decimals:
          type:
            - integer
            - 'null'
          format: int32
          minimum: 0
        image_url:
          type:
            - string
            - 'null'
    RouteDetails:
      type: object
      required:
        - hop_count
        - steps
      properties:
        hop_count:
          type: integer
          description: Number of hops in `steps`, or across all splits for a split trade.
          minimum: 0
        total_fee_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: Total fees across all hops, in basis points (`100` = 1%).
          minimum: 0
        steps:
          type: array
          items:
            $ref: '#/components/schemas/RouteStep'
          description: Hops of the route, in order. Empty for a split trade; see `splits`.
        amount_raw:
          type:
            - string
            - 'null'
          description: |-
            Input of this split, in the sell token's smallest unit. Only set on
            items inside `splits`.
        estimated_amount_out_raw:
          type:
            - string
            - 'null'
          description: >-
            Estimated output of this split, in the buy token's smallest unit.
            Only

            set on items inside `splits`.
        price_impact_pct:
          type:
            - number
            - 'null'
          format: double
          description: |-
            How much worse your rate is than the current market price because of
            the size of your trade, in percent. Fees are not included.
        splits:
          type: array
          items:
            $ref: '#/components/schemas/RouteDetails'
          description: >-
            When the trade is split, the separate routes it is split into. Each

            uses different pools and all run in one transaction. Their amounts
            add

            up to the quote totals.
    ReferralFee:
      type: object
      required:
        - bps
        - wallet
      properties:
        amount:
          type:
            - string
            - 'null'
        bps:
          type: integer
          format: int32
          minimum: 0
        wallet:
          type: string
        deducted_from:
          type:
            - string
            - 'null'
    EvmTransactionRequest:
      type: object
      required:
        - to
        - from
        - data
        - value
        - chain_id
        - approvals
      properties:
        to:
          type: string
        from:
          type: string
        data:
          type: string
        value:
          type: string
        gas_limit:
          type:
            - string
            - 'null'
        gas_price:
          type:
            - string
            - 'null'
        max_fee_per_gas:
          type:
            - string
            - 'null'
        max_priority_fee_per_gas:
          type:
            - string
            - 'null'
        nonce:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        chain_id:
          type: integer
          format: int64
        approval_address:
          type:
            - string
            - 'null'
        approvals:
          type: array
          items:
            $ref: '#/components/schemas/EvmApprovalRequirement'
        approval_transactions:
          type: array
          items:
            $ref: '#/components/schemas/EvmWireTransaction'
          description: >-
            Approval transactions to send before the swap, in this order. May

            include resetting an existing allowance to zero and Permit2
            approvals.

            After they confirm, build the swap again before signing it.
    SolanaTransactionRequest:
      type: object
      properties:
        transaction:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SolanaSerializedTransaction'
        instructions:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SolanaInstructionBundle'
        last_valid_block_height:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        recent_blockhash:
          type:
            - string
            - 'null'
    EvmRoutingDetails:
      type: object
      required:
        - recipient_minimum_enforced
      properties:
        quote:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/EvmRoute'
              description: >-
                Full route details, including every hop, gas estimate and
                splits.
        adapter:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/EvmAdapterContext'
              description: >-
                Set instead of a full route when the trade goes directly through
                a

                single protocol selected with `only_protocols`.
        simulation:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/EvmSimulation'
              description: Result of simulating the swap, when it was simulated.
        minimum_output_basis:
          type:
            - string
            - 'null'
          description: |-
            What the minimum output is checked against, for example
            `recipient_balance_delta` (the recipient's actual balance increase).
        recipient_minimum_enforced:
          type: boolean
          description: |-
            True when the minimum output is checked against the recipient's
            actual balance increase.
    DexTradingErrorInfo:
      type: object
      required:
        - version
        - credits_consumed
        - compute_time_ms
      properties:
        version:
          type: string
        credits_consumed:
          type: integer
          format: int32
          minimum: 0
        compute_time_ms:
          type: number
          format: float
    SolanaPriorityFeeBudget:
      type: object
      required:
        - priority_level_with_max_lamports
      properties:
        priority_level_with_max_lamports:
          $ref: '#/components/schemas/SolanaPriorityLevelWithMaxLamports'
    RouteStep:
      type: object
      description: 'One hop of a route: a swap through a single pool.'
      required:
        - protocol
        - token_in
        - token_out
      properties:
        protocol:
          type: string
          description: Protocol of the pool, for example `uniswap_v3`.
        pool_address:
          type:
            - string
            - 'null'
          description: Pool used for this hop.
        token_in:
          type: string
          description: Token going into this hop.
        token_out:
          type: string
          description: Token coming out of this hop.
        amount_in:
          type:
            - string
            - 'null'
          description: Amount going into this hop, in normal token units.
        amount_in_raw:
          type:
            - string
            - 'null'
          description: Amount going into this hop, in the token's smallest unit.
        estimated_amount_out:
          type:
            - string
            - 'null'
          description: Estimated amount coming out of this hop, in normal token units.
        estimated_amount_out_raw:
          type:
            - string
            - 'null'
          description: >-
            Estimated amount coming out of this hop, in the token's smallest
            unit.
        fee_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: Fee for this hop in basis points (`100` = 1%).
          minimum: 0
        token_in_metadata:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TokenSummary'
              description: |-
                Details (symbol, name, decimals, image) of `token_in`. Fields we
                don't know are null.
        token_out_metadata:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TokenSummary'
              description: >-
                Details (symbol, name, decimals, image) of `token_out`. Fields
                we

                don't know are null.
    EvmApprovalRequirement:
      type: object
      required:
        - token
        - spender
      properties:
        token:
          type: string
        spender:
          type: string
        amount:
          type:
            - string
            - 'null'
    EvmWireTransaction:
      type: object
      description: An unsigned EVM transaction. Sign and send it from `from`.
      required:
        - chain_id
        - from
        - to
        - data
        - value
      properties:
        chain_id:
          type: integer
          format: int64
          minimum: 0
        from:
          type: string
        to:
          type: string
        data:
          type: string
        value:
          type: string
    SolanaSerializedTransaction:
      type: object
      required:
        - serialized
        - variant
      properties:
        serialized:
          type: string
        variant:
          $ref: '#/components/schemas/SolanaTransactionVariant'
    SolanaInstructionBundle:
      type: object
      required:
        - compute_budget_instructions
        - setup_instructions
        - swap_instructions
        - cleanup_instructions
        - address_lookup_table_addresses
      properties:
        compute_budget_instructions:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstruction'
        setup_instructions:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstruction'
        swap_instructions:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstruction'
        cleanup_instructions:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstruction'
        address_lookup_table_addresses:
          type: array
          items:
            type: string
    EvmRoute:
      type: object
      required:
        - schema_version
        - quote_status
        - amount_unit
        - chain_id
        - from
        - to
        - block
        - hops
        - quoted
        - optimization_complete
        - states_examined
        - estimated_gas
        - quote_failures
      properties:
        direction:
          $ref: '#/components/schemas/TradeDirection'
          description: '`exact_in` or `exact_out`.'
        schema_version:
          type: integer
          format: int32
          description: Version of this response format.
          minimum: 0
        quote_status:
          $ref: '#/components/schemas/EvmQuoteStatus'
          description: >-
            `model_quote` when amounts were calculated; `topology_only` when
            only

            the path was found, without amounts.
        amount_unit:
          type: string
          description: Unit of the amount fields. `raw` means the token's smallest unit.
        chain_id:
          type: integer
          format: int64
          description: EVM chain id.
          minimum: 0
        from:
          type: string
          description: Token you sell.
        to:
          type: string
          description: Token you buy.
        amount:
          type:
            - string
            - 'null'
          description: >-
            Input amount as sent in the request, when given in normal token
            units.
        amount_raw:
          type:
            - string
            - 'null'
          description: Input amount, in the input token's smallest unit.
        estimated_amount_out:
          type:
            - string
            - 'null'
          description: |-
            Same as `estimated_amount_out_raw` (smallest unit). Kept for
            compatibility.
        estimated_amount_out_raw:
          type:
            - string
            - 'null'
          description: |-
            Estimated output, in the output token's smallest unit. This is an
            estimate; the amount actually received can differ.
        estimated_amount_out_human:
          type:
            - string
            - 'null'
          description: Estimated output in normal token units.
        block:
          $ref: '#/components/schemas/EvmBlock'
          description: Block the quote was priced at.
        hops:
          type: array
          items:
            $ref: '#/components/schemas/EvmHop'
          description: |-
            Hops (pools) of the route, in order. Empty when the trade is split;
            see `splits`.
        quoted:
          type: boolean
          description: True when amounts were calculated for this route.
        optimization_complete:
          type: boolean
          description: |-
            True when the search finished and this is the best route found.
            False when the search was stopped early; the route is still valid
            but a slightly better one may exist.
        states_examined:
          type: integer
          description: Number of candidate routes checked.
          minimum: 0
        estimated_gas:
          type: integer
          format: int64
          description: Estimated gas units for the swap.
          minimum: 0
        gas_adjusted_amount_out_raw:
          type:
            - string
            - 'null'
          description: >-
            Estimated output after subtracting the gas cost, in the output
            token's

            smallest unit. Omitted when the gas cost could not be priced.
        quote_failures:
          type: object
          description: |-
            How many pool price checks failed while searching, by reason. For
            information only.
          additionalProperties:
            type: integer
            minimum: 0
          propertyNames:
            type: string
        splits:
          type: array
          items:
            $ref: '#/components/schemas/EvmRoute'
          description: >-
            When the trade is split, the separate routes it is split into. In
            that

            case `hops` is empty, each split is a complete route using different

            pools, and their amounts add up to the totals.
        compute_ms:
          type:
            - number
            - 'null'
          format: double
          description: Time taken to find the route, in milliseconds.
        input_conversion:
          type:
            - string
            - 'null'
          description: >-
            `wrap` or `unwrap` when the input is converted between the native
            token

            and its wrapped form before the first hop. On a split trade, set on
            each

            split that converts, and on the top level when any split does.
        output_conversion:
          type:
            - string
            - 'null'
          description: >-
            `wrap` or `unwrap` when the output is converted between the native
            token

            and its wrapped form after the last hop.
        gas_cost_source:
          type:
            - string
            - 'null'
          description: >-
            Where the gas price used for `gas_adjusted_amount_out_raw` came
            from:

            `request` (your `gas_cost_per_unit_raw`) or `derived` (current
            network

            fees).
        gas_price_wei:
          type:
            - string
            - 'null'
          description: |-
            Gas price used, in wei per gas unit. Only when `gas_cost_source` is
            `derived`.
        executor:
          type:
            - string
            - 'null'
          description: |-
            Name of the swap contract the transaction goes through, for example
            `struct_router` or `universal_router`. For information only.
        token_in:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TokenSummary'
              description: Details of the token you sell. Only on the top-level route.
        token_out:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TokenSummary'
              description: Details of the token you buy. Only on the top-level route.
        amount_usd:
          type:
            - number
            - 'null'
          format: double
          description: USD value of `amount_raw`. Omitted when no price is available.
        estimated_amount_out_usd:
          type:
            - number
            - 'null'
          format: double
          description: |-
            USD value of `estimated_amount_out_raw`. Omitted when no price is
            available.
        total_fee_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Total fees across all hops, in basis points. Omitted on the top
            level

            of a split trade; see each split.
          minimum: 0
        price_impact_pct:
          type:
            - number
            - 'null'
          format: double
          description: |-
            How much worse your rate is than the current market price because of
            the size of your trade, in percent. Fees are not included.
        value_change_pct:
          type:
            - number
            - 'null'
          format: double
          description: >-
            USD value you receive compared with the USD value you pay, in
            percent,

            including fees and price impact. Negative means you receive less
            value

            than you pay. Only on the top-level route; omitted when either USD

            value is unavailable.
    EvmAdapterContext:
      type: object
      description: |-
        Quote details for a trade that goes directly through a single protocol.
        It has no route search, gas estimate or pool fee breakdown.
      required:
        - schema_version
        - direction
        - quote_status
        - chain_id
        - block
        - from
        - to
        - amount_raw
        - estimated_amount_out_raw
        - hops
      properties:
        schema_version:
          type: integer
          format: int32
          minimum: 0
        direction:
          $ref: '#/components/schemas/TradeDirection'
        quote_status:
          $ref: '#/components/schemas/EvmQuoteStatus'
        chain_id:
          type: integer
          format: int64
          minimum: 0
        block:
          $ref: '#/components/schemas/EvmBlock'
        from:
          type: string
        to:
          type: string
        amount_raw:
          type: string
        estimated_amount_out_raw:
          type: string
        hops:
          type: array
          items:
            $ref: '#/components/schemas/RouteStep'
    EvmSimulation:
      type: object
      description: Result of simulating the swap before you sign it.
      required:
        - status
        - executable_at_quoted_block
        - block
        - method
        - gas_price_raw
        - gas_limit
        - gas_cost_included
        - synthetic_funding
      properties:
        failed_calls:
          type: array
          items: {}
          description: Calls that failed during the simulation, with the reason.
        rejected_routes:
          type: array
          items: {}
          description: Routes that were tried and dropped because their simulation failed.
        status:
          $ref: '#/components/schemas/EvmSimulationStatus'
          description: Overall result. See the status values.
        executable_at_quoted_block:
          type: boolean
          description: True only when the simulated amounts match the quote.
        transaction_succeeded:
          type:
            - boolean
            - 'null'
          description: >-
            Whether the simulated transaction succeeded. Null when it was not
            run.
        block:
          $ref: '#/components/schemas/EvmBlock'
          description: Block the simulation ran at.
        method:
          type: string
          description: How the simulation was run.
        gas_price_raw:
          type: string
          description: |-
            Gas price used in the simulation, in wei. Not a recommendation for
            your transaction.
        gas_limit:
          type: integer
          format: int64
          description: Gas limit used in the simulation.
          minimum: 0
        gas_cost_included:
          type: boolean
          description: True when gas costs are counted in the simulated amounts.
        synthetic_funding:
          type: boolean
          description: >-
            True if the simulation used token balances the sender does not
            really

            hold. False means the sender's real balances were used.
        sender_amount_in_raw:
          type:
            - string
            - 'null'
          description: |-
            Amount the sender actually paid in the simulation, in the input
            token's smallest unit.
        recipient_amount_out_raw:
          type:
            - string
            - 'null'
          description: >-
            Amount the recipient actually received in the simulation, in the
            output

            token's smallest unit.
        input_matches_quote:
          type:
            - boolean
            - 'null'
          description: Whether the simulated input matches the quote.
        output_matches_quote:
          type:
            - boolean
            - 'null'
          description: Whether the simulated output matches the quote.
        minimum_output_satisfied:
          type:
            - boolean
            - 'null'
          description: Whether the recipient received at least the minimum output.
        error:
          type:
            - string
            - 'null'
          description: Reason the simulation failed or could not run, if any.
    SolanaPriorityLevelWithMaxLamports:
      type: object
      required:
        - priority_level
        - max_lamports
      properties:
        priority_level:
          $ref: '#/components/schemas/SolanaPriorityLevel'
          description: |-
            How quickly you want the transaction to land. Higher levels pay a
            higher priority fee.
        max_lamports:
          type: integer
          format: int64
          description: Maximum priority fee budget in lamports.
          minimum: 0
        global:
          type:
            - boolean
            - 'null'
          description: |-
            Base the fee on network-wide fees instead of fees for the accounts
            this swap touches.
    SolanaTransactionVariant:
      type: string
      enum:
        - legacy
        - versioned
        - v1
    SolanaInstruction:
      type: object
      required:
        - program_id
        - accounts
        - data
      properties:
        program_id:
          type: string
        accounts:
          type: array
          items:
            $ref: '#/components/schemas/SolanaInstructionAccount'
        data:
          type: string
    EvmQuoteStatus:
      type: string
      description: |-
        `model_quote`: amounts were calculated. `topology_only`: only the path
        was found, without amounts.
      enum:
        - topology_only
        - model_quote
    EvmBlock:
      type: object
      description: The block the quote was priced at.
      required:
        - number
        - hash
        - parent_hash
        - timestamp
      properties:
        number:
          type: integer
          format: int64
          minimum: 0
        hash:
          type: string
        parent_hash:
          type: string
        timestamp:
          type: integer
          format: int64
          minimum: 0
    EvmHop:
      type: object
      required:
        - from
        - to
        - pool_id
        - protocol
        - fee_pips
        - effective_fee_pips
        - block
        - block_hash
        - ticks_crossed
      properties:
        native_conversion_before:
          type:
            - string
            - 'null'
          description: |-
            `wrap` or `unwrap` when the native token is converted 1:1 to or from
            its wrapped form before this hop.
        hook_protocol_fee_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: Extra protocol fee charged by the pool's hook, in basis points.
          minimum: 0
        hook_creator_tax_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: Extra creator tax charged by the pool's hook, in basis points.
          minimum: 0
        from:
          type: string
          description: Token going into this hop.
        to:
          type: string
          description: Token coming out of this hop.
        pool_id:
          type: string
          description: Pool used for this hop.
        protocol:
          type: string
          description: Protocol of the pool, for example `uniswap_v3`.
        fee_pips:
          type: integer
          format: int32
          description: |-
            Pool's liquidity provider fee, in pips (1,000,000 = 100%). Use
            `effective_fee_pips` for the fee actually charged on this swap.
          minimum: 0
        effective_fee_pips:
          type: integer
          format: int32
          description: Fee actually charged on this swap, in pips (1,000,000 = 100%).
          minimum: 0
        pool_key_fee:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Uniswap V4 only: the fee value stored in the pool key. For pools
            with

            a changing fee this is a flag, not a fee; use `fee_pips` instead.
          minimum: 0
        input_token_sell_tax_pips:
          type:
            - integer
            - 'null'
          format: int32
          description: Tax the input token charges when sold, in pips (1,000,000 = 100%).
          minimum: 0
        output_token_buy_tax_pips:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Tax the output token charges when bought, in pips (1,000,000 =
            100%).
          minimum: 0
        block:
          type: integer
          format: int64
          description: Block number the hop was priced at.
          minimum: 0
        block_hash:
          type: string
          description: Hash of that block.
        amount_in:
          type:
            - string
            - 'null'
          description: Amount going into this hop, in the token's smallest unit.
        estimated_amount_out:
          type:
            - string
            - 'null'
          description: >-
            Estimated amount coming out of this hop, in the token's smallest
            unit.
        fee_amount_raw:
          type:
            - string
            - 'null'
          description: Pool fee paid on this hop, in the input token's smallest unit.
        ticks_crossed:
          type: integer
          description: >-
            Number of price ticks the swap moves through in the pool
            (concentrated

            liquidity pools). Higher means a bigger price move.
          minimum: 0
        fee_bps:
          type:
            - integer
            - 'null'
          format: int32
          description: |-
            Total fee for this hop in basis points (`100` = 1%), including hook
            fees.
          minimum: 0
        amount_in_human:
          type:
            - string
            - 'null'
          description: >-
            `amount_in` in normal token units, when the token's decimals are
            known.
        estimated_amount_out_human:
          type:
            - string
            - 'null'
          description: >-
            `estimated_amount_out` in normal token units, when the token's
            decimals

            are known.
        from_metadata:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TokenSummary'
              description: >-
                Details (symbol, name, decimals, image) of the token going into
                this

                hop. Omitted when unknown.
        to_metadata:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TokenSummary'
              description: >-
                Details (symbol, name, decimals, image) of the token coming out
                of

                this hop. Omitted when unknown.
    EvmSimulationStatus:
      type: string
      description: |-
        Result of the swap simulation:
        `verified` (the swap works and the amounts match the quote),
        `mismatch` (the swap works but the amounts differ from the quote),
        `failed` (the swap would fail),
        `approvals_required` (send the approvals first, then build again),
        `unavailable` (the simulation could not be run; try again),
        `not_requested` (simulation was turned off).
      enum:
        - not_requested
        - approvals_required
        - unavailable
        - failed
        - mismatch
        - verified
    SolanaPriorityLevel:
      type: string
      enum:
        - medium
        - high
        - very_high
    SolanaInstructionAccount:
      type: object
      required:
        - pubkey
        - is_signer
        - is_writable
      properties:
        pubkey:
          type: string
        is_signer:
          type: boolean
        is_writable:
          type: boolean
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Secret API key (`sk_*`) or JWT public key (`pk_jwt_*`).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.