# Retrieve Delta price with fallback to Market

## Get Delta Price with fallback to Market

<mark style="color:blue;">`GET`</mark> `https://api.paraswap.io/quote`

When implementing this endpoint, you can enable API to fallback to market prices if the Delta pricing is not available. If the quote obtained comes from Market pricing data, you’ll get the learn more about the cause in the fallback reason parameter.

{% hint style="info" %}
This endpoint is also available in [Velora SDK](https://github.com/paraswap/paraswap-sdk). You can find example usage [here](https://github.com/paraswap/paraswap-sdk/blob/master/src/examples/simpleQuote.ts).
{% endhint %}

#### Query Parameters

| Name                                           | Type                         | Description                                                                                                                                                                                                                             |
| ---------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| srcToken<mark style="color:red;">\*</mark>     | string                       | Source Token Address.                                                                                                                                                                                                                   |
| srcDecimals<mark style="color:red;">\*</mark>  | integer                      | Source Token Decimals.                                                                                                                                                                                                                  |
| destToken<mark style="color:red;">\*</mark>    | string                       | Destination Token Address. For cross-chain quote - destination token on the destination chain. Supported destination tokens for cross-chain can be obtained from `/bridge-info` endpoint                                                |
| destDecimals<mark style="color:red;">\*</mark> | integer                      | Destination Token Decimals.                                                                                                                                                                                                             |
| amount<mark style="color:red;">\*</mark>       | string                       | <p>srcToken amount (in case of SELL) or destToken amount (in case of BUY). <br>The amount should be in <strong>WEI/Raw units</strong> (eg. 1WBTC -> 100000000) </p>                                                                     |
| side                                           | `SELL` \| `BUY`              | Default: `SELL`.                                                                                                                                                                                                                        |
| chainId<mark style="color:red;">\*</mark>      | number                       | Chain ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100).                                                                            |
| userAddress                                    | string                       | User's Wallet Address.                                                                                                                                                                                                                  |
| partner                                        | string                       | <p>Partner string.</p><p><br>If no <code>partner</code> is passed, it defaults to anon which charges a flat 1bps fee for all swaps. <code>partner</code> should be different from the existing ones that may charge indepent fees. </p> |
| mode                                           | `ALL` \| `DELTA` \| `MARKET` | <p>Preferred mode for the trade. In case of "all", Delta pricing is returned, with Market as a fallback.<br>Default: <code>ALL</code>.<br><code>MARKET</code> mode is not supported for cross-chain orders</p>                          |
| destChainId                                    | number                       | Destination chain ID for cross-chain quote. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100).                                          |

## Query Modes Explained

The endpoint behaves differently based on the `mode` passed:

* `DELTA` - will return the Delta pricing data in the `delta` field, which can then be used to build, sign and submit a Delta Order.
* `MARKET` - will return the Market pricing data in the `market` field , which is an equivalent to the successful response from `/prices?version=6.2` of the Velora API, which can then be used to [build a swap transaction](/api/velora-api/velora-market-api/build-parameters-for-transaction.md). Cross-chain orders are not supported in `MARKET` mode.
* `ALL` - **default** mode. Will return the Delta pricing data in the `delta` field. In case the Delta prices are unavailable, fallback to `MARKET` mode and returns the Market pricing data. Also specifies the fallback reason in `fallbackReason` field. Refer [here](/api/velora-api/velora-delta-api/example-quote-with-fallback/quote-with-fallback.md) for example of usage of this mode.

## Response

#### Fields

| Field          | Type      | Description                                                                                                                              |
| -------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `delta`        | `object?` | Main data structure containing details about the swap and bridge operation. Used to sign and submit a Delta order. See below for details |
| `market`       | `object?` | Will return the Market pricing . Included when `mode=MARKET`, or `mode=ALL` and delta pricing is not available                           |
| `deltaAddress` | `string`  | Address of the Delta smart contract used to execute the transaction.                                                                     |

### `delta` Object

This section provides information about the swap, bridging path, fees, and available bridge routes.

