# Velora API

Velora's API provides the most straightforward and efficient access to the Velora Protocol. It connects your application to a vast network of liquidity sources guaranteeing optimal token swap rates across multiple blockchain networks.

Velora currently has two versions of its API available:

<table data-card-size="large" data-view="cards" data-full-width="false"><thead><tr><th align="center"></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><strong>Velora Delta API</strong></td><td>Access an intent-based protocol that enables  gas-less swaps where multiple agents compete to execute the trade at the best price possible. By using Velora Delta, users don’t need to make a transaction themselves but only to sign a Delta Order.</td><td><a href="/pages/aBd8lttzMYzfqKkbfpqV">/pages/aBd8lttzMYzfqKkbfpqV</a></td></tr><tr><td align="center"><strong>Velora Market API</strong></td><td>Access a decentralized exchange aggregator that allows developers to access hundreds of DEXs and tens of thousands of liquidity pools in real-time.</td><td><a href="/pages/mDSZg3LZM1suGYkjbwk9">/pages/mDSZg3LZM1suGYkjbwk9</a></td></tr></tbody></table>


# Velora Delta API

Here, you'll find everything you need to understand how the Delta API works and how to implement it. Start with our brief overview for a quick introduction to Delta's smart contract, then explore how to use its functions effectively.

<table data-header-hidden data-full-width="false"><thead><tr><th align="center"></th><th data-hidden data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><a href="/pages/IdjtT8L3IE44n1W7vDUW">Overview</a></td><td><a href="/pages/IdjtT8L3IE44n1W7vDUW">/pages/IdjtT8L3IE44n1W7vDUW</a></td></tr><tr><td align="center"><a href="/pages/Ruif9t7e37k9A3dxpvKs">Contracts</a></td><td></td></tr><tr><td align="center"><a href="/pages/K690HWhFH6b7Yws9p0Sv">Retrieve delta Price with fallback to market</a></td><td></td></tr><tr><td align="center"><a href="/pages/QRAOD1DNcP9Vk06NEAGf">Build a Delta Order to Sign</a></td><td></td></tr><tr><td align="center"><a href="/pages/dnwWSlLRMtmSFcHvmKTi">Submit a Delta Order</a></td><td></td></tr><tr><td align="center"><a href="/pages/6r0DKUONrrHGdPsN9dFV">Track a Delta Order auction status</a></td><td></td></tr><tr><td align="center"><a href="/pages/vnlLT9IpZVSjgFPy3Whv">Example: Quote With Fallback</a></td><td></td></tr></tbody></table>


# Overview

Velora Delta is a new set of smart contracts developed by Velora. It's built on top of the Portikus Intents network and is currently available on the Ethereum and Base networks. This development unlocks several benefits for swapping tokens, including:

* **Gas-less trading: users** can submit a trade without using a gas token, as Delta will execute the trades on their behalf.
* **MEV Protection:** By submitting your trade through Velora Delta, you can protect your users’ swaps from events like sandwich attacks.
* **Price Competition:** Velora Delta is increasingly competitive as different agents compete to deliver the best possible prices to users.

{% hint style="info" %}
The easiest way to make use of the Delta is to use the [Velora SDK](https://github.com/paraswap/paraswap-sdk). Refer [here](https://github.com/paraswap/paraswap-sdk/blob/master/docs/DELTA.md) SDK Delta documentation.
{% endhint %}

Simple Delta flow using API with `axios` looks like this:

### 1. Request prices for a token pair

This function is used to **fetch a price quote** for swapping

**In this case, we’re swapping 100 DAI for PSP tokens** on Ethereum (chainId: 1) using **Velora's Delta API**.

```typescript
const API_URL = 'https://api.paraswap.io';
const DAI_TOKEN = '0x6b175474e89094c44da98b954eedeac495271d0f';
const PSP_TOKEN = '0xcafe001067cdef266afb7eb5a286dcfd277f3de5';

const { data: quote } = await axios.get(`${API_URL}/quote`, {
  params: {
    chainId: 1,
    srcToken: DAI_TOKEN,
    destToken: PSP_TOKEN,
    amount: '100000000000000000000', // 100 DAI
    srcDecimals: 18,
    destDecimals: 18,
    mode: 'delta',
    side: 'SELL',
  },
});
```

### 2. Build a Delta order

On this section, partners can pick between two models:

* **Fee Model:** It allows partners to take up to 2% of the trade in partner fees (200 bps)
* **Surplus Model:** Which only works if a surplus is generated from the trade. On this case, the partner will collect 50% of the order surplus instead of a flat percent fee to the specified partner address.

{% hint style="info" %}
If you want to earn fees on your users orders, they have to be set on this step. For more details, check the [Partner Fees Section in Order Building](/api/velora-api/velora-delta-api/build-a-delta-order-to-sign#partner-fees).
{% endhint %}

```typescript
const accountWallet = new ethers.Wallet(/*Private Key or Mnemonic*/);

const { data: builtOrder } = await axios.post(`${API_URL}delta/orders/build`, {
  price: quote.delta,
  chainId: 1,
  owner: account.address,
  /* if you want to collect fees
  partnerAddress: /.../,
  partnerFeeBps: /.../, - takes precedence if passed with `partnerTakesSurplus`
  partnerTakesSurplus: true,
  */
});
```

### 3. Sign the received Order

This part of the code uses EIP-712 for Signing, which is a standard for signing structured data on Ethereum, allowing off-chain signatures that can be verified on-chain without gas costs. This ensures a secure, gas-efficient, and human-readable signing process.

```typescript
// Delta protocol works with EIP-712 signatures
const signature = accountWallet.signTypedData(
  builtOrder.domain,
  builtOrder.types,
  builtOrder.value,
);

// compact the signature
const compactSignature = ethers.Signature.from(signature).compactSerialized;
```

### 4. Submit the signed Order

At this stage, the signed order is sent and an auction is performed between all the available Agents.

```typescript
const { data: deltaAuction } = await axios.post(`${API_URL}/orders`, {
  chainId: 1,
  order: builtOrder.value,
  signature: compactSignature,
  // partner: '...' // if available
});
```

{% hint style="info" %}
For more details, check the [Submit a Delta order](https://developers.paraswap.network/api/paraswap-api/delta-api/submit-a-delta-order) section.
{% endhint %}

### 5. Check the Order Auction Status

This function is used to check the status of an order and retrieve a result.

If the order **status** is executed, it means a taker has filled the order, and the swap has been completed.

If the status is still **'PENDING'** or **'OPEN'**, the order is waiting for execution.

```typescript
// poll if necessary
const { data: auction } = await axios.get(`${API_URL}/orders/${deltaAuction.id}`);
if (auction?.status === 'EXECUTED') {
  console.log('Auction was executed');
}
```

{% hint style="info" %}
For more information on Order Auction Status, check the [Track Delta Order Auction Status](https://developers.paraswap.network/api/paraswap-api/delta-api/track-delta-order-auction-status) section.
{% endhint %}

**A more detailed example of Delta usage, including fallback to Market (traditional swapping flow), can be found in** [**examples**](/api/velora-api/velora-delta-api/example-quote-with-fallback)**.**


# Contracts

### Portikus Adapter

Portikus Adapter is Velora's Delta contract

When working on the API implementation, you’ll use the following contract addresses at these stages:

* Order creation
* Signing order
* Submitting Order to API
* On-Chain Execution

Delta’s contract has been deployed on Ethereum and Base networks. It shares the same address across both chains.

### &#x20;Addresses of Delta contract

<table><thead><tr><th width="179">Network</th><th>Address</th></tr></thead><tbody><tr><td>Ethereum</td><td><a href="https://etherscan.io/address/0x0000000000bbf5c5fd284e657f01bd000933c96d">0x0000000000bbf5c5fd284e657f01bd000933c96d</a></td></tr><tr><td>Base</td><td><a href="https://basescan.org/address/0x0000000000bbf5c5fd284e657f01bd000933c96d">0x0000000000bbf5c5fd284e657f01bd000933c96d</a></td></tr><tr><td>Optimism</td><td><a href="https://optimistic.etherscan.io/address/0x0000000000bbF5c5Fd284e657F01Bd000933C96D">0x0000000000bbf5c5fd284e657f01bd000933c96d</a></td></tr><tr><td>Arbitrum</td><td><a href="https://arbiscan.io/address/0x0000000000bbf5c5fd284e657f01bd000933c96d">0x0000000000bbf5c5fd284e657f01bd000933c96d</a></td></tr><tr><td>Polygon</td><td><a href="https://polygonscan.com/address/0x0000000000bbf5c5fd284e657f01bd000933c96d">0x0000000000bbf5c5fd284e657f01bd000933c96d</a></td></tr><tr><td>BSC</td><td><a href="https://bscscan.com/address/0x0000000000bbf5c5fd284e657f01bd000933c96d">0x0000000000bbf5c5fd284e657f01bd000933c96d</a></td></tr></tbody></table>


# 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). 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) 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.


# Retrieve details for creating cross-chain order

## Get Bridge Info

<mark style="color:green;">`GET`</mark> `https://api.paraswap.io/delta/prices/bridge-info`&#x20;

Returns info on supported source destination chains and destination tokens for cross-chain orders.

The data structure is a nested dictionary where the primary keys are `sourceChainId` values, and the secondary keys are `destinationChainId` values. Each combination of `sourceChainId` and `destinationChainId` maps to a list of supported token addresses on destination chain for cross-chain transactions.

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "supportedTokens": {
    "1": {
      "10": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
        "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
        "0x68f180fcCe6836688e9084f035309E29Bf0A2095",
        "0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea",
        "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
        "0xFE8B128bA8C78aabC59d4c64cEE7fF28e9379921",
        "0xFf733b2A3557a7ed6697007ab5D11B79FdD1b76B",
        "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",
        "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4",
        "0x395Ae52bB17aef68C2888d941736A71dC6d4e125"
      ],
      "137": [
        "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
        "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
        "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
        "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
        "0x3066818837c5e6eD6601bd5a91B0762877A6B731",
        "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
        "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3",
        "0xF328b73B6c685831F238c30a23Fc19140CB4D8FC",
        "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
        "0x25788a1a171ec66Da6502f9975a15B609fF54CF6"
      ],
      "324": [
        "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4",
        "0xBBeB516fb02a01611cBBE0453Fe3c580D7281011",
        "0x4B9eb6c0b6ea15176BBF62841C6B2A8a398cb656",
        "0x493257fD37EDB34451f62EDf8D2a0C418852bA4C"
      ],
      "480": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x79A02482A880bCE3F13e09Da970dC34db4CD24d1",
        "0x03C7054BCB39f7b2e5B2c7AcB37583e32D70Cfa3",
        "0x7077C71B4AF70737a08287E279B717Dcf64fdC57"
      ],
      "690": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ],
      "1135": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x03C7054BCB39f7b2e5B2c7AcB37583e32D70Cfa3",
        "0x05D032ac25d322df992303dCa074EE7392C117b9",
        "0xac485391EB2d7D88253a7F1eF18C37f4242D1A24"
      ],
      "8453": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
        "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
        "0x4158734D47Fc9692176B5085E0F52ee0Da5d47F1",
        "0xd652C5425aea2Afd5fb142e120FeCf79e18fafc3"
      ],
      "34443": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0xd988097fb8612cc24eeC14542bC03424c656005f",
        "0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF",
        "0xf0F161fDA2712DB8b566946122a5af183995e2eD"
      ],
      "41455": [
        "0xB3f0eE446723f4258862D949B4c9688e7e7d35d3",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0xD648529D4803d3467bA8850577BEd4e4b8Ae583C"
      ],
      "42161": [
        "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
        "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
        "0xd693Ec944A85eeca4247eC1c3b130DCa9B0C3b22",
        "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
        "0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8",
        "0x53691596d1BCe8CEa565b84d4915e69e03d9C99d",
        "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
        "0xCF934E2402A5e072928a39a956964eb8F2B5B79C"
      ]
    },
    "8453": {
      "1": [
        "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x6B175474E89094C44Da98b954EedeAC495271d0F",
        "0xba100000625a3754423978a60c9317c58a424e3D",
        "0x0cEC1A9154Ff802e7934Fc916Ed7Ca50bDE6844e"
      ],
      "10": [
        "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
        "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
        "0xFE8B128bA8C78aabC59d4c64cEE7fF28e9379921",
        "0x395Ae52bB17aef68C2888d941736A71dC6d4e125"
      ],
      "137": [
        "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
        "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
        "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
        "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
        "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3",
        "0x25788a1a171ec66Da6502f9975a15B609fF54CF6"
      ],
      "324": [
        "0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4",
        "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x4B9eb6c0b6ea15176BBF62841C6B2A8a398cb656"
      ],
      "480": [
        "0x79A02482A880bCE3F13e09Da970dC34db4CD24d1",
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x7077C71B4AF70737a08287E279B717Dcf64fdC57"
      ],
      "690": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ],
      "1135": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ],
      "34443": [
        "0xd988097fb8612cc24eeC14542bC03424c656005f",
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ],
      "41455": [
        "0xB3f0eE446723f4258862D949B4c9688e7e7d35d3",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ],
      "42161": [
        "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
        "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
        "0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8",
        "0xCF934E2402A5e072928a39a956964eb8F2B5B79C"
      ],
      "57073": [
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ],
      "59144": [
        "0x176211869cA2b568f2A7D4EE941E073a821EE1ff",
        "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5"
      ],
      "81457": [
        "0x4300000000000000000000000000000000000004",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x4300000000000000000000000000000000000003"
      ],
      "534352": [
        "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
        "0x5300000000000000000000000000000000000004",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0xF9Af83FC41e0cc2af2fba93644D542Df6eA0F2b7"
      ],
      "7777777": [
        "0xCccCCccc7021b32EBb4e8C08314bD62F7c653EC4",
        "0x4200000000000000000000000000000000000006",
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}


# Build a Delta Order to Sign

## Build a Delta Order to Sign

<mark style="color:blue;">`POST`</mark> `https://api.paraswap.io/delta/orders/build`

This section explains how to construct a Delta Order, which is essential for executing trades using the Velora Delta API. The /orders/build endpoint retrieves a Delta price and allows fallback to market prices.

A successfully built order includes a structured object ready for signing.

Common errors include validation failures, unsupported assets, and signature mismatches.

Use this guide to generate a Delta Order and prepare it for signing before submission.

#### Request Body Parameters

<table><thead><tr><th width="170">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>price<mark style="color:red;">*</mark></td><td>DeltaPrice</td><td>The <code>delta</code> object retrieved from <code>/quote</code> <a href="/pages/K690HWhFH6b7Yws9p0Sv#mode-delta-200-successful-response">endpoint</a>.</td></tr><tr><td>chainId<mark style="color:red;">*</mark></td><td>number</td><td>Chain ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100).</td></tr><tr><td>owner<mark style="color:red;">*</mark></td><td>string</td><td>Order owner address.</td></tr><tr><td>bridge</td><td>DeltaBridge</td><td>Required only for cross-chain orders. See below for details</td></tr><tr><td>beneficiary</td><td>string</td><td>Order beneficiary. Default: <code>zero address</code>, meaning owner address.</td></tr><tr><td>slippage</td><td>number</td><td>Slippage in base points (<code>100</code> is <code>1%</code>). Default: <code>100</code>.</td></tr><tr><td>deadline</td><td>number</td><td>Order expiry time as UNIX timestamp. Default: 1 hour from order creation.</td></tr><tr><td>nonce</td><td>string</td><td>Arbitrary <code>uint256</code> value to be used as order <code>nonce</code>. Default: <code>value generated with internal algos</code>. It is recommended to omit this param.</td></tr><tr><td>permit</td><td>string</td><td>Encoded permit to be used in order settlement. Supported permit types are described <a href="#supported-permits">here</a>. Default: <code>0x</code>.</td></tr><tr><td>partiallyFillable</td><td>boolean</td><td>If <code>true</code>, order will be generated as partially fillable. Default: <code>false.</code> </td></tr><tr><td>partnerAddress</td><td>string</td><td>Address of the partner. Used to collect fees from the order. Default: <code>zero address</code>.</td></tr><tr><td>partnerFeeBps</td><td>number</td><td>Partner fee percent in base points (<code>100</code> is <code>1%</code>). Max value is <code>200</code>. Default: <code>0</code>. </td></tr><tr><td>partnerTakesSurplus</td><td>boolean</td><td>If <code>true</code>, partner will collect <code>50%</code> of the order surplus instead of flat percent fee. Default: <code>false</code>.</td></tr></tbody></table>

`DeltaBridge` structure:

| Name               | Type   | Description                                                                                                                                                                                                                                                                                |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| protocolSelector   | string | Selector that indicates the bridge protocol used. Obtained from the price API                                                                                                                                                                                                              |
| destinationChainId | number | Destination chain ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100).                                                                                                                   |
| outputToken        | string | Output token on the destination chain. List of supported output tokens can be obtained from `/bridge-info` [endpoint](/api/velora-api/velora-delta-api/retrieve-details-for-creating-cross-chain-order#get-bridge-info). Output token can also be obtained from `price.bridge.outputToken` |
| scalingFactor      | number | Specifies difference between the decimals in source bridge token and destination token                                                                                                                                                                                                     |
| protocolData       | string | Protocol-specific data, obtained from pricing API                                                                                                                                                                                                                                          |

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

```json
{
  "toSign": {
    "domain": {
      "name": "Portikus",
      "version": "2.0.0",
      "chainId": 1,
      "verifyingContract": "0x0000000000bbf5c5fd284e657f01bd000933c96d"
    },
    "types": {
      "Order": [
        {
          "name": "owner",
          "type": "address"
        },
        {
          "name": "beneficiary",
          "type": "address"
        },
        {
          "name": "srcToken",
          "type": "address"
        },
        {
          "name": "destToken",
          "type": "address"
        },
        {
          "name": "srcAmount",
          "type": "uint256"
        },
        {
          "name": "destAmount",
          "type": "uint256"
        },
        {
          "name": "expectedAmount",
          "type": "uint256"
        },
        {
          "name": "deadline",
          "type": "uint256"
        },
        {
          "name": "kind",
          "type": "uint8"
        },
        {
          "name": "nonce",
          "type": "uint256"
        },
        {
          "name": "partnerAndFee",
          "type": "uint256"
        },
        {
          "name": "permit",
          "type": "bytes"
        },
        {
          "name": "metadata",
          "type": "bytes"
        },
        {
          "name": "bridge",
          "type": "Bridge"
        }
      ],
      "Bridge": [
        {
          "name": "protocolSelector",
          "type": "bytes4"
        },
        {
          "name": "destinationChainId",
          "type": "uint256"
        },
        {
          "name": "outputToken",
          "type": "address"
        },
        {
          "name": "scalingFactor",
          "type": "int8"
        },
        {
          "name": "protocolData",
          "type": "bytes"
        }
      ]
    },
    "value": {
      "owner": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "beneficiary": "0x0000000000000000000000000000000000000000",
      "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "destToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "srcAmount": "10000000",
      "destAmount": "9127760",
      "expectedAmount": "9219960",
      "deadline": 1757333024,
      "kind": 0,
      "nonce": "47551995136396664604384293391986507799897145387152361812735887931703330715323",
      "permit": "0x",
      "partnerAndFee": "0",
      "metadata": "0x",
      "bridge": {
        "protocolSelector": "0x21eaa4cd",
        "destinationChainId": 8453,
        "outputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
        "scalingFactor": 0,
        "protocolData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
      }
    }
  }
}
```

{% endtab %}

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

```json
{
    "errorType": "InvalidHmac",
    "details": "Invalid HMAC"
}
```

{% endtab %}
{% endtabs %}

#### Most common error types&#x20;

* `ValidationError` - validation for params failed
* `UnsupportedChain` - the chain ID is not supported by Delta.
* `UnsupportedToken` - the token is not supported by Delta.
* `InvalidHmac` - `hmac` check failed, meaning `price` object returned from `/quote` endpoint was mutated.

### Supported Permits

* `Permit(ERC-2612)` - expected to have 224 bytes length (owner, spender, value, deadline, v, r, s).
* `Permit2`
  * `TransferFrom` format - expected length is 96 bytes (32 for permitNonce, 64 for compact signature), amount and deadline should be the same as in `Order.`
  * `Allowance` format - expected length is 192 bytes.
* `DAI Style Permit` - expected length is 256 bytes.
* `0x01` - special `permit` value that signifies existing `Permit2` allowance.

[Delta Contract](/api/velora-api/velora-delta-api/contracts) should be specified as a spender is a permit.

## Sign an Order

Once the Delta Order is built, it must be signed using the EIP-712 standard before submission. This section provides a working example using ethers.js and axios.

Example:

```typescript
import { ethers, TypedDataEncoder } from "ethers"; // ethers V6
import axios from "axios";

const userWallet = new ethers.Wallet(ethers.id("alice"));
const userAddress = userWallet.address;
const chainId = 1;
// fetch price
const { data: quoteData } = await axios.get("https://api.paraswap.io/quote?mode=delta&...");
const price = quoteData.delta;
// prepare build order params
const buildOrderParams = {
    price,
    owner: userAddress,
    chainId,
    partnerAddress: "0x81037e7be71bce9591de0c54bb485ad3e048b8de",
    partnerFeeBps: 100, // 1%
    partnerTakesSurplus: false, // the default
};
// build the order to sign
const { data: buildOrderData } = await axios.post("https://api.paraswap.io/delta/orders/build", buildOrderParams);
const { domain, types, value: order } = buildOrderData.toSign;
// hash the order
const eip712Hash = TypedDataEncoder.hash(
  domain,
  types,
  order,
);
// sign and compact
const signature = userWallet.signingKey.sign(typedHash).compactSerialized; // ERC-2098 representation
```

## Sign an order (cross-chain)

The following snippet provides an example implementation of constructing the `DeltaBridge` structure for the cross-chain swap

```typescript
import { ethers, TypedDataEncoder } from "ethers"; // ethers V6
import axios from "axios";

const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; // same across all chains
const USDC_ADDRESS_ETH = "0xA0b86991c6218b36c1d19D4a2e9EB0CE3606EB48"; // USDC on Ethereum
const WETH_ADDRESS_OP = "0x4200000000000000000000000000000000000006";

const userWallet = new ethers.Wallet(ethers.id("alice"));
const userAddress = userWallet.address;
const srcChainId = 1;
const destChainId = 10;


const buildAndSignOrder = async (
	srcToken: string,
	srcDecimals: number,
	// dest token on destination chain
	destToken: string,
	destDecimals: number,
	srcChainId: number,
	destChainId: number,
	amount: number,
) => {
	const { data: quoteData } = await axios.get(`https://api.paraswap.io/quote`, {
		params: {
			mode: "delta",
			srcToken,
			srcDecimals,
			destToken,
			destDecimals,
			chainId: srcChainId,
			destChainId,
			amount,
		},
	});

	const price = quoteData.delta;

	// prepare build order params
	const buildOrderParams = {
		price,
		owner: userAddress,
		chainId: srcChainId,
		partnerAddress: "0x81037e7be71bce9591de0c54bb485ad3e048b8de",
		partnerFeeBps: 100, // 1%
		partnerTakesSurplus: false, // the default,
		bridge: price.bridge,
	};
	// build the order to sign
	const { data: buildOrderData } = await axios.post(
		"https://api.paraswap.io/delta/orders/build",
		buildOrderParams,
	);
	const { domain, types, value: order } = buildOrderData.toSign;
	// hash the order
	const eip712Hash = TypedDataEncoder.hash(domain, types, order);
	// sign and compact
	const signature = userWallet.signingKey.sign(eip712Hash).compactSerialized; // ERC-2098 representation

	return { order, signature };
};

// swap 1 USDC on Mainnet to WETH on Optimism
const order = await buildAndSignOrder(
	USDC_ADDRESS_ETH,
	6,
	WETH_ADDRESS_OP,
	18,
	srcChainId,
	destChainId,
	10 ** 18,
);


```

## Partner Fees

{% hint style="info" %}
This is just technical explanation. If you are using our [Order Building](#build-a-delta-order-to-sign) endpoint, this knowledge is not required.
{% endhint %}

The fees are enabled by encoding `partnerAndFee` param of the order, before its signed by a user.

The param includes three values:

* `partnerAddress` - on-chain address which will be able to collect the fees.
* `partnerFeeBps` - flat fee percent which will be taken from the order. The value is in **base points** (`100`is `1%`), which the maximum allowed value of `200`.
* `partnerTakeSurplus` - a flag that, if set, allows the partner to collect `50%` of the `surplus` as fees. It has no impact if passed together with `partnerFeeBps`, since `partnerFeeBps` takes precedence.

These are encoded into a single `uint256` value, which then is used as `partnerAndFee`.


# Submit a Delta Order

## Submit Delta Order for Auction

<mark style="color:blue;">`POST`</mark> `https://api.paraswap.io/delta/orders`

The **Submit Delta Order for Auction** endpoint allows you to submit a Delta order to be auctioned on Velora Delta. This enables decentralized and efficient execution of large token swaps through the Delta smart contract.

By sending a properly formatted request, you can specify order details such as the source and destination tokens, amounts, deadline, and additional parameters required for execution.

Use this endpoint to initiate a Delta auction order and optimize your trade execution on the Velora Delta network.

#### Request Body Params

<table><thead><tr><th width="252">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>order<mark style="color:red;">*</mark></td><td>Order</td><td>The <a href="/pages/QRAOD1DNcP9Vk06NEAGf">built</a> order to be submitted. </td></tr><tr><td>signature<mark style="color:red;">*</mark></td><td>string</td><td>Signature of the order from <code>order.owner</code> address. EOA signatures must be submitted in ERC-2098 Compact Representation. </td></tr><tr><td>chainId<mark style="color:red;">*</mark></td><td>string</td><td>Chain ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100).</td></tr><tr><td>type</td><td>MARKET | LIMIT</td><td>Indicates order type.  Defaults to <code>MARKET</code>. Used for filtering only</td></tr><tr><td>partiallyFillable</td><td>boolean</td><td>Allow the order to be filled in parts. Default: <code>false</code></td></tr><tr><td>partner</td><td>string</td><td>Partner string.</td></tr><tr><td>includeAgents</td><td>string[]</td><td>List of agent names to include. If not provided, all the agents are included</td></tr><tr><td>excludeAgents</td><td>string[]</td><td>List of agent names to exclude. If not provided, none of the agents are excluded</td></tr><tr><td>referrerAddress</td><td>string</td><td>Referrer address</td></tr></tbody></table>

**Example Responses:**

The first example response indicates a **successful order submission** because it includes an `id, orderHash, status`, and other relevant order details. The `status` is `"NOT_STARTED"`, meaning the order has been created but not yet processed.

The second response, `{ "error": "Validation failed with error" }`, indicates a **failed submission** due to a validation issue, likely caused by missing or incorrect parameters in the request.

{% tabs %}
{% tab title="200 Successful Create Order Response." %}

```json
{
  "id": "57165af8-eee8-408e-b8e8-86cc7f5c9f5c",
  "auctionOrderId": "e4579d19-e4b9-4fa1-87f3-edcf6c002a3b",
  "deltaVersion": "2.0",
  "user": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
  "signature": "0xd3696d88ae37871f79356a8cc5fee465a6cf514e7e875a6e4e004caac16079f69d03023d2deecbaf8e11fd300572b25dd9a7669986e8c6dbbb712f489071ce23",
  "status": "NOT_STARTED",
  "bridgeStatus": null,
  "order": {
    "owner": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
    "beneficiary": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
    "srcToken": "0x4200000000000000000000000000000000000006",
    "destToken": "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
    "srcAmount": "500000000000000",
    "destAmount": "2140607",
    "expectedAmount": "2151364",
    "kind": 0,
    "metadata": "0x",
    "deadline": 1757371581,
    "nonce": "1757367983280",
    "partnerAndFee": "90631063861114836560958097440945986548822432573276877133894239693005947666432",
    "permit": "0x",
    "bridge": {
      "protocolSelector": "0x21eaa4cd",
      "destinationChainId": 10,
      "outputToken": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
      "scalingFactor": 0,
      "protocolData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001490"
    }
  },
  "bridgeMetadata": null,
  "orderVersion": "2.0.0",
  "orderHash": "0x079ea5b71361f8140259f8cf3844f7a29bb310c1cf8f8688bb5e9f40a688efcd",
  "partiallyFillable": false,
  "chainId": 8453,
  "type": "MARKET",
  "partner": "paraswap.io",
  "referrerAddress": null,
  "includeAgents": null,
  "excludeAgents": null,
  "bridgeProtocol": "ACROSS",
  "deltaGasOverhead": 185712,
  "expiresAt": "2025-09-08T22:46:21.000Z",
  "createdAt": "2025-09-08T21:46:40.398Z",
  "updatedAt": "2025-09-08T21:46:40.398Z"
}
```

{% endtab %}

{% tab title="400 Get Action Error" %}

```
{
  "error": "Validation failed with error"
}
```

{% endtab %}
{% endtabs %}


# Cancel a Delta Order

To cancel orders, you can use the `/cancel` endpoint provided by the API, which would remove the orders from the order book. The signature is an EIP-712 signature, built with the following structure. Both `LIMIT` and `MARKET` orders can be canceled.