#### Core Fields

| Field                 | Type          | Description                                                                                                                            |
| --------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `srcToken`            | `string`      | ERC20 token address being sent (source token).                                                                                         |
| `destToken`           | `string`      | Token address being received . For cross-chain orders, this would be the token received on the source chain and sent to bridge         |
| `srcAmount`           | `string`      | Amount of `srcToken` to be sent                                                                                                        |
| `destAmount`          | `string`      | Final amount received after all fees. For cross-chain orders, this would be the amount received on the source chain and sent to bridge |
| `destAmountBeforeFee` | `string`      | Destination token amount before applying fees                                                                                          |
| `gasCostUSD`          | `string`      | Estimated gas cost of executing the transaction, in USD.                                                                               |
| `gasCost`             | `string`      | Estimated gas cost in units of gas.                                                                                                    |
| `srcUSD`              | `string`      | USD equivalent of `srcAmount`.                                                                                                         |
| `destUSD`             | `string`      | USD equivalent of `destAmount` after all fees.                                                                                         |
| `partner`             | `string`      | Partner identifier                                                                                                                     |
| `partnerFee`          | `number`      | Partner fee                                                                                                                            |
| `bridge`              | `Bridge?`     | Bridge details that should be signed within the order. Available only for cross-chain orders                                           |
| `bridgeInfo`          | `BridgeInfo?` | Provides metadata about the selected bridge route.                                                                                     |
| `hmac`                | `string`      | Hash-based message authentication code                                                                                                 |

**`BridgeInfo` object**

| Field                   | Type          | Description                                                                          |
| ----------------------- | ------------- | ------------------------------------------------------------------------------------ |
| `protocolName`          | `string`      | Name of the bridge protocol (e.g., `Across`, `CCTPStandard`, `StargateTaxi`).        |
| `destAmountAfterBridge` | `string`      | Amount expected after bridging, in destination token units, on the destination chain |
| `destUSDAfterBridge`    | `string`      | USD value of `destAmountAfterBridge`.                                                |
| `estimatedTimeMs`       | `number`      | Estimated transfer time in milliseconds.                                             |
| `fees`                  | `BridgeFee[]` | Breakdown of fees charged by the bridge protocol. Some bridges might have no fee     |

**`BridgeFee` object**

| Field         | Type     | Description                                                             |
| ------------- | -------- | ----------------------------------------------------------------------- |
| `feeToken`    | `string` | Token address in which the fee is charged (`0xeeee...` = native token). |
| `amount`      | `string` | Fee amount in token’s smallest unit.                                    |
| `amountInUSD` | `string` | Fee value in USD.                                                       |

### <sub>`AvailableBridge`</sub> <sub></sub><sub>object</sub>

Lists all potential bridge routes and their parameters.\
Each item represents one destination bridge option, containing:

| Field                 | Type             | Description                                                          |
| --------------------- | ---------------- | -------------------------------------------------------------------- |
| `destToken`           | `string`         | Destination token received on the source chain                       |
| `destAmount`          | `string`         | Destination amount received on the source chain                      |
| `destAmountBeforeFee` | `string`         | Destination amount received on the source chain before applying fees |
| `destUSD`             | `string`         | USD equivalent of `destAmount`.                                      |
| `gasCostUSD`          | `string`         | Gas cost estimate in USD for the transaction                         |
| `bridgeParams`        | `BridgeParams[]` | Set of configurations and objects for each protocol variant.         |

### <sub>`BridgeParams`</sub>&#x20;

| Field        | Type         | Description                                                      |
| ------------ | ------------ | ---------------------------------------------------------------- |
| `bridgeInfo` | `BridgeInfo` | Bridge metadata (same structure as above)                        |
| `bridge`     | `Bridge`     | Protocol configuration for that bridge (same structure as above) |

Examples for Successful Responses for each `mode`.

{% tabs %}
{% tab title="mode=DELTA 200 Successful Response " %}

```json
{
  "delta": {
    "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "destToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
    "srcAmount": "100000000",
    "destAmount": "41290907243749599",
    "destAmountBeforeFee": "42763539574055205",
    "gasCostUSD": "3.436417",
    "gasCost": "318930",
    "srcUSD": "99.99940000000001",
    "destUSD": "96.3531578668",
    "destUSDBeforeFee": "99.7895748668493",
    "gasCostBeforeFee": "98300",
    "gasCostUSDBeforeFee": "1.0591657900269833",
    "partner": "paraswap.io-staging",
    "partnerFee": 0,
    "hmac": "7c6b4b9d3a7bfed5c29c924f84abe4bce4add7e9"
  },
  "deltaAddress": "0x0000000000bbf5c5fd284e657f01bd000933c96d"
}
```

{% endtab %}

{% tab title="mode=DELTA  cross-chain 200 Successful response (cross-chain)" %}

```json
{
  "delta": {
    "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "destToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "srcAmount": "10000000",
    "destAmount": "9479298",
    "destAmountBeforeFee": "10000000",
    "gasCostUSD": "0.5206030000",
    "gasCost": "338300",
    "srcUSD": "9.9980900000",
    "destUSD": "9.4774870000",
    "destUSDBeforeFee": "9.9980900000",
    "gasCostBeforeFee": "25000",
    "gasCostUSDBeforeFee": "0.0384722157",
    "partner": "anon",
    "partnerFee": 0,
    "bridge": {
      "outputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
      "protocolData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002258",
      "scalingFactor": 0,
      "destinationChainId": 8453,
      "protocolSelector": "0x21eaa4cd"
    },
    "bridgeInfo": {
      "protocolName": "Across",
      "destAmountAfterBridge": "9474900",
      "destUSDAfterBridge": "9.473090294099999",
      "estimatedTimeMs": 20000,
      "fees": [
        {
          "amount": "4396",
          "feeToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
          "amountInSrcToken": "4396",
          "amountInUSD": "0.004395160364"
        }
      ]
    },
    "availableBridges": [
      {
        "destToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "destAmount": "9479298",
        "destAmountBeforeFee": "10000000",
        "destUSD": "9.4774870000",
        "destUSDBeforeFee": "9.9980900000",
        "gasCostUSD": "0.5206030000",
        "gasCost": "338300",
        "gasCostUSDBeforeFee": "0.0384722157",
        "gasCostBeforeFee": "25000",
        "bridgeParams": [
          {
            "bridgeInfo": {
              "protocolName": "StargateTaxi",
              "destAmountAfterBridge": "9405953",
              "destUSDAfterBridge": "9.404156462977",
              "estimatedTimeMs": 180828,
              "fees": [
                {
                  "feeToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                  "amount": "14777250162456",
                  "amountInSrcToken": "59126",
                  "amountInUSD": "0.0591156504123971"
                }
              ]
            },
            "bridge": {
              "protocolSelector": "0x7ae1d4cb",
              "destinationChainId": 8453,
              "outputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
              "scalingFactor": 0,
              "protocolData": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000075e8000000000000000000000000c026395860db2d07ee33e05fe50ed7bd583189c7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008d644d0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000d7098bf27180000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000001cdec000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
            }
          }
        ]
      },
      {
        "destToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "destAmount": "9479298",
        "destAmountBeforeFee": "10000000",
        "destUSD": "9.4774870000",
        "destUSDBeforeFee": "9.9980900000",
        "gasCostUSD": "0.5206030000",
        "gasCost": "338300",
        "gasCostUSDBeforeFee": "0.0384722157",
        "gasCostBeforeFee": "25000",
        "bridgeParams": [
          {
            "bridgeInfo": {
              "protocolName": "CCTPStandard",
              "destAmountAfterBridge": "9476819",
              "destUSDAfterBridge": "9.475008927571",
              "estimatedTimeMs": 900000,
              "fees": [
                {
                  "feeToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                  "amount": "619803340000",
                  "amountInUSD": "0.0025",
                  "amountInSrcToken": "2479"
                }
              ]
            },
            "bridge": {
              "protocolSelector": "0x786b64df",
              "destinationChainId": 8453,
              "outputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
              "scalingFactor": 0,
              "protocolData": "0x0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007d0"
            }
          },
          {
            "bridgeInfo": {
              "protocolName": "CCTPFast",
              "destAmountAfterBridge": "9475819",
              "destUSDAfterBridge": "9.474009118570999",
              "estimatedTimeMs": 20000,
              "fees": [
                {
                  "feeToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                  "amount": "619803340000",
                  "amountInUSD": "0.0025",
                  "amountInSrcToken": "2479"
                },
                {
                  "feeToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                  "amount": "1000",
                  "amountInSrcToken": "1000",
                  "amountInUSD": "0.000999809"
                }
              ]
            },
            "bridge": {
              "protocolSelector": "0x786b64df",
              "destinationChainId": 8453,
              "outputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
              "scalingFactor": 0,
              "protocolData": "0x000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000003e8"
            }
          }
        ]
      },
      {
        "destToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "destAmount": "9479298",
        "destAmountBeforeFee": "10000000",
        "destUSD": "9.4774870000",
        "destUSDBeforeFee": "9.9980900000",
        "gasCostUSD": "0.5206030000",
        "gasCost": "338300",
        "gasCostUSDBeforeFee": "0.0384722157",
        "gasCostBeforeFee": "25000",
        "bridgeParams": [
          {
            "bridgeInfo": {
              "protocolName": "Across",
              "destAmountAfterBridge": "9474900",
              "destUSDAfterBridge": "9.473090294099999",
              "estimatedTimeMs": 20000,
              "fees": [
                {
                  "amount": "4396",
                  "feeToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                  "amountInSrcToken": "4396",
                  "amountInUSD": "0.004395160364"
                }
              ]
            },
            "bridge": {
              "outputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
              "protocolData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002258",
              "scalingFactor": 0,
              "destinationChainId": 8453,
              "protocolSelector": "0x21eaa4cd"
            }
          }
        ]
      }
    ],
    "hmac": "9079eea5889a708d7addff1658084bd508fe3798"
  },
  "deltaAddress": "0x76e0ebb8d4c6dccb3fdedab7a3e1c87036719a42"
}
```