<table><thead><tr><th></th><th></th></tr></thead><tbody><tr><td>domain</td><td><pre><code>{
  "name": "Portikus",
  "version": "2.0.0",
  "chainId": &#x3C;chainId>,
  "verifyingContract": &#x3C;deltaAddress>
}
</code></pre></td></tr><tr><td>type</td><td><pre><code>{
  "OrderCancellations": [
    {
      "name": "orderIds",
      "type": "string[]",
    }
  ]
}
</code></pre></td></tr><tr><td>value</td><td><pre><code>{
  "orderIds": [&#x3C;id1>, &#x3C;id2>]
}
</code></pre></td></tr></tbody></table>

<mark style="color:green;">`POST`</mark> `https://api.paraswap.io/delta/orders/cancel`

**Body**

| Name        | Type      | Description                                          |
| ----------- | --------- | ---------------------------------------------------- |
| `orderIds`  | string\[] | Order IDs to cancel                                  |
| `signature` | string    | EIP-712 signature with the structure described above |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "errorType": "OrderCancellationError",
  "details": "Order not found"
}
```

{% endtab %}
{% endtabs %}

Upon successful cancellation, the API will return a confirmation message indicating that the limit order has been successfully cancelled.


# Track Delta Order Status

## Get Delta Order Auction Status

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

This endpoint enables users to retrieve real-time details of a specific auction, ensuring transparency and efficient execution monitoring.

{% tabs %}
{% tab title="200 Successful Get Order Response." %}

```json
{
  "id": "57165af8-eee8-408e-b8e8-86cc7f5c9f5c",
  "deltaVersion": "2.0",
  "status": "EXECUTED",
  "user": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
  "order": {
    "owner": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
    "beneficiary": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
    "srcToken": "0x4200000000000000000000000000000000000006",
    "destToken": "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
    "srcAmount": "500000000000000",
    "destAmount": "2140607",
    "expectedAmount": "2151364",
    "kind": 0,
    "metadata": "0x",
    "deadline": 1757371581,
    "nonce": "1757367983280",
    "partnerAndFee": "90631063861114836560958097440945986548822432573276877133894239693005947666432",
    "permit": "0x",
    "bridge": {
      "protocolSelector": "0x21eaa4cd",
      "destinationChainId": 10,
      "outputToken": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
      "scalingFactor": 0,
      "protocolData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001490"
    }
  },
  "orderHash": "0x079ea5b71361f8140259f8cf3844f7a29bb310c1cf8f8688bb5e9f40a688efcd",
  "chainId": 8453,
  "partner": "paraswap.io",
  "expiresAt": "2025-09-08T22:46:21.000Z",
  "createdAt": "2025-09-08T21:46:40.398Z",
  "updatedAt": "2025-09-08T21:47:10.977Z",
  "partiallyFillable": false,
  "includeAgents": null,
  "excludeAgents": null,
  "bridgeMetadata": {
    "depositId": 4598367,
    "fillDeadline": 1757379701,
    "outputAmount": "2148676",
    "fillTx": "0x0043cf3ae9f69c6cc7098b4a5bc6454af90067a1a7c553900d20a2afe5dcf8e3"
  },
  "bridgeStatus": "filled",
  "referrerAddress": null,
  "type": "MARKET",
  "transactions": [
    {
      "id": "d7e43ea0-5254-4330-9e96-cb55b54ee546",
      "hash": "0x0cdd73270941d1a366c34340a2b77a51f56cc3b445f4a9f268fd12af9d6c16a7",
      "blockNumber": 35289330,
      "blockHash": "0xf141d321f442494a3caaeeb069ec58ce1de5ef17827841ae6d569334dcf0aef9",
      "gasUsed": 276385,
      "gasPrice": 2999412,
      "blobGasUsed": 0,
      "blobGasPrice": 0,
      "index": 155,
      "status": 1,
      "from": "0x2e5ef37ade8afb712b8be858fec7389fe32857e2",
      "to": "0x0000000000bbf5c5fd284e657f01bd000933c96d",
      "receivedAmount": "2152016",
      "receivedAmountUSD": 2.15,
      "spentAmount": "500000000000000",
      "spentAmountUSD": 2.16,
      "filledPercent": 10000,
      "protocolFee": "651",
      "partnerFee": "0",
      "agent": "laita",
      "orderId": "57165af8-eee8-408e-b8e8-86cc7f5c9f5c",
      "bidId": "2081f754-9c72-4243-8557-9f3b9d6c90f6"
    }
  ]
}

```

{% endtab %}

{% tab title="400 Get Order Error" %}

```
{
  "error": "Validation failed with error"
}
```

{% endtab %}
{% endtabs %}

Available order statuses (`status` property)

| Status                  | Description                                                                                                                                                                                                                                                                                                                                                                                           |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| NOT\_STARTED            | The initial state of an order when it enters the system. Orders in this state are waiting to be included in a batch auction. Orders that failed execution may also be reset to this state to retry.                                                                                                                                                                                                   |
| RUNNING                 | Orders that are actively being considered for execution in the current batch auction.                                                                                                                                                                                                                                                                                                                 |
| EXECUTING               | Orders that have been assigned to a winning agent who has been notified to execute them. This status indicates that on-chain execution is in progress. Orders remain in this state untiltransaction confirmation or timeout.                                                                                                                                                                          |
| INSUFFICIENT\_BALANCE   | This state indicates that an order has insufficient token balance during secondary validation. This happens when a user's token balance drops below the required amount after the initial validation. Since this is a non-terminal status, the system will periodically recheck the balance, allowing the order to proceed to auction if the user adds sufficient funds.                              |
| INSUFFICIENT\_ALLOWANCE | This state indicates that an order has insufficient token allowance during secondary validation. This occurs when a user's approval for the Delta contract is reduced or revoked after initial validation. Since this is a non-terminal status, the system will periodically recheck the allowance, allowing the order to proceed if the user reinstates or increases the approval.                   |
| INVALIDATED             | A terminal status indicating that an order has failed secondary validation before being included in an auction. This happens when orders undergo re-validation after initial posting but before auction inclusion. Orders may be invalidated due to changed conditions since initial validation, for example nonce was invalidated because other order with the same nonce has already been executed. |
| EXECUTED                | A terminal state indicating that the order has been successfully executed on-chain.                                                                                                                                                                                                                                                                                                                   |
| FAILED                  | A terminal state indicating that the order failed execution after multiple retry attempts.                                                                                                                                                                                                                                                                                                            |
| EXPIRED                 | A terminal state indicating that the order's deadline has passed without successful execution.                                                                                                                                                                                                                                                                                                        |

Available bridge statuses (`bridgeStatus` property, set only for cross-chain orders, `null` for same-chain orders).

| status   | Description                                                                                                                                                                                                                         |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| PENDING  | The initial status for a bridged order after execution on the source chain. Indicates that the transaction has been successfully executed on the source chain, but hasn't been bridged yet.                                         |
| FILLED   | A terminal state indicating that the order has been filled on the destination chain. `fillTx` property in `bridgeMetadata` becomes available.                                                                                       |
| REFUNDED | A terminal state indicating that the order has been refunded on the source chain. The refunded token would be the one that was sent to bridge after the swap. `depositRefundTxHash` property in `bridgeMetadata` becomes available. |

## Get Delta Orders for a User

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

The Get Delta Orders for a User endpoint allows integrators to fetch all orders associated with a specific address, making it invaluable for dashboards, trade history tracking, and compliance purposes.

#### Query Parameters

<table><thead><tr><th width="299">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>userAddress<mark style="color:red;">*</mark></td><td>string</td><td>User Address. </td></tr><tr><td>chainId</td><td>string[]</td><td>Comma-separated list of chain ids (e.g. <code>chainId=1,8453</code></td></tr><tr><td>page</td><td>integer</td><td>Default: <code>1</code>.</td></tr><tr><td>limit</td><td>integer</td><td>Default: <code>100</code>.</td></tr><tr><td>type</td><td><code>LIMIT | MARKET</code> </td><td>Filters orders by types. </td></tr><tr><td>status</td><td><code>OrderStatus[]</code> </td><td>Comma-separated list of statuses described above. Other possible values are:<br>- <code>ACTIVE</code> - any non-terminal status from the list above<br>- <code>INACTIVE</code> - any terminal status from the list above <br>- <code>SUSPENDED</code> - orders that are suspended, but might be executed in future (<code>INSUFFICIENT_BALANCE</code>/<code>INSUFFICIENT_ALLOWANCE</code> statuses)</td></tr></tbody></table>

{% tabs %}
{% tab title="200 Successful Get Auction Response." %}

```json
[
  {
    "id": "57165af8-eee8-408e-b8e8-86cc7f5c9f5c",
    "deltaVersion": "2.0",
    "user": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
    "status": "EXECUTED",
    "order": {
      "owner": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
      "beneficiary": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
      "srcToken": "0x4200000000000000000000000000000000000006",
      "destToken": "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
      "srcAmount": "500000000000000",
      "destAmount": "2140607",
      "expectedAmount": "2151364",
      "kind": 0,
      "metadata": "0x",
      "deadline": 1757371581,
      "nonce": "1757367983280",
      "partnerAndFee": "90631063861114836560958097440945986548822432573276877133894239693005947666432",
      "permit": "0x",
      "bridge": {
        "protocolSelector": "0x21eaa4cd",
        "destinationChainId": 10,
        "outputToken": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
        "scalingFactor": 0,
        "protocolData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001490"
      }
    },
    "partiallyFillable": false,
    "orderHash": "0x079ea5b71361f8140259f8cf3844f7a29bb310c1cf8f8688bb5e9f40a688efcd",
    "chainId": 8453,
    "partner": "paraswap.io",
    "expiresAt": "2025-09-08T22:46:21.000Z",
    "createdAt": "2025-09-08T21:46:40.398Z",
    "updatedAt": "2025-09-08T21:47:10.977Z",
    "includeAgents": null,
    "excludeAgents": null,
    "bridgeMetadata": {
      "depositId": 4598367,
      "fillDeadline": 1757379701,
      "outputAmount": "2148676",
      "fillTx": "0x0043cf3ae9f69c6cc7098b4a5bc6454af90067a1a7c553900d20a2afe5dcf8e3"
    },
    "bridgeStatus": "filled",
    "referrerAddress": null,
    "type": "MARKET",
    "transactions": [
      {
        "id": "d7e43ea0-5254-4330-9e96-cb55b54ee546",
        "hash": "0x0cdd73270941d1a366c34340a2b77a51f56cc3b445f4a9f268fd12af9d6c16a7",
        "blockNumber": 35289330,
        "blockHash": "0xf141d321f442494a3caaeeb069ec58ce1de5ef17827841ae6d569334dcf0aef9",
        "gasUsed": 276385,
        "gasPrice": 2999412,
        "blobGasUsed": 0,
        "blobGasPrice": 0,
        "index": 155,
        "status": 1,
        "from": "0x2e5ef37ade8afb712b8be858fec7389fe32857e2",
        "to": "0x0000000000bbf5c5fd284e657f01bd000933c96d",
        "receivedAmount": "2152016",
        "receivedAmountUSD": 2.15,
        "spentAmount": "500000000000000",
        "spentAmountUSD": 2.16,
        "filledPercent": 10000,
        "protocolFee": "651",
        "partnerFee": "0",
        "agent": "laita",
        "orderId": "57165af8-eee8-408e-b8e8-86cc7f5c9f5c",
        "bidId": "2081f754-9c72-4243-8557-9f3b9d6c90f6"
      }
    ]
  },
  {
    "id": "7e6b0bf4-4b71-4b93-bd84-a6dac8d2911a",
    "deltaVersion": "2.0",
    "user": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
    "status": "EXECUTED",
    "order": {
      "owner": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
      "beneficiary": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
      "srcToken": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
      "destToken": "0x4200000000000000000000000000000000000006",
      "srcAmount": "6505099",
      "destAmount": "1491804070300740",
      "expectedAmount": "1499300573166573",
      "kind": 0,
      "metadata": "0x",
      "deadline": 1757085896,
      "nonce": "1757082301370",
      "partnerAndFee": "90631063861114836560958097440945986548822432573276877133894239693005947666432",
      "permit": "0x000000000000000000000000b0326588271f2531fbfc9a13d52d3da45be1d9560000000000000000000000000000000000bbf5c5fd284e657f01bd000933c96d000000000000000000000000000000000000000000000000000000000063428b0000000000000000000000000000000000000000000000000000000068bee73a000000000000000000000000000000000000000000000000000000000000001bf7e752fbd74f7e10cb3457fe444e4c9f33f0d339a6dd86f44ef7fae93ff630415610f6dd6997d3771e19f5864988c68be8e00a737efa950481412c3427af1b37",
      "bridge": {
        "protocolSelector": "0x21eaa4cd",
        "destinationChainId": 8453,
        "outputToken": "0x4200000000000000000000000000000000000006",
        "scalingFactor": 0,
        "protocolData": "0x000000000000000000000000924a9f036260ddd5808007e1aa95f08ed08aa56900000000000000000000000000000000000000000000000000000021864c4f46"
      }
    },
    "partiallyFillable": false,
    "orderHash": "0x1b07c0e7e7a98ec8e4d391b112465ad3343bd6b8cb420aa6a0d2e203ba3a5b96",
    "chainId": 10,
    "partner": "paraswap.io",
    "expiresAt": "2025-09-05T15:24:56.000Z",
    "createdAt": "2025-09-05T14:25:11.292Z",
    "updatedAt": "2025-09-05T14:25:43.733Z",
    "includeAgents": null,
    "excludeAgents": null,
    "bridgeMetadata": {
      "depositId": 3383355,
      "fillDeadline": 1757094011,
      "outputAmount": "1499413876136046",
      "fillTx": "0x84da86fd9449a2b8a4d2b6914879cc1ccc5267ec58696560b58f46c97655eb1c"
    },
    "bridgeStatus": "filled",
    "referrerAddress": null,
    "type": "MARKET",
    "transactions": [
      {
        "id": "d6efdcd5-d169-46f8-bfef-206d818ac483",
        "hash": "0xa1c0d6ac1d1f9ba354ac034b4c780f01a23a183d66e957daa486b13afc216855",
        "blockNumber": 140741769,
        "blockHash": "0x5cb55e493165cf1e7a2cce2349a700bcbabd7b9daf25aaed6528485bf38779bf",
        "gasUsed": 362017,
        "gasPrice": 1101208,
        "blobGasUsed": 0,
        "blobGasPrice": 0,
        "index": 15,
        "status": 1,
        "from": "0x2e5ef37ade8afb712b8be858fec7389fe32857e2",
        "to": "0x0000000000bbf5c5fd284e657f01bd000933c96d",
        "receivedAmount": "1499557863204788",
        "receivedAmountUSD": 6.52,
        "spentAmount": "6505099",
        "spentAmountUSD": 6.5,
        "filledPercent": 10000,
        "protocolFee": "257290038215",
        "partnerFee": "0",
        "agent": "laita",
        "orderId": "7e6b0bf4-4b71-4b93-bd84-a6dac8d2911a",
        "bidId": "b992925a-54a9-48bc-9dfd-cd159cd60d5f"
      }
    ]
  },
  {
    "id": "45545c6a-a657-48f3-b3ce-c3e9be2316d0",
    "deltaVersion": "2.0",
    "user": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
    "status": "EXECUTED",
    "order": {
      "owner": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
      "beneficiary": "0xb0326588271f2531fbfc9a13d52d3da45be1d956",
      "srcToken": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
      "destToken": "0x4200000000000000000000000000000000000006",
      "srcAmount": "2196554",
      "destAmount": "488746921607604",
      "expectedAmount": "491202936289050",
      "kind": 0,
      "metadata": "0x",
      "deadline": 1757082771,
      "nonce": "1757079183686",
      "partnerAndFee": "90631063861114836560958097440945986548822432573276877133894239693005947666432",
      "permit": "0x000000000000000000000000b0326588271f2531fbfc9a13d52d3da45be1d9560000000000000000000000000000000000bbf5c5fd284e657f01bd000933c96d000000000000000000000000000000000000000000000000000000000021844a0000000000000000000000000000000000000000000000000000000068bedb06000000000000000000000000000000000000000000000000000000000000001c4675562642981eb04e9858348310ff987d90c3a7ec562401c9fe6c1bc3911be127f10f1fcf57b7d4a68e094bf368ee328d6f1016ead6af2fdb40e4bad238e999",
      "bridge": {
        "protocolSelector": "0x21eaa4cd",
        "destinationChainId": 8453,
        "outputToken": "0x4200000000000000000000000000000000000006",
        "scalingFactor": 0,
        "protocolData": "0x000000000000000000000000924a9f036260ddd5808007e1aa95f08ed08aa5690000000000000000000000000000000000000000000000000000000afbbe917c"
      }
    },
    "partiallyFillable": false,
    "orderHash": "0xcdc9843d583ac27251090548f8c697f3a2dd3593282da26fcdca857acb743ecc",
    "chainId": 10,
    "partner": "paraswap.io",
    "expiresAt": "2025-09-05T14:32:51.000Z",
    "createdAt": "2025-09-05T13:33:14.493Z",
    "updatedAt": "2025-09-05T13:44:43.679Z",
    "includeAgents": null,
    "excludeAgents": null,
    "bridgeMetadata": {
      "depositId": 3383287,
      "fillDeadline": 1757090893,
      "outputAmount": "490189613478551",
      "fillTx": "0xe018e615c93abb6d16613d28a860476459c0d077559ac7699a18b1cc6b9f5bc5"
    },
    "bridgeStatus": "filled",
    "referrerAddress": null,
    "type": "MARKET",
    "transactions": [
      {
        "id": "37370696-5f9d-4c55-b1ad-8af4fc06bbe9",
        "hash": "0x9d68335c7350c9f70bfd67bb74240fa99eed8a5c335029a704720f8384627bfd",
        "blockNumber": 140740211,
        "blockHash": "0xaf50d44ca9473c7ceef1e1ddbc7afa9ec0694c3a3366913422cab498c9856d49",
        "gasUsed": 423252,
        "gasPrice": 1101096,
        "blobGasUsed": 0,
        "blobGasPrice": 0,
        "index": 5,
        "status": 1,
        "from": "0x2e5ef37ade8afb712b8be858fec7389fe32857e2",
        "to": "0x0000000000bbf5c5fd284e657f01bd000933c96d",
        "receivedAmount": "490236786721811",
        "receivedAmountUSD": 2.19,
        "spentAmount": "2196554",
        "spentAmountUSD": 2.2,
        "filledPercent": 10000,
        "protocolFee": "0",
        "partnerFee": "0",
        "agent": "laita",
        "orderId": "45545c6a-a657-48f3-b3ce-c3e9be2316d0",
        "bidId": "dd4b8cb4-ece4-4718-a133-fdc5045790b0"
      }
    ]
  }
]
```

{% endtab %}

{% tab title="400 Get Orders Error" %}

```
{
  "error": "Validation failed with error"
}
```

{% endtab %}
{% endtabs %}

#### Most common error messages

These are the two most common messages when using this endpoint.

* `ValidationError` - validation for params failed
* `UnsupportedChain` - the chain ID is not supported by Delta.

To avoid running into `ValidationError` and `UnsupportedChain` errors when using this endpoint, here are some recommendations:

#### **Avoiding `ValidationError`**

1. **Check Required Parameters**: Ensure all mandatory parameters are included in your request. Missing or incorrectly formatted fields often trigger this error.
2. **Validate Data Types**: Confirm that parameters match the expected types (e.g., numbers vs. strings, correct JSON structure).
3. **Follow API Documentation**: Double-check the expected format for each parameter in the official API documentation.

#### **Avoiding `UnsupportedChain`**

1. **Verify Supported Chains**: Check the API documentation or a dedicated "supported chains" endpoint to ensure the chain ID is compatible with Delta.
2. **Use Correct Chain IDs**: Some APIs require chain IDs in decimal format, while others expect hex. Ensure you’re using the correct format.


# Example: Quote With Fallback

This example shows an implementation for token swapping using the Velora API, particularly focusing on getting a quote for a token swap and handling both Delta pricing and a fallback to market pricing when Delta fails.

{% hint style="info" %}
We recommend using [Velora SDK](https://github.com/paraswap/paraswap-sdk) for better developer experience. You can find SDK example of the exact functionality of this code [here](https://github.com/paraswap/paraswap-sdk/blob/master/src/examples/simpleQuote.ts).
{% endhint %}

Example:

```typescript
import axios from 'axios';
import { ethers } from 'ethers';

const API_URL = "https://api.paraswap.io";

const chainId = 1; // Mainnet
const DAI_TOKEN = '0x6b175474e89094c44da98b954eedeac495271d0f';
const PSP_TOKEN = '0xcafe001067cdef266afb7eb5a286dcfd277f3de5';

async function quoteWithFallback() {
  // @ts-expect-error assume window.ethereum is available
  const ethersProvider = new ethers.providers.Web3Provider(window.ethereum);

  const accounts = await ethersProvider.listAccounts();
  const account = accounts[0]!;
  const signer = ethersProvider.getSigner(account);

  const amount = '100000000000000000000'; // 100 DAI

  const { data: quote } = await axios.get(`${API_URL}/quote`, {
    params: {
      chainId,
      srcToken: DAI_TOKEN,
      destToken: PSP_TOKEN,
      amount,
      userAddress: account,
      srcDecimals: 18,
      destDecimals: 18,
      mode: 'all', // Delta quote if possible, with fallback to Market price
      side: 'SELL',
    },
  });

  if ('delta' in quote) {
    // Delta pricing is available - we can build and submit a order
    const price = quote.delta;
    
    // build order
    const { data: builtOrder } = await axios.post(`${API_URL}/orders/build`, {
      price,
      chainId,
      owner: account,
    });
    
    // sign the order
    const signature = signer.signTypedData(
      builtOrder.domain,
      builtOrder.types,
      builtOrder.value,
    );
    
    // compact the signature
    const compactSignature = ethers.Signature.from(signature).compactSerialized;

    // submit the order
    const { data: deltaAuction } = await axios.post(`${API_URL}/orders`, {
      order: builtOrder.value,
      signature: compactSignature,
      // partner: '...' // if available
    });

    // poll if necessary
    const { data: auction } = await axios.get(`${API_URL}/orders/${deltaAuction.id}`);
    if (auction?.status === 'EXECUTED') {
      console.log('Auction was executed');
    }
  } else {
    // Delta pricing failed - falling back to market
    console.log(
      `Delta Quote failed: ${quote.fallbackReason.errorType} - ${quote.fallbackReason.details}`
    );
    const priceRoute = quote.market;

    // build transaction params
    const { data: txParams } = await axios.post(`${API_URL}/transactions/${chainId}`, {
      srcToken: DAI_TOKEN,
      destToken: PSP_TOKEN,
      srcAmount: amount,
      slippage: 100, // 1%
      priceRoute,
      userAddress: account,
      // partner: '...' // if available
    });

    // submit the transaction
    const swapTx = await signer.sendTransaction(txParams);
  }
}
```

#### **Expected Behavior for Integrators:**

When executed, this script:

1. Connects to an **Ethereum wallet.**
2. Retrieves the **user's wallet address** and prepares to swap **100 DAI for PSP tokens** on **Ethereum Mainnet (Chain ID: 1)**.
3. Requests a **quote from Velora** with the `mode: "all"`, meaning it will prioritize **Delta pricing** but fall back to **market pricing** if Delta is unavailable.
4. If **Delta pricing is available**, the script:
   * Builds an **order** for execution.
   * **Signs the order** using EIP-712 structured signing.
   * **Submits the order** for execution through the Delta auction system.
   * Polls the order status to confirm whether it was executed.
5. If **Delta pricing is not available**, the script:
   * Logs the **reason** for the fallback.
   * Retrieves a **market price route** instead.
   * Builds a **transaction** using the market price.
   * **Submits the transaction** directly to the Ethereum network using the user's wallet.

This example ensures the swap execution is **optimized for efficiency** while providing a **fail-safe fallback** in case Delta pricing is unavailable. As a developer, you should expect a seamless experience for token swaps with automatic routing adjustments.


# Quote With Fallback

This example shows an implementation for token swapping using the [ParaSwap API](https://x.com/i/grok?text=ParaSwap%20API), particularly focusing on getting a quote for a token swap and handling both [Delta pricing](https://x.com/i/grok?text=Delta%20pricing) and a fallback to market pricing when Delta fails.

{% hint style="info" %}
We recommend using [Paraswap SDK](https://github.com/paraswap/paraswap-sdk) for better developer experience. You can find SDK example of the exact functionality of this code [here](https://github.com/paraswap/paraswap-sdk/blob/master/src/examples/simpleQuote.ts).
{% endhint %}

Example:

```typescript
import axios from 'axios';
import { ethers } from 'ethers';

const API_URL = "https://api.paraswap.io";

const chainId = 1; // Mainnet
const DAI_TOKEN = '0x6b175474e89094c44da98b954eedeac495271d0f';
const PSP_TOKEN = '0xcafe001067cdef266afb7eb5a286dcfd277f3de5';

async function quoteWithFallback() {
  // @ts-expect-error assume window.ethereum is available
  const ethersProvider = new ethers.providers.Web3Provider(window.ethereum);

  const accounts = await ethersProvider.listAccounts();
  const account = accounts[0]!;
  const signer = ethersProvider.getSigner(account);

  const amount = '100000000000000000000'; // 100 DAI

  const { data: quote } = await axios.get(`${API_URL}/quote`, {
    params: {
      chainId,
      srcToken: DAI_TOKEN,
      destToken: PSP_TOKEN,
      amount,
      userAddress: account,
      srcDecimals: 18,
      destDecimals: 18,
      mode: 'all', // Delta quote if possible, with fallback to Market price
      side: 'SELL',
    },
  });

  if ('delta' in quote) {
    // Delta pricing is available - we can build and submit a order
    const price = quote.delta;
    
    // build order
    const { data: builtOrder } = await axios.post(`${API_URL}/orders/build`, {
      price,
      chainId,
      owner: account,
    });
    
    // sign the order
    const signature = signer.signTypedData(
      builtOrder.domain,
      builtOrder.types,
      builtOrder.value,
    );
    
    // compact the signature
    const compactSignature = ethers.Signature.from(signature).compactSerialized;

    // submit the order
    const { data: deltaAuction } = await axios.post(`${API_URL}/orders`, {
      order: builtOrder.value,
      signature: compactSignature,
      // partner: '...' // if available
    });

    // poll if necessary
    const { data: auction } = await axios.get(`${API_URL}/orders/${deltaAuction.id}`);
    if (auction?.status === 'EXECUTED') {
      console.log('Auction was executed');
    }
  } else {
    // Delta pricing failed - falling back to market
    console.log(
      `Delta Quote failed: ${quote.fallbackReason.errorType} - ${quote.fallbackReason.details}`
    );
    const priceRoute = quote.market;

    // build transaction params
    const { data: txParams } = await axios.post(`${API_URL}/transactions/${chainId}`, {
      srcToken: DAI_TOKEN,
      destToken: PSP_TOKEN,
      srcAmount: amount,
      slippage: 100, // 1%
      priceRoute,
      userAddress: account,
      // partner: '...' // if available
    });

    // submit the transaction
    const swapTx = await signer.sendTransaction(txParams);
  }
}
```


# Velora Market API

In this guide, you'll explore the Velora Market API, its different versions, and the various actions it enables.&#x20;

Start by reading the Overview section to better understand how the Market API aggregates liquidity across multiple DEXs and AMMs to provide optimal trade execution.&#x20;

This guide will help you to:

* Leverage the API effectively.
* Retrieve a price and get the most optimal route for a trade.
* Build parameters for a transaction with the response from the prices endpoint.
* Find the optimal fee strategy for your integration.

|                                                                                           |
| :---------------------------------------------------------------------------------------: |
|                   [Overview](/api/velora-api/velora-market-api/overview)                  |
|                  [API versions](/api/velora-api/velora-market-api/master)                 |
|      [Retrieve a price](/api/velora-api/velora-market-api/get-rate-for-a-token-pair)      |
| [Build a transaction](/api/velora-api/velora-market-api/build-parameters-for-transaction) |
|   [Get Price & Calldata](/api/velora-api/velora-market-api/get-rate-for-a-token-pair-1)   |
|                   [Examples](/api/velora-api/velora-market-api/examples)                  |


# Overview

Velora Market API is the most straightforward and efficient way to access to the Velora Protocol. It connects your application to a vast network of liquidity sources guaranteeing optimal token swap rates across multiple blockchain networks.

To get started, we recommend familiarizing yourself with the available API versions to understand their unique features and differences. From there, dive into the various endpoints tailored for specific tasks, whether you need to fetch a price quote, construct a transaction, or streamline both processes using the all-in-one Swap endpoint.

You’ll also find a practical example to guide you through the implementation process, making it easier to integrate Velora into your application.

If you'd like to find the latest integrations, feel free to use [DexLib](https://github.com/paraswap/paraswap-dex-lib), our open-source library that contains all live and pending DEX integrations.


# API Versions

In this section you can find all the information related to Velora API available versions

Velora currently has two versions of its API available. It is highly recommended to integrate or upgrade to v6.2, the latest version of the Market API, to take full advantage of its latest innovations.

v6.2 introduces key enhancements, including gas optimizations and greater flexibility for partners in managing their fees.

<table data-card-size="large" data-view="cards"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center">API v6.2</td><td><a href="/pages/SW7QAU7hmhQzOX7Or5J6">/pages/SW7QAU7hmhQzOX7Or5J6</a></td></tr><tr><td align="center">API v5</td><td><a href="/pages/-MhY5V6Vze2tY1WuQ9dp">/pages/-MhY5V6Vze2tY1WuQ9dp</a></td></tr></tbody></table>

{% hint style="info" %}
Please note that as of the launch of v6.2, Velora no longer maintains v5.
{% endhint %}


# API v6.2

Introduction to Velora API v6.2

{% hint style="success" %}
Velora v6.2 has been released! See what's new here: <https://x.com/VeloraDEX/status/1803435422011498551>
{% endhint %}

{% hint style="info" %}
To switch to **v6.2**, you only need to pass `&version=6.2` to `/prices` & you're good to go!
{% endhint %}

Velora V6.2's main goal is to provide the best possible gas-optimized protocol for order routing. It has significant improvements in terms of smart contract architecture that achieve both best-in-class gas efficiency and scalability through modularity.&#x20;

To use V6.2, you need to pass `&version=6.2` query param when calling `/prices`.  The process for swapping remains the same:&#x20;

* Call `GET /prices` to retrieve an optimal price for a given pair & amount.
* Call `POST /transactions` for retrieving the[ Transaction Object](https://ethereum.org/en/developers/docs/transactions/) that includes the call data
* Alternatively, you can use GET `/swap` to retrieve both the price config & Transaction Object.

You can also use the JavaScript/TypeScript SDK for easier integrations: [Velora SDK](https://github.com/paraswap/paraswap-sdk)

[**Major changes in V6.2:**](#user-content-fn-1)[^1]

* No longer need to approve a different smart contract for ERC20 tokens. **Augustus V6.2 is the only contract you need to interact with**. More details [here](/augustus-swapper/augustus-v6.2-smart-contracts).
* More control over [partner fees](https://doc.paraswap.network/integrating-paraswap/integrating-paraswap-overview/paraswap-api-revenue-sharing): should you choose to take a surplus fee, you can cap it to 1% of the trade volume as protection for your users if it applies to your specific case. You can also send partner fees directly to the user. Take a look at the new params  (`isCapSurplus` , `isSurplusToUser` , `isDirectFeeTransfer`) params in  [/transactions](/api/velora-api/velora-market-api/build-parameters-for-transaction) section.
* Flat fees are capped at 2% as a security protection for users.&#x20;
* `excludeDirectContractMethods` is no longer supported in /prices. It has been replaced by `excludeContractMethodsWithoutFeeModel`, which ensures all swaps can be monetized.

### **Supported methods:**

&#x20; **SELL:**

* swapExactAmountIn
* swapExactAmountInOnUniswapV2
* swapExactAmountInOnUniswapV3
* swapExactAmountInOnBalancerV2
* swapExactAmountInOnCurveV1
* swapExactAmountInOnCurveV2
* swapOnAugustusRFQTryBatchFill
* swapExactAmountInOutOnMakerPSM

**BUY:**

* swapExactAmountOut
* swapExactAmountOutOnUniswapV2
* swapExactAmountOutOnUniswapV3
* swapExactAmountOutOnBalancerV2
* swapOnAugustusRFQTryBatchFill
* swapExactAmountInOutOnMakerPSM

[^1]:


# API v5

Introduction to Velora API version 5

{% hint style="warning" %}
Please note that as of the launch of v6.2, Velora no longer maintains v5.\
We recommend all v5 integrations to upgrade to v6.2.
{% endhint %}

Velora's goal is to deliver the best market prices by aggregating over multiple decentralized exchanges, market makers, and lending protocols.

Velora API allows users to fetch optimal prices to swap from one token to another and then build transaction data that can be used to execute transactions on-chain.  Currently, Velora only supports EVM-based networks (Ethereum, BSC, Polygon, etc) and tokens following ERC20 standard.&#x20;

Before you get deeper into the docs, here is a quick overview of the general flow you will use to interact with the Velora API. Let's take the example of you wanting to swap 10 ETH to DAI.&#x20;

* First, you should call `/prices` endpoint (detailed documentation [here](/api/velora-api/velora-market-api/get-rate-for-a-token-pair-1)) using an HTTP query like `GET https://api.paraswap.io/prices/?srcToken=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&destToken=0x6b175474e89094c44da98b954eedeac495271d0f&amount=10000000000000000000&srcDecimals=18&destDecimals=18&side=SELL&network=1&version=5`. This will return the optimal prices using ParaSwap's Hopper Algorithm
* If you are satisfied with the price, you can call the `/transactions` endpoint (detailed documentation [here](/api/velora-api/velora-market-api/build-parameters-for-transaction)). This will return a transaction object.
* You should then give the appropriate allowance to the `tokenTransferProxy` for the source token.  You can find the address of `tokenTransferProxy` in the payload returned in the price endpoint. You can skip this step if a high enough allowance was already given.&#x20;
* You can finally use this transaction data to execute the swaps on-chain by sending it to the provider.&#x20;