{% endtab %}

{% tab title="200 mode=ALL Successful Response" %}

```json
{
    "fallbackReason": {
        "errorType": "UnsupportedToken",
        "details": "Token 0xa4bc2b90743294e5e6fd3321a9a131947f7785db is not supported"
    },
    "market": {
        "blockNumber": 21222968,
        "network": 1,
        "srcToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "srcDecimals": 18,
        "srcAmount": "1000000000000000000",
        "destToken": "0xa4bc2b90743294e5e6fd3321a9a131947f7785db",
        "destDecimals": 9,
        "destAmount": "1106884085431",
        "bestRoute": [
            {
                "percent": 100,
                "swaps": [
                    {
                        "srcToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                        "srcDecimals": 18,
                        "destToken": "0xa4bc2b90743294e5e6fd3321a9a131947f7785db",
                        "destDecimals": 9,
                        "swapExchanges": [
                            {
                                "exchange": "UniswapV2",
                                "srcAmount": "1000000000000000000",
                                "destAmount": "1106884085431",
                                "percent": 100,
                                "poolAddresses": [
                                    "0x98555273b697fA2b4CF3e009403B5ae31Fd2C7A1"
                                ],
                                "data": {
                                    "router": "0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07",
                                    "path": [
                                        "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                                        "0xa4bc2b90743294e5e6fd3321a9a131947f7785db"
                                    ],
                                    "factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
                                    "initCode": "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",
                                    "feeFactor": 10000,
                                    "pools": [
                                        {
                                            "address": "0x98555273b697fA2b4CF3e009403B5ae31Fd2C7A1",
                                            "fee": 30,
                                            "direction": false
                                        }
                                    ],
                                    "gasUSD": "5.896714"
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "gasCostUSD": "9.771593",
        "gasCost": "132570",
        "side": "SELL",
        "version": "6.2",
        "contractAddress": "0x6a000f20005980200259b80c5102003040001068",
        "tokenTransferProxy": "0x6a000f20005980200259b80c5102003040001068",
        "contractMethod": "swapExactAmountInOnUniswapV2",
        "partnerFee": 0,
        "srcUSD": "3102.2276074900",
        "destUSD": "3121.4131209154",
        "partner": "paraswap.io",
        "maxImpactReached": false,
        "hmac": "b9c7c2ed6a47c98af2a835184a64db4a50fc2b61"
    }
}
```

{% endtab %}

{% tab title="200 mode=MARKET Successful Response" %}

```json
{
    "market": {
        "blockNumber": 21222968,
        "network": 1,
        "srcToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "srcDecimals": 18,
        "srcAmount": "1000000000000000000",
        "destToken": "0xa4bc2b90743294e5e6fd3321a9a131947f7785db",
        "destDecimals": 9,
        "destAmount": "1106884085431",
        "bestRoute": [
            {
                "percent": 100,
                "swaps": [
                    {
                        "srcToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                        "srcDecimals": 18,
                        "destToken": "0xa4bc2b90743294e5e6fd3321a9a131947f7785db",
                        "destDecimals": 9,
                        "swapExchanges": [
                            {
                                "exchange": "UniswapV2",
                                "srcAmount": "1000000000000000000",
                                "destAmount": "1106884085431",
                                "percent": 100,
                                "poolAddresses": [
                                    "0x98555273b697fA2b4CF3e009403B5ae31Fd2C7A1"
                                ],
                                "data": {
                                    "router": "0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07",
                                    "path": [
                                        "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                                        "0xa4bc2b90743294e5e6fd3321a9a131947f7785db"
                                    ],
                                    "factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
                                    "initCode": "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",
                                    "feeFactor": 10000,
                                    "pools": [
                                        {
                                            "address": "0x98555273b697fA2b4CF3e009403B5ae31Fd2C7A1",
                                            "fee": 30,
                                            "direction": false
                                        }
                                    ],
                                    "gasUSD": "5.896714"
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "gasCostUSD": "9.771593",
        "gasCost": "132570",
        "side": "SELL",
        "version": "6.2",
        "contractAddress": "0x6a000f20005980200259b80c5102003040001068",
        "tokenTransferProxy": "0x6a000f20005980200259b80c5102003040001068",
        "contractMethod": "swapExactAmountInOnUniswapV2",
        "partnerFee": 0,
        "srcUSD": "3102.2276074900",
        "destUSD": "3121.4131209154",
        "partner": "paraswap.io",
        "maxImpactReached": false,
        "hmac": "b9c7c2ed6a47c98af2a835184a64db4a50fc2b61"
    }
}
```

{% endtab %}

{% tab title="400 Price Error" %}

```json
{
    "errorType": "UnsupportedToken",
    "details": "Token 0xa4bc2b90743294e5e6fd3321a9a131947f7785db is not supported"
}
```

{% endtab %}
{% endtabs %}

#### Most common fallback reasons and error types&#x20;

The following is a list of the most common error messages and fallback reasons of the `/delta/quote` endpoint. Most are self-explanatory and can be self-solved, but feel free to contact Velora Support using the chat in the bottom right corner of this page.

* `ValidationError` - validation for params failed
* `UnsupportedChain` - the chain ID is not supported by Delta.
* `UnsupportedToken` - the token is not supported by Delta.
* `SourceEth` - Native chain token cannot be used as source token in Delta.
* `UnsupportedSide` - `BUY` is not supported by Delta yet.
* `PricingError` - internal oracle failed to provide a price.
* `GasCostExceedsTradeAmount` - estimated value paid for gas is bigger than trade amount.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.velora.xyz/api/velora-api/velora-delta-api/retrieve-delta-price-with-fallback-to-market.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