Check out the following pages to understand the Velora v5 API. To try out all API endpoints, visit the [Open-API documentation](https://app.swaggerhub.com/apis/paraswapv5/api/1.0) of Velora v5.

Developers can also use our JS/TS SDK for web and Node.js integrations <https://github.com/paraswap/paraswap-sdk>

If you want to do some swaps, you can directly use our UI.

### **Supported methods:**

**SELL:**

* simpleSwap
* multiSwap
* megaSwap
* swapOnUniswapV2Fork
* directUniV3Swap
* directCurveV1Swap
* directCurveV2Swap
* directBalancerV2GivenInSwap

**BUY:**

* simpleBuy
* buy
* buyOnUniswapV2Fork
* directUniV3Buy
* directBalancerV2GivenOutSwap


# Retrieve a price: /prices

## Get Price Route

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

This endpoint gets the optimal price and price route required to swap from one token to another.

You’ll find the parameters to build a successful query below:

#### Query Parameters

| Name                                           | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ---------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| srcToken<mark style="color:red;">\*</mark>     | string  | Source Token Address. Instead **Token Symbol** could be used for tokens listed in the `/tokens` endpoint.                                                                                                                                                                                                                                                                                                                                       |
| srcDecimals<mark style="color:red;">\*</mark>  | integer | Source Token Decimals. (Can be omitted if Token Symbol is used in `srcToken`).                                                                                                                                                                                                                                                                                                                                                                  |
| destToken<mark style="color:red;">\*</mark>    | string  | Destination Token Address. Instead **Token Symbol** could be used for tokens listed in the  `/tokens` endpoint.                                                                                                                                                                                                                                                                                                                                 |
| 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                                           | string  | <p><strong>SELL</strong> or <strong>BUY</strong>. <br>Default: <code>SELL</code>.</p>                                                                                                                                                                                                                                                                                                                                                           |
| network                                        | string  | <p>Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Sonic - 146, Unichain - 130, Plasma - 9745).<br>Default: <code>1</code>.</p>                                                                                                                                                                                                                               |
| otherExchangePrices                            | boolean | <p>If provided, <strong>others</strong> object is filled in the response with price quotes from other exchanges <em>(if available for comparison)</em>.<br>Default: <code>false</code></p>                                                                                                                                                                                                                                                      |
| includeDEXS                                    | string  | <p>Comma Separated List of DEXs to include. <br>All supported DEXs by chain can be found <a href="https://api.paraswap.io/adapters/list/1">here </a><br>eg: <code>UniswapV3, CurveV1</code></p>                                                                                                                                                                                                                                                 |
| excludeDEXS                                    | string  | <p>Comma Separated List of DEXs to exclude.<br>All supported DEXs by chain can be found <a href="https://api.paraswap.io/adapters/list/1">here </a><br>eg: <code>UniswapV3, CurveV1</code></p>                                                                                                                                                                                                                                                  |
| excludeRFQ                                     | boolean | <p>Exclude all RFQs from pricing <br>eg: <code>AugustusRFQ, Hashflow</code><br>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                  |
| includeContractMethods                         | string  | Comma Separated List of Comma Separated List of Contract Methods to include in pricing (without spaces). View the list of the supported methods for [V5 ](https://developers.paraswap.network/api/master/api-v5#supported-methods)and [V6](https://developers.paraswap.network/api/master/api-v6.2#supported-methods) eg: `swapExactAmountIn,swapExactAmountInOnUniswapV2`                                                                      |
| excludeContractMethods                         | string  | Comma Separated List of Contract Methods to exclude from pricing (without spaces). View the list of the supported methods for [V5 ](https://developers.paraswap.network/api/master/api-v5#supported-methods)and [V6](https://developers.paraswap.network/api/master/api-v6.2#supported-methods)                                                                                                                                                 |
| userAddress                                    | string  | User's Wallet Address.                                                                                                                                                                                                                                                                                                                                                                                                                          |
| route                                          | string  | <p>Dash (-) separated list of tokens (addresses or symbols from <code>/tokens</code>) to comprise the price route. <em>Max 4 tokens.</em> <br><em><strong>\*Note:</strong> If <code>route</code> is specified, the response will only comprise of the route specified which might not be the optimal route.</em> </p>                                                                                                                           |
| 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>                                                                                                                                                                                                         |
| destDecimals<mark style="color:red;">\*</mark> | integer | Destination Token Decimals. (Can be omitted if Token Symbol is used in `destToken`).                                                                                                                                                                                                                                                                                                                                                            |
| maxImpact                                      | number  | In %. It's a way to bypass the API price impact check (default = 15%).                                                                                                                                                                                                                                                                                                                                                                          |
| receiver                                       | String  | Receiver's Wallet address. (Can be omitted if swapping tokens from and to same account)                                                                                                                                                                                                                                                                                                                                                         |
| srcTokenTransferFee                            | string  | <p>If the source token is a tax token, you should specify the tax amount in BPS.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                           |
| destTokenTransferFee                           | string  | <p>If the destination token is a tax token, you should specify the tax amount in BPS.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                      |
| srcTokenDexTransferFee                         | string  | <p>If the source token is a tax token, you should specify the tax amount in BPS.<br>Some tokens only charge tax when swapped in/out DEXs and not on ordinary transfers.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>    |
| destTokenDexTransferFee                        | string  | <p>If the destination token is a tax token, you should specify the tax amount in BPS. <br>Some tokens only charge tax when swapped in/out DEXs, not on ordinary transfers.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p> |
| version                                        | number  | <p>To specify the protocol version. <strong>Values:</strong> 5 or 6.2<br><strong>Default</strong>: 5</p>                                                                                                                                                                                                                                                                                                                                        |
| excludeContractMethodsWithoutFeeModel          | boolean | Specify that methods without fee support should be excluded from the price route. Default: `false`                                                                                                                                                                                                                                                                                                                                              |
| ignoreBadUsdPrice                              | boolean | If tokens USD prices are not available, `Bad USD Price` error will be thrown. Use this param to skip this check. Default: `false`                                                                                                                                                                                                                                                                                                               |

Here are two examples of a successful price response and a failed query.

The first query was a sell price request on Ethereum Mainnet (chainId: 1) using Velora's Market API. The request aimed to swap 1,000 USDC for ETH (destToken: 0xeeee...eeee) while retrieving the best possible route for the trade.

As a result, it successfully retrieved an optimized route for swapping 1,000 USDC to ETH via Uniswap V3, with minimal slippage and efficient execution while estimating gas costs.

{% tabs %}
{% tab title="200 Successful Price Response." %}

```
{
    "priceRoute": {
        "blockNumber": 19462957,
        "network": 1,
        "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "srcDecimals": 6,
        "srcAmount": "1000000000",
        "destToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "destDecimals": 18,
        "destAmount": "283341969876959340",
        "bestRoute": [
            {
                "percent": 100,
                "swaps": [
                    {
                        "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                        "srcDecimals": 6,
                        "destToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
                        "destDecimals": 18,
                        "swapExchanges": [
                            {
                                "exchange": "UniswapV3",
                                "srcAmount": "1000000000",
                                "destAmount": "283341969876959340",
                                "percent": 100,
                                "poolAddresses": [
                                    "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"
                                ],
                                "data": {
                                    "path": [
                                        {
                                            "tokenIn": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                                            "tokenOut": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                                            "fee": "500",
                                            "currentFee": "500"
                                        }
                                    ],
                                    "gasUSD": "13.515820"
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "gasCostUSD": "14.656605",
        "gasCost": "118200",
        "side": "SELL",
        "version": "6.2",
        "contractAddress": "0x6a000f20005980200259b80c5102003040001068",
        "tokenTransferProxy": "0x6a000f20005980200259b80c5102003040001068",
        "contractMethod": "swapExactAmountInOnUniswapV3",
        "partnerFee": 0,
        "srcUSD": "999.4370000000",
        "destUSD": "1003.8267642998",
        "partner": "anon",
        "maxImpactReached": false,
        "hmac": "7975cda2fd343cb90f1a15d1ec11302c467a8d7d"
    }
}
```

{% endtab %}

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

```
{
  "error": "Validation failed with error"
  }
```

{% endtab %}
{% endtabs %}

#### Most common error messages

The following is a list of the most common error messages of the `/prices` 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.

* `Invalid route, from token should be the first token of the route`
* `Invalid route, to token should be the last token of the route`
* `Token not found. Please pass srcDecimals & destDecimals query params to trade any tokens` -Check the doc for more details <https://developers.paraswap.network/api/get-rate-for-a-token-pair>
* `Invalid tokens` - (srcToken and destToken) or (route) params are not passed
* `If receiver is defined userAddress should also be defined`
* `It is not allowed to pass both params: "positiveSlippageToUser" and "takeSurplus".` - We advice removing "positiveSlippageToUser", because it is deprecated
* `excludeDirectContractMethods param is deprecated, please use excludeContractMethodsWithoutFeeModel for newer versions`
* `Invalid Amount` - amount param is not a valid number
* `Validation failed: <error>` - params validation failed (message has the exact reason for failure)
* `Price Timeout` - reverts when a query takes more time than expected
* `No routes found with enough liquidity`&#x20;
* `Bad USD price` ![:large\_orange\_circle:](https://a.slack-edge.com/production-standard-emoji-assets/14.0/apple-medium/1f7e0.png) - src or dest tokens don’t have valid usd price&#x20;
* `Estimated_loss_greater_than_max_impact`
* `Internal Error while computing the price` - something went wrong during the price route calculation
* `Invalid max USD impact` - maxUSDImpact is not a valid number
* `Error while handling price request` - something went wrong during the price route calculation

\ <br>


# Build a transaction: /transactions

## Build Transaction

<mark style="color:green;">`POST`</mark> `https://api.paraswap.io/transactions/:network`

Build parameters for a transaction with the response from `/prices` endpoint.

#### Path Parameters

Path parameters define the network on which the transaction will be executed. Since blockchain networks operate independently, specifying the correct network ensures that the API queries the right environment for liquidity and transaction execution.

| Name    | Type   | Description                                                                                                                                                                    |
| ------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| network | number | Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Sonic - 146, Unichain - 130, Plasma - 9745). |

#### Query Parameters

As an integrator, you can modify the behavior of the API call based on the Query parameters. This allows you to customize the response based on your needs.

| Name              | Type    | Description                                                                                                                                                                                                                                                                                                                                                                        |
| ----------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| gasPrice          | string  | Gas-price to be used for the transaction ***in wei***.                                                                                                                                                                                                                                                                                                                             |
| ignoreChecks      | boolean | <p>Allows the API to skip performing on-chain checks such as <em><strong>balances</strong></em>, <em><strong>allowances</strong></em>, as well as possible <em><strong>transaction failures</strong></em>. <br><strong>\*Note</strong>: The response does not contain <code>gas</code> parameter when <code>ignoreChecks</code> is set to true.<br>Default: <code>false</code></p> |
| ignoreGasEstimate | boolean | <p>Allows the API to skip gas checks <br><strong>\*Note</strong>: The response does not contain <code>gas</code> parameter when <code>ignoreGasEstimate</code> is set to true.<br>Default: <code>false</code></p>                                                                                                                                                                  |
| onlyParams        | boolean | <p>Allows the API to return the contract parameters only.<br>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                       |
| eip1559           | boolean | <p>Allows the API to return EIP-1559 styled transaction with <code>maxFeePerGas</code> and <code>maxPriorityFeePerGas</code> paramters. </p><p>\*Note: We currently support EIP1559 transactions in the following chains:</p><p>Mainnet, Ropsten, and Avalanche.</p><p></p><p>Default: <code>false</code></p>                                                                      |

#### Request Body

The request body provides the details needed to execute a swap, including token details, amounts, pricing data, and user-specific parameters.

| Name                | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| srcToken            | string  | Destination Token Address. *Only Token Symbol could be speciﬁed for tokens from* `/tokens`.                                                                                                                                                                                                                                                                                                                                                                                                                     |
| srcDecimals         | integer | Source Token Decimals. (Can be omitted if Token Symbol is provided for `srcToken`).                                                                                                                                                                                                                                                                                                                                                                                                                             |
| destToken           | string  | Destination Token Address. *Only Token Symbol could be speciﬁed for tokens from* `/tokens`.                                                                                                                                                                                                                                                                                                                                                                                                                     |
| destDecimals        | integer | Destination Token Decimals. (Can be omitted if Token Symbol is provided for `destToken`).                                                                                                                                                                                                                                                                                                                                                                                                                       |
| srcAmount           | integer | Source Amount with decimals. Required if **side=SELL**. Could only be omitted if **slippage** is provided when **side=BUY**                                                                                                                                                                                                                                                                                                                                                                                     |
| destAmount          | integer | Destination amount with decimals. Required if **side=BUY**. Could only be omitted if **slippage** is provided when **side=SELL**.                                                                                                                                                                                                                                                                                                                                                                               |
| priceRoute          | object  | `priceRoute` from response body returned from `/prices` endpoint. `priceRoute` should be sent exactly as it was returned by the `/prices` endpoint.                                                                                                                                                                                                                                                                                                                                                             |
| slippage            | integer | <p>Allowed slippage percentage represented in basis points. <br><em>Eg:</em> for <strong>2.5%</strong> slippage, set the value to <strong>2.5 \* 100 = 250</strong>; for 10% = 1000. Slippage could be passed instead of <code>destAmount</code> when <strong>side=SELL</strong> or <code>srcAmount</code> when <strong>side=BUY</strong>. <br><code>Min: 0; Max: 10000</code></p>                                                                                                                              |
| userAddress         | string  | Address of the caller of the transaction (`msg.sender`)                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| txOrigin            | string  | Whenever `msg.sender` (userAddress) i.e. address calling the Velora contract is different than the address sending the transaction, `txOrigin` must be passed along with `userAddress`.                                                                                                                                                                                                                                                                                                                         |
| receiver            | string  | Address of the Receiver (that will receive the output of the swap). Used for Swap\&Transfer.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| partnerAddress      | string  | <p>Address that will be entitled to claim fees or surplus.</p><p></p><p><em>\*Note: Fees have to be claimed from the</em> <a href="https://developers.paraswap.network/smart-contracts#fee-claimer"><em>Fee Claimer contract</em></a> <em>unless <code>isSurplusToUser</code> or <code>isDirectFeeTransfer</code>  are used</em></p>                                                                                                                                                                            |
| partnerFeeBps       | string  | <p>If provided it is used together with <code>partnerAddress</code>. Should be in basis points percentage. Look at <code>slippage</code> parameter description for understanding better.<br>Eg: <code>200</code> (for 2% fee percent)</p><p></p><p><em>\*Note: Fees have to be claimed from the</em> <a href="https://developers.paraswap.network/smart-contracts#fee-claimer"><em>Fee Claimer contract</em></a> <em>unless <code>isSurplusToUser</code> or <code>isDirectFeeTransfer</code>  are used</em></p> |
| partner             | string  | <p>Your <strong>project</strong> name.</p><p>Used for providing analytics on your <strong>project</strong> swaps.</p>                                                                                                                                                                                                                                                                                                                                                                                           |
| permit              | string  | Hex string for the signature used for Permit. This can be used to avoid giving approval. *Helps in saving gas.*                                                                                                                                                                                                                                                                                                                                                                                                 |
| deadline            | integer | <p>Timestamp (10 digit/seconds precision) <strong>till when the given transaction is valid</strong>. For a deadline of 5 minute, <em>deadline:</em> <code>Math.floor(Date.now()/1000) + 300</code><br><em>E.g.: 1629214486</em></p>                                                                                                                                                                                                                                                                             |
| isCapSurplus        | boolean | <p>Allows for capping the surplus at 1% maximum.</p><p>Default: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                           |
| takeSurplus         | boolean | <p>Allows to collect surplus. Works with <code>partnerAddress</code></p><p>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                      |
| isSurplusToUser     | boolean | <p>Specify if user should receive surplus instead of partner.<br>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                |
| isDirectFeeTransfer | boolean | <p>Specify if fees should be sent directly to the partner instead of registering them on FeeClaimer.</p><p>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                      |

**Example:**

Here’s an example of a successful and failed transaction.

{% tabs %}
{% tab title="200 Transaction Request Response (When onlyParams=false)" %}

```
{
    "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "to": "0x6a000f20005980200259b80c5102003040001068",
    "value": "0",
    "data": "0xe3ead59e0000000000000000000000005f0000d4780a00d2dce0a00004000800cb0e5041000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000db4d11c67691ad50000000000000000000000000000000000000000000000000dd8426a4440caf10a8104c26c244959a1d46f205acc49520000000000000000000000000133fc2c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000160a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000006000240000ff00000300000000000000000000000000000000000000000000000000000000a9059cbb0000000000000000000000004610ba8d5d10fba8c048a2051a0883ce04eabace00000000000000000000000000000000000000000000000000000000000f42406a000f20005980200259b80c51020030400010680000008000240000ff0600030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000f4240000000000000000000004de54610ba8d5d10fba8c048a2051a0883ce04eabace",
    "gasPrice": "16000000000",
    "chainId": 1
}
```

{% endtab %}

{% tab title="400 Transaction Building Error" %}

```
{
  "error": "Unable to process the transaction"
}
```

{% endtab %}
{% endtabs %}

#### Most common error messages

The following is a list of the most common error messages of the `/transactions` 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.

* `Validation failed: permit signature should be lower than 706`
* `Validation failed: <error>` - params validation failed (message has the exact reason of failure)
* `Missing price route` - price route param is not passed
* `Missing srcAmount` (sell)
* `Cannot specify both slippage and destAmount` (sell)
* `Missing slippage or destAmount` (sell)
* `Missing slippage or srcAmount` (buy)
* `Source Amount Mismatch` (sell)
* `Destination Amount Mismatch` (buy)
* `Missing destAmount` (buy)
* `Cannot specify both slippage and srcAmount` (buy)
* `Network Mismatch`
* `Source Token Mismatch`
* `Destination Token Mismatch`
* `Contract method doesn't support swap and transfer`
* `Side Mismatch`
* `Source Decimals Mismatch`
* `Destination Decimals Mismatch`
* `It is not allowed to pass both params: "positiveSlippageToUser" and "takeSurplus".` - We advise removing "positiveSlippageToUser" because it is deprecated
* `When "isSurplusToUser"="true", "takeSurplus" must be also "true" and either "partnerAddress" or "partner" must be set`
* `When "isDirectFeeTransfer"="true", please also set "takeSurplus"="true" and provide partner/fee information via "partnerFeeBps" & "partnerAddress" or valid "partner" params; or add "referrer" param`
* `Internal Error while building transaction` - something went wrong during the transaction build
* `Unable to build transaction <code>` -  something went wrong during the transaction build
* `It is not allowed to have limit-orders Dex or paraswappool Dex in route and 'ignoreChecks=true' together. Consider requesting the price with excluded limit-orders if you want to use 'ignoreChecks': &excludeDEXS=ParaSwapPool,ParaSwapLimitOrders`
* `It seems like the rate has changed, please re-query the latest Price`
* `The rate has changed, please re-query the latest Price`
* `This transaction has some errors and may fail. Please contact support for more details`
* `Not enough <token> balance`
* `Not enough <token> allowance given to TokenTransferProxy(<spender>)`
* `Unable to check price impact` - src or dest tokens don’t have valid usd price&#x20;


# Get Price & Calldata: /swap

The /swap endpoint allows you to make one API call to get both the priceRoute object as well as the Transaction Object.

It is designed to simplify the trading process by combining price estimation and transaction calldata generation into a single API call. This makes it a convenient option for users who want a quick and streamlined way to execute trades without handling multiple requests. However, while it offers ease of use, it also comes with certain limitations.

## Limitations

* Lower rate limits
* It doesn't check sufficient allowances and balances
* It doesn't return the gas field in txParams, thus the transaction should be simulated locally
* It automatically excludes RFQ-based DEXs such as AugustusRFQ & ParaSwapLimitOrders.&#x20;

## Get Price Route & Transaction Building

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

This endpoint gets the optimal price and price route required to swap from one token to another.

Additionally the swap endpoint also generates the parameters required for the transaction.

#### Query Parameters

| Name                                           | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ---------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| srcToken<mark style="color:red;">\*</mark>     | string  | Source Token Address. Instead **Token Symbol** could be used for tokens listed in the `/tokens` endpoint.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| srcDecimals<mark style="color:red;">\*</mark>  | integer | Source Token Decimals. (Can be omitted if Token Symbol is used in `srcToken`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| destToken<mark style="color:red;">\*</mark>    | string  | Destination Token Address. Instead **Token Symbol** could be used for tokens listed in the  `/tokens` endpoint.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| 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                                           | string  | <p><strong>SELL</strong> or <strong>BUY</strong>. <br>Default: <code>SELL</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| network                                        | string  | <p>Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Sonic - 146, Unichain - 130, Plasma - 9745).<br>Default: <code>1</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| otherExchangePrices                            | boolean | <p>If provided, <strong>others</strong> object is filled in the response with price quotes from other exchanges <em>(if available for comparison)</em>.<br>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| includeDEXS                                    | string  | <p>Comma Separated List of DEXs to include. <br><strong>Supported DEXs:</strong> <br>Uniswap, Kyber, Bancor, AugustusRFQ, Oasis, Compound, Fulcrum, 0x, MakerDAO, Chai, Aave, Aave2, MultiPath, MegaPath, Curve, Curve3, Saddle, IronV2, BDai, idle, Weth, Beth, UniswapV2, Balancer, 0xRFQt, SushiSwap, LINKSWAP, Synthetix, DefiSwap, Swerve, CoFiX, Shell, DODOV1, DODOV2, OnChainPricing, PancakeSwap, PancakeSwapV2, ApeSwap, Wbnb, acryptos, streetswap, bakeryswap, julswap, vswap, vpegswap, beltfi, ellipsis, QuickSwap, COMETH, Wmatic, Nerve, Dfyn, UniswapV3, Smoothy, PantherSwap, OMM1, OneInchLP, CurveV2, mStable, WaultFinance, MDEX, ShibaSwap, CoinSwap, SakeSwap, JetSwap, Biswap, BProtocol<br>eg: <code>UniswapV3,0x</code></p> |
| excludeDEXS                                    | string  | Comma Separated List of DEXs to exclude. (from the list of DEXs mentioned above).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| includeContractMethods                         | string  | <p>Comma Separated List of Contract Methods to include without spaces. <strong>Available values:</strong> swapOnUniswap, buyOnUniswap, swapOnUniswapFork, buyOnUniswapFork, swapOnUniswapV2Fork, buyOnUniswapV2Fork, simpleBuy, simpleSwap, multiSwap, megaSwap, protectedMultiSwap, protectedMegaSwap, protectedSimpleSwap, protectedSimpleBuy, swapOnZeroXv2, swapOnZeroXv4, buy.<br>eg: <code>simpleSwap,multiSwap</code></p>                                                                                                                                                                                                                                                                                                                      |
| excludeContractMethods                         | string  | Comma Separated List of Contract Methods to exclude without spaces. (from the list of contract methods mentioned above).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| userAddress                                    | string  | User's Wallet Address.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| route                                          | string  | <p>Dash (-) separated list of tokens (addresses or symbols from <code>/tokens</code>) to comprise the price route. <em>Max 4 tokens.</em> <br><em><strong>\*Note:</strong> If <code>route</code> is specified, the response will only comprise of the route specified which might not be the optimal route.</em> </p>                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| partner                                        | string  | Partner string.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| partnerFeeBps                                  | string  | <p>If provided it is used together with <code>partnerAddress</code>. Should be in basis points percentage. Look at <code>slippage</code> parameter description for understanding better. Eg: <code>200</code> (for 2% fee percent)</p><p><em>\*Note: Fees have to be claimed from the</em> <a href="https://developers.paraswap.network/smart-contracts#fee-claimer"><em>Fee Claimer contract</em></a> <em>unless <code>isSurplusToUser</code> or <code>isDirectFeeTransfer</code> are used</em></p>                                                                                                                                                                                                                                                  |
| partnerAddress                                 | string  | <p>Address that will be entitled to claim fees or surplus.</p><p><em>\*Note: Fees have to be claimed from the</em> <a href="https://developers.paraswap.network/smart-contracts#fee-claimer"><em>Fee Claimer contract</em></a> <em>unless <code>isSurplusToUser</code> or <code>isDirectFeeTransfer</code> are used</em></p>                                                                                                                                                                                                                                                                                                                                                                                                                          |
| slippage                                       | integer | <p>Allowed slippage percentage represented in basis points. <br><em>Eg:</em> for <strong>2.5%</strong> slippage, set the value to <strong>2.5 \* 100 = 250</strong>; for 10% = 1000. Slippage could be passed instead of <code>destAmount</code> when <strong>side=SELL</strong> or <code>srcAmount</code> when <strong>side=BUY</strong>. <br><code>Min: 0; Max: 10000</code></p>                                                                                                                                                                                                                                                                                                                                                                    |
| destDecimals<mark style="color:red;">\*</mark> | integer | Destination Token Decimals. (Can be omitted if Token Symbol is used in `destToken`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| maxImpact                                      | number  | In %. It's a way to bypass the API price impact check (default = 15%).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| receiver                                       | String  | Receiver's Wallet address. (Can be omitted if swapping tokens from and to same account)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| srcTokenTransferFee                            | string  | <p>If the source token is a tax token, you should specify the tax amount in BPS.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                                                                                                                                                                                                                                                                                                                                 |
| destTokenTransferFee                           | string  | <p>If the destination token is a tax token, you should specify the tax amount in BPS.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                                                                                                                                                                                                                                                                                                                            |
| srcTokenDexTransferFee                         | string  | <p>If the source token is a tax token, you should specify the tax amount in BPS.<br>Some tokens only charge tax when swapped in/out DEXs and not on ordinary transfers.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                                                                                                                                                                                                                                          |
| destTokenDexTransferFee                        | string  | <p>If the destination token is a tax token, you should specify the tax amount in BPS. <br>Some tokens only charge tax when swapped in/out DEXs, not on ordinary transfers.</p><p><em>\*For example: for a token with a 5% tax, you should set it to 500 as</em><br><em><code>\[(500/10000)\*100=5%]</code></em></p><p><em>\*\*Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.</em> </p>                                                                                                                                                                                                                                                                                                       |
| version                                        | number  | To specify the protocol version. **Values:** 5 or 6.2 **Default**: 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ignoreBadUsdPrice                              | boolean | If tokens USD prices are not available, `Bad USD Price` error will be thrown. Use this param to skip this check. Default: `false`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| isSurplusToUser                                | boolean | <p>Specify if user should receive surplus instead of partner.<br>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| isDirectFeeTransfer                            | boolean | <p>Specify if fees should be sent directly to the partner instead of registering them on FeeClaimer.</p><p>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| isCapSurplus                                   | boolean | <p>Allows for capping the surplus at 1% maximum.</p><p>Default: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| takeSurplus                                    | boolean | <p>Allows to collect surplus. Works with <code>partnerAddress</code></p><p>Default: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

**Example:**&#x20;

Here’s an example of an integrator that used the swap function to request a price and generate a transaction.

{% tabs %}
{% tab title="200 Successful Price Response." %}

```
{
  "priceRoute": {
    "blockNumber": 20184108,
    "network": 1,
    "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "srcDecimals": 6,
    "srcAmount": "1000000",
    "destToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
    "destDecimals": 18,
    "destAmount": "997620341641628401",
    "bestRoute": [
      {
        "percent": 100,
        "swaps": [
          {
            "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
            "srcDecimals": 6,
            "destToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
            "destDecimals": 18,
            "swapExchanges": [
              {
                "exchange": "ShibaSwap",
                "srcAmount": "1000000",
                "destAmount": "997620341641628401",
                "percent": 100,
                "poolAddresses": [
                  "0x4610bA8d5D10FBa8C048A2051a0883CE04eaBAcE"
                ],
                "data": {
                  "router": "0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07",
                  "path": [
                    "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                    "0x6b175474e89094c44da98b954eedeac495271d0f"
                  ],
                  "factory": "0x115934131916C8b277DD010Ee02de363c09d037c",
                  "initCode": "0x65d1a3b1e46c6e4f1be1ad5f99ef14dc488ae0549dc97db9b30afe2241ce1c7a",
                  "feeFactor": 10000,
                  "pools": [
                    {
                      "address": "0x4610bA8d5D10FBa8C048A2051a0883CE04eaBAcE",
                      "fee": 30,
                      "direction": false
                    }
                  ],
                  "gasUSD": "5.515040"
                }
              }
            ]
          }
        ]
      }
    ],
    "gasCostUSD": "5.932529",
    "gasCost": "107570",
    "side": "SELL",
    "version": "6.2",
    "contractAddress": "0x6a000f20005980200259b80c5102003040001068",
    "tokenTransferProxy": "0x6a000f20005980200259b80c5102003040001068",
    "contractMethod": "swapExactAmountIn",
    "partnerFee": 0,
    "srcUSD": "1.0000000000",
    "destUSD": "0.9973641328",
    "partner": "anon",
    "maxImpactReached": false,
    "hmac": "39d19445379b69c115149340c5caaa05c898e840"
  },
  "txParams": {
    "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "to": "0x6a000f20005980200259b80c5102003040001068",
    "value": "0",
    "data": "0xe3ead59e0000000000000000000000005f0000d4780a00d2dce0a00004000800cb0e5041000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000db4d11c67691ad50000000000000000000000000000000000000000000000000dd8426a4440caf10a8104c26c244959a1d46f205acc49520000000000000000000000000133fc2c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000160a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000006000240000ff00000300000000000000000000000000000000000000000000000000000000a9059cbb0000000000000000000000004610ba8d5d10fba8c048a2051a0883ce04eabace00000000000000000000000000000000000000000000000000000000000f42406a000f20005980200259b80c51020030400010680000008000240000ff0600030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000f4240000000000000000000004de54610ba8d5d10fba8c048a2051a0883ce04eabace",
    "gasPrice": "16000000000",
    "chainId": 1
  }
}
```

{% endtab %}

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

```
{
  "error": "computePrice Error
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
🧙Though **srcDecimals** and **destDecimals** are optional parameters it is highly recommended to add them while doing the pricing. This will allow you to get prices for all the tokens, including the ones which are also not listed by Velora.&#x20;
{% endhint %}

{% hint style="warning" %}
Swaps fees and Swap\&Transfer (where the receiver is not the same as the sender) don't work when `swapOnUniswap`, `swapOnUniswapFork`, `swapOnZeroXv2`, and `swapOnZeroXv4` etc. contract methods are used.&#x20;

If you would like to disable these methods you can do so by setting a whitelist for methods where Swap\&Transfer is supported`includeContractMethods=simpleSwap,multiSwap,megaSwap`
{% endhint %}

#### Most common error messages

The following is a list of the most common error messages of the `/swap` 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.

* `Missing response from pricing API` - failed to get a response from pricing API
* `Can not receive price route` - failed to receive price route from the pricing API response


# Example: Fetch Price & Build Transaction

Here’s an example of an implementation for Velora's Market API. It utilizes Velora's endpoints to fetch pricing information and build transactions for token swaps.

{% tabs %}
{% tab title="API" %}
{% embed url="<https://gist.github.com/Velenir/64f6449e4461cf965ea5a18941a330f9>" %}

{% endtab %}

{% tab title="SDK" %}
{% embed url="<https://gist.github.com/Velenir/a9b0b1a1958ad9e2fe6543d596320743>" %}

{% endtab %}
{% endtabs %}

{% embed url="<https://codesandbox.io/p/sandbox/still-violet-zhtgzh>" %}


# Get Tokens List

## Get tokens list for a network

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

This endpoint allows you to obtain a list of tokens curated by Velora.

#### Path Parameters

| Name    | Type   | Description                                                                                                                                                                                                       |
| ------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| network | number | <p>Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Sonic - 146, Unichain - 130, Plasma - 9745).<br>Default: <code>1</code>.</p> |

{% tabs %}
{% tab title="200 List of available tokens" %}

```
{
  "tokens": [
    {
      "symbol": "ETH",
      "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
      "decimals": 18,
      "img": "https://img.paraswap.network/ETH.png",
      "network": 1
    },
    {
      "symbol": "USDT",
      "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
      "decimals": 6,
      "img": "https://img.paraswap.network/USDT.png",
      "network": 1
    }
  ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="danger" %}
Velora's API is not limited to the tokens that are listed on the tokens endpoint. Tokens endpoint is merely a list of tokens curated by Velora. This list is not actively maintained and will soon be deprecated. To use a more up-to-date list of tokens it is suggested to use [token-lists](https://tokenlists.org/).&#x20;
{% endhint %}


# AugustusRFQ

## **What is** Velora's AugustusRF&#x51;**?**

Velora AugustusRFQ Protocol is a set of smart contracts developed by Velora and available in Ethereum, Polygon, Binance Smart Chain, Avalanche, Arbitrum, and Optimism.&#x20;

The goal of Velora's Multichain RFQ Protocol is to become a public good with which anyone can interact and build dApp use cases in a completely decentralized way.


# Introduction

## Key Features

The protocol goes beyond ERC-20 token PMM RFQ and enables, among others, ERC721 NFT peer-to-peer, RFQ, and OTC trading.&#x20;

* **Top gas efficiency:** Velora's AugustusRFQ offer the most gas-efficient transactions in the market.&#x20;
* **Greater flexibility for users:** the protocol allows not only token-to-token trade but also token-to-NFT, multiple token-to-NFT trading, and NFT-to-NFT swap. Moreover, it allows users to buy & sell ERC721 in the token of their choosing, independently of the other party’s token choice.<br>

### Supported chains and tokens

**Chains**

* Ethereum
* Arbitrum
* Avalanche
* BSC
* Optimism
* Polygon

**Tokens**

* ERC-20
* ERC721
* ERC1155


# Contracts

### AugustusRFQ

AugustusRFQ is Velora's contracts

### &#x20;Addresses of AugustusRFQ contract

<table><thead><tr><th width="179">Network</th><th>Address</th></tr></thead><tbody><tr><td>Ethereum</td><td><a href="https://etherscan.io/address/0xe92b586627cca7a83dc919cc7127196d70f55a06">0xe92b586627ccA7a83dC919cc7127196d70f55a06</a></td></tr><tr><td>Arbitrum</td><td><a href="https://arbiscan.io/address/0x0927fd43a7a87e3e8b81df2c44b03c4756849f6d">0x0927FD43a7a87E3E8b81Df2c44B03C4756849F6D</a></td></tr><tr><td>Avalanche</td><td><a href="https://snowtrace.io/address/0x34302c4267d0da0a8c65510282cc22e9e39df51f">0x34302c4267d0dA0A8c65510282Cc22E9e39df51f</a></td></tr><tr><td>Base</td><td><a href="https://basescan.org/address/0xa003dFBA51C9e1e56C67ae445b852bdEd7aC5EEd">0xa003dFBA51C9e1e56C67ae445b852bdEd7aC5EEd</a></td></tr><tr><td>BSC</td><td><a href="https://bscscan.com/address/0x8dcdfe88ef0351f27437284d0710cd65b20288bb">0x8DcDfe88EF0351f27437284D0710cD65b20288bb</a></td></tr><tr><td>Gnosis</td><td><a href="https://gnosisscan.io/address/0x92EaD5bACf6F0E995FA46Ad8215A9b11f67ca241">0x92EaD5bACf6F0E995FA46Ad8215A9b11f67ca241</a></td></tr><tr><td>Optimism</td><td><a href="https://optimistic.etherscan.io/address/0x0927fd43a7a87e3e8b81df2c44b03c4756849f6d">0x0927FD43a7a87E3E8b81Df2c44B03C4756849F6D</a></td></tr><tr><td>Polygon</td><td><a href="https://polygonscan.com/address/0xF3CD476C3C4D3Ac5cA2724767f269070CA09A043">0xF3CD476C3C4D3Ac5cA2724767f269070CA09A043</a></td></tr></tbody></table>


# On chain Data Structure

## ERC20: Order structure

```json
{
    "maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
    "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
    "nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
    "expiry": 0,
    "makerAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
    "takerAsset": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
    "makerAmount": "10000000000000000",
    "takerAmount": "7775870000000000",
    "signature": "0x43de8dbc8228594171d0ed3e623ca0ab5c24f46bf0575800624ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b" 
}
```

* `maker`: address of owner of the order. (The user or contract who want to swap `makerAsset` to `takerAsset`).
* `taker`: address that can fulfilled this order on chain.
  * `taker == 0`: anybody can fill the order
  * `taker != 0`: during the execution we will verify that `msg.sender == taker`. (taker needs to be the contract or user who fill an order).
* `nonceAndMeta`: This field combine nonce value (guarantee uniqueness of the order) and some meta data
* `expiry`: expiry timestamp in seconds. Can also be set 0 for an order that never expires
* `makerAsset`: address of ERC20 token that maker want to sell to the taker.
* `takerAsset`: address of ERC20 token that maker want to buy from the taker.
* `makerAmount`: amount of `makerAsset` that maker want to swap to taker.
* `takerAmount`: amount of `makerAsset` that maker want to swap to taker.
* `signature`: EIP712 Signature of a JSON Object with all above fields signed with the private key of maker.

## ERC 20/721/1155: Order structure

```json
{
	"maker": "0x0838956f18c895be401834E29F67Dd59Fe459b1F",
	"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
	"nonceAndMeta": "13369123495123320437930534572810746342548445613241166057167403033431113728",
	"expiry": 1653750633,
	"makerAsset": "3341504144865114989387489881442130991666264814706",
	"makerAmount": "1",
	"makerAssetId": "3333",
	"takerAsset": "381568316899389611396986334098972276236720652278",
	"takerAssetId": "0",
	"takerAmount": "2000000000000000000"
	"signature": "0x9281423eb0679d03dc110ce8d9002059f9dd02b05e5425179a0bdd3d2b154f89105cd8c2f2c040548d9fa605dd46eb71216c25908a7f3d227517fcd26c6b18b51b",
}
```

### Token type encoding

```
ERC20   -> 00
ERC1155 -> 01
ERC721  -> 10
```

* `maker`: address of owner of the order. (The user or contract who want to swap `makerAsset` to `takerAsset`).
* `taker`: address that can fulfilled this order on chain.
  * `taker == 0`: anybody can fill the order
  * `taker != 0`: during the execution we will verify that `msg.sender == taker`. (taker needs to be the contract or user who fill an order).
* `nonceAndMeta`: This field combine nonce value (guarantee uniqueness of the order) and some meta data
* `expiry`: expiry timestamp in seconds. Can also be set 0 for an order that never expires
* `makerAsset`: Packed field containing address of an ERC20/721/1155 token that maker want to sell to the taker (between  `0-19 bits`). Token type encoded as show above on `20-21 bits`.
* `makerAssetId`: ignored for ERC20. For ERC/721/1155 the `maker` token.
* `takerAsset`: Packed field containing address of an  ERC20/721/1155  token that maker want to sell to the taker (between  `0-19 bits`). Token type encoded as show above on `20-21 bits`.
* `makerAssetId`: ignored for ERC20. For ERC/721/1155 the `taker` token.
* `makerAmount`: amount of `makerAsset`  (at id `makerAssetId` for ERC/721/1155) that maker want to swap to taker.
* `takerAmount`: amount of `takerAsset` (at id `takerAssetId` for ERC/721/1155) that maker want to swap to taker.
* `signature`: EIP712 Signature of a JSON Object with all above fields signed with the private key of maker.


# AugustusRFQ API Specification

Want to become a market maker on Velora?  This document describes the API you need to provide to us to make that happen!

## Objectives

This is intended to be a common API format for all market makers to use, substantially reducing the amount of work we have to do to integrate a new market maker, and most of the back and forth agreeing a protocol between us.

This specification is newly created for new market makers wanting to integrate against Velora via our efficient AugustusRFQ protocol smart contracts.

## How does it work?

In Velora, market makers are enabled by them providing us with an API (one for each chain) to get information on what tokens they support, which base/quote pairs, and the price grid containing something akin to an order book with lists of bids and asks defining the pricing curve.

This information is regularly requested to keep the prices up to date.  To enable more control on update of prices, and also save bandwidth potentially, it is recommended to support streaming price grid updates to us via WebSockets.

When a user on Velora requests pricing, we go through all DEXs and market makers, computing prices.  For market makers, this means using the previously cached price grid.  We cannot do a request for (indicative) quote on each user individually, as that would make a huge volume of requests and add unwanted latency.

When a user comes to actually make a swap using a market maker, we then contact the market maker for a firm quote, in the form of a signed order, which can be executed on chain using Velora's AugustusRFQ contract.  This may be requested for an amount in either the bought or sold asset.

Users may be blacklisted by a market maker for making too many swap requests without actually executing the swap on chain.  To avoid issues, we request market makers to provide a list of blacklisted users.  This allows us not to provide pricing to that user for the market maker that has blacklisted them, and prevents subsequent failure on transaction building.

Should a market maker not fulfill their promise to provide a signed order for a given amount when requested, or give a bad price in the order that is returned (i.e. deviating from the price they have given in the price grid) they may be punished by having their market making disabled in Velora.  This may also happen if the signature cannot be validated (as either EOA or via smart contract), there is insufficient allowance to AugustusRFQ contract, or insufficient funds in the maker wallet.

## Endpoints

All regular HTTP endpoints (except WebSockets) should have a common base URL that we can use to make requests.  These endpoints must be secured using the procedures described below, however they may also employ IP whitelisting of Velora servers for additional security.  All endpoints should return JSON data as a response at all times, even if there is an error.  All error responses should return an unsuccessful HTTP response code (4xx or 5xx) and in the body a JSON object with the key `"error"` containing a string describing the error.  All non-error responses may include a `"message"` key in the top level object, alongside the normal payload data, the contents of which will be logged on Velora servers for any request.

A WebSocket API is optional and may be configured on a different URL than the other endpoints (but it could also use the same URL with `/ws` at the end, as you prefer...).

### Authentication (optional)

There are three key pieces of information we require from a market maker for security purposes:

* Domain - this is a string you can use to identify traffic coming from us (in case you want to enable market making with someone else), and optionally to differentiate between production, staging and test.  In the simplest case this can simply be the string `"paraswap"`.
* Access Key - this is a string that we will send back to you in request headers as a kind of passcode to quickly check that the request is coming from us.  It may be different for each domain and it should not be shared with anyone except Velora.
* Secret Key - this is a string used by us to authenticate our requests to your servers as detailed below.  It may be different for each domain and it should not be shared with anyone except Velora.

In order to authenticate our requests we will do the following:

1. Get the current timestamp as milliseconds since Unix epoch (i.e. that returned by `Date.now()` in JavaScript)
2. Compute the payload to be signed by concatenating the following (with no spaces or other separator between):

   1. Timestamp (as a string in decimal form)
   2. HTTP method in UPPERCASE (will be `GET` or `POST`)
   3. Path of the request (the part after the domain, beginning with a `/`) e.g. `/prices`.  Note that if the base URL already contains a path e.g. `/mainnet` it will be included.
   4. Query parameters that were passed in the URL exactly as given including the initial `?` e.g. `?base=WETH&quote=USDC`.  If there are no query parameters, use an empty string instead.  Note that none of the endpoints in this specification use query parameters, so this part will normally be an empty string.
   5. If present, the payload sent in a e.g. `POST` request, exactly as sent and received.  This will always be a JSON object in this specification, enclosed by `{}`.  If no payload e.g. for `GET` request, use an empty string.

   So a full payload may look something like this (if the URL used is e.g. `https://pspool.org/endpoint?key=value`):\
   `1234512345123POST/endpoint?key=value{"amount":"123"}`\
   For WebSockets connection opening we assume current timestamp, method of `GET`, the path of the URL used to connect, no query parameters and no payload.
3. Compute the HMAC-SHA256 of this payload in hexadecimal using the Secret Key as the key.  We would do this using Node.js crypto library (can be used as a reference) e.g. \
   `const { createHmac } = require('crypto');`\
   `const hmac = createHmac('sha256', '<secret key>');`\
   `hmac.update('<payload>');`\
   `console.log(hmac.digest('hex'));`
4. Attach the following headers to the request:
   * `X-AUTH-DOMAIN` - the Domain as described earlier
   * `X-AUTH-ACCESS-KEY` - the Access Key specified for the Domain
   * `X-AUTH-TIMESTAMP` - the timestamp used to create the signature
   * `X-AUTH-SIGNATURE` - the HMAC-SHA256 computed in the previous step

It is mandatory for the market maker to verify all these headers are correct/matching and the timestamp is sufficiently close to the current time (e.g. +/- 30 seconds).  Otherwise, the request should be rejected with an appropriate error message to describe the issue.

### Tokens endpoint

Path: `/tokens`

Method: `GET`

This endpoint provides details of all tokens used by the market maker.  The response should be a JSON object with the key `"tokens"`, which in turn contains an object containing a number of entries, the key of which is a Token ID (recommended to use the token's symbol if it is unique), and the value is an object with the following fields (most are just for informational purposes):

* `"symbol"` (string) - the token's symbol as determined by the market maker (should probably be the same as the one provided by the token's contract)
* `"name"` (string) - a full name for the token as determined by the market maker (should probably be the same as the one provided by the token's contract)
* `"description"` (string) - a description of the token, noting any important details where appropriate e.g. if it has been deprecated in favour of another token
* `"address"` (string) - the address of the token (case is ignored and normalized to lowercase on our side)
* `"decimals"` (number) - the number of decimals this token has i.e. which power of 10 value represents one whole token when it is processed on chain, normally the value returned by the `decimals()` method of the token's contract
* `"type"` (string) - type of token, for now we only support `"ERC20"` for market making (but we may also support `"ERC1155"` or `"ERC721"` in future since they are implemented in the smart contract)

This is an example of what to return from this endpoint (but without the newlines, indentation, spacing etc. that are not required, and given here to improve readability):

```json
{
  "tokens": {
    "WETH": {
      "symbol": "WETH",
      "name": "Wrapped Ether",
      "description": "Canonical wrapped Ether on Ethereum mainnet",
      "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "decimals": 18,
      "type": "ERC20"
    },
    "USDC": {
      "symbol": "USDC",
      "name": "USD Coin",
      "description": "Popular US dollar stablecoin, provided by Circle",
      "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "decimals": 6,
      "type": "ERC20"
    }
  }
}
```

### Pairs endpoint

Path: `/pairs`

Method: `GET`

This endpoint provides a list of trading pairs supported by this market maker (or recently disabled), mapping Pair IDs to base and quote Token IDs, and also giving an estimated indication of liquidity in USD terms associated with this pair (this is used to assist with finding routes between tokens).  Pairs should normally only be given in one direction of base vs. quote since the pricing of the other direction can be easily derived.

The response should be a JSON object containing the key `"pairs"`, which in turn contains a JSON object containing a number of entries, the key of which is the Pair ID, and the value being a JSON object with the following:

* `"base"` (string) - Token ID representing the base token of this pair (the token which the bids/asks are for)
* `"quote"` (string) - Token ID representing the quote token of this pair (the token in which prices are given)
* `"liquidityUSD"` (number) - an estimate of the liquidity the market maker has backing this pair, in US dollar terms (could be the maximum the market maker is willing to sell in both tokens, converted to USD and added together)

The Pair ID is recommended to be base token ID/symbol followed by `/` then the quote token ID/symbol.  Here is an example payload returned from this endpoint (again ignoring newlines/indentation/spacing):

```json
{
  "pairs": {
    "WETH/USDC": {
      "base": "WETH",
      "quote": "USDC",
      "liquidityUSD": 468000
    },
    "WETH/USDT": {
      "base": "WETH",
      "quote": "USDT",
      "liquidityUSD": 512500
    },
    "WBTC/WETH": {
      "base": "WBTC",
      "quote": "WETH",
      "liquidityUSD": 129800
    }
  }
}
```

### Prices endpoint

Path: `/prices`

Method: `GET`

This endpoint provides the full grid of price curves for all the supported pairs, which Velora will store in its cache, and can also specify pairs to remove from the cache, or even restrict trading to a single direction.

The response should be a JSON object containing the key `"prices"`, which in turn contains a JSON object with a number of entries, with the key being a Pair ID, and the value being an object which may contain the keys `"bids"` and `"asks"` (omitting either key means that trading in that direction is disabled and the corresponding cache entry will be cleared; to disable the pair entirely, both can be omitted so the object is empty `{}`).

Both `"bids"` and `"asks"` if present, should consist of an array of `[price, amount]` tuples defining the price curve as an order book, where `price` is a string representing the price of one base token in terms of the quote token, and `amount` is a string representing the amount of base token for this entry.  We use `bignumber.js` library to parse these strings as decimal numbers with high precision.  When computing a price the "orders" (tuples) are filled in sequential order, until the desired amount is reached.  As such it is expected that the entries start with the best price and get progressively worse (however this is not enforced, so any price curve can be used).  It is also expected that the best ask price is above the best bid price (this is not enforced neither, so market makers can risk arbitrage to deliver market beating prices and/or accelerate trading volume if they so wish).

Here is an example payload (newlines/indentation/spacing may be removed in the real thing):

```json
{
  "prices": {
    "WETH/USDC": {
      "bids": [
        ["1540", "0.5"],
        ["1500", "1.5"],
        ["1480", "3"]
      ],
      "asks": [
        ["1560", "1"],
        ["1580", "1.5"],
        ["1600", "2"],
        ["1650", "9"]
      ]
    },
    "WETH/USDT": {}
  }
}
```

In this example, trading for WETH/USDT is disabled (the cached prices for it will be cleared).  A user selling 1.5 WETH to this market maker should receive 1540 \* 0.5 + 1500 \* 1 = 2270 USDC (average price 1513.333 USDC), whereas buying 10 WETH from the market maker, they would spend 1560 \* 1 + 1580 \* 1.5 + 1600 \* 2 + 1650 \* 5.5 = 16205 USDC (average price 1620.5 USDC).  For computing prices based on a quote token amount (USDC in this case) we invert the order book (bids become asks and vice versa, new price is computed as 1 / price, and new amount is price \* amount), then use the same process.

Note that if you wish to remove a pair from trading, it should not be removed from `/pairs` endpoint straight away.  Instead, it must be retained there and given prices of `{}` as shown above for WETH/USDT for a period of time, after which it can finally be removed.

Failing to respond to this endpoint or responding with an error will cause market making to be temporarily disabled for this market maker, which may be done intentionally if you wish to cease trading entirely for a period of time.

### Firm quotes endpoint

Path: `/firm`

Method: `POST`

This endpoint is used to obtain a firm rate from the market maker, which is represented as a signed order for the AugustusRFQ smart contract.

For use in the Velora system the taker is set as a Velora contract (depending on execution context it can be Augustus V5, Augustus V6 or another contract) and the user of Velora (the `msg.sender` to AugustusSwapper) is encoded as metadata in the `nonceAndMeta` field; AugustusSwapper or other contracts are programmed to always check the user and metadata are matching when interacting with AugustusRFQ, so that no one can steal the order from the user and importantly to avoid users spamming requests for firm quotes, since they have to use a real user address and this address can be blacklisted by the market maker if they do so.

The body of the `POST` request will contain the following in a JSON object:

* `"makerAsset"` (string) - address of the token the maker is selling
* `"takerAsset"` (string) - address of the token the taker is selling
* `"makerAmount"` or `"takerAmount"` (string) - amount of the maker or taker asset respectively that is to be traded (only one may be specified and the other is calculated by the market maker based on current prices), this is specified as an integer by scaling up by 10^decimals
* `"userAddress"` (string) - address of the user as described above
* `"takerAddress"` (string) - address of the Velora contract that fills the order passed by Velora on calling POST /firm (either Augustus or another contract depending on the execution context. For V5 it's always [AugustusV5](https://developers.paraswap.network/smart-contracts#augustusswapper), for V6 it's either AugustusV6 or Executors). These addresses can be verified in the documentation [<mark style="color:blue;">here</mark>](https://developers.paraswap.network/smart-contracts#augustusswapper) or by the API endpoint [here](https://api.paraswap.io/adapters/contract-takers?network=137).

Here is an example payload sent to market maker (will be sent without newlines/indentation/spacing, the case of alphabetic characters in addresses is not specified, it may be all lowercase/uppercase or checksum encoded, the market maker should normalize it to the desired format):

```json
{
  "makerAsset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  "takerAsset": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
  "takerAmount": "1500000000000000000",
  "userAddress": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
  "takerAddress": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57"
}
```

This request represents a user selling 1.5 WETH for USDC.

Note that the specified amount specified in taker or maker asset may be slightly larger than the amount the user is able to swap, so that there is some flexibility if e.g. it is part of a multihop and the user receives less/more of the taker asset from a previous swap.

The response to this request should be a JSON object containing the key `"order"`, which in turn contains a JSON object with the following fields:

* `"nonceAndMeta"` (string) - a number (`uint256`) which encodes the user's address in the lower 160 bits and is otherwise filled with random/unpredictable data i.e. to calculate this, convert the address to an integer, and add it to a random integer shifted left by 160 bits (the random integer must be less than 2^96), e.g. in Python `(random.randint(0, 2**96 - 1) << 160) + int(address, 16)`
* `"expiry"` (number) - the time in seconds past UNIX epoch at which this order becomes no longer executable, this should be at least 2 minutes in the future
* `"makerAsset"` (string) - same as one passed in
* `"takerAsset"` (string) - same as one passed in
* `"maker"` (string) - this is the address containing the market maker's funds and it must have approved the AugustusRFQ contract to spend them, it is also the signer of the order if it is an EOA, otherwise it is a smart contract implementing EIP-1271
* `"taker"` (string) - the address of the contract that fills the order which can be picked from the request payload (either Augustus or another contract depending on the execution context. Augustus addresses can be verified [<mark style="color:blue;">here</mark>](https://developers.paraswap.network/smart-contracts#augustusswapper))
* `"makerAmount"` (string) - same as that passed in or calculated from the taker amount
* `"takerAmount"` (string) - same as that passed in or calculated from the maker amount
* `"signature"` (string) - `0x` followed by any number of bytes encoded in hexadecimal (lowercased) representing the `bytes` signature in the AugustusRFQ smart contract (the order hash of all other fields listed here is computed using EIP-712, and this must be signed using either an EOA or a smart contract EIP-1271 signature)

For creating the signature using an EOA maker address, please refer to the Velora SDKs (TypeScript or Python) for sample code or even consider using them directly.  For example in the Python SDK you can use the function `create_managed_p2p_order` to create a suitable order and `OrderHelper.sign_order` to sign it using `web3`.  If you use a EIP-1271 signature it depends on your smart contract how the signing will work, so you may need custom code.

Here is an example response payload (yet again ignore newlines/indentation/spacing):

```json
{
  "order": {
    "nonceAndMeta": "77194726158210796949047323338180021686013833221005105572687668833110133598159",
    "expiry": 1667344557,
    "makerAsset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "takerAsset": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "maker": "0x7777777777777777777777777777777777777777",
    "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
    "makerAmount": "2270000000",
    "takerAmount": "1500000000000000000",
    "signature": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcc"
  }
}
```

This payload corresponds to previously given examples regarding assets and prices etc.

If the request cannot be processed because the user address is blacklisted, and only in this case, you can return a successful response without any `"order"` key.  Optionally, this can contain a `"message"` field explaining that the user was blacklisted and even having a reason why.  When a user is detected blacklisted in this way it is added to the cache just as if it was received in the `/blacklist` endpoint described below.

You could also use our [SDK](/api/augustusrfq/sdk) for order signing. Please note, that you should pass `takerAddress` from the payload (whitelisted Velora contract) as `contractTaker`, and `userAddress` (actual user address) as `taker`, as described in the example [here](/api/augustusrfq/sdk/typescript#to-sign-a-limit-order).

### Blacklist endpoint

Path: `/blacklist`

Method: `GET`

This endpoint is used to list any user addresses which are currently blacklisted.  The payload is simply a JSON object with a key `"blacklist"` containing an array of blacklisted user addresses.  This should not contain duplicate entries!  Here is an example:

```json
{
  "blacklist": [
    "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
    "0x0000000000000000000000000000000000000000"
  ]
}
```

### WebSocket connection (optional)

Market makers may optionally provide a WebSocket interface, in addition to the other endpoints.  This is a one way channel from market maker to Velora, intended to serve pricing updates more efficiently.  Each message is a JSON object, and it can be used to send any information from other endpoints at any time, except for `"order"`, however instead of sending the complete data each time (except for the very first message), it sends updates (creating or updating entries only, not deleting them).  Here are specific details for each possible key:

* `"tokens"` should contain details of any newly supported tokens or corrections to existing ones
* `"pairs"` should contain any newly added pairs or corrections to existing ones, it is not recommended to update `"liquidityUSD"` by WebSockets since it is not used from this source and it is anyhow constantly changing
* `"prices"` should contain any pairs which need their prices updated, refreshed in the cache (after not being updated for too long), or that should be removed from the cache (bids, asks or both)
* `"blacklist"` should contain only newly added user addresses
* `"message"` can be used at any time to cause information to be logged on Velora servers

When the WebSocket is connected the first message should contain the complete responses to `/tokens`, `/pairs`, `/prices` and `/blacklist` endpoints in one JSON object (so that they don't need to be requested separately and potentially introduce synchronization issue).  Once the connection is established the `/blacklist` endpoint will still be queried periodically in order to refresh the blacklisted status of all blacklisted users, which is only stored in cache temporarily.

Should the market maker wish to stop trading entirely, the websocket connection can simply be disconnected and refuse to reconnect until they wish to start trading again.


# Data structure in our centralized system

This page explains the data structure of Velora's centralized service handling limit orders. It's adding some features like:

* tracking **maker** `balance` and `allowance` for ERC20 tokens.
* tracking state of orders

  * Fulfillment.
  * Cancellation.
  * Expiration.
  * Partially fulfillment.

For more information, please refer to the following document:

{% content-ref url="/pages/UVaMjvQgfQmLLPmINxSg" %}
[On chain Data Structure](/api/augustusrfq/on-chain-data-structure)
{% endcontent-ref %}

## ERC20: Order structure

```json
{
    "expiry": 0,
    "createdAt": 1661165141,
    "updatedAt": 1661165141,
    "transactionHash": null,
    "chainId": 137,
    "nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
    "maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
    "taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
    "takerFromMeta": "0x0000000000000000000000000000000000000000",
    "makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
    "takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
    "makerAmount": "10000000000000000",
    "fillableBalance": "10000000000000000",
    "swappableBalance": "10000000000000000",
    "makerBalance": "10000000000000000",
    "takerAmount": "7775870000000000",
    "signature": "0x43dd8dbc8228594171d0ed3e633ca0eb5c24f46bf0575100623ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b",
    "orderHash": "0xdef400fd95d028d8caaba2c4887d2694563e0bc7f73c17d747feac2e24ed411d",
    "permitMakerAsset": null,
    "type": "LIMIT",
    "state": "PENDING"
}
```

### Difference with on-chain limit order

* `nonceAndMeta`: In our centralized system we force nonce and meta to be constructed from an address plus a random integer between `0` and `2 ^  53 - 1` shifted 160 bits. The address that we pack is the actual taker address. (The address that swap `takerAsset` to `maketAsset`)

```
nonceAndMeta = address + (randInt(0, 2 ^ 53 - 1) << 160)
```

* `takerFromMeta`: is the decoded taker from `nonceAndMeta`. In Augustus contract we check the actual `takerAddress` (The address who swap `takerAsset` to `makerAsset`) by extracting its value from `nonceAndMeta`.
* `fillableBalance`:  is the amount that remains to be filled and can be used to check if the amount is partially filled. (`fillableBalance` ≠ `makeAmount`)
* `swappableBalance`:  is the actual amount that can be filled at this time.
* `makerBalance`: max amount `makerAddress` can fill the limit order.
* `orderHash`: hash of the on-chain Data structure.
* permitMakerAsset: always null for now will be used to store permit.
* `type`: `P2P` / `LIMIT` differentiate `p2p` from normal orders
  * `P2P`: has `takerFromMeta` set to some specific address.
  * `LIMIT`: has `takerFromMeta` set to `0x....0`.
* `state`: `PENDING` / `FULFILLED` / `EXPIRED` / `CANCELLED`.
  * `PENDING`: order is still usable.
  * `FULFILLED`: order is fully fulfilled.
  * `EXPIRED`: order is expired.
  * `CANCELLED`: order is canceled.

## NFT ERC 20/721/1155 Order structure

```
{
    "expiry": 1664716033,
    "createdAt": 1663853026,
    "transactionHash": null,
    "chainId": 137,
    "nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
    "maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
    "taker": "0x0000000000000000000000000000000000000000",
    "takerFromMeta": "0x0000000000000000000000000000000000000000",
    "makerAsset": "0xcd494673999194365033d7a287af9f0a3b163874",
    "makerAssetId": "1027",
    "makerAssetType": 2,
    "takerAsset": "0xad6d458402f60fd3bd25163575031acdce07538d",
    "takerAssetId": "0",
    "takerAssetType": 0,
    "makerAmount": "1",
    "fillableBalance": "1",
    "takerAmount": "50",
    "signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c",
    "orderHash": "0xe40182a75563c4c84e2ff4f2b4b44045fc94f66c929780ee82560d30cbadeb83",
    "permitMakerAsset": null,
    "type": "LIMIT",
    "state": "PENDING"
}

```

#### Difference with on-chain NFT order

* `makerAsset`: is the decoded address of the `makerAsset` from our limit order contract.
* `makerAssetId`: is the decoded token type from the `makerAsset` from our limit order contract.
* `takerAsset`: is the decoded address of the `makerAsset` from our limit order contract.
* `takerAssetId`: is the decoded token type from the `takerAsset` from our limit order contract.
* `takerFromMeta`: is the decoded taker from `nonceAndMeta`. In Augustus contract we check the actual `takerAddress` (The address who swap `takerAsset` to `makerAsset`) by extracting its value from `nonceAndMeta`.
* `fillableBalance`:  is the amount that remains to be filled and can be used to check if the amount is partially filled. (`fillableBalance` ≠ `makeAmount`)
* `orderHash`: hash of the on-chain Data structure.
* permitMakerAsset: always null for now will be used to store permit.
* `type`: `P2P` / `LIMIT` differentiate `p2p` from normal orders
  * `P2P`: has `takerFromMeta` set to some specific address.
  * `LIMIT`: has `takerFromMeta` set to `0x....0`.
* `state`: `PENDING` / `FULFILLED` / `EXPIRED` / `CANCELLED`.
  * `PENDING`: order is still usable.
  * `FULFILLED`: order is fully fulfilled.
  * `EXPIRED`: order is expired.
  * `CANCELLED`: order is canceled.


# API References

### API Architecture

API is separated in two different endpoints:

* `/ft/` for fungible token: this endpoints is to interact with limit orders from one ERC20 to another ERC20.
  * `/ft/orders/`: to interact with limit orders fillable by anybody.
  * `/ft/p2p/`: to interact with p2p orders.
* `/nft/` for non fungible token: this endpoints is used to interact with limit orders from any supported token to any supported token.
  * `/nft/p2p/` to interact with limit orders fillable by anybody.
  * `/nft/orders/`to interact with p2p orders.


# Fungible tokens

/ft/ fungible api

{% content-ref url="/pages/qGt3Hd1HEqRAQjC8sRGt" %}
[Create a p2p limit order](/api/augustusrfq/api-references/fungible-tokens/create-a-p2p-limit-order)
{% endcontent-ref %}

{% content-ref url="/pages/OUNzlbdmoImc8tFGorM5" %}
[Get limit orders by maker](/api/augustusrfq/api-references/fungible-tokens/get-limit-orders-by-maker)
{% endcontent-ref %}

{% content-ref url="/pages/b9aUNrXEiJTsNqOd7JN4" %}
[Get limit orders by taker](/api/augustusrfq/api-references/fungible-tokens/get-limit-orders-by-taker)
{% endcontent-ref %}

{% content-ref url="/pages/vA5SQhs5BFyCeR8wMY2h" %}
[Get Pairs](/api/augustusrfq/api-references/fungible-tokens/get-pairs)
{% endcontent-ref %}

{% content-ref url="/pages/JDbbaFpC5Xf0qusbydgO" %}
[Get Orderbook](/api/augustusrfq/api-references/fungible-tokens/get-orderbook)
{% endcontent-ref %}

{% content-ref url="/pages/8b4fYlGu8jezS90LU4zb" %}
[Fill a limit order](/api/augustusrfq/api-references/fungible-tokens/fill-a-limit-order)
{% endcontent-ref %}

{% content-ref url="/pages/6mKNVlw1ciYGUqEEanhs" %}
[Cancel a limit order](/api/augustusrfq/api-references/fungible-tokens/cancel-a-limit-order)
{% endcontent-ref %}

{% content-ref url="/pages/44nzdhvpEl5n7qR7QxAB" %}
[Create a limit order](/api/augustusrfq/api-references/fungible-tokens/create-a-limit-order)
{% endcontent-ref %}


# Create a limit order

### POST /ft/orders/:chainId/

#### Examples

{% tabs %}
{% tab title="curl" %}
The data to be sent to the endpoint consists of limit order parameters and a signature of those parameters produced by order maker.\
\
Generating this data consists of these steps:\
1\. compose [order parameters](https://github.com/paraswap/paraswap-sdk/blob/b56d23fab8bd9d849fef3a037839c005e5dde9ef/src/methods/limitOrders/helpers/buildOrderData.ts#L43-L52)\
2\. [sign an object with these parameters](https://github.com/paraswap/paraswap-sdk/blob/b56d23fab8bd9d849fef3a037839c005e5dde9ef/src/methods/limitOrders/helpers/buildOrderData.ts#L37) with `eth_signTypedData`\
3\. combine order parameters with the signature.

\
The resulting data will be validated and accepted by the POST endpoint and will have the [specified shape](/api/augustusrfq/on-chain-data-structure).

```bash
curl -X POST \
  'https://api.paraswap.io/ft/orders/137' \
  --header 'Content-Type: application/json' \
  --data-raw '{ 
    "maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
    "taker": "0x0000000000000000000000000000000000000000",
    "nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
    "expiry": 0,
    "makerAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
    "takerAsset": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
    "makerAmount": "10000000000000000",
    "takerAmount": "7775870000000000",
    "signature": "0x43de8dbc8228594171d0ed3e623ca0ab5c24f46bf0575800624ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b"
}'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';
import { ethers } from 'ethers';

import {
  // swap methods
  constructPartialSDK,
  constructEthersContractCaller,
  constructAxiosFetcher,
  // limitOrders methods
  constructBuildLimitOrder,
  constructSignLimitOrder,
  constructPostLimitOrder,
  // extra types
  SignableOrderData,
  LimitOrderToSend,
} from '..';

const account = '0x1234...';

const fetcher = constructAxiosFetcher(axios);

// provider must have write access to account
// this would usually be wallet provider (Metamask)
const provider = ethers.getDefaultProvider(1);
const contractCaller = constructEthersContractCaller(
  {
    ethersProviderOrSigner: provider,
    EthersContract: ethers.Contract,
  },
  account
);

// type BuildLimitOrderFunctions
// & SignLimitOrderFunctions
// & PostLimitOrderFunctions

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 1,
    fetcher,
    contractCaller,
  },
  constructBuildLimitOrder,
  constructSignLimitOrder,
  constructPostLimitOrder
);

const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F';
const HEX = '0x2b591e99afe9f32eaa6214f7b7629768c40eeb39';

const orderInput = {
  nonce: 1,
  expiry: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 7, // week from now, in sec
  makerAsset: DAI,
  takerAsset: HEX,
  makerAmount: (1e18).toString(10),
  takerAmount: (8e18).toString(10),
  maker: account,
};

async function run() {
  const signableOrderData: SignableOrderData =
    await paraSwapLimitOrderSDK.buildLimitOrder(orderInput);

  const signature: string = await paraSwapLimitOrderSDK.signLimitOrder(
    signableOrderData
  );

  const orderToPostToApi: LimitOrderToSend = {
    ...signableOrderData.data,
    signature,
  };

  const newOrder = await paraSwapLimitOrderSDK.postLimitOrder(orderToPostToApi);
  console.log(newOrder);
}

run();
```

{% endtab %}

{% tab title="Python" %}

```python
MAKER_ASSET = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"
TAKER_ASSET = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"

network = Network.Polygon

# initialize http rpc provider
provider = HTTPProvider("YOUR RPC PROVIDER")

# initialize web3
web3 = Web3(provider)

# create web3 account with pk1
account1 = web3.eth.account.from_key("your pk")

# hack to make PoA work (for example polygon)
web3.middleware_onion.inject(geth_poa_middleware, layer=0)

# create order helper object, TODO: maybe rename it to augustusRFQ helper
# orderHelper is an helper for the augustusRFQ contract
orderHelper = OrderHelper(
    network,
    web3,
)

# get ftApi object instance
# fungible api is a wrapper to our limit orders api
ftApi = create_fungible_api(network, api_url)

# create_managed_order is used to createa a limit order that our backend track fillability
# and also using for pricing inside paraswap protocol
order = create_managed_order(
    expiry=0,  # 0 means the order never expire
    maker=account1.address,  # account1 is the maker of the order
    maker_asset=MAKER_ASSET,  # account1 is selling maker_asset
    taker_asset=TAKER_ASSET,  # account1 is buying taker_asset
    maker_amount=1000000000000,  # amount of maker_asset that account1 is selling
    taker_amount=845718000000,  # amount of taker_asset that account1 is buying
)

# The created order needs to be sign with an account to be valid
orderWithSignature = orderHelper.sign_order(account1, order)

# send this signed order to our centralised api.
# It means that the order will be use in pricing
print("Order created")
print(res
```

{% endtab %}
{% endtabs %}

#### Query parameters:

* `chainId:`network id (Ethereum Mainnet = 1)

#### Body parameters

```json
{ 
    "maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
    "taker": "0x0000000000000000000000000000000000000000",
    "nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
    "expiry": 0,
    "makerAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
    "takerAsset": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
    "makerAmount": "10000000000000000",
    "takerAmount": "7775870000000000",
    "signature": "0x43de8dbc8228594171d0ed3e623ca0ab5c24f46bf0575800624ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b"
}
```

Important notice:

* `nonceAndMeta`: needs to be encoded as described in:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

#### Response&#x20;

Understand the response by checking our dedicated page:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

```json
{
	"order": {
		"expiry": 0,
		"createdAt": 1661165141,
		"updatedAt": 1661165141,
		"transactionHash": null,
		"chainId": 137,
		"nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
		"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
		"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
		"takerFromMeta": "0x0000000000000000000000000000000000000000",
		"makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
		"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
		"makerAmount": "10000000000000000",
		"fillableBalance": "10000000000000000",
		"swappableBalance": "10000000000000000",
		"makerBalance": "10000000000000000",
		"takerAmount": "7775870000000000",
		"signature": "0x43dd8dbc8228594171d0ed3e633ca0eb5c24f46bf0575100623ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b",
		"orderHash": "0xdef400fd95d028d8caaba2c4887d2694563e0bc7f73c17d747feac2e24ed411d",
		"permitMakerAsset": null,
		"type": "LIMIT",
		"state": "PENDING"
	}
}
```


# Create a p2p limit order

You can notice the difference between p2p and normal limit orders by looking at the path.

### **POST /ft/p2p/:chainId/**

#### Examples

{% tabs %}
{% tab title="curl" %}
The process of composing the order and the payload to POST to API endpoint is pretty much the [same as with usual non-p2p orders](/api/augustusrfq/api-references/fungible-tokens/create-a-limit-order).

The only differences are:

* slightly different route (`/ft/p2p/...` instead of `/ft/orders/...` )
* taker should contain [Augustus Swapper](/augustus-swapper/smart-contracts) address
* the intended order taker is [encoded in the nonceAndMeta](/api/augustusrfq/data-structure-in-our-centralized-system) field

```bash
curl -X POST \
  'https://api.paraswap.io/ft/p2p/1' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "nonceAndMeta": "1490585846052014974250870934243084527261268076495",
  "expiry": 1665493373,
  "makerAsset": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
  "takerAsset": "0x2b591e99afe9f32eaa6214f7b7629768c40eeb39",
  "maker": "0xB4E6f1c1f9Ba3aD97e09603966b4ac773303a8d1",
  "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
  "makerAmount": "1000000000000000000",
  "takerAmount": "8000000000000000000",
  "signature": "0x1647ae642db6e02c39ac80f40b73df032ca43648c2d11c44d5c7437e0c3a151739e54b7d3ea22067226b723ac84ac577a487579b04e7197bc3b13abee5d3952a1c"
}'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';
import { ethers } from 'ethers';

import {
  // swap methods
  constructPartialSDK,
  constructEthersContractCaller,
  constructAxiosFetcher,
  // limitOrders methods
  constructBuildLimitOrder,
  constructSignLimitOrder,
  constructPostLimitOrder,
  // extra types
  SignableOrderData,
  LimitOrderToSend,
} from '..';

const wallet = ethers.Wallet.createRandom();

const fetcher = constructAxiosFetcher(axios);

const provider = wallet.connect(ethers.getDefaultProvider(1));
const contractCaller = constructEthersContractCaller(
  {
    ethersProviderOrSigner: provider,
    EthersContract: ethers.Contract,
  },
  wallet.address
);

// type BuildLimitOrderFunctions
// & SignLimitOrderFunctions
// & PostLimitOrderFunctions

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 1,
    fetcher,
    contractCaller,
  },
  constructBuildLimitOrder,
  constructSignLimitOrder,
  constructPostLimitOrder
);

const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F';
const HEX = '0x2b591e99afe9f32eaa6214f7b7629768c40eeb39';

const orderInput = {
  nonce: 1,
  expiry: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 7, // week from now, in sec
  makerAsset: DAI,
  takerAsset: HEX,
  makerAmount: (1e18).toString(10),
  takerAmount: (8e18).toString(10),
  maker: wallet.address,
  taker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
};

async function run() {
  const signableOrderData: SignableOrderData =
    await paraSwapLimitOrderSDK.buildLimitOrder(orderInput);

  const signature: string = await paraSwapLimitOrderSDK.signLimitOrder(
    signableOrderData
  );

  const orderToPostToApi: LimitOrderToSend = {
    ...signableOrderData.data,
    signature,
  };

  const newOrder = await paraSwapLimitOrderSDK.postP2POrder(orderToPostToApi);
  console.log(newOrder);
}

run();
```

{% endtab %}

{% tab title="Python" %}

```python
MAKER_ASSET = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"
TAKER_ASSET = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"

network = Network.Polygon

api_url = "https://api.paraswap.io/"

# initialize http rpc provider
provider = HTTPProvider("YOUR RPC PROVIDER")

# initialize web3
web3 = Web3(provider)

# create web3 account with pk1
account1 = web3.eth.account.from_key("your pk")

# hack to make PoA work (for example polygon)
web3.middleware_onion.inject(geth_poa_middleware, layer=0)

# create order helper object, TODO: maybe rename it to augustusRFQ helper
# orderHelper is an helper for the augustusRFQ contract
orderHelper = OrderHelper(
    network,
    web3,
)

# get ftApi object instance
# fungible api is a wrapper to our limit orders api
ftApi = create_fungible_api(network, api_url)

# create_managed_order is used to createa a limit order that our backend track fillability
# and also using for pricing inside paraswap protocol
order = create_managed_p2p_order(
    network, # to get the correct augustus address
    expiry=0,  # 0 means the order never expire
    maker=account1.address,  # account1 is the maker of the order
    maker_asset=MAKER_ASSET,  # account1 is selling maker_asset
    taker_asset=TAKER_ASSET,  # account1 is buying taker_asset
    maker_amount=1000000000000,  # amount of maker_asset that account1 is selling
    taker_amount=845718000000,  # amount of taker_asset that account1 is buying
    "actual taker address",
)

# The created order needs to be sign with an account to be valid
orderWithSignature = orderHelper.sign_order(account1, order)

# send this signed order to our centralised api.
# It means that the order will be use in pricing
print("Order created")
print(res)
```

{% endtab %}
{% endtabs %}

#### Query parameters:

* `chainId:`network id (Ethereum Mainnet = 1)

#### Body parameters

```json
{ 
    "maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
    "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
    "nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
    "expiry": 0,
    "makerAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
    "takerAsset": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
    "makerAmount": "10000000000000000",
    "takerAmount": "7775870000000000",
    "signature": "0x43de8dbc8228594171d0ed3e623ca0ab5c24f46bf0575800624ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b"
}
```

Important notice:

* `nonceAndMeta`: needs to be encoded as described in (here we are in the p2p case so we should add the address of the person you want to execute a trade in `nonceAndMeta`):

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

#### Response&#x20;

Understand the response by checking our dedicated page:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

```json
{
	"order": {
		"expiry": 0,
		"createdAt": 1661165141,
		"updatedAt": 1661165141,
		"transactionHash": null,
		"chainId": 137,
		"nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
		"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
		"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
		"takerFromMeta": "0x0000000000000000000000000000000000000000",
		"makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
		"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
		"makerAmount": "10000000000000000",
		"fillableBalance": "10000000000000000",
		"swappableBalance": "10000000000000000",
		"makerBalance": "10000000000000000",
		"takerAmount": "7775870000000000",
		"signature": "0x43dd8dbc8228594171d0ed3e633ca0eb5c24f46bf0575100623ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b",
		"orderHash": "0xdef400fd95d028d8caaba2c4887d2694563e0bc7f73c17d747feac2e24ed411d",
		"permitMakerAsset": null,
		"type": "LIMIT",
		"state": "PENDING"
	}
}
```


# Get limit orders by maker

### GET /ft/orders/:chainId/maker/:address

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/ft/orders/1/maker/0x7BA594DF3161729BF2E68A9d0A11dceB57A2e306'
```

{% endtab %}

{% tab title="Typescript" %}

<pre class="language-typescript"><code class="lang-typescript"><strong>/* eslint-disable @typescript-eslint/no-unused-vars */
</strong>import axios from 'axios';

import {
  // swap methods
  constructPartialSDK,
  constructAxiosFetcher,
  // limitOrders methods
  constructGetLimitOrders,
} from '..';

const fetcher = constructAxiosFetcher(axios);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 1,
    fetcher,
  },
  constructGetLimitOrders
);

async function run() {
  const orders = await paraSwapLimitOrderSDK.getLimitOrders({
    maker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
    type: 'LIMIT',
  });
  console.log('orders', orders);
}

run();

</code></pre>

{% endtab %}

{% tab title="Python" %}

```python
network = Network.Polygon

api_url = "https://api.paraswap.io/"

# get ftApi object instance
# fungible api is a wrapper to our limit orders api
ftApi = create_fungible_api(network, api_url)

ordersResponse = ftApi.get_orders_by_maker("maker address")
```

{% endtab %}
{% endtabs %}

### GET /ft/p2p/:chainId/maker/:address (for p2p)

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/ft/p2p/1/maker/0x7BA594DF3161729BF2E68A9d0A11dceB57A2e306'
```

{% endtab %}

{% tab title="Typescript" %}

<pre class="language-typescript"><code class="lang-typescript"><strong>/* eslint-disable @typescript-eslint/no-unused-vars */
</strong>import axios from 'axios';

import {
  // swap methods
  constructPartialSDK,
  constructAxiosFetcher,
  // limitOrders methods
  constructGetLimitOrders,
} from '..';

const fetcher = constructAxiosFetcher(axios);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 1,
    fetcher,
  },
  constructGetLimitOrders
);

async function run() {
  const p2pOrders = await paraSwapLimitOrderSDK.getLimitOrders({
    maker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
    type: 'P2P',
  });
  console.log('p2pOrders', p2pOrders);
}

run();
</code></pre>

{% endtab %}
{% endtabs %}

#### Query parameters:

* `chainId:`network id (Ethereum Mainnet = 1).
* `address`: will return you the orders in which `maker == address`.
* `limit` (Optional): max count of orders.
* `offset` (Optional): pagination offset.
* `hideSmallBalances` (Optional, default: false): boolean if true will hide all orders in which 99.99% of the value has already been swapped.&#x20;

#### Response&#x20;

Understand the response by checking our dedicated page:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

```json
{
	"limit": 2,
	"offset": 0,
	"orders": [
		{
			"expiry": 0,
			"createdAt": 1661162877,
			"updatedAt": 1661162877,
			"transactionHash": null,
			"chainId": 137,
			"nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x0000000000000000000000000000000000000000",
			"makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
			"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
			"makerAmount": "10000000000000000",
			"fillableBalance": "10000000000000000",
			"swappableBalance": "0",
			"makerBalance": "10000000000000000",
			"isFillOrKill": false,
			"takerAmount": "7775870000000000",
			"signature": "0x43dd8dbc8228594171d0ed3e633ca0eb5c24f46bf0575100623ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b",
			"orderHash": "0xdef400fd95d028d8caaba2c4887d2694563e0bc7f73c17d747feac2e24ed411d",
			"permitMakerAsset": null,
			"type": "LIMIT",
			"state": "PENDING"
		},
		{
			"expiry": 0,
			"createdAt": 1661102635,
			"updatedAt": 1661162851,
			"transactionHash": "0x235aaa8472de0a724ea09daee5f2ed57d4365753d521008bcd9550d83a4461c7",
			"chainId": 137,
			"nonceAndMeta": "5138925241883764339325856218512467102197816820790096695352360960",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x0000000000000000000000000000000000000000",
			"makerAsset": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
			"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
			"makerAmount": "1000000",
			"fillableBalance": "27806",
			"swappableBalance": "27806",
			"makerBalance": "27806",
			"isFillOrKill": false,
			"takerAmount": "999800000000000000",
			"signature": "0x98e2cbd4e56290665c8301b7fd8b2590ce4d1e46fa674be601efef48f07599bf7f5cd7b1dc95653a3736bf06da0a41f251f85546ebe72491cd21a240b70ef66f1c",
			"orderHash": "0xef9fdf84be98cc70c05dbfe62af88412c1231f3025d3c829cf93b29f578a66fd",
			"permitMakerAsset": null,
			"type": "LIMIT",
			"state": "CANCELLED"
		}
	]
}
```


# Get limit orders by taker

### GET /ft/orders/:chainId/taker/:address

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/ft/orders/137/taker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';

import {
  constructPartialSDK,
  constructAxiosFetcher,
  constructGetLimitOrders,
} from '..';

const fetcher = constructAxiosFetcher(axios);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 1,
    fetcher,
  },
  constructGetLimitOrders
);

async function run() {
  const orders = await paraSwapLimitOrderSDK.getLimitOrders({
    taker: 'curl -X GET \
  'https://api.paraswap.io/ft/orders/137/maker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'curl -X GET \
  'https://api.paraswap.io/ft/orders/137/maker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'az',
    type: 'LIMIT',
  });
  console.log('orders', orders);
}

run();
```

{% endtab %}

{% tab title="Python" %}

```python
network = Network.Polygon

api_url = "https://api.paraswap.io/"

# get ftApi object instance
# fungible api is a wrapper to our limit orders api
ftApi = create_fungible_api(network, api_url)

ordersResponse = ftApi.get_orders_by_taker("taker address")
```

{% endtab %}
{% endtabs %}

### GET /ft/p2p/:chainId/taker/:address (for p2p)

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/ft/p2p/137/taker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';

import {
  constructPartialSDK,
  constructAxiosFetcher,
  constructGetLimitOrders,
} from '..';

const fetcher = constructAxiosFetcher(axios);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 1,
    fetcher,
  },
  constructGetLimitOrders
);

async function run() {
  const p2pOrders = await paraSwapLimitOrderSDK.getLimitOrders({
    taker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
    type: 'P2P',
  });
  console.log('p2pOrders', p2pOrders);
}

run();
```

{% endtab %}
{% endtabs %}

#### Query parameters:

* `chainId:`network id (Ethereum Mainnet = 1).
* address: will return you the orders in which `taker == address`.
* `limit` (Optional): max count of orders.
* `offset` (Optional): pagination offset.
* `hideSmallBalances` (Optional, default: false): boolean if true will hide all orders in which 99.99% of the value has already been swapped.&#x20;

#### Response&#x20;

Understand the response by checking our dedicated page:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

```json
{
	"limit": 2,
	"offset": 0,
	"orders": [
		{
			"expiry": 0,
			"createdAt": 1661162877,
			"updatedAt": 1661162877,
			"transactionHash": null,
			"chainId": 137,
			"nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x0000000000000000000000000000000000000000",
			"makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
			"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
			"makerAmount": "10000000000000000",
			"fillableBalance": "10000000000000000",
			"swappableBalance": "0",
			"makerBalance": "10000000000000000",
			"isFillOrKill": false,
			"takerAmount": "7775870000000000",
			"signature": "0x43dd8dbc8228594171d0ed3e633ca0eb5c24f46bf0575100623ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b",
			"orderHash": "0xdef400fd95d028d8caaba2c4887d2694563e0bc7f73c17d747feac2e24ed411d",
			"permitMakerAsset": null,
			"type": "LIMIT",
			"state": "PENDING"
		},
		{
			"expiry": 0,
			"createdAt": 1661102635,
			"updatedAt": 1661162851,
			"transactionHash": "0x235aaa8472de0a724ea09daee5f2ed57d4365753d521008bcd9550d83a4461c7",
			"chainId": 137,
			"nonceAndMeta": "5138925241883764339325856218512467102197816820790096695352360960",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x0000000000000000000000000000000000000000",
			"makerAsset": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
			"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
			"makerAmount": "1000000",
			"fillableBalance": "27806",
			"swappableBalance": "27806",
			"makerBalance": "27806",
			"isFillOrKill": false,
			"takerAmount": "999800000000000000",
			"signature": "0x98e2cbd4e56290665c8301b7fd8b2590ce4d1e46fa674be601efef48f07599bf7f5cd7b1dc95653a3736bf06da0a41f251f85546ebe72491cd21a240b70ef66f1c",
			"orderHash": "0xef9fdf84be98cc70c05dbfe62af88412c1231f3025d3c829cf93b29f578a66fd",
			"permitMakerAsset": null,
			"type": "LIMIT",
			"state": "CANCELLED"
		}
	]
}
```


# Get Pairs

### GET /ft/orders/:chainId/pairs

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/ft/orders/137/pairs'
```

{% endtab %}

{% tab title="Python" %}

```python
network = Network.Polygon

api_url = "https://api.paraswap.io/"

# get ftApi object instance
# fungible api is a wrapper to our limit orders api
ftApi = create_fungible_api(network, api_url)

pairs = ftApi.get_orderbook_pairs()

print(pairs)
```

{% endtab %}
{% endtabs %}

#### Query parameters

* `chainId:`network id (Ethereum Mainnet = 1).

#### Response

Example:

```
GET https://api.paraswap.io/ft/orders/137/pairs
```

```json
{
	"success": true,
	"pairs": [
		{
			"makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
			"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"
		}
	]
}
```


# Get Orderbook

### GET /ft/orders/:chainId/orderbook/

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/ft/orders/137/orderbook/?makerAsset=0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270&takerAsset=0x42d61d766b85431666b39b89c43011f24451bff6'
```

{% endtab %}

{% tab title="Python" %}

```python
MAKER_ASSET = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"
TAKER_ASSET = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"

network = Network.Polygon

api_url = "https://api.paraswap.io/"

# get ftApi object instance
# fungible api is a wrapper to our limit orders api
ftApi = create_fungible_api(network, api_url)

orderbook = ftApi.get_orderbook(MAKER_ASSET, TAKER_ASSET)

print(orderbook)
```

{% endtab %}
{% endtabs %}

#### Query parameters:

`makerAsset`: address of an ERC20 token

`takerAsset`: address of an ERC20 token

#### Response

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

This is returning you all the orders which respect `makerAsset == makerAsset` and `takerAsset == takerAsset`.

```json
{
	"success": true,
	"orders": [
		{
			"expiry": 0,
			"createdAt": 1663770783,
			"updatedAt": 1663770840,
			"transactionHash": "0xb0ec72d4b061a16e2bedad7153c6252f1d5ec21f1f88027f9cd465fa4cb19740",
			"chainId": 137,
			"nonceAndMeta": "1371981144015609647766132190312392568087326926048459362461024256",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0x0000000000000000000000000000000000000000",
			"takerFromMeta": "0x0000000000000000000000000000000000000000",
			"makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
			"takerAsset": "0x42d61d766b85431666b39b89c43011f24451bff6",
			"makerAmount": "1000000000000000",
			"fillableBalance": "116228613935036",
			"swappableBalance": "116228613935036",
			"makerBalance": "116228613935036",
			"isFillOrKill": false,
			"takerAmount": "25811200000000000",
			"signature": "0x4738ef41c95b11ae409eb605399b747357061478ebcc6eefb92ae50976135ac41fce9d04dfaa2ba4e0fdd37ca407ca0f3dc68acad736588d3af8f885492c9f0c1b",
			"orderHash": "0x9b52dd896e283acef9033f7a3079f2c656d109941f22d8be2144ae21857b30e6",
			"permitMakerAsset": null,
			"type": "LIMIT",
			"state": "PENDING"
		}
	]
}
```


# Fill a limit order

{% tabs %}
{% tab title="Typescript" %}
In order to fill an order, a [SwappableOrder](https://github.com/paraswap/paraswap-sdk/blob/b56d23fab8bd9d849fef3a037839c005e5dde9ef/src/methods/swap/transaction.ts#L28) data is required as an input.&#x20;

It can be [retrieved from API web](/api/augustusrfq/api-references/fungible-tokens/get-limit-orders-by-maker) service or [composed by maker](/api/augustusrfq/api-references/fungible-tokens/create-a-limit-order).

**Parameters**

```typescript
const orderWithSignature: SwappableOrder {
  nonceAndMeta: '1461501637330902918203684832716283019655932542976',
  expiry: 1665587100,
  makerAsset: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
  takerAsset: '0x2b591e99afe9f32eaa6214f7b7629768c40eeb39',
  maker: '0x2bb45fa7c25071ff37a49877A02b5b3986113A3A',
  taker: '0x0000000000000000000000000000000000000000',
  makerAmount: '1000000000000000000',
  takerAmount: '2800000000',
  signature: '0x97166e35e63ecab23a0c4e7ec4ec6863193b48ddcee4f9f8291ac95a05e9545c46037cdcf01445d7a2b5dd0fdce66bc9f8b49cac75be03a3ba07dc0d467387351c'
}
```

This data can then be supplemented by additional required params and sent to ParaSwap web API to generate [Augustus Swapper route](/augustus-swapper) for the fulfilment transaction:

```typescript
const txData = await sdk.buildLimitOrderTx(
  {
    srcDecimals: 18,
    destDecimals: 8,
    userAddress: taker.address,
    orders: [orderWithSignature],
  })
```

The returned transaction params can be used to send a transaction.&#x20;

**Example**

<pre class="language-typescript"><code class="lang-typescript">/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';
import BigNumber from 'bignumber.js';
import { ethers } from 'ethers';

import {
  constructPartialSDK,
  constructEthersContractCaller,
  constructAxiosFetcher,
  constructBuildLimitOrderTx,
  SwappableOrder,
} from '..';

const taker = ethers.Wallet.createRandom().connect(
  ethers.getDefaultProvider(1)
);

const fetcher = constructAxiosFetcher(axios);

const provider = taker;
const contractCaller = constructEthersContractCaller(
  {
    ethersProviderOrSigner: provider,
    EthersContract: ethers.Contract,
  },
  taker.address
);

const takerSDK = constructPartialSDK(
  {
    chainId: 1,
    contractCaller,
    fetcher,
  },
  constructBuildLimitOrderTx
);

const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F';
const HEX = '0x2b591e99afe9f32eaa6214f7b7629768c40eeb39';

<strong>const orderWithSignature: SwappableOrder = {
</strong>  nonceAndMeta: '1461501637330902918203684832716283019655932542976',
  expiry: 1665584787,
  makerAsset: DAI,
  takerAsset: HEX,
  maker: '0x5ad4346504d1DF55f22091058Ae9Db960E09a6E2',
  taker: '0x0000000000000000000000000000000000000000',
  makerAmount: (1e18).toString(10),
  takerAmount: (28e8).toString(10), // hex has 8 decimals
  signature:
    '0x7a554a9fcd423a2d3110366f8e265c8001049e86f03d9b4e84276496b7713dbb1d394adc38290a7ef231f7f7cc7908f11953cebb5650709e4558271b3203a5c41c',
};

async function run() {
  // build calldata for order fulfilling transaction
  const txData = await takerSDK.buildLimitOrderTx(
    {
      srcDecimals: 18,
      destDecimals: 18,
      userAddress: taker.address,
      orders: [orderWithSignature],
    },
    { ignoreChecks: true }
  );

  const { gas: payloadGas, ...LOPayloadTxParams } = txData;

  // compose ethers transaction out of provided params
  const transaction: ethers.providers.TransactionRequest = {
    ...LOPayloadTxParams,
    gasPrice: '0x' + new BigNumber(LOPayloadTxParams.gasPrice).toString(16),
    gasLimit: '0x' + new BigNumber(payloadGas || 5000000).toString(16),
    value: '0x' + new BigNumber(LOPayloadTxParams.value).toString(16),
  };

  // send
  const takerFillsOrderTx: ethers.providers.TransactionResponse =
    await taker.sendTransaction(transaction);

  console.log('takerFillsOrderTx', takerFillsOrderTx);
}

run();

</code></pre>

{% endtab %}
{% endtabs %}


# Cancel a limit order

To cancel an earlier placed order(s), a transaction [AugustusRFQ](/api/augustusrfq/contracts).[cancelOrder](https://etherscan.io/address/0xe92b586627cca7a83dc919cc7127196d70f55a06/advanced#writeContract#F3) (or [CancelOrders](https://etherscan.io/address/0xe92b586627cca7a83dc919cc7127196d70f55a06/advanced#writeContract#F4)) needs to be sent on behalf of the order's maker.

#### Transaction parameters:

`orderHash`: limit order unique id&#x20;

#### Example

{% tabs %}
{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';
import * as dotenv from 'dotenv';
import { ethers } from 'ethers';
import {
  constructPartialSDK,
  constructEthersContractCaller,
  constructAxiosFetcher,
  constructCancelLimitOrder,
  constructGetLimitOrders,
} from '..';
dotenv.config();

const maker = new ethers.Wallet(process.env.PK).connect(ethers.getDefaultProvider(1));

const fetcher = constructAxiosFetcher(axios);

// provider must have write access to account
// this would usually be wallet provider (Metamask)
const provider = ethers.getDefaultProvider(1);
const contractCaller = constructEthersContractCaller(
  {
    ethersProviderOrSigner: provider,
    EthersContract: ethers.Contract,
  },
  maker.address
);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 1,
    fetcher,
    contractCaller,
  },
  constructGetLimitOrders,
  constructCancelLimitOrder
);

async function run() {
  const { orders: currentOrders } = await paraSwapLimitOrderSDK.getLimitOrders({
    maker: maker.address,
    type: 'LIMIT',
  });

  if (!currentOrders[0]?.orderHash) throw new Error('No orders found');

  const deleteTx: ethers.ContractTransaction =
    await paraSwapLimitOrderSDK.cancelLimitOrder(currentOrders[0].orderHash);

  console.log('deleteTx', deleteTx);
}

```

{% endtab %}
{% endtabs %}


# NFT

/nft/ non-fungible api

{% content-ref url="/pages/j3TglElMxBJHSVLS9w5G" %}
[Create an order](/api/augustusrfq/api-references/nft/create-an-order)
{% endcontent-ref %}

{% content-ref url="/pages/0mHY4ScDKmpENoyQ7Lsf" %}
[Create a p2p order](/api/augustusrfq/api-references/nft/create-a-p2p-order)
{% endcontent-ref %}

{% content-ref url="/pages/PqGaSjrP4MdTO50WXHm8" %}
[Get NFT orders by maker](/api/augustusrfq/api-references/nft/get-nft-orders-by-maker)
{% endcontent-ref %}

{% content-ref url="/pages/QdrwoWOnQU7iLpTgDA1I" %}
[Get NFT orders by taker](/api/augustusrfq/api-references/nft/get-nft-orders-by-taker)
{% endcontent-ref %}

{% content-ref url="/pages/XvvYHSEb9u6daKgmImOH" %}
[Get Pairs](/api/augustusrfq/api-references/nft/get-pairs)
{% endcontent-ref %}

{% content-ref url="/pages/HdDuLymgg7sWNQosudkp" %}
[Get orderbook](/api/augustusrfq/api-references/nft/get-orderbook)
{% endcontent-ref %}

{% content-ref url="/pages/mlftg70Ah1bNcwwUYtDa" %}
[Fill a limit order](/api/augustusrfq/api-references/nft/fill-a-limit-order)
{% endcontent-ref %}

{% content-ref url="/pages/7MDF1QfwrzxARXuswmfS" %}
[Cancel a limit order](/api/augustusrfq/api-references/nft/cancel-a-limit-order)
{% endcontent-ref %}


# Create an order

### **POST /nft/orders/:chainId/**

#### **Examples**

{% tabs %}
{% tab title="curl" %}
The process of composing an NFT order and the payload to POST to API endpoint is pretty much the [same as with usual "fungible to fungible token" orders](/api/augustusrfq/api-references/fungible-tokens/create-a-limit-order).

The only differences are:

* slightly different endpoint route (`/nft/orders/...` instead of `/ft/orders/...` )
* `makerAssetType` and `takerAssetType` fields are required
* `makerAsset` and `takerAsset` contain not plain token addresses, but token address and token type encoded as described in [#body-parameters](#body-parameters "mention")
* `takerAssetId` and `makerAssetId` will contain NFT `tokenId` .  If it's "NFT to fungible" order, `takerAssetId` = 0 and `makerAssetId` = tokenID. If it's "fungible to NFT", then the opposite.

```bash
curl -X POST \
  'https://api.paraswap.io/nft/orders/137' \
  --header 'Content-Type: application/json' \
  --data-raw '{
	"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
	"expiry": 1664716033,
	"makerAsset": "4094980474276800865989028098863468306593436022900",
	"makerAssetId": "1027",
	"takerAsset": "990092240248101882666250324982272499898038834061",
	"takerAssetId": "0",
	"maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
	"taker": "0x0000000000000000000000000000000000000000",
	"makerAmount": "1",
	"takerAmount": "50",
	"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c"
}'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as dotenv from 'dotenv';
import axios from 'axios';
import { ethers } from 'ethers';

import {
  constructPartialSDK,
  constructEthersContractCaller,
  constructAxiosFetcher,
  constructBuildNFTOrder,
  constructSignNFTOrder,
  constructPostNFTOrder,
  BuildNFTOrderInput,
  SignableNFTOrderData,
  NFTOrderToSend,
  AssetType,
} from '..';
dotenv.config();

const randomPK = ethers.Wallet.createRandom().privateKey;

const wallet = new ethers.Wallet(process.env.PK || randomPK);

const fetcher = constructAxiosFetcher(axios);

const provider = wallet.connect(ethers.getDefaultProvider(137));
const contractCaller = constructEthersContractCaller(
  {
    ethersProviderOrSigner: provider,
    EthersContract: ethers.Contract,
  },
  wallet.address
);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 137,
    fetcher,
    contractCaller,
  },
  constructBuildNFTOrder,
  constructSignNFTOrder,
  constructPostNFTOrder
);

const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F';
const NFT = '0x2953399124f0cbb46d2cbacd8a89cf0599974963';
const NFT_ID =
  '7772759950848685723459796247330971791008072228632493699501910275462086524929';

const orderInput: BuildNFTOrderInput = {
  nonce: 1,
  expiry: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 7, // week from now, in sec
  makerAsset: NFT,
  makerAssetType: AssetType.ERC1155,
  makerAssetId: NFT_ID,
  takerAssetType: AssetType.ERC20,
  takerAsset: DAI,
  makerAmount: (1).toString(10),
  takerAmount: (8e18).toString(10),
  maker: wallet.address,
};

async function run() {
  const signableOrderData: SignableNFTOrderData =
    await paraSwapLimitOrderSDK.buildNFTOrder(orderInput);

  const signature: string = await paraSwapLimitOrderSDK.signNFTOrder(
    signableOrderData
  );

  const orderToPostToApi: NFTOrderToSend = {
    ...signableOrderData.data,
    signature,
  };

  const newOrder = await paraSwapLimitOrderSDK.postNFTLimitOrder(
    orderToPostToApi
  );
  console.log(newOrder);
}

run();
```

{% endtab %}
{% endtabs %}

#### Query parameters:

* `chainId:`network id (Ethereum Mainnet = 1)

#### Body parameters

```json
{
	"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
	"expiry": 1664716033,
	"makerAsset": "4094980474276800865989028098863468306593436022900",
	"makerAssetId": "1027",
	"takerAsset": "990092240248101882666250324982272499898038834061",
	"takerAssetId": "0",
	"maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
	"taker": "0x0000000000000000000000000000000000000000",
	"makerAmount": "1",
	"takerAmount": "50",
	"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c"
}
```

* `nonceAndMeta`: needs to be encoded as described in:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

* `makerAsset` and `takerAsset` needs to be encode as packed field containing address of an ERC20/721/1155 token that maker want to sell to the taker (between  `0-19 bits`). Token type encoded as show above on `20-21 bits`.

Example encoding in JavaScript:

```javascript
const ERC20 = 0;
const ERC721 = 2;
const ERC1155 = 1;

const encodeAddress = (address, assetType) => BigInt(address) | (BigInt(assetType) << BigInt(160));
encodedAddress = encodeAddress('0xcd494673999194365033d7a287af9f0a3b163874', ERC721);
```

#### Response&#x20;

Understand the response by checking our dedicated page:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

```json
{
	"order": {
		"expiry": 1664716033,
		"createdAt": 1663852073,
		"transactionHash": null,
		"chainId": 137,
		"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
		"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
		"taker": "0x0000000000000000000000000000000000000000",
		"takerFromMeta": "0x0000000000000000000000000000000000000000",
		"makerAsset": "0xcd494673999194365033d7a287af9f0a3b163874",
		"makerAssetId": "1027",
		"makerAssetType": 2,
		"takerAsset": "0xad6d458402f60fd3bd25163575031acdce07538d",
		"takerAssetId": "0",
		"takerAssetType": 0,
		"makerAmount": "1",
		"fillableBalance": "1",
		"takerAmount": "50",
		"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c",
		"orderHash": "0xe40182a75563c4c84e2ff4f2b4b44045fc94f66c929780ee82560d30cbadeb83",
		"permitMakerAsset": null,
		"type": "LIMIT",
		"state": "PENDING"
	}
}
```


# Create a p2p order

You can notice the difference between p2p and normal limit orders by looking at the path.

### **POST /nft/p2p/:chainId/**

#### **Examples**

{% tabs %}
{% tab title="curl" %}
The process of composing the order and the payload to POST to API endpoint is pretty much the [same as with usual non-p2p orders](/api/augustusrfq/api-references/nft/create-an-order).

The only differences are:

* slightly different route (`/nft/p2p/...` instead of `/nft/orders/...` )
* taker should contain [Augustus Swapper](/augustus-swapper/smart-contracts) address
* the intended order taker is [encoded in the nonceAndMeta](/api/augustusrfq/data-structure-in-our-centralized-system) field\`\`\`\`

```bash
curl -X POST \
  'https://api.paraswap.io/nft/p2p/137' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "nonceAndMeta": "1490585846052014974250870934243084527261268076495",
  "expiry": 1665643036,
  "makerAsset": "1697426235576502185006439320944601702126017005923",
  "takerAsset": "611382286831621467233887798921843936019654057231",
  "maker": "0x7BA594DF3161729BF2E68A9d0A11dceB57A2e306",
  "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
  "makerAmount": "1",
  "takerAmount": "8000000000000000000",
  "makerAssetId": "7772759950848685723459796247330971791008072228632493699501910275462086524929",
  "takerAssetId": "0",
  "signature": "0x292e484328f98ea5e59b0d57b8d0fc41ac67fc275146f43c0d005c1422d639014bd69dcd447eb583315dc578f7b087f0ad60711237b9fc4b518f22a0d09fc9341c"
}'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as dotenv from 'dotenv';
import axios from 'axios';
import { ethers } from 'ethers';

import {
  constructPartialSDK,
  constructEthersContractCaller,
  constructAxiosFetcher,
  constructBuildNFTOrder,
  constructSignNFTOrder,
  constructPostNFTOrder,
  BuildNFTOrderInput,
  SignableNFTOrderData,
  NFTOrderToSend,
  AssetType,
} from '..';
dotenv.config();

const randomPK = ethers.Wallet.createRandom().privateKey;

const wallet = new ethers.Wallet(process.env.PK || randomPK);

const fetcher = constructAxiosFetcher(axios);

const provider = wallet.connect(ethers.getDefaultProvider(137));
const contractCaller = constructEthersContractCaller(
  {
    ethersProviderOrSigner: provider,
    EthersContract: ethers.Contract,
  },
  wallet.address
);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 137,
    fetcher,
    contractCaller,
  },
  constructBuildNFTOrder,
  constructSignNFTOrder,
  constructPostNFTOrder
);

const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F';
const NFT = '0x2953399124f0cbb46d2cbacd8a89cf0599974963';
const NFT_ID =
  '7772759950848685723459796247330971791008072228632493699501910275462086524929';

const orderInput: BuildNFTOrderInput = {
  nonce: 1,
  expiry: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 7, // week from now, in sec
  makerAsset: NFT,
  makerAssetType: AssetType.ERC1155,
  makerAssetId: NFT_ID,
  takerAssetType: AssetType.ERC20,
  takerAsset: DAI,
  makerAmount: (1).toString(10),
  takerAmount: (8e18).toString(10),
  maker: wallet.address,
  taker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
};

async function run() {
  const signableOrderData: SignableNFTOrderData =
    await paraSwapLimitOrderSDK.buildNFTOrder(orderInput);

  const signature: string = await paraSwapLimitOrderSDK.signNFTOrder(
    signableOrderData
  );

  const orderToPostToApi: NFTOrderToSend = {
    ...signableOrderData.data,
    signature,
  };

  const newOrder = await paraSwapLimitOrderSDK.postNFTP2POrder(
    orderToPostToApi
  );
  console.log(newOrder);
}

run();

```

{% endtab %}
{% endtabs %}

#### Query parameters:

* `chainId:`network id (Ethereum Mainnet = 1)

#### Body parameters

```json
{
	"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
	"expiry": 1664716033,
	"makerAsset": "4094980474276800865989028098863468306593436022900",
	"makerAssetId": "1027",
	"takerAsset": "990092240248101882666250324982272499898038834061",
	"takerAssetId": "0",
	"maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
	"taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
	"makerAmount": "1",
	"takerAmount": "50",
	"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c"
}
```

* `nonceAndMeta`: needs to include the actual taker as described here:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

* `makerAsset` and `takerAsset` needs to be encode as packed field containing address of an ERC20/721/1155 token that maker want to sell to the taker (between  `0-19 bits`). Token type encoded as show above on `20-21 bits`.

Example encoding in JavaScript:

```javascript
const ERC20 = 0;
const ERC721 = 2;
const ERC1155 = 1;

const encodeAddress = (address, assetType) => BigInt(address) | (BigInt(assetType) << BigInt(160));
encodedAddress = encodeAddress('0xcd494673999194365033d7a287af9f0a3b163874', ERC721);
```

#### Response&#x20;

Understand the response by checking our dedicated page:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

```json
{
	"order": {
		"expiry": 1664717831,
		"createdAt": 1663853865,
		"transactionHash": null,
		"chainId": 137,
		"nonceAndMeta": "5849534550391847890058685755479665482115680361250527628888286063",
		"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
		"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
		"takerFromMeta": "0x6dac5cac7bbcce4db3c1cc5c8fe39dcdde52a36f",
		"makerAsset": "0xcd494673999194365033d7a287af9f0a3b163874",
		"makerAssetId": "1027",
		"makerAssetType": 2,
		"takerAsset": "0xad6d458402f60fd3bd25163575031acdce07538d",
		"takerAssetId": "0",
		"takerAssetType": 0,
		"makerAmount": "1",
		"fillableBalance": "1",
		"takerAmount": "50",
		"signature": "0xdb265004d19c79b2284ae327c586725c7f3535eeb1693d166a727d62efd521304874b658d106ca552f09352effa34be72826e2abdf6c6b09591318199eeb16081b",
		"orderHash": "0x33c5ca652106ef8340673b01e2ab8a713837bf42c2b3bef67143b65f9b89934c",
		"permitMakerAsset": null,
		"type": "P2P",
		"state": "PENDING"
	}
}
```


# Get NFT orders by maker

### GET /nft/orders/:chainId/maker/:address

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/nft/orders/137/maker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';

import {
  constructPartialSDK,
  constructAxiosFetcher,
  constructGetNFTOrders,
} from '..';

const fetcher = constructAxiosFetcher(axios);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 137,
    fetcher,
  },
  constructGetNFTOrders
);

async function run() {
  const orders = await paraSwapLimitOrderSDK.getNFTOrders({
    maker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
    type: 'LIMIT',
  });
  console.log('limit orders', orders);
}

run();

```

{% endtab %}
{% endtabs %}

### GET /nft/p2p/:chainId/maker/:address (for p2p)

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/nft/p2p/137/maker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
```

{% endtab %}

{% tab title="Second Tab" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';

import {
  constructPartialSDK,
  constructAxiosFetcher,
  constructGetNFTOrders,
} from '..';

const fetcher = constructAxiosFetcher(axios);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 137,
    fetcher,
  },
  constructGetNFTOrders
);

async function run() {
  const p2pOrders = await paraSwapLimitOrderSDK.getNFTOrders({
    maker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
    type: 'P2P',
  });
  console.log('p2pOrders', p2pOrders);
}

run();

```

{% endtab %}
{% endtabs %}

#### Query parameters:

* `chainId:`network id (Ethereum Mainnet = 1).
* `address`: will return you the orders in which `maker == address`.

#### Response&#x20;

Understand the response by checking our dedicated page:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

```json
{
	"orders": [
		{
			"expiry": 1664717831,
			"createdAt": 1663853865,
			"transactionHash": null,
			"chainId": 137,
			"nonceAndMeta": "5849534550391847890058685755479665482115680361250527628888286063",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x6dac5cac7bbcce4db3c1cc5c8fe39dcdde52a36f",
			"makerAsset": "0xcd494673999194365033d7a287af9f0a3b163874",
			"makerAssetId": "1027",
			"makerAssetType": 2,
			"takerAsset": "0xad6d458402f60fd3bd25163575031acdce07538d",
			"takerAssetId": "0",
			"takerAssetType": 0,
			"makerAmount": "1",
			"fillableBalance": "1",
			"takerAmount": "50",
			"signature": "0xdb265004d19c79b2284ae327c586725c7f3535eeb1693d166a727d62efd521304874b658d106ca552f09352effa34be72826e2abdf6c6b09591318199eeb16081b",
			"orderHash": "0x33c5ca652106ef8340673b01e2ab8a713837bf42c2b3bef67143b65f9b89934c",
			"permitMakerAsset": null,
			"type": "P2P",
			"state": "PENDING"
		}
	]
}
```


# Get NFT orders by taker

### GET /ft/orders/:chainId/taker/:address

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/nft/orders/137/taker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';

import {
  constructPartialSDK,
  constructAxiosFetcher,
  constructGetNFTOrders,
} from '..';

const fetcher = constructAxiosFetcher(axios);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 137,
    fetcher,
  },
  constructGetNFTOrders
);

async function run() {
  const orders = await paraSwapLimitOrderSDK.getNFTOrders({
    taker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
    type: 'LIMIT',
  });
  console.log('orders', orders);
}

run();
```

{% endtab %}
{% endtabs %}

### GET /ft/p2p/:chainId/taker/:address (for p2p)

#### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/nft/p2p/137/taker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';

import {
  constructPartialSDK,
  constructAxiosFetcher,
  constructGetNFTOrders,
} from '..';

const fetcher = constructAxiosFetcher(axios);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 137,
    fetcher,
  },
  constructGetNFTOrders
);

async function run() {
  const orders = await paraSwapLimitOrderSDK.getNFTOrders({
    taker: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
    type: 'P2P',
  });
  console.log('orders', orders);
}

run();

```

{% endtab %}
{% endtabs %}

#### Query parameters:

* `chainId:`network id (Ethereum Mainnet = 1).
* address: will return you the orders in which `taker == address`.

#### Response&#x20;

Understand the response by checking our dedicated page:

{% content-ref url="/pages/7EU4hKrvjbDV4PuKGPpS" %}
[Data structure in our centralized system](/api/augustusrfq/data-structure-in-our-centralized-system)
{% endcontent-ref %}

```json
{
	"orders": [
		{
			"expiry": 1664717831,
			"createdAt": 1663853865,
			"transactionHash": null,
			"chainId": 137,
			"nonceAndMeta": "5849534550391847890058685755479665482115680361250527628888286063",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x6dac5cac7bbcce4db3c1cc5c8fe39dcdde52a36f",
			"makerAsset": "0xcd494673999194365033d7a287af9f0a3b163874",
			"makerAssetId": "1027",
			"makerAssetType": 2,
			"takerAsset": "0xad6d458402f60fd3bd25163575031acdce07538d",
			"takerAssetId": "0",
			"takerAssetType": 0,
			"makerAmount": "1",
			"fillableBalance": "1",
			"takerAmount": "50",
			"signature": "0xdb265004d19c79b2284ae327c586725c7f3535eeb1693d166a727d62efd521304874b658d106ca552f09352effa34be72826e2abdf6c6b09591318199eeb16081b",
			"orderHash": "0x33c5ca652106ef8340673b01e2ab8a713837bf42c2b3bef67143b65f9b89934c",
			"permitMakerAsset": null,
			"type": "P2P",
			"state": "PENDING"
		}
	]
}{
	"limit": 2,
	"offset": 0,
	"orders": [
		{
			"expiry": 0,
			"createdAt": 1661162877,
			"updatedAt": 1661162877,
			"transactionHash": null,
			"chainId": 137,
			"nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x0000000000000000000000000000000000000000",
			"makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
			"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
			"makerAmount": "10000000000000000",
			"fillableBalance": "10000000000000000",
			"swappableBalance": "0",
			"makerBalance": "10000000000000000",
			"isFillOrKill": false,
			"takerAmount": "7775870000000000",
			"signature": "0x43dd8dbc8228594171d0ed3e633ca0eb5c24f46bf0575100623ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b",
			"orderHash": "0xdef400fd95d028d8caaba2c4887d2694563e0bc7f73c17d747feac2e24ed411d",
			"permitMakerAsset": null,
			"type": "LIMIT",
			"state": "PENDING"
		},
		{
			"expiry": 0,
			"createdAt": 1661102635,
			"updatedAt": 1661162851,
			"transactionHash": "0x235aaa8472de0a724ea09daee5f2ed57d4365753d521008bcd9550d83a4461c7",
			"chainId": 137,
			"nonceAndMeta": "5138925241883764339325856218512467102197816820790096695352360960",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x0000000000000000000000000000000000000000",
			"makerAsset": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
			"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
			"makerAmount": "1000000",
			"fillableBalance": "27806",
			"swappableBalance": "27806",
			"makerBalance": "27806",
			"isFillOrKill": false,
			"takerAmount": "999800000000000000",
			"signature": "0x98e2cbd4e56290665c8301b7fd8b2590ce4d1e46fa674be601efef48f07599bf7f5cd7b1dc95653a3736bf06da0a41f251f85546ebe72491cd21a240b70ef66f1c",
			"orderHash": "0xef9fdf84be98cc70c05dbfe62af88412c1231f3025d3c829cf93b29f578a66fd",
			"permitMakerAsset": null,
			"type": "LIMIT",
			"state": "CANCELLED"
		}
	]
}
```


# Get Pairs

### GET /nft/orders/:chainId/pairs

#### Example

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/nft/orders/137/pairs'
```

{% endtab %}
{% endtabs %}

#### Response

```
{
	"success": true,
	"pairs": [
		{
			"makerAsset": {
				"type": 2,
				"address": "0xcd494673999194365033d7a287af9f0a3b163874"
			},
			"takerAsset": {
				"type": 0,
				"address": "0xad6d458402f60fd3bd25163575031acdce07538d"
			}
		}
	]
}
```


# Get orderbook

### GET /nft/orders/:chainId/orderbook/

#### Query parameters:

`makerAsset (optional)`: address of an ERC20/721/1155 token

`makerAssetType (optional)`: encoded token type ERC20/721/1155 (0: ERC20, 1: ERC1155, 2: ERC721)

`takerAsset (optional)`: address of an ERC20/721/1155 token

`takerAssetType (optional)`: encoded token type ERC20/721/1155 (0: ERC20, 1: ERC1155, 2: ERC721)

#### Example:

* &#x20;Get the whole orderbook

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/nft/orders/137/orderbook/'
```

{% endtab %}
{% endtabs %}

* Get orderbook where `makerAsset` equal `0x2953399124f0cbb46d2cbacd8a89cf0599974963`

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/nft/orders/137/orderbook/?makerAsset=0x2953399124f0cbb46d2cbacd8a89cf0599974963'
```

{% endtab %}
{% endtabs %}

* Get orderbook where `makerAsset` type is `ERC1155` and `takerAsset` is `ERC20`:

{% tabs %}
{% tab title="curl" %}

```bash
curl -X GET \
  'https://api.paraswap.io/nft/orders/137/orderbook/?makerAssetType=1&takerAssetType=0'
```

{% endtab %}
{% endtabs %}

#### Response

```json
{
	"success": true,
	"orders": [
		{
			"expiry": 1664717831,
			"createdAt": 1663853865,
			"transactionHash": null,
			"chainId": 137,
			"nonceAndMeta": "5849534550391847890058685755479665482115680361250527628888286063",
			"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
			"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
			"takerFromMeta": "0x6dac5cac7bbcce4db3c1cc5c8fe39dcdde52a36f",
			"makerAsset": "0xcd494673999194365033d7a287af9f0a3b163874",
			"makerAssetId": "1027",
			"makerAssetType": 2,
			"takerAsset": "0xad6d458402f60fd3bd25163575031acdce07538d",
			"takerAssetId": "0",
			"takerAssetType": 0,
			"makerAmount": "1",
			"fillableBalance": "1",
			"takerAmount": "50",
			"signature": "0xdb265004d19c79b2284ae327c586725c7f3535eeb1693d166a727d62efd521304874b658d106ca552f09352effa34be72826e2abdf6c6b09591318199eeb16081b",
			"orderHash": "0x33c5ca652106ef8340673b01e2ab8a713837bf42c2b3bef67143b65f9b89934c",
			"permitMakerAsset": null,
			"type": "P2P",
			"state": "PENDING"
		}
	]
}
```


# Fill a limit order

{% tabs %}
{% tab title="Typescript" %}
In order to fill an order, a [SwappableNFTOrder](https://github.com/paraswap/paraswap-sdk/blob/b56d23fab8bd9d849fef3a037839c005e5dde9ef/src/methods/swap/transaction.ts#L33-L38) data is required as an input.&#x20;

It can be [retrieved from API](/api/augustusrfq/api-references/nft/get-nft-orders-by-maker) web service or [composed by maker](/api/augustusrfq/api-references/nft/create-an-order).

**Parameters**

```typescript
const orderWithSignature: SwappableNFTOrder = {
  expiry: 1665645962,
  nonceAndMeta: '1490585846052014974250870934243084527261268076495',
  maker: '0x7ba594df3161729bf2e68a9d0a11dceb57a2e306',
  taker: '0xdef171fe48cf0115b1d80b88dc8eab59176fee57',
  makerAsset: '0x2953399124f0cbb46d2cbacd8a89cf0599974963',
  makerAssetId:
    '7772759950848685723459796247330971791008072228632493699501910275462086524929',
  makerAssetType: 1,
  takerAsset: '0x6b175474e89094c44da98b954eedeac495271d0f',
  takerAssetId: '0',
  takerAssetType: 0,
  makerAmount: '1',
  takerAmount: '8000000000000000000',
  signature:
    '0x9247734939b4354ce6f99178ad95cbc19635e2ba86395370e29a8ac6a95cf5054203df0ba607717af1541a30d9df00962f16ada5273ef39633f304cc88faac0d1c',
};
```

This data can then be supplemented by additional required params and sent to ParaSwap web API to generate [Augustus Swapper route](/augustus-swapper) for the fulfilment transaction:

```typescript
const txData = await sdk.buildLimitOrderTx(
  {
    srcDecimals: 18,
    userAddress: taker.address,
    orders: [orderWithSignature],
  })
```

The returned transaction params can be used to send a transaction.&#x20;

**Example**

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as dotenv from 'dotenv';
import axios from 'axios';
import { ethers } from 'ethers';
import BigNumber from 'bignumber.js';
import {
  constructPartialSDK,
  constructEthersContractCaller,
  constructAxiosFetcher,
  constructBuildNFTOrderTx,
  SwappableNFTOrder,
} from '..';

dotenv.config();

const pk = ethers.Wallet.createRandom().privateKey;

const taker = new ethers.Wallet(process.env.PK || pk).connect(
  ethers.getDefaultProvider(137)
);

const fetcher = constructAxiosFetcher(axios);

// provider must have write access to account
// this would usually be wallet provider (Metamask)
const provider = taker;
const contractCaller = constructEthersContractCaller(
  {
    ethersProviderOrSigner: provider,
    EthersContract: ethers.Contract,
  },
  taker.address
);

const takerSDK = constructPartialSDK(
  {
    chainId: 137,
    contractCaller,
    fetcher,
  },
  constructBuildNFTOrderTx
);

const orderWithSignature: SwappableNFTOrder = {
  expiry: 1665645962,
  nonceAndMeta: '1490585846052014974250870934243084527261268076495',
  maker: '0x7ba594df3161729bf2e68a9d0a11dceb57a2e306',
  taker: '0xdef171fe48cf0115b1d80b88dc8eab59176fee57',
  makerAsset: '0x2953399124f0cbb46d2cbacd8a89cf0599974963',
  makerAssetId:
    '7772759950848685723459796247330971791008072228632493699501910275462086524929',
  makerAssetType: 1,
  takerAsset: '0x6b175474e89094c44da98b954eedeac495271d0f',
  takerAssetId: '0',
  takerAssetType: 0,
  makerAmount: '1',
  takerAmount: '8000000000000000000',
  signature:
    '0x9247734939b4354ce6f99178ad95cbc19635e2ba86395370e29a8ac6a95cf5054203df0ba607717af1541a30d9df00962f16ada5273ef39633f304cc88faac0d1c',
};

async function run() {
  // build calldata for order fulfilling transaction
  const txData = await takerSDK.buildNFTOrderTx(
    {
      srcDecimals: 18,
      userAddress: taker.address,
      orders: [orderWithSignature],
    },
    { ignoreChecks: true }
  );

  const { gas: payloadGas, ...LOPayloadTxParams } = txData;

  // compose ethers transaction out of provided params
  const transaction: ethers.providers.TransactionRequest = {
    ...LOPayloadTxParams,
    gasPrice: '0x' + new BigNumber(LOPayloadTxParams.gasPrice).toString(16),
    gasLimit: '0x' + new BigNumber(payloadGas || 5000000).toString(16),
    value: '0x' + new BigNumber(LOPayloadTxParams.value).toString(16),
  };

  // send
  const takerFillsNFTOrderTx: ethers.providers.TransactionResponse =
    await taker.sendTransaction(transaction);

  console.log('takerFillsNFTOrderTx', takerFillsNFTOrderTx);
}

run();
```

{% endtab %}
{% endtabs %}


# Cancel a limit order

The cancellation of an NFT order works in the same way as the [cancelation of "fungible tokens" order](/api/augustusrfq/api-references/fungible-tokens/cancel-a-limit-order)

#### Transaction parameters:

`orderHash`: limit order unique id&#x20;

#### Example&#x20;

{% tabs %}
{% tab title="Typescript" %}

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as dotenv from 'dotenv';
import axios from 'axios';
import { ethers } from 'ethers';
import {
  constructPartialSDK,
  constructEthersContractCaller,
  constructAxiosFetcher,
  constructCancelLimitOrder,
  constructGetLimitOrders,
} from '..';

dotenv.config();

const maker = new ethers.Wallet(process.env.PK).connect(
  ethers.getDefaultProvider(137)
);

const fetcher = constructAxiosFetcher(axios);

// provider must have write access to account
// this would usually be wallet provider (Metamask)
const provider = maker;
const contractCaller = constructEthersContractCaller(
  {
    ethersProviderOrSigner: provider,
    EthersContract: ethers.Contract,
  },
  maker.address
);

const paraSwapLimitOrderSDK = constructPartialSDK(
  {
    chainId: 137,
    fetcher,
    contractCaller,
  },
  constructGetLimitOrders,
  constructCancelLimitOrder
);

async function run() {
  const deleteTx: ethers.ContractTransaction =
    await paraSwapLimitOrderSDK.cancelLimitOrder(
      '0x045cf1a02e39cc59d2027d3cb9ea6d832d6e0f2904cc1f1afab39061eb589d05'
    );

  console.log('deleteTx', deleteTx);
}

run();
s
```

{% endtab %}
{% endtabs %}


# SDK

{% content-ref url="/pages/oczsViCJv3UEKrAZuAgQ" %}
[Typescript](/api/augustusrfq/sdk/typescript)
{% endcontent-ref %}

{% content-ref url="/pages/hU258DEEGhRHTuXMfvsc" %}
[Python](/api/augustusrfq/sdk/python)
{% endcontent-ref %}


# Typescript

[![](https://cdn.paraswap.io/brand/paraswap.png)](https://paraswap.io)

## SDK for the ParaSwap API

Refer to the documentation of the ParaSwap API: <https://developers.paraswap.network>

### Features

**Versatility**: works with both [web3](https://www.npmjs.com/package/web3) and [ethers](https://www.npmjs.com/package/ethers) without direct dependency

**Canonical**: bring only the functions you actually need

**Lightweight**: 400B Gzipped for the minimal variant

### Installing ParaSwap SDK

```bash
yarn add @paraswap/sdk
```

### Using ParaSwap SDK

There are multiple ways to use ParaSwap SDK, ranging from a simple construct-and-use approach to a fully composable *bring what you need* approach which allows for advanced tree-shaking and minimizes bundle size.

#### Simple SDK

Can be created by providing `chainId` and either `axios` or `window.fetch` (or alternative `fetch` implementation). The resulting SDK will be able to use all methods that query the API.

```ts
  import { constructSimpleSDK } from '@paraswap/sdk';
  import axios from 'axios';

  // construct minimal SDK with fetcher only
  const paraSwapMin = constructSimpleSDK({chainId: 1, axios});
  // or
  const paraSwapMin = constructSimpleSDK({chainId: 1, fetch: window.fetch});

  const ETH = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
  const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F';

  async function swapExample() {
    //                                     or any other signer/provider 
    const signer: JsonRpcSigner = ethers.Wallet.fromMnmemonic('__your_mnemonic__');
    const senderAddress = signer.address;

    const priceRoute = await paraSwapMin.swap.getRate({
      srcToken: ETH,
      destToken: DAI,
      amount: srcAmount,
      userAddress: senderAddress,
      side: SwapSide.SELL,
    });

    const txParams = await paraSwapMin.swap.buildTx(
      {
        srcToken,
        destToken,
        srcAmount,
        destAmount,
        priceRoute,
        userAddress: senderAddress,
        partner: referrer,
      }     
    );

    const transaction = {
      ...txParams,
      gasPrice: '0x' + new BigNumber(txParams.gasPrice).toString(16),
      gasLimit: '0x' + new BigNumber(5000000).toString(16),
      value: '0x' + new BigNumber(txParams.value).toString(16),
    };

    const txr = await signer.sendTransaction(transaction);
  }


  async function approveTokenYourselfExample() {
    const TransferProxy = await paraSwapMin.swap.getSpender();

    const DAI_CONTRACT = new ethers.Contract(DAI, ERC20_ABI, ethersSignerOrProvider);

    const tx = await DAI_CONTRACT.approve(TransferProxy, amountInWei);

    const txReceipt = await tx.wait(1);
  }
```

If optional `providerOptions` is provided as the second parameter, then the resulting SDK will also be able to approve Tokens for swap.

```ts
  // 
  // with ethers.js
  const providerOptionsEther = {
    ethersProviderOrSigner: provider, // JsonRpcProvider
    EthersContract: ethers.Contract,
    account: senderAddress,
  };

  // or with web3.js
  const providerOptionsWeb3 = {
    web3, // new Web3(...) instance
    account: senderAddress,
  };

  const paraSwap = constructSimpleSDK({chainId: 1, axios}, providerOptionsEther);

  async function approveTokenExample() {
    const txHash = await paraSwap.approveToken(amountInWei, DAI);

    // await tx somehow
    await provider.waitForTransaction(txHash);
  }
```

#### Composed SDK

Import the necessary functions

```typescript
import { constructSDK, constructAxiosFetcher, constructEthersContractCaller } from '@paraswap/sdk';
```

#### Construct the ParaSwap object

```typescript
const signer = ethers.Wallet.fromMnmemonic('__your_mnemonic__'); // or any other signer/provider 
const account = '__signer_address__';

const contractCaller = constructEthersContractCaller({
  ethersProviderOrSigner: signer,
  EthersContract: ethers.Contract,
}, account); // alternatively constructWeb3ContractCaller
const fetcher = constructAxiosFetcher(axios); // alternatively constructFetchFetcher

const paraswap = constructSDK({
  chainId: 1,
  fetcher,
  contractCaller,
});
```

#### To approve ParaSwap contracts to swap an ERC20 token

```typescript
// if created with constructEthersContractCaller
const contractTx: ContractTransaction = await paraSwap.approveToken(amount, tokenAddress);
const txReceipt = await contractTx.wait();

// if created with constructWeb3ContractCaller
const unpromiEvent: Web3UnpromiEvent = await paraSwap.approveToken(amount, tokenAddress);
const txReceipt = await new Promise<Web3TransactionReceipt>((resolve, reject) => {
  unpromiEvent.once('receipt', resolve);
  unpromiEvent.once('error', reject);
})
```

#### To get the rate of a token pair

```typescript
const srcToken = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'; // ETH
const destToken = '0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5'; // PSP
const srcAmount = '1000000000000000000'; //The source amount multiplied by its decimals: 10 ** 18 here
const srcDecimals = 18;
const destDecimals = 18;

const priceRoute = await paraSwap.getRate(
  {
    srcToken,
    destToken,
    amount,
    srcDecimals,
    destDecimals,
  }
);
```

Where priceRoute contains the rate and the distribution among exchanges, checkout the OptimalRates type for more details.

#### To build a transaction

```typescript
const srcToken = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
const srcDecimals = 18;
const srcAmount = '1000000000000000000'; // The source amount multiplied by its decimals
const destToken = '0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5';
const destDecimals = 18;
const destAmount = priceRoute.destAmount; // price route being output of paraSwap.getRate()
const senderAddress = '__sender_address__'; // mandatory
const receiver = '__receiver_address__'; // optional: for swap and transfer
const partnerAddress = '__fee_receiver_address__'; // optional: for permission-less monetization
const partnerFeeBps = 50; // optional: fee in base point, for permission-less monetization


const txParams = await paraSwap.buildTx(
  {
    srcAmount,
    srcToken,
    srcDecimals,
    destAmount,
    destToken,
    destDecimals,
    priceRoute,
    senderAddress,
    receiver,
    partnerAddress,
    partnerFeeBps,
  }
);

const transactionResponse = await signer.sendTransaction(txParams);
const transactionReceipt = await transactionResponse.wait();
```

#### To sign a Limit Order

```typescript
import {
	constructAxiosFetcher,
	constructBuildLimitOrder,
	constructEthersContractCaller,
	constructPartialSDK,
	constructSignLimitOrder,
	constructSimpleSDK
} from '@paraswap/sdk'
import axios from 'axios'
import { ethers } from 'ethers'

const signer = ethers.Wallet.fromMnemonic('__your_mnemonic__') // or any other signer/provider
const account = signer.address

const fetcher = constructAxiosFetcher(axios)
const contractCaller = constructEthersContractCaller(
	{
		ethersProviderOrSigner: signer,
		EthersContract: ethers.Contract
	},
	account
)

const paraSwapLimitOrderSDK = constructPartialSDK(
	{ chainId: 1, fetcher, contractCaller },
	constructBuildLimitOrder,
	constructSignLimitOrder
)

const order = {
	maker: account,
	/** actual user taker which will go into nonceAndMeta */
	taker: '0x6b175474e89094c44da98b954eedeac495271d0f',
	expiry: 0,
	makerAsset: '0xcafe001067cdef266afb7eb5a286dcfd277f3de5',
	takerAsset: '0xcafe001067cdef266afb7eb5a286dcfd277f3de5',
	makerAmount: '1000000000000',
	takerAmount: '1000000000000',
	/** (optional) contract executor (Augustus or similar) that is allowed to execute the order as Order.taker */
	contractTaker: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'
}

const signableOrderData = await paraSwapLimitOrderSDK.buildLimitOrder(order)
const signature = await paraSwapLimitOrderSDK.signLimitOrder(signableOrderData

```

### Playground

Interact with the ParaSwap SDK in a CodeSandbox playground [here](https://codesandbox.io/s/gallant-flower-7yuker)

### Bundle Optimization

For bundle-size savvy developers, you can construct a lightweight version of the SDK and bring only the functions you need.

e.g. for only getting rates and allowances:

```typescript
import { constructPartialSDK, constructFetchFetcher, constructGetRate, constructGetBalances } from '@paraswap/sdk';

const fetcher = constructFetchFetcher(window.fetch);

const minParaSwap = constructPartialSDK({
  chainId: 1,
  fetcher,
}, constructGetRate, constructGetBalances);

const priceRoute = await minParaSwap.getRate(params);
const allowance = await minParaSwap.getAllowance(userAddress, tokenAddress);
```

### Legacy

The `ParaSwap` class is exposed for backwards compatibility with previous versions of the SDK.

```typescript
import { ParaSwap } from '@paraswap/sdk';
import axios from 'axios';
import Web3 from 'web3';

const web3Provider = new Web3(window.ethereum);
const account = '__user_address__';

const paraswap = new ParaSwap({chainId: 1, web3Provider, account, axios});
```

Or you can use `ethers` in place of `web3`

```typescript
import { ParaSwap } from '@paraswap/sdk';
import { ethers } from "ethers";

const ethersProvider = new ethers.providers.Web3Provider(window.ethereum)
const account = '__user_address__';

const paraswap = new ParaSwap({
  chainId: 1,
  account,
  ethersDeps: {
    ethersProviderOrSigner: ethersProvider;
    EthersContract: ethers.Contract;
  },
  fetch: window.fetch,
 });
```

By analogy to `constructPartialSDK`, you can leverage a lightweight version of the sdk for fetching only.

```typescript
import { ParaSwap } from '@paraswap/sdk';

const paraswap = new ParaSwap({chainId: 1, fetch: window.fetch});
```

Refer to [this README for depecreated documentation](https://github.com/paraswap/paraswap-sdk/blob/c4c70c674fb2be4ec528064649d992d4b38c654b/README.md) for functions usage.

Refer to SDK API documentation for detailed documentation on the methods provided in this SDK.

### Tests

To run `yarn test` it is necessary to provide `PROVIDER_URL=<mainnet_rpc_url>` environment variable. If it is necessary to run tests against a different API endpoint, provide `API_URL=url_to_API` environment variable.

![](/files/Jw0kXFJrHoPJWLuPDUmB)


# Python

https\://github.com/paraswap/paraswap-python-sdk

ParaSwap's Python SDK V1 currently handles ParaSwap limit orders.

## Install

```
python3 setup.py build
python3 setup.py install # may need privilege authorization
```

## Run examples

You need to add the previous variables inside a .env file to run our examples.

PK1 and PK2 are two EVM-compatible secret keys that will be used to sign orders.

```
PK1=
PK2=

RPC_HTTP_1=
RPC_HTTP_3=
RPC_HTTP_10=
RPC_HTTP_56=
RPC_HTTP_137=
RPC_HTTP_250=
RPC_HTTP_42161=
RPC_HTTP_43114=
```

## Examples:

```
everything in ./examples/
```


# Augustus Swapper

Augustus is the exchange proxy that enables swaps to happen in ParaSwap.

## Introduction

In this section, we'll describe the architecture of Augustus Swapper and its different internal mechanisms.

## Simple-Path Swaps (Simple Swap)

Simple Swap is the simplest way for swapping tokens where there is no need to use any intermediary token.

Eg: Swapping 50 ETH --> MKR through one or more DEXs.

![paraswap.io](/files/-MhoXnq6JptVyr09QvOq)

## Multi-Path Swaps

A multi-path swap corresponds to using one or multiple intermediary tokens in a single swap in order to maximize the gain of the destination Token.&#x20;

An example would be **100 ETH** **--> USDT**, where the best route could be:&#x20;

* First, swapping 100 ETH to DAI,
* Then, swapping the corresponding DAI to USDT.

Here each step would use one or multiple DEXs.

![Example from paraswap.io](/files/-MhoWc0kUTGph-JvF59V)

## Mega-path Swaps

Mega Path is a generalized case for Multi Swap. Here, a swap can be broken down into ***multiple Multi-Swaps***. It's generally useful with larger amounts.

![paraswap.io](/files/-MhoX1lb1ixgaKqPQ75Z)

## Fee Structure

Partners integrating with ParaSwap using the ParaSwap API can control the fee structure of their integration, deciding whether to charge a swap fee or participate in surplus sharing.

For more information on how Partner Fees are implemented, please refer to the API Partners - Revenue Share Overview Section.

{% embed url="<https://doc.paraswap.network/integrating-paraswap/integrating-paraswap-overview/paraswap-api-revenue-sharing#partners-fees-overview>" %}

## Architecture

The primary AugustusSwapper contract acts as a proxy contract. It passes on the calls to respective routers as per the function signature. Each function call has its own specific router which needs to be registered by the admin.

## Routers

For each specific trade type, we have built a separate router. Currently, we have routers for:

* SimpleSwap,
* Multipath (with Megapath included),
* direct swaps on Uniswap V2 (and forks)
* direct swaps on 0x V2 and V4 (used to execute RFQ orders from ParaSwapPools)
* Additional helper functions (used by simple swap for example)

Multipath routers delegate calls to adapters.

## Adapters

Adapters are a collection of different exchange handlers. The number of exchange handlers is limited by the quantity of code allowed in one contract, so multiple adapters may be in use to cover all possible exchanges.

![image](https://user-images.githubusercontent.com/1330744/119963571-87e0ce00-bfa8-11eb-8d36-9eab98361425.png)

## Exchange Routers

These are not part of the Augustus architecture per se but independent contracts.  These are for use with simple swap where normally we'd use the official router contract of a DEX, but instead we may use a customized router (optimized to save gas).  Currently this is only done for Uniswap V2 and similar forks.


# Augustus v6.2 smart contracts

Augustus is the exchange middleware that enables on-chain swaps

## AugustusSwapper

The contract router is responsible for making swaps.

* Mainnet : [0x6a000f20005980200259b80c5102003040001068](https://etherscan.io/address/0x6a000f20005980200259b80c5102003040001068)
* Arbitrum: [0x6a000f20005980200259b80c5102003040001068](https://arbiscan.io/address/0x6A000F20005980200259B80c5102003040001068)
* Avalanche: [0x6a000f20005980200259b80c5102003040001068](https://snowscan.xyz/address/0x6A000F20005980200259B80c5102003040001068)
* Base: [0x6a000f20005980200259b80c5102003040001068](https://basescan.org/address/0x6A000F20005980200259B80c5102003040001068)
* BSC: [0x6a000f20005980200259b80c5102003040001068](https://bscscan.com/address/0x6A000F20005980200259B80c5102003040001068)
* Gnosis: [0x6A000F20005980200259B80c5102003040001068](https://gnosisscan.io/address/0x6A000F20005980200259B80c5102003040001068)
* Optimism: [0x6a000f20005980200259b80c5102003040001068](https://optimistic.etherscan.io/address/0x6A000F20005980200259B80c5102003040001068)
* Polygon: [0x6a000f20005980200259b80c5102003040001068](https://polygonscan.com/address/https://optimistic.etherscan.io/address/0x6A000F20005980200259B80c5102003040001068)
* Sonic: [0x6a000f20005980200259b80c5102003040001068](https://sonicscan.org/address/0x6a000f20005980200259b80c5102003040001068)
* Unichain: [0x6a000f20005980200259b80c5102003040001068](https://unichain.blockscout.com/address/0x6A000F20005980200259B80c5102003040001068)
* Plasma: [0x6a000f20005980200259b80c5102003040001068](https://plasmascan.to/address/0x6a000f20005980200259b80c5102003040001068)

{% file src="/files/ZVrxBCDarEU5taX6pdM9" %}

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;

// Interfaces
import { IERC20 } from "@openzeppelin/token/ERC20/IERC20.sol";

/*//////////////////////////////////////////////////////////////
                        GENERIC SWAP DATA
//////////////////////////////////////////////////////////////*/

/// @notice Struct containg data for generic swapExactAmountIn/swapExactAmountOut
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param quotedAmount The quoted expected amount of destToken/srcToken
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
struct GenericData {
    IERC20 srcToken;
    IERC20 destToken;
    uint256 fromAmount;
    uint256 toAmount;
    uint256 quotedAmount;
    bytes32 metadata;
    address payable beneficiary;
}

/*//////////////////////////////////////////////////////////////
                            UNISWAPV2
//////////////////////////////////////////////////////////////*/

/// @notice Struct for UniswapV2 swapExactAmountIn/swapExactAmountOut data
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param quotedAmount The quoted expected amount of destToken/srcToken
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
/// @param pools data consisting of concatenated token0 and token1 address for each pool with the direction flag being
/// the right most bit of the packed token0-token1 pair bytes used in the path
struct UniswapV2Data {
    IERC20 srcToken;
    IERC20 destToken;
    uint256 fromAmount;
    uint256 toAmount;
    uint256 quotedAmount;
    bytes32 metadata;
    address payable beneficiary;
    bytes pools;
}

/*//////////////////////////////////////////////////////////////
                            UNISWAPV3
//////////////////////////////////////////////////////////////*/

/// @notice Struct for UniswapV3 swapExactAmountIn/swapExactAmountOut data
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param quotedAmount The quoted expected amount of destToken/srcToken
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
/// @param pools data consisting of concatenated token0-
/// token1-fee bytes for each pool used in the path, with the direction flag being the left most bit of token0 in the
/// concatenated bytes
struct UniswapV3Data {
    IERC20 srcToken;
    IERC20 destToken;
    uint256 fromAmount;
    uint256 toAmount;
    uint256 quotedAmount;
    bytes32 metadata;
    address payable beneficiary;
    bytes pools;
}

/*//////////////////////////////////////////////////////////////
                            CURVE V1
//////////////////////////////////////////////////////////////*/

/// @notice Struct for CurveV1 swapExactAmountIn data
/// @param curveData Packed data for the Curve pool, first 160 bits is the target exchange address,
/// the 161st bit is the approve flag, bits from (162 - 163) are used for the wrap flag,
//// bits from (164 - 165) are used for the swapType flag and the last 91 bits are unused:
/// Approve Flag - a) 0 -> do not approve b) 1 -> approve
/// Wrap Flag - a) 0 -> do not wrap b) 1 -> wrap native & srcToken == eth
/// c) 2 -> unwrap and destToken == eth d) 3 - >srcToken == eth && do not wrap
/// Swap Type Flag -  a) 0 -> EXCHANGE b) 1 -> EXCHANGE_UNDERLYING
/// @param curveAssets Packed uint128 index i and uint128 index j of the pool
/// The first 128 bits is the index i and the second 128 bits is the index j
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount that must be recieved
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param quotedAmount The expected amount of destToken to be recieved
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
struct CurveV1Data {
    uint256 curveData;
    uint256 curveAssets;
    IERC20 srcToken;
    IERC20 destToken;
    uint256 fromAmount;
    uint256 toAmount;
    uint256 quotedAmount;
    bytes32 metadata;
    address payable beneficiary;
}

/*//////////////////////////////////////////////////////////////
                            CURVE V2
//////////////////////////////////////////////////////////////*/

/// @notice Struct for CurveV2 swapExactAmountIn data
/// @param curveData Packed data for the Curve pool, first 160 bits is the target exchange address,
/// the 161st bit is the approve flag, bits from (162 - 163) are used for the wrap flag,
//// bits from (164 - 165) are used for the swapType flag and the last 91 bits are unused
/// Approve Flag - a) 0 -> do not approve b) 1 -> approve
/// Approve Flag - a) 0 -> do not approve b) 1 -> approve
/// Wrap Flag - a) 0 -> do not wrap b) 1 -> wrap native & srcToken == eth
/// c) 2 -> unwrap and destToken == eth d) 3 - >srcToken == eth && do not wrap
/// Swap Type Flag -  a) 0 -> EXCHANGE b) 1 -> EXCHANGE_UNDERLYING c) 2 -> EXCHANGE_UNDERLYING_FACTORY_ZAP
/// @param i The index of the srcToken
/// @param j The index of the destToken
/// The first 128 bits is the index i and the second 128 bits is the index j
/// @param poolAddress The address of the CurveV2 pool (only used for EXCHANGE_UNDERLYING_FACTORY_ZAP)
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount that must be recieved
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param quotedAmount The expected amount of destToken to be recieved
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiary The address to send the swapped tokens to
struct CurveV2Data {
    uint256 curveData;
    uint256 i;
    uint256 j;
    address poolAddress;
    IERC20 srcToken;
    IERC20 destToken;
    uint256 fromAmount;
    uint256 toAmount;
    uint256 quotedAmount;
    bytes32 metadata;
    address payable beneficiary;
}

/*//////////////////////////////////////////////////////////////
                            BALANCER V2
//////////////////////////////////////////////////////////////*/

/// @notice Struct for BalancerV2 swapExactAmountIn data
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param quotedAmount The quoted expected amount of destToken/srcToken
/// = quotedAmountOut for swapExactAmountIn and quotedAmountIn for swapExactAmountOut
/// @param metadata Packed uuid and additional metadata
/// @param beneficiaryAndApproveFlag The beneficiary address and approve flag packed into one uint256,
/// the first 20 bytes are the beneficiary address and the left most bit is the approve flag
struct BalancerV2Data {
    uint256 fromAmount;
    uint256 toAmount;
    uint256 quotedAmount;
    bytes32 metadata;
    uint256 beneficiaryAndApproveFlag;
}

/*//////////////////////////////////////////////////////////////
                            MAKERPSM
//////////////////////////////////////////////////////////////*/

/// @notice Struct for Maker PSM swapExactAmountIn data
/// @param srcToken The token to swap from
/// @param destToken The token to swap to
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param toll Used to calculate gem amount for the swapExactAmountIn
/// @param to18ConversionFactor Used to calculate gem amount for the swapExactAmountIn
/// @param gemJoinAddress The address of the gemJoin contract
/// @param exchange The address of the exchange contract
/// @param metadata Packed uuid and additional metadata
/// @param beneficiaryDirectionApproveFlag The beneficiary address, swap direction and approve flag packed
/// into one uint256, the first 20 bytes are the beneficiary address, the left most bit is the approve flag and the
/// second left most bit is the swap direction flag, 0 for swapExactAmountIn and 1 for swapExactAmountOut
struct MakerPSMData {
    IERC20 srcToken;
    IERC20 destToken;
    uint256 fromAmount;
    uint256 toAmount;
    uint256 toll;
    uint256 to18ConversionFactor;
    address exchange;
    address gemJoinAddress;
    bytes32 metadata;
    uint256 beneficiaryDirectionApproveFlag;
}

/*//////////////////////////////////////////////////////////////
                            AUGUSTUS RFQ
//////////////////////////////////////////////////////////////*/

/// @notice Order struct for Augustus RFQ
/// @param nonceAndMeta The nonce and meta data packed into one uint256,
/// the first 160 bits is the user address and the last 96 bits is the nonce
/// @param expiry The expiry of the order
/// @param makerAsset The address of the maker asset
/// @param takerAsset The address of the taker asset
/// @param maker The address of the maker
/// @param taker The address of the taker, if the taker is address(0) anyone can take the order
/// @param makerAmount The amount of makerAsset
/// @param takerAmount The amount of takerAsset
struct Order {
    uint256 nonceAndMeta;
    uint128 expiry;
    address makerAsset;
    address takerAsset;
    address maker;
    address taker;
    uint256 makerAmount;
    uint256 takerAmount;
}

/// @notice Struct containing order info for Augustus RFQ
/// @param order The order struct
/// @param signature The signature for the order
/// @param takerTokenFillAmount The amount of takerToken to fill
/// @param permitTakerAsset The permit data for the taker asset
/// @param permitMakerAsset The permit data for the maker asset
struct OrderInfo {
    Order order;
    bytes signature;
    uint256 takerTokenFillAmount;
    bytes permitTakerAsset;
    bytes permitMakerAsset;
}

/// @notice Struct containing common data for executing swaps on Augustus RFQ
/// @param fromAmount The amount of srcToken to swap
/// = amountIn for swapExactAmountIn and maxAmountIn for swapExactAmountOut
/// @param toAmount The minimum amount of destToken to receive
/// = minAmountOut for swapExactAmountIn and amountOut for swapExactAmountOut
/// @param wrapApproveDirection The wrap, approve and direction flag packed into one uint8,
/// the first 2 bits is wrap flag (10 for wrap dest, 01 for wrap src, 00 for no wrap), the next bit is the approve flag
/// (1 for approve, 0 for no approve) and the last bit is the direction flag (0 for swapExactAmountIn and 1 for
/// swapExactAmountOut)
/// @param metadata Packed uuid and additional metadata
struct AugustusRFQData {
    uint256 fromAmount;
    uint256 toAmount;
    uint8 wrapApproveDirection;
    bytes32 metadata;
    address payable beneficiary;
}

```

### Interfaces

#### GenericSwapExactAmountIn

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;

// Interfaces
import { IErrors } from "./IErrors.sol";

// Types
import { GenericData } from "../AugustusV6Types.sol";

/// @title IGenericSwapExactAmountIn
/// @notice Interface for executing a generic swapExactAmountIn through an Augustus executor
interface IGenericSwapExactAmountIn is IErrors {
    /*//////////////////////////////////////////////////////////////
                          SWAP EXACT AMOUNT IN
    //////////////////////////////////////////////////////////////*/

    /// @notice Executes a generic swapExactAmountIn using the given executorData on the given executor
    /// @param executor The address of the executor contract to use
    /// @param swapData Generic data containing the swap information
    /// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
    /// 20 bytes is the partner address
    /// @param permit The permit data
    /// @param executorData The data to execute on the executor
    /// @return receivedAmount The amount of destToken received after fees
    /// @return paraswapShare The share of the fees for Paraswap
    /// @return partnerShare The share of the fees for the partner
    function swapExactAmountIn(
        address executor,
        GenericData calldata swapData,
        uint256 partnerAndFee,
        bytes calldata permit,
        bytes calldata executorData
    )
        external
        payable
        returns (uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
}
```

#### GenericSwapExactAmountOut

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;

// Interfaces
import { IErrors } from "./IErrors.sol";

// Types
import { GenericData } from "../AugustusV6Types.sol";

/// @title IGenericSwapExactAmountOut
/// @notice Interface for executing a generic swapExactAmountOut through an Augustus executor
interface IGenericSwapExactAmountOut is IErrors {
    /*//////////////////////////////////////////////////////////////
                         SWAP EXACT AMOUNT OUT
    //////////////////////////////////////////////////////////////*/

    /// @notice Executes a generic swapExactAmountOut using the given executorData on the given executor
    /// @param executor The address of the executor contract to use
    /// @param swapData Generic data containing the swap information
    /// @param partnerAndFee packed partner address and fee percentage, the first 12 bytes is the feeData and the last
    /// 20 bytes is the partner address
    /// @param permit The permit data
    /// @param executorData The data to execute on the executor
    /// @return spentAmount The actual amount of tokens used to swap
    /// @return receivedAmount The amount of tokens received from the swap
    /// @return paraswapShare The share of the fees for Paraswap
    /// @return partnerShare The share of the fees for the partner
    function swapExactAmountOut(
        address executor,
        GenericData calldata swapData,
        uint256 partnerAndFee,
        bytes calldata permit,
        bytes calldata executorData
    )
        external
        payable
        returns (uint256 spentAmount, uint256 receivedAmount, uint256 paraswapShare, uint256 partnerShare);
}
```

### **Fee Vault**

* Ethereum: [0x00700052c0608f670705380a4900e0a8080010cc](https://etherscan.io/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Arbitrum: [0x00700052c0608f670705380a4900e0a8080010cc](https://arbiscan.io/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Avalanche: [0x00700052c0608f670705380a4900e0a8080010cc](https://snowtrace.io/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Base: [0x00700052c0608f670705380a4900e0a8080010cc](https://basescan.org/address/0x00700052c0608f670705380a4900e0a8080010cc)
* BSC: [0x00700052c0608f670705380a4900e0a8080010cc](https://bscscan.com/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Fantom: [0x00700052c0608f670705380a4900e0a8080010cc](https://ftmscan.com/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Gnosis: [0x00700052c0608F670705380a4900e0a8080010CC](https://gnosisscan.io/address/0x00700052c0608F670705380a4900e0a8080010CC)
* Optimism: [0x00700052c0608f670705380a4900e0a8080010cc](https://optimistic.etherscan.io/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Polygon [0x00700052c0608f670705380a4900e0a8080010cc](https://polygonscan.com/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Sonic: [0x00700052c0608f670705380a4900e0a8080010cc](https://sonicscan.org/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Unichain: [0x00700052c0608f670705380a4900e0a8080010cc](https://unichain.blockscout.com/address/0x00700052c0608f670705380a4900e0a8080010cc)
* Plasma: [0x00700052c0608f670705380a4900e0a8080010cc](https://plasmascan.to/address/0x00700052c0608f670705380a4900e0a8080010cc)

{% file src="/files/bGhtLjTi2tCIwJMcyc8O" %}

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;

// Interfaces
import { IERC20 } from "@openzeppelin/token/ERC20/IERC20.sol";

/// @title IAugustusFeeVault
/// @notice Interface for the AugustusFeeVault contract
interface IAugustusFeeVault {
    /*//////////////////////////////////////////////////////////////
                                 ERRORS
    //////////////////////////////////////////////////////////////*/

    /// @notice Error emitted when withdraw amount is zero or exceeds the stored amount
    error InvalidWithdrawAmount();

    /// @notice Error emmitted when caller is not an approved augustus contract
    error UnauthorizedCaller();

    /// @notice Error emitted when an invalid parameter length is passed
    error InvalidParameterLength();

    /// @notice Error emitted when batch withdraw fails
    error BatchCollectFailed();

    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Emitted when an augustus contract approval status is set
    /// @param augustus The augustus contract address
    /// @param approved The approval status
    event AugustusApprovalSet(address indexed augustus, bool approved);

    /*//////////////////////////////////////////////////////////////
                                STRUCTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Struct to register fees
    /// @param addresses The addresses to register fees for
    /// @param token The token to register fees for
    /// @param fees The fees to register
    struct FeeRegistration {
        address[] addresses;
        IERC20 token;
        uint256[] fees;
    }

    /*//////////////////////////////////////////////////////////////
                                COLLECT
    //////////////////////////////////////////////////////////////*/

    /// @notice Allows partners to withdraw fees allocated to them and stored in the vault
    /// @param token The token to withdraw fees in
    /// @param amount The amount of fees to withdraw
    /// @param recipient The address to send the fees to
    /// @return success Whether the transfer was successful or not
    function withdrawSomeERC20(IERC20 token, uint256 amount, address recipient) external returns (bool success);

    /// @notice Allows partners to withdraw all fees allocated to them and stored in the vault for a given token
    /// @param token The token to withdraw fees in
    /// @param recipient The address to send the fees to
    /// @return success Whether the transfer was successful or not
    function withdrawAllERC20(IERC20 token, address recipient) external returns (bool success);

    /// @notice Allows partners to withdraw all fees allocated to them and stored in the vault for multiple tokens
    /// @param tokens The tokens to withdraw fees i
    /// @param recipient The address to send the fees to
    /// @return success Whether the transfer was successful or not
    function batchWithdrawAllERC20(IERC20[] calldata tokens, address recipient) external returns (bool success);

    /// @notice Allows partners to withdraw fees allocated to them and stored in the vault
    /// @param tokens The tokens to withdraw fees in
    /// @param amounts The amounts of fees to withdraw
    /// @param recipient The address to send the fees to
    /// @return success Whether the transfer was successful or not
    function batchWithdrawSomeERC20(
        IERC20[] calldata tokens,
        uint256[] calldata amounts,
        address recipient
    )
        external
        returns (bool success);

    /*//////////////////////////////////////////////////////////////
                            BALANCE GETTERS
    //////////////////////////////////////////////////////////////*/

    /// @notice Get the balance of a given token for a given partner
    /// @param token The token to get the balance of
    /// @param partner The partner to get the balance for
    /// @return feeBalance The balance of the given token for the given partner
    function getBalance(IERC20 token, address partner) external view returns (uint256 feeBalance);

    /// @notice Get the balances of a given partner for multiple tokens
    /// @param tokens The tokens to get the balances of
    /// @param partner The partner to get the balances for
    /// @return feeBalances The balances of the given tokens for the given partner
    function batchGetBalance(
        IERC20[] calldata tokens,
        address partner
    )
        external
        view
        returns (uint256[] memory feeBalances);

    /// @notice Returns the unallocated fees for a given token
    /// @param token The token to get the unallocated fees for
    /// @return unallocatedFees The unallocated fees for the given token
    function getUnallocatedFees(IERC20 token) external view returns (uint256 unallocatedFees);

    /*//////////////////////////////////////////////////////////////
                                 OWNER
    //////////////////////////////////////////////////////////////*/

    /// @notice Registers the given feeData to the vault
    /// @param feeData The fee registration data
    function registerFees(FeeRegistration memory feeData) external;

    /// @notice Sets the augustus contract approval status
    /// @param augustus The augustus contract address
    /// @param approved The approval status
    function setAugustusApproval(address augustus, bool approved) external;

    /// @notice Sets the contract pause state
    /// @param _isPaused The new pause state
    function setContractPauseState(bool _isPaused) external;
}

```

### Augustus Registry

Use AugustusRegistry to verify AugustusSwapper addresses.

* Mainnet: [0xa68bEA62Dc4034A689AA0F58A76681433caCa663](https://etherscan.io/address/0xa68bEA62Dc4034A689AA0F58A76681433caCa663)
* Arbitrum: [0xdC6E2b14260F972ad4e5a31c68294Fba7E720701](https://arbiscan.io/address/0xdC6E2b14260F972ad4e5a31c68294Fba7E720701)
* Avalanche: [0xfD1E5821F07F1aF812bB7F3102Bfd9fFb279513a](https://snowtrace.io/address/0xfD1E5821F07F1aF812bB7F3102Bfd9fFb279513a)
* Base: [0x7e31b336f9e8ba52ba3c4ac861b033ba90900bb3](https://basescan.org/address/0x7e31b336f9e8ba52ba3c4ac861b033ba90900bb3)
* BSC: [0x05b4486f643914a818ed93afc07457e9074be211](https://bscscan.com/address/0x05b4486f643914a818ed93afc07457e9074be211)
* Fantom: [0x161383b5dAFc1cc05Ec058e5B0b0703BA175bdA6](https://ftmscan.com/address/0x161383b5dAFc1cc05Ec058e5B0b0703BA175bdA6)
* Gnosis: [0xa1686Ee049A745211D64ef2B305495D9425e7BD3](https://gnosisscan.io/address/0xa1686Ee049A745211D64ef2B305495D9425e7BD3)
* Optimism: [0x6e7bE86000dF697facF4396efD2aE2C322165dC3](https://optimistic.etherscan.io/address/0x6e7bE86000dF697facF4396efD2aE2C322165dC3)
* Polygon: [0xca35a4866747Ff7A604EF7a2A7F246bb870f3ca1](https://polygonscan.com/address/0xca35a4866747Ff7A604EF7a2A7F246bb870f3ca1)
* Sonic: [0x515D89fB6b472D56Ca065AB21b32975f6ab8da3E](https://sonicscan.org/address/0x515D89fB6b472D56Ca065AB21b32975f6ab8da3E)
* Unichain: [0xB5253c895361678FF5D0fFDdA81Dd02f1F7a81D6](https://unichain.blockscout.com/address/0xB5253c895361678FF5D0fFDdA81Dd02f1F7a81D6)
* Plasma: [0x09920244F4c4f79c4926b6DCD8bE2Efc5CD1224E](https://plasmascan.to/address/0x09920244F4c4f79c4926b6DCD8bE2Efc5CD1224E)

```solidity
interface IAugustusRegistry {

    function isAugustusBanned(address augustus) external view returns (bool);

    function isValidAugustus(address augustus) external view returns (bool);

    function getAugustusCount() external view returns (uint256);

    function getLatestVersion() external view returns (string memory);

    function getLatestAugustus() external view returns (address);

    function getAugustusByVersion(string calldata version) external view returns (address);
}
```


# Augustus v5 smart contracts

{% hint style="warning" %}
Allowance should be given to **TokenTransferProxy** contract and not to **AugustusSwapper, FUNDS MAY BE LOST OTHERWISE!**
{% endhint %}

## AugustusSwapper

The contract router is responsible for making swaps.

* Mainnet : [<mark style="color:blue;">0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57</mark>](https://etherscan.io/address/0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57#code)
* Arbitrum: [<mark style="color:blue;">0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57</mark>](https://arbiscan.io/address/0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57)
* Avalanche: [<mark style="color:blue;">0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57</mark>](https://cchain.explorer.avax.network/address/0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57/contracts)
* Base: [<mark style="color:blue;">0x59C7C832e96D2568bea6db468C1aAdcbbDa08A52</mark>](https://basescan.org/address/0x59C7C832e96D2568bea6db468C1aAdcbbDa08A52)
* BSC: [<mark style="color:blue;">0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57</mark>](https://bscscan.com/address/0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57#code)
* Optimism: [<mark style="color:blue;">0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57</mark>](https://optimistic.etherscan.io/address/0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57)
* Polygon: [<mark style="color:blue;">0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57</mark>](https://polygonscan.com/address/0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57#code)

![](/files/-Mhm8p5mjBN3H9_VpqC6)

### TokenTransferProxy

The Spender contract is responsible for moving ERC20 tokens (and equivalents on side chains). To get the address, you can call `getTokenTransferProxy()` on Augustus.

* Mainnet: [<mark style="color:blue;">0x216b4b4ba9f3e719726886d34a177484278bfcae</mark>](https://etherscan.io/address/0x216b4b4ba9f3e719726886d34a177484278bfcae#code)
* Arbitrum: [<mark style="color:blue;">0x216B4B4Ba9F3e719726886d34a177484278Bfcae</mark>](https://arbiscan.io/address/0x216B4B4Ba9F3e719726886d34a177484278Bfcae)
* Avalanche: [<mark style="color:blue;">0x216b4b4ba9f3e719726886d34a177484278bfcae</mark>](https://cchain.explorer.avax.network/address/0x216B4B4Ba9F3e719726886d34a177484278Bfcae/contracts)
* Base: [<mark style="color:blue;">0x93aAAe79a53759cD164340E4C8766E4Db5331cD7</mark>](https://basescan.org/address/0x93aAAe79a53759cD164340E4C8766E4Db5331cD7)
* BSC: [<mark style="color:blue;">0x216b4b4ba9f3e719726886d34a177484278bfcae</mark>](https://ropsten.etherscan.io/address/0x216b4b4ba9f3e719726886d34a177484278bfcae)
* Optimism: [<mark style="color:blue;">0x216B4B4Ba9F3e719726886d34a177484278Bfcae</mark>](https://optimistic.etherscan.io/address/0x216b4b4ba9f3e719726886d34a177484278bfcae)
* Polygon: [<mark style="color:blue;">0x216b4b4ba9f3e719726886d34a177484278bfcae</mark>](https://polygonscan.com/address/0x216B4B4Ba9F3e719726886d34a177484278Bfcae#code)

```solidity
pragma solidity 0.7.5;


interface ITokenTransferProxy {

    function transferFrom(
        address token,
        address from,
        address to,
        uint256 amount
    )
        external;
}

```

### Augustus Registry

Use AugustusRegistry to verify AugustusSwapper addresses.

* Mainnet: [<mark style="color:blue;">0xa68bEA62Dc4034A689AA0F58A76681433caCa663</mark>](https://etherscan.io/address/0xa68bEA62Dc4034A689AA0F58A76681433caCa663)
* Arbitrum: [<mark style="color:blue;">0xdC6E2b14260F972ad4e5a31c68294Fba7E720701</mark>](https://arbiscan.io/address/0xdC6E2b14260F972ad4e5a31c68294Fba7E720701)
* Avalanche: [<mark style="color:blue;">0xfD1E5821F07F1aF812bB7F3102Bfd9fFb279513a</mark>](https://snowtrace.io/address/0xfD1E5821F07F1aF812bB7F3102Bfd9fFb279513a)
* Base: [<mark style="color:blue;">0x7e31b336f9e8ba52ba3c4ac861b033ba90900bb3</mark>](https://basescan.org/address/0x7e31b336f9e8ba52ba3c4ac861b033ba90900bb3)
* BSC: [<mark style="color:blue;">0x05b4486f643914a818ed93afc07457e9074be211</mark>](https://bscscan.com/address/0x05b4486f643914a818ed93afc07457e9074be211)
* Optimism: [<mark style="color:blue;">0x6e7bE86000dF697facF4396efD2aE2C322165dC3</mark>](https://optimistic.etherscan.io/address/0x6e7bE86000dF697facF4396efD2aE2C322165dC3)
* Polygon: [<mark style="color:blue;">0xca35a4866747Ff7A604EF7a2A7F246bb870f3ca1</mark>](https://polygonscan.com/address/0xca35a4866747Ff7A604EF7a2A7F246bb870f3ca1)

```solidity
interface IAugustusRegistry {

    function isAugustusBanned(address augustus) external view returns (bool);

    function isValidAugustus(address augustus) external view returns (bool);

    function getAugustusCount() external view returns (uint256);

    function getLatestVersion() external view returns (string memory);

    function getLatestAugustus() external view returns (address);

    function getAugustusByVersion(string calldata version) external view returns (address);
}
```

### AugustusSwapper (implements IParaswap through fallback method)

#### ABI (merged AugustusSwapper and IParaswap ABIs)

{% file src="/files/-MjZ8685KZTNGIaoeid5" %}

### &#x20;**IAugustusSwapper**

```solidity
interface IAugustusSwapper {
  struct FeeStructure {
    uint256 partnerShare;
    bool noPositiveSlippage;
    bool positiveSlippageToUser;
    uint16 feePercent;
    string partnerId;
    bytes data;
  }

  function DEFAULT_ADMIN_ROLE (  ) external view returns ( bytes32 );
  function ROUTER_ROLE (  ) external view returns ( bytes32 );
  function WHITELISTED_ROLE (  ) external view returns ( bytes32 );
  function getAdapterData ( bytes32 key ) external view returns ( bytes );
  function getFeeWallet (  ) external view returns ( address );
  function getImplementation ( bytes4 selector ) external view returns ( address );
  function getPartnerFeeStructure ( address partner ) external view returns ( FeeStructure memory );
  function getRoleAdmin ( bytes32 role ) external view returns ( bytes32 );
  function getRoleMember ( bytes32 role, uint256 index ) external view returns ( address );
  function getRoleMemberCount ( bytes32 role ) external view returns ( uint256 );
  function getRouterData ( bytes32 key ) external view returns ( bytes );
  function getTokenTransferProxy (  ) external view returns ( address );
  function getVersion (  ) external pure returns ( string );
  function grantRole ( bytes32 role, address account ) external;
  function hasRole ( bytes32 role, address account ) external view returns ( bool );
  function initializeAdapter ( address adapter, bytes data ) external;
  function initializeRouter ( address router, bytes data ) external;
  function isAdapterInitialized ( bytes32 key ) external view returns ( bool );
  function isRouterInitialized ( bytes32 key ) external view returns ( bool );
  function registerPartner ( address partner, uint256 _partnerShare, bool _noPositiveSlippage, bool _positiveSlippageToUser, uint16 _feePercent, string partnerId, bytes _data ) external;
  function renounceRole ( bytes32 role, address account ) external;
  function revokeRole ( bytes32 role, address account ) external;
  function setFeeWallet ( address _feeWallet ) external;
  function setImplementation ( bytes4 selector, address implementation ) external;
  function transferTokens ( address token, address destination, uint256 amount ) external;
}
```

(Generated from AugustusSwapper ABI using [ABI2Solidity tool](https://bia.is/tools/abi2solidity/) then edited to add FeeStructure)

### IParaswap

```solidity
pragma solidity 0.7.5;

import "./lib/Utils.sol";

interface IParaswap {
    event Swapped(
        bytes16 uuid,
        address initiator,
        address indexed beneficiary,
        address indexed srcToken,
        address indexed destToken,
        uint256 srcAmount,
        uint256 receivedAmount,
        uint256 expectedAmount
    );

    event Bought(
        bytes16 uuid,
        address initiator,
        address indexed beneficiary,
        address indexed srcToken,
        address indexed destToken,
        uint256 srcAmount,
        uint256 receivedAmount
    );

    event FeeTaken(
        uint256 fee,
        uint256 partnerShare,
        uint256 paraswapShare
    );

    function multiSwap(
        Utils.SellData calldata data
    )
        external
        payable
        returns (uint256);

    function megaSwap(
        Utils.MegaSwapSellData calldata data
    )
        external
        payable
        returns (uint256);

    function protectedMultiSwap(
        Utils.SellData calldata data
    )
        external
        payable
        returns (uint256);

    function protectedMegaSwap(
        Utils.MegaSwapSellData calldata data
    )
        external
        payable
        returns (uint256);

    function protectedSimpleSwap(
        Utils.SimpleData calldata data
    )
        external
        payable
        returns (uint256 receivedAmount);

    function protectedSimpleBuy(
        Utils.SimpleData calldata data
    )
        external
        payable;

    function simpleSwap(
        Utils.SimpleData calldata data
    )
        external
        payable
        returns (uint256 receivedAmount);

    function simpleBuy(
        Utils.SimpleData calldata data
    )
        external
        payable;

    function swapOnUniswap(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path
    )
        external
        payable;

    function swapOnUniswapFork(
        address factory,
        bytes32 initCode,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path
    )
        external
        payable;

    function buyOnUniswap(
        uint256 amountInMax,
        uint256 amountOut,
        address[] calldata path
    )
        external
        payable;

    function buyOnUniswapFork(
        address factory,
        bytes32 initCode,
        uint256 amountInMax,
        uint256 amountOut,
        address[] calldata path
    )
        external
        payable;

    function swapOnUniswapV2Fork(
        address tokenIn,
        uint256 amountIn,
        uint256 amountOutMin,
        address weth,
        uint256[] calldata pools
    )
        external
        payable;

    function buyOnUniswapV2Fork(
        address tokenIn,
        uint256 amountInMax,
        uint256 amountOut,
        address weth,
        uint256[] calldata pools
    )
        external
        payable;

    function swapOnZeroXv2(
        IERC20 fromToken,
        IERC20 toToken,
        uint256 fromAmount,
        uint256 amountOutMin,
        address exchange,
        bytes calldata payload
    )
    external
    payable;

    function swapOnZeroXv4(
        IERC20 fromToken,
        IERC20 toToken,
        uint256 fromAmount,
        uint256 amountOutMin,
        address exchange,
        bytes calldata payload
    )
    external
    payable;
}
```

### Utils

```solidity
pragma solidity 0.7.5;

library Utils {
    /**
   * @param fromToken Address of the source token
   * @param fromAmount Amount of source tokens to be swapped
   * @param toAmount Minimum destination token amount expected out of this swap
   * @param expectedAmount Expected amount of destination tokens without slippage
   * @param beneficiary Beneficiary address
   * 0 then 100% will be transferred to beneficiary. Pass 10000 for 100%
   * @param path Route to be taken for this swap to take place

   */
    struct SellData {
        address fromToken;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        address payable beneficiary;
        Utils.Path[] path;
        address payable partner;
        uint256 feePercent;
        bytes permit;
        uint256 deadline;
        bytes16 uuid;
    }

    struct MegaSwapSellData {
        address fromToken;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        address payable beneficiary;
        Utils.MegaSwapPath[] path;
        address payable partner;
        uint256 feePercent;
        bytes permit;
        uint256 deadline;
        bytes16 uuid;
    }

    struct SimpleData {
        address fromToken;
        address toToken;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 expectedAmount;
        address[] callees;
        bytes exchangeData;
        uint256[] startIndexes;
        uint256[] values;
        address payable beneficiary;
        address payable partner;
        uint256 feePercent;
        bytes permit;
        uint256 deadline;
        bytes16 uuid;
    }

    struct Adapter {
        address payable adapter;
        uint256 percent;
        uint256 networkFee;
        Route[] route;
    }

    struct Route {
        uint256 index;//Adapter at which index needs to be used
        address targetExchange;
        uint percent;
        bytes payload;
        uint256 networkFee;//Network fee is associated with 0xv3 trades
    }

    struct MegaSwapPath {
        uint256 fromAmountPercent;
        Path[] path;
    }

    struct Path {
        address to;
        uint256 totalNetworkFee;//Network fee is associated with 0xv3 trades
        Adapter[] adapters;
    }
}
```

### **Fee Claimer**

* Ethereum: [<mark style="color:blue;">0xeF13101C5bbD737cFb2bF00Bbd38c626AD6952F7</mark>](https://etherscan.io/address/0xeF13101C5bbD737cFb2bF00Bbd38c626AD6952F7)
* Arbitrum: [<mark style="color:blue;">0xA7465CCD97899edcf11C56D2d26B49125674e45F</mark>](https://arbiscan.io/address/0xA7465CCD97899edcf11C56D2d26B49125674e45F)
* Avalanche: [<mark style="color:blue;">0xbFcd68FD74B4B458961495F3392Bf96f46A29E67</mark>](https://snowtrace.io/address/0xbFcd68FD74B4B458961495F3392Bf96f46A29E67)
* Base: [<mark style="color:blue;">0x9aaB4B24541af30fD72784ED98D8756ac0eFb3C7</mark>](https://basescan.org/address/0x9aaB4B24541af30fD72784ED98D8756ac0eFb3C7#code)
* BSC: [<mark style="color:blue;">0x2DF17455B96Dde3618FD6B1C3a9AA06D6aB89347</mark>](https://bscscan.com/address/0x2DF17455B96Dde3618FD6B1C3a9AA06D6aB89347)
* Fantom: [<mark style="color:blue;">0x4F14fE8c86A00D6DFB9e91239738499Fc0F587De</mark>](https://ftmscan.com/address/0x4F14fE8c86A00D6DFB9e91239738499Fc0F587De)
* Optimism: [<mark style="color:blue;">0xA7465CCD97899edcf11C56D2d26B49125674e45F</mark>](https://optimistic.etherscan.io/address/0xA7465CCD97899edcf11C56D2d26B49125674e45F)
* Polygon: [<mark style="color:blue;">0x8b5cF413214CA9348F047D1aF402Db1b4E96c06</mark>](https://polygonscan.com/address/0x8b5cF413214CA9348F047D1aF402Db1b4E96c060)

```solidity
pragma solidity 0.7.5;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IFeeClaimer {
    /**
     * @notice register partner's, affiliate's and PP's fee
     * @dev only callable by AugustusSwapper contract
     * @param _account account address used to withdraw fees
     * @param _token token address
     * @param _fee fee amount in token
     */
    function registerFee(
        address _account,
        IERC20 _token,
        uint256 _fee
    ) external;

    /**
     * @notice claim partner share fee in ERC20 token
     * @dev transfers ERC20 token balance to the caller's account
     *      the call will fail if withdrawer have zero balance in the contract
     * @param _token address of the ERC20 token
     * @param _recipient address
     * @return true if the withdraw was successfull
     */
    function withdrawAllERC20(IERC20 _token, address _recipient) external returns (bool);

    /**
     * @notice batch claim whole balance of fee share amount
     * @dev transfers ERC20 token balance to the caller's account
     *      the call will fail if withdrawer have zero balance in the contract
     * @param _tokens list of addresses of the ERC20 token
     * @param _recipient address of recipient
     * @return true if the withdraw was successfull
     */
    function batchWithdrawAllERC20(IERC20[] calldata _tokens, address _recipient) external returns (bool);

    /**
     * @notice claim some partner share fee in ERC20 token
     * @dev transfers ERC20 token amount to the caller's account
     *      the call will fail if withdrawer have zero balance in the contract
     * @param _token address of the ERC20 token
     * @param _recipient address
     * @return true if the withdraw was successfull
     */
    function withdrawSomeERC20(
        IERC20 _token,
        uint256 _tokenAmount,
        address _recipient
    ) external returns (bool);

    /**
     * @notice batch claim some amount of fee share in ERC20 token
     * @dev transfers ERC20 token balance to the caller's account
     *      the call will fail if withdrawer have zero balance in the contract
     * @param _tokens address of the ERC20 tokens
     * @param _tokenAmounts array of amounts
     * @param _recipient destination account addresses
     * @return true if the withdraw was successfull
     */
    function batchWithdrawSomeERC20(
        IERC20[] calldata _tokens,
        uint256[] calldata _tokenAmounts,
        address _recipient
    ) external returns (bool);

    /**
     * @notice compute unallocated fee in token
     * @param _token address of the ERC20 token
     * @return amount of unallocated token in fees
     */
    function getUnallocatedFees(IERC20 _token) external view returns (uint256);

    /**
     * @notice returns unclaimed fee amount given the token
     * @dev retrieves the balance of ERC20 token fee amount for a partner
     * @param _token address of the ERC20 token
     * @param _partner account address of the partner
     * @return amount of balance
     */
    function getBalance(IERC20 _token, address _partner) external view returns (uint256);

    /**
     * @notice returns unclaimed fee amount given the token in batch
     * @dev retrieves the balance of ERC20 token fee amount for a partner in batch
     * @param _tokens list of ERC20 token addresses
     * @param _partner account address of the partner
     * @return _fees array of the token amount
     */
    function batchGetBalance(IERC20[] calldata _tokens, address _partner)
        external
        view
        returns (uint256[] memory _fees);
}
```


# Subgraphs

Query historical ParaSwap swap transactions on all supported chains through a GraphQL api via TheGraph.

Subgraph links for each supported chain

## Augustus v5

* [Ethereum](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-subgraph)
* [Arbitrum](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-subgraph-arbitrum)&#x20;
* [Avalanche ](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-subgraph-avalanche)
* [Base](https://api.studio.thegraph.com/query/52704/paraswap-subgraph-base/v0.0.1)
* [BSC](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-subgraph-bsc)
* [Optimism](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-subgraph-optimism)
* [Polygon ](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-subgraph-polygon)

## AugustusRFQ (Limit Orders, RFQ, P2P, NFTs)

* [Ethereum](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-rfq-subgraph-mainnet)
* [Arbitrum](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-rfq-subgraph-arbitrum)
* [Avalanche](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-rfq-subgraph-avalanche)
* [BSC](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-rfq-subgraph-bsc)
* [Optimism](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-rfq-subgraph-optimism)
* [Polygon](https://thegraph.com/hosted-service/subgraph/paraswap/paraswap-rfq-subgraph-polygon)

The source code is publicly accessible on github [here](https://github.com/paraswap/paraswap-subgraph).


# Security

In this page you can explore all the security details and audits of ParaSwap

<table data-view="cards" data-full-width="false"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center">Augustus V6.2</td><td><a href="/pages/Iu6WwqfjHdxpL6MgSyYf">/pages/Iu6WwqfjHdxpL6MgSyYf</a></td></tr><tr><td align="center">Augustus V6.1</td><td><a href="/pages/pbFTRhBptyymWWrun3iB">/pages/pbFTRhBptyymWWrun3iB</a></td></tr><tr><td align="center">Augustus RFQ</td><td><a href="/pages/z6EbYO52NzDBfUO8Wnpe">/pages/z6EbYO52NzDBfUO8Wnpe</a></td></tr><tr><td align="center">Augustus V5</td><td><a href="/pages/FXzlGf13yiud4Wl1XHLv">/pages/FXzlGf13yiud4Wl1XHLv</a></td></tr></tbody></table>


# Augustus V6.2 security audit

In this page you can find all the security details and audit reports relevant to Augustus V6.2

Augustus V6.2 refines the fee-claiming process for partners while maintaining the security standards of V6.1.

Since V6.2 introduces only minor changes to its predecessor, the [five audits and verification by Certora for V6.1](/security/augustus-v6.1) remain relevant. Nonetheless, Augustus V6.2 was audited by three additional security firms to ensure protection against vulnerabilities.

### Audits

{% file src="/files/c32YtDKquMwfAIyJdYCk" %}

{% file src="/files/zFqZuLPhoDFMGhpG3HlT" %}

{% file src="/files/TGckYyLNHtIIuynegnvy" %}


# Augustus V6.1

In this page you can find all the security details and audit reports relevant to Augustus V6.1

## Security Improvements

Augustus V6.1 incorporates additional security measures to improve security and reliability, including:

* **Full re-audit by leading security firms**\
  Augustus V6.1 has undergone a rigorous audit process conducted by five leading security firms: Certora, Hexens, Peckshield, Hacken, and Astrasec. These comprehensive audits confirmed that Augustus V6.1 meets the highest security standards.\
  In addition, Augustus V6.1 received a [formal verification](https://docs.certora.com/projects/tutorials/en/latest/lesson1_prerequisites/formal_verification.html) by Certora, providing an additional security guarantee and making ParaSwap the first DEX aggregator to achieve this formal verification.
* **An additional mechanism for accelerated threat response**\
  Augustus V6.1 is designed to be fully pausable, allowing swift response to potential issues. This means that if any suspicious activity is detected, it can be immediately halted.
* **TimeLock mechanism for Admin Actions**\
  Except for Pausing, all Augustus V6.1 contract admin actions are subject to a TimeLock, which makes it resilient to immediate changes.

### Audits

{% file src="/files/xBsOH0zBLAieFnGqG7ru" %}

{% file src="/files/hqpLKer5gYLN2es9B35B" %}

{% file src="/files/mO9GCzNefqgm7y5Txsqd" %}

{% file src="/files/sd0DFYOlf26MBJEVz9Fu" %}

{% file src="/files/v9GO5cjVUgXTJ2hAOWxi" %}


# Augustus RFQ

In this page you can find all the security details and audit reports relevant to Augustus RFQ

## Audits

{% file src="/files/B94W8LKPHjImXrndOOYT" %}


# Augustus V5 security audit

In this page you can find all the security details and audit reports relevant to Augustus V6

## Audits

{% file src="/files/eLy2Fwcr07jOmrvw90YJ" %}

{% file src="/files/ztl0UtuyV9BXsAtLx6CT" %}


