Only this pageAll pages
Powered by GitBook
1 of 59

Developer Docs

API

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Fungible tokens

/ft/ fungible api

Create a p2p limit orderGet limit orders by makerGet limit orders by takerGet PairsGet OrderbookFill a limit orderCancel a limit orderCreate a limit order

SDK

TypescriptPython

NFT

/nft/ non-fungible api

Create an orderCreate a p2p orderGet NFT orders by makerGet NFT orders by takerGet PairsGet orderbookFill a limit orderCancel a limit order

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 remain relevant. Nonetheless, Augustus V6.2 was audited by three additional security firms to ensure protection against vulnerabilities.

Audits

320KB
Augustus-6.2-AstraSec.pdf
PDF
Open
258KB
Augustus-6.2-Certora.pdf
PDF
Open
304KB
Augustus-6.2-PeckShield.pdf
PDF
Open

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.

Augustus RFQ

In this page you can find all the security details and audit reports relevant to Augustus RFQ

Audits

328KB
Augustus-RFQ-PeckShield.pdf
PDF
Open

Augustus V5 security audit

In this page you can find all the security details and audit reports relevant to Augustus V6

Audits

140KB
Augustus-5-Solidified.pdf
PDF
Open
327KB
Augustus-5-PeckShield.pdf
PDF
Open

Limit Orders

What is Velora Limit Order Protocol?

Velora Limit Order Protocol is a set of smart contracts developed by Velora and available in Ethereum, Polygon, Binance Smart Chain, Avalanche, Arbitrum, and Optimism.

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

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.

Please note that as of the launch of v6.2, Velora no longer maintains v5.

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.

domain

type

value

POST https://api.paraswap.io/delta/orders/cancel

Body

Name
Type
Description

Response

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

Security

In this page you can explore all the security details and audits of ParaSwap

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.

Velora Market API

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

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.

This guide will help you to:

  • Leverage the API effectively.

  • Retrieve a price and get the most optimal route for a trade.

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.

Get Tokens List

Get tokens list for a network

GET https://api.paraswap.io/tokens/:network

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

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 , our open-source library that contains all live and pending DEX integrations.

API v5

Introduction to Velora API version 5

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.

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.

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.

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:

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 by Certora, providing an additional security guarantee and making ParaSwap the first DEX aggregator to achieve this formal verification.

Path Parameters
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). Default: 1.

{
  "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
    }
  ]
}

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.

First, you should call /prices endpoint (detailed documentation here) 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). 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.

  • You can finally use this transaction data to execute the swaps on-chain by sending it to the provider.

  • Check out the following pages to understand the Velora v5 API. To try out all API endpoints, visit the Open-API documentation 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

    API v6.2

    API v5

    Augustus V6.2

    Augustus V6.1

    Augustus RFQ

    Augustus V5

    Overview

    Contracts

    Retrieve delta Price with fallback to market

    Build a Delta Order to Sign

    Submit a Delta Order

    Track a Delta Order auction status

    Example: Quote With Fallback

    DexLib

    orderIds

    string[]

    Order IDs to cancel

    signature

    string

    EIP-712 signature with the structure described above

    {
      "name": "Portikus",
      "version": "2.0.0",
      "chainId": <chainId>,
      "verifyingContract": <deltaAddress>
    }
    {
      "OrderCancellations": [
        {
          "name": "orderIds",
          "type": "string[]",
        }
      ]
    }
    {
      "orderIds": [<id1>, <id2>]
    }
    {
      "success": true
    }
    {
      "errorType": "OrderCancellationError",
      "details": "Order not found"
    }
  • 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

    formal verification
    320KB
    Augustus-6.1-AstraSec.pdf
    PDF
    Open
    258KB
    Augustus-6.1-Certora.pdf
    PDF
    Open
    2MB
    Augustus-6.1-Hacken.pdf
    PDF
    Open
    5MB
    Augustus-6.1-Hexens.pdf
    PDF
    Open
    327KB
    Augustus-6.1-PeckShield.pdf
    PDF
    Open
    Velora Delta is increasingly competitive as different agents compete to deliver the best possible prices to users.

    The easiest way to make use of the Delta is to use the Velora SDK. Refer here SDK Delta documentation.

    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.

    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.

    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.

    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.

    4. Submit the signed Order

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

    For more details, check the Submit a Delta order section.

    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.

    For more information on Order Auction Status, check the Track Delta Order Auction Status section.

    A more detailed example of Delta usage, including fallback to Market (traditional swapping flow), can be found in examples.

    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',
      },
    });
    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,
      */
    });
    // 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;
    const { data: deltaAuction } = await axios.post(`${API_URL}/orders`, {
      chainId: 1,
      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');
    }
    Build parameters for a transaction with the response from the prices endpoint.
  • Find the optimal fee strategy for your integration.

  • 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:

    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.

    Addresses of Delta contract

    Network
    Address

    API v6.2

    Introduction to Velora API v6.2

    Velora v6.2 has been released! See what's new here: https://x.com/VeloraDEX/status/1803435422011498551

    To switch to v6.2, you only need to pass &version=6.2 to /prices & you're good to go!

    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.

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

    • Call GET /prices to retrieve an optimal price for a given pair & amount.

    • Call POST /transactions for retrieving the 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:

    Major changes in V6.2:

    • 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 .

    • More control over : 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 section.

    Supported methods:

    SELL:

    • swapExactAmountIn

    • swapExactAmountInOnUniswapV2

    • swapExactAmountInOnUniswapV3

    • swapExactAmountInOnBalancerV2

    BUY:

    • swapExactAmountOut

    • swapExactAmountOutOnUniswapV2

    • swapExactAmountOutOnUniswapV3

    • swapExactAmountOutOnBalancerV2

    Introduction

    Key Features

    The protocol goes beyond ERC-20 token limit orders and enables, among others, ERC721 NFT limit orders, peer-to-peer, RFQ, and OTC trading.

    • Top gas efficiency: Velora's limit orders offer the most gas-efficient transactions in the market. Our benchmark shows that Velora limit orders are 6% more gas efficient than 1inch and 8% better than 0x.

    • 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.

    How can it be used? Web, mobile, and API

    Velora Limit Order Protocol can be accessed via Velora's web and mobile apps and through Velora Limit Orders API.

    Limit orders are created and stored off-chain, and signed according to EIP-712. They are recorded on-chain once filled.

    Supported chains and tokens

    Chains

    • Ethereum

    • Arbitrum

    • Avalanche

    • BSC

    Tokens

    • ERC-20

    • ERC721

    • ERC1155

    Contracts

    AugustusRFQ

    AugustusRFQ is Velora's limit order contract

    Addresses of AugustusRFQ contract

    Network
    Address

    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

    AugustusRFQ (Limit Orders, RFQ, P2P, NFTs)

    The source code is publicly accessible on github .

    Get Pairs

    GET /nft/orders/:chainId/pairs

    Example

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

    Response

    Get Pairs

    GET /ft/orders/:chainId/pairs

    Examples

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

    Query parameters

    • chainId:network id (Ethereum Mainnet = 1).

    Response

    Example:

    Get orderbook

    GET /nft/orders/:chainId/orderbook/

    Query parameters:

    makerAsset (optional)

    Python

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

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

    Install

    Run examples

    Cancel a limit order

    The cancellation of an NFT order works in the same way as the

    Transaction parameters:

    orderHash: limit order unique id

    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.

    Optimism

  • Polygon

  • Velora Delta API

    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.

    Velora Market API

    Access a decentralized exchange aggregator that allows developers to access hundreds of DEXs and tens of thousands of liquidity pools in real-time.

    Flat fees are capped at 2% as a security protection for users.
  • excludeDirectContractMethods is no longer supported in /prices. It has been replaced by excludeContractMethodsWithoutFeeModel, which ensures all swaps can be monetized.

  • swapExactAmountInOnCurveV1
  • swapExactAmountInOnCurveV2

  • swapOnAugustusRFQTryBatchFill

  • swapExactAmountInOutOnMakerPSM

  • swapOnAugustusRFQTryBatchFill
  • swapExactAmountInOutOnMakerPSM

  • Transaction Object
    Velora SDK
    here
    partner fees
    /transactions

    Optimism

  • Polygon

  • Arbitrum
    Avalanche
    Base
    BSC
    Optimism
    Polygon
    Ethereum
    Arbitrum
    Avalanche
    BSC
    here
    Overview
    API versions
    Retrieve a price
    Build a transaction
    Get Price & Calldata
    Examples
    {
    	"success": true,
    	"pairs": [
    		{
    			"makerAsset": {
    				"type": 2,
    				"address": "0xcd494673999194365033d7a287af9f0a3b163874"
    			},
    			"takerAsset": {
    				"type": 0,
    				"address": "0xad6d458402f60fd3bd25163575031acdce07538d"
    			}
    		}
    	]
    }
    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)
    : 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:

    • Get the whole orderbook

    curl -X GET \
      'https://api.paraswap.io/nft/orders/137/orderbook/'
    • Get orderbook where makerAsset equal 0x2953399124f0cbb46d2cbacd8a89cf0599974963

    curl -X GET \
      'https://api.paraswap.io/nft/orders/137/orderbook/?makerAsset=0x2953399124f0cbb46d2cbacd8a89cf0599974963'
    • Get orderbook where makerAsset type is ERC1155 and takerAsset is ERC20:

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

    Response

    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.

    Examples:

    python3 setup.py build
    python3 setup.py install # may need privilege authorization
    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=
    everything in ./examples/
    GET https://api.paraswap.io/ft/orders/137/pairs
    {
    	"success": true,
    	"pairs": [
    		{
    			"makerAsset": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
    			"takerAsset": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"
    		}
    	]
    }
    {
    	"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"
    		}
    	]
    }

    Ethereum

    0x0000000000bbf5c5fd284e657f01bd000933c96d

    Base

    0x0000000000bbf5c5fd284e657f01bd000933c96d

    Optimism

    0x0000000000bbf5c5fd284e657f01bd000933c96d

    Arbitrum

    0x0000000000bbf5c5fd284e657f01bd000933c96d

    Polygon

    0x0000000000bbf5c5fd284e657f01bd000933c96d

    BSC

    Optimism

    Polygon

    Ethereum

    0xe92b586627ccA7a83dC919cc7127196d70f55a06

    Arbitrum

    0x0927FD43a7a87E3E8b81Df2c44B03C4756849F6D

    Avalanche

    0x34302c4267d0dA0A8c65510282Cc22E9e39df51f

    Base

    0xa003dFBA51C9e1e56C67ae445b852bdEd7aC5EEd

    BSC

    0x8DcDfe88EF0351f27437284D0710cD65b20288bb

    Gnosis

    Example
    /* eslint-disable @typescript-eslint/no-unused-vars */
    import * as dotenv from 'dotenv';
    import axios from 'axios';
    import { ethers } from 'ethers';
    import {
      constructPartialSDK,
      constructEthersContractCaller
    
    cancelation of "fungible tokens" order
    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

    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.

    An example would be 100 ETH --> USDT, where the best route could be:

    • 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

    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

    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.

    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

    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.

    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.

    We recommend using Velora SDK for better developer experience. You can find SDK example of the exact functionality of this code here.

    Example:

    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.

    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.

    Retrieve details for creating cross-chain order

    Get Bridge Info

    GET https://api.paraswap.io/delta/prices/bridge-info

    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

    Submit a Delta Order

    Submit Delta Order for Auction

    POST 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

    Name
    Type
    Description

    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.

    Get Orderbook

    GET /ft/orders/:chainId/orderbook/

    Examples

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

    Query parameters:

    makerAsset: address of an ERC20 token

    takerAsset: address of an ERC20 token

    Response

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

    On chain Data Structure

    ERC20: Order structure

    • 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

    Token type encoding

    • 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.

    Cancel a limit order

    To cancel an earlier placed order(s), a transaction AugustusRFQ.cancelOrder (or CancelOrders) needs to be sent on behalf of the order's maker.

    Transaction parameters:

    orderHash: limit order unique id

    Example

    Build a transaction: /transactions

    Build Transaction

    POST https://api.paraswap.io/transactions/:network

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

    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);
      }
    }
    {
        "maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
        "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
        "nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
        "expiry": 0,
        "makerAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
        "takerAsset": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
        "makerAmount": "10000000000000000",
        "takerAmount": "7775870000000000",
        "signature": "0x43de8dbc8228594171d0ed3e623ca0ab5c24f46bf0575800624ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b" 
    }

    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.

  • 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.

  • ,
    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
    0x0000000000bbf5c5fd284e657f01bd000933c96d
    0x92EaD5bACf6F0E995FA46Ad8215A9b11f67ca241
    0x0927FD43a7a87E3E8b81Df2c44B03C4756849F6D
    0xF3CD476C3C4D3Ac5cA2724767f269070CA09A043
    {
      "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"
          ]
        }
      }
    }
    /* 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);
    }
    

    partiallyFillable

    boolean

    Allow the order to be filled in parts. Default: false

    partner

    string

    Partner string.

    includeAgents

    string[]

    List of agent names to include. If not provided, all the agents are included

    excludeAgents

    string[]

    List of agent names to exclude. If not provided, none of the agents are excluded

    referrerAddress

    string

    Referrer address

    order*

    Order

    The built order to be submitted.

    signature*

    string

    Signature of the order from order.owner address. EOA signatures must be submitted in ERC-2098 Compact Representation.

    chainId*

    string

    Chain ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100).

    type

    MARKET | LIMIT

    Indicates order type. Defaults to MARKET. Used for filtering only

    Data structure in our centralized system
    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)
    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.

  • {
      "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"
    }
    {
      "error": "Validation failed with error"
    }
    {
    	"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"
    		}
    	]
    }
    {
    	"maker": "0x0838956f18c895be401834E29F67Dd59Fe459b1F",
    	"taker": "0xdef171fe48cf0115b1d80b88dc8eab59176fee57",
    	"nonceAndMeta": "13369123495123320437930534572810746342548445613241166057167403033431113728",
    	"expiry": 1653750633,
    	"makerAsset": "3341504144865114989387489881442130991666264814706",
    	"makerAmount": "1",
    	"makerAssetId": "3333",
    	"takerAsset": "381568316899389611396986334098972276236720652278",
    	"takerAssetId": "0",
    	"takerAmount": "2000000000000000000"
    	"signature": "0x9281423eb0679d03dc110ce8d9002059f9dd02b05e5425179a0bdd3d2b154f89105cd8c2f2c040548d9fa605dd46eb71216c25908a7f3d227517fcd26c6b18b51b",
    }
    ERC20   -> 00
    ERC1155 -> 01
    ERC721  -> 10
    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

    Allows the API to skip performing on-chain checks such as balances, allowances, as well as possible transaction failures. *Note: The response does not contain gas parameter when ignoreChecks is set to true. Default: false

    ignoreGasEstimate

    boolean

    Allows the API to skip gas checks *Note: The response does not contain gas parameter when ignoreGasEstimate is set to true. Default: false

    onlyParams

    boolean

    Allows the API to return the contract parameters only. Default: false

    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 specified 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 specified for tokens from /tokens.

    destDecimals

    integer

    Destination Token Decimals. (Can be omitted if Token Symbol is provided for destToken).

    Example:

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

    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

    Build a Delta Order to Sign

    Build a Delta Order to Sign

    POST 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

    Name
    Type
    Description

    DeltaBridge structure:

    Name
    Type
    Description

    Most common error types

    • ValidationError - validation for params failed

    • UnsupportedChain - the chain ID is not supported by Delta.

    • UnsupportedToken - the token is not supported by Delta.

    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.

    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:

    Sign an order (cross-chain)

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

    Partner Fees

    This is just technical explanation. If you are using our endpoint, this knowledge is not required.

    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 (100is 1%), which the maximum allowed value of 200.

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

    Get NFT orders by maker

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

    Examples

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

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

    Examples

    Query parameters:

    • chainId:network id (Ethereum Mainnet = 1).

    • address: will return you the orders in which maker == address.

    Response

    Understand the response by checking our dedicated page:

    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

    Fill a limit order

    In order to fill an order, a data is required as an input.

    It can be web service or .

    Parameters

    This data can then be supplemented by additional required params and sent to ParaSwap web API to generate for the fulfilment transaction:

    The returned transaction params can be used to send a transaction.

    Example

    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

    Fill a limit order

    In order to fill an order, a data is required as an input.

    It can be service or .

    Parameters

    This data can then be supplemented by additional required params and sent to ParaSwap web API to generate for the fulfilment transaction:

    The returned transaction params can be used to send a transaction.

    Example

    {
        "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "to": "0x6a000f20005980200259b80c5102003040001068",
        "value": "0",
        "data": "0xe3ead59e0000000000000000000000005f0000d4780a00d2dce0a00004000800cb0e5041000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000db4d11c67691ad50000000000000000000000000000000000000000000000000dd8426a4440caf10a8104c26c244959a1d46f205acc49520000000000000000000000000133fc2c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000160a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000006000240000ff00000300000000000000000000000000000000000000000000000000000000a9059cbb0000000000000000000000004610ba8d5d10fba8c048a2051a0883ce04eabace00000000000000000000000000000000000000000000000000000000000f42406a000f20005980200259b80c51020030400010680000008000240000ff0600030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000f4240000000000000000000004de54610ba8d5d10fba8c048a2051a0883ce04eabace",
        "gasPrice": "16000000000",
        "chainId": 1
    }
    {
      "error": "Unable to process the transaction"
    }

    eip1559

    boolean

    Allows the API to return EIP-1559 styled transaction with maxFeePerGas and maxPriorityFeePerGas paramters.

    *Note: We currently support EIP1559 transactions in the following chains:

    Mainnet, Ropsten, and Avalanche.

    Default: false

    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

    Allowed slippage percentage represented in basis points. Eg: for 2.5% slippage, set the value to 2.5 * 100 = 250; for 10% = 1000. Slippage could be passed instead of destAmount when side=SELL or srcAmount when side=BUY. Min: 0; Max: 10000

    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

    Address that will be entitled to claim fees or surplus.

    *Note: Fees have to be claimed from the Fee Claimer contract unless isSurplusToUser or isDirectFeeTransfer are used

    partnerFeeBps

    string

    If provided it is used together with partnerAddress. Should be in basis points percentage. Look at slippage parameter description for understanding better. Eg: 200 (for 2% fee percent)

    *Note: Fees have to be claimed from the Fee Claimer contract unless isSurplusToUser or isDirectFeeTransfer are used

    partner

    string

    Your project name.

    Used for providing analytics on your project swaps.

    permit

    string

    Hex string for the signature used for Permit. This can be used to avoid giving approval. Helps in saving gas.

    deadline

    integer

    Timestamp (10 digit/seconds precision) till when the given transaction is valid. For a deadline of 5 minute, deadline: Math.floor(Date.now()/1000) + 300 E.g.: 1629214486

    isCapSurplus

    boolean

    Allows for capping the surplus at 1% maximum.

    Default: true

    takeSurplus

    boolean

    Allows to collect surplus. Works with partnerAddress

    Default: false

    isSurplusToUser

    boolean

    Specify if user should receive surplus instead of partner. Default: false

    isDirectFeeTransfer

    boolean

    Specify if fees should be sent directly to the partner instead of registering them on FeeClaimer.

    Default: false

    Data structure in our centralized system
    /* 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();
    
    curl -X GET \
      'https://api.paraswap.io/nft/p2p/137/maker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
    /* 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();
    
    SwappableNFTOrder
    retrieved from API
    composed by maker
    Augustus Swapper route
    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',
    };

    SwappableOrder
    retrieved from API web
    composed by maker
    Augustus Swapper route
    const orderWithSignature: SwappableOrder {
      nonceAndMeta: '1461501637330902918203684832716283019655932542976',
      expiry: 1665587100,
      makerAsset: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
      takerAsset: '0x2b591e99afe9f32eaa6214f7b7629768c40eeb39',
      maker: '0x2bb45fa7c25071ff37a49877A02b5b3986113A3A',
      taker: '0x0000000000000000000000000000000000000000',
      makerAmount: '1000000000000000000',
      takerAmount: '2800000000',
      signature: '0x97166e35e63ecab23a0c4e7ec4ec6863193b48ddcee4f9f8291ac95a05e9545c46037cdcf01445d7a2b5dd0fdce66bc9f8b49cac75be03a3ba07dc0d467387351c'
    }
    const txData = await sdk.buildLimitOrderTx(
      {
        srcDecimals: 18,
        destDecimals: 8,
        userAddress: taker.address,
        orders: [orderWithSignature],
      })
    {
    	"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"
    		}
    	]
    }
    const txData = await sdk.buildLimitOrderTx(
      {
        srcDecimals: 18,
        userAddress: taker.address,
        orders: [orderWithSignature],
      })
    /* 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();
    /* 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';
    
    const orderWithSignature: SwappableOrder = {
      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();
    

    beneficiary

    string

    Order beneficiary. Default: zero address, meaning owner address.

    slippage

    number

    Slippage in base points (100 is 1%). Default: 100.

    deadline

    number

    Order expiry time as UNIX timestamp. Default: 1 hour from order creation.

    nonce

    string

    Arbitrary uint256 value to be used as order nonce. Default: value generated with internal algos. It is recommended to omit this param.

    permit

    string

    Encoded permit to be used in order settlement. Supported permit types are described . Default: 0x.

    partiallyFillable

    boolean

    If true, order will be generated as partially fillable. Default: false.

    partnerAddress

    string

    Address of the partner. Used to collect fees from the order. Default: zero address.

    partnerFeeBps

    number

    Partner fee percent in base points (100 is 1%). Max value is 200. Default: 0.

    partnerTakesSurplus

    boolean

    If true, partner will collect 50% of the order surplus instead of flat percent fee. Default: false.

    protocolData

    string

    Protocol-specific data, obtained from pricing API

    InvalidHmac - hmac check failed, meaning price object returned from /quote endpoint was mutated.

    Allowance format - expected length is 192 bytes.

  • DAI Style Permit - expected length is 256 bytes.

  • 0x01 - special permit value that signifies existing Permit2 allowance.

  • 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.

    price*

    DeltaPrice

    The delta object retrieved from /quote endpoint.

    chainId*

    number

    Chain ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Fantom - 250, zkEVM - 1101, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100).

    owner*

    string

    Order owner address.

    bridge

    DeltaBridge

    Required only for cross-chain orders. See below for details

    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. Output token can also be obtained from price.bridge.outputToken

    scalingFactor

    number

    Specifies difference between the decimals in source bridge token and destination token

    Delta Contract
    Order Building

    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.

  • Get Price Route & Transaction Building

    GET 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*

    string

    Source Token Address. Instead Token Symbol could be used for tokens listed in the /tokens endpoint.

    srcDecimals*

    integer

    Source Token Decimals. (Can be omitted if Token Symbol is used in srcToken).

    destToken*

    string

    Destination Token Address. Instead Token Symbol could be used for tokens listed in the /tokens endpoint.

    amount*

    string

    srcToken amount (in case of SELL) or destToken amount (in case of BUY). The amount should be in WEI/Raw units (eg. 1WBTC -> 100000000)

    Example:

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

    🧙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.

    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.

    If you would like to disable these methods you can do so by setting a whitelist for methods where Swap&Transfer is supportedincludeContractMethods=simpleSwap,multiSwap,megaSwap

    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

    Fulfillment.

  • Cancellation.

  • Expiration.

  • Partially fulfillment.

  • For more information, please refer to the following document:

    ERC20: Order structure

    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)

    • 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.

    • state: PENDING / FULFILLED / EXPIRED / CANCELLED.

      • PENDING: order is still usable.

    NFT ERC 20/721/1155 Order structure

    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.

    • state: PENDING / FULFILLED / EXPIRED / CANCELLED.

      • PENDING: order is still usable.

    On chain Data Structure

    Get limit orders by maker

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

    Examples

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

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

    Examples

    Query parameters:

    • chainId:network id (Ethereum Mainnet = 1).

    • address: will return you the orders in which maker == address.

    • limit (Optional): max count of orders.

    Response

    Understand the response by checking our dedicated page:

    Get limit orders by taker

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

    Examples

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

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

    Examples

    Query parameters:

    • chainId:network id (Ethereum Mainnet = 1).

    • address: will return you the orders in which taker == address.

    • limit (Optional): max count of orders.

    Response

    Understand the response by checking our dedicated page:

    Get NFT orders by taker

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

    Examples

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

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

    Examples

    Query parameters:

    • chainId:network id (Ethereum Mainnet = 1).

    • address: will return you the orders in which taker == address.

    Response

    Understand the response by checking our dedicated page:

    Fee Sharing | Velora User Docsdoc.paraswap.network

    Track Delta Order Status

    Get Delta Order Auction Status

    GET 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.

    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

    {
      "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"
          }
        }
      }
    }
    {
        "errorType": "InvalidHmac",
        "details": "Invalid HMAC"
    }
    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
    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,
    );
    
    
    {
      "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
      }
    }
    {
      "error": "computePrice Error
    {
        "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"
    }
    nonceAndMeta = address + (randInt(0, 2 ^ 53 - 1) << 160)
    {
        "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"
    }
    

    LIMIT: has takerFromMeta set to 0x....0.

    FULFILLED: order is fully fulfilled.

  • EXPIRED: order is expired.

  • CANCELLED: order is canceled.

  • LIMIT: has takerFromMeta set to 0x....0.

    FULFILLED: order is fully fulfilled.

  • EXPIRED: order is expired.

  • CANCELLED: order is canceled.

  • side

    string

    SELL or BUY. Default: SELL.

    network

    string

    Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Sonic - 146, Unichain - 130, Plasma - 9745). Default: 1.

    otherExchangePrices

    boolean

    If provided, others object is filled in the response with price quotes from other exchanges (if available for comparison). Default: false

    includeDEXS

    string

    Comma Separated List of DEXs to include. Supported DEXs: 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 eg: UniswapV3,0x

    excludeDEXS

    string

    Comma Separated List of DEXs to exclude. (from the list of DEXs mentioned above).

    includeContractMethods

    string

    Comma Separated List of Contract Methods to include without spaces. Available values: swapOnUniswap, buyOnUniswap, swapOnUniswapFork, buyOnUniswapFork, swapOnUniswapV2Fork, buyOnUniswapV2Fork, simpleBuy, simpleSwap, multiSwap, megaSwap, protectedMultiSwap, protectedMegaSwap, protectedSimpleSwap, protectedSimpleBuy, swapOnZeroXv2, swapOnZeroXv4, buy. eg: simpleSwap,multiSwap

    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

    Dash (-) separated list of tokens (addresses or symbols from /tokens) to comprise the price route. Max 4 tokens. *Note: If route is specified, the response will only comprise of the route specified which might not be the optimal route.

    partner

    string

    Partner string.

    partnerFeeBps

    string

    If provided it is used together with partnerAddress. Should be in basis points percentage. Look at slippage parameter description for understanding better. Eg: 200 (for 2% fee percent)

    *Note: Fees have to be claimed from the Fee Claimer contract unless isSurplusToUser or isDirectFeeTransfer are used

    partnerAddress

    string

    Address that will be entitled to claim fees or surplus.

    *Note: Fees have to be claimed from the Fee Claimer contract unless isSurplusToUser or isDirectFeeTransfer are used

    slippage

    integer

    Allowed slippage percentage represented in basis points. Eg: for 2.5% slippage, set the value to 2.5 * 100 = 250; for 10% = 1000. Slippage could be passed instead of destAmount when side=SELL or srcAmount when side=BUY. Min: 0; Max: 10000

    destDecimals*

    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

    If the source token is a tax token, you should specify the tax amount in BPS.

    *For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

    **Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

    destTokenTransferFee

    string

    If the destination token is a tax token, you should specify the tax amount in BPS.

    *For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

    **Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

    srcTokenDexTransferFee

    string

    If the source token is a tax token, you should specify the tax amount in BPS. Some tokens only charge tax when swapped in/out DEXs and not on ordinary transfers.

    *For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

    **Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

    destTokenDexTransferFee

    string

    If the destination token is a tax token, you should specify the tax amount in BPS. Some tokens only charge tax when swapped in/out DEXs, not on ordinary transfers.

    *For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

    **Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

    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

    Specify if user should receive surplus instead of partner. Default: false

    isDirectFeeTransfer

    boolean

    Specify if fees should be sent directly to the partner instead of registering them on FeeClaimer.

    Default: false

    isCapSurplus

    boolean

    Allows for capping the surplus at 1% maximum.

    Default: true

    takeSurplus

    boolean

    Allows to collect surplus. Works with partnerAddress

    Default: false

    here

    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.

  • Data structure in our centralized system
    /* eslint-disable @typescript-eslint/no-unused-vars */
    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();
    
    curl -X GET \
      'https://api.paraswap.io/ft/p2p/1/maker/0x7BA594DF3161729BF2E68A9d0A11dceB57A2e306'
    /* eslint-disable @typescript-eslint/no-unused-vars */
    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();

    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.

  • Data structure in our centralized system
    /* 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();
    curl -X GET \
      'https://api.paraswap.io/ft/p2p/137/taker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
    /* 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();
    Data structure in our centralized system
    /* 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();
    curl -X GET \
      'https://api.paraswap.io/nft/p2p/137/taker/0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf'
    /* 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();
    
    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")
    {
    	"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"
    		}
    	]
    }
    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")
    {
    	"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"
    		}
    	]
    }
    {
    	"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"
    		}
    	]
    }

    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.

    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

    GET 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

    Name
    Type
    Description

    userAddress*

    string

    User Address.

    chainId

    string[]

    Comma-separated list of chain ids (e.g. chainId=1,8453

    page

    integer

    Default: 1.

    limit

    integer

    Default: 100.

    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.

    {
      "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"
        }
      ]
    }
    

    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.

    The only differences are:

    • slightly different route (/nft/p2p/... instead of /nft/orders/... )

    • taker should contain Augustus Swapper address

    • the intended order taker is field````

    Query parameters:

    • chainId:network id (Ethereum Mainnet = 1)

    Body parameters

    • nonceAndMeta: needs to include the actual taker as described here:

    • 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:

    Response

    Understand the response by checking our dedicated page:

    Data structure in our centralized system
    Data structure in our centralized system
    Logo

    Create an order

    POST /nft/orders/:chainId/

    Examples

    The process of composing an NFT order and the payload to POST to API endpoint is pretty much the .

    The only differences are:

    • slightly different endpoint route (/nft/orders/... instead of /ft/orders/... )

    • makerAssetType and takerAssetType fields are required

    • makerAsset

    Query parameters:

    • chainId:network id (Ethereum Mainnet = 1)

    Body parameters

    • nonceAndMeta: needs to be encoded as described in:

    • 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:

    Response

    Understand the response by checking our dedicated page:

    Create a limit order

    POST /ft/orders/:chainId/

    Examples

    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

    Retrieve a price: /prices

    Get Price Route

    GET 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:

    [
      {
        "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"
          }
        ]
      }
    ]
    {
      "error": "Validation failed with error"
    }
    {
      "error": "Validation failed with error"
    }
    /* 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();
    
    {
    	"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
    	"expiry": 1664716033,
    	"makerAsset": "4094980474276800865989028098863468306593436022900",
    	"makerAssetId": "1027",
    	"takerAsset": "990092240248101882666250324982272499898038834061",
    	"takerAssetId": "0",
    	"maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
    	"taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
    	"makerAmount": "1",
    	"takerAmount": "50",
    	"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c"
    }
    const ERC20 = 0;
    const ERC721 = 2;
    const ERC1155 = 1;
    
    const encodeAddress = (address, assetType) => BigInt(address) | (BigInt(assetType) << BigInt(160));
    encodedAddress = encodeAddress('0xcd494673999194365033d7a287af9f0a3b163874', ERC721);
    {
    	"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"
    	}
    }

    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.

    type

    LIMIT | MARKET

    Filters orders by types.

    status

    OrderStatus[]

    Comma-separated list of statuses described above. Other possible values are: - ACTIVE - any non-terminal status from the list above - INACTIVE - any terminal status from the list above - SUSPENDED - orders that are suspended, but might be executed in future (INSUFFICIENT_BALANCE/INSUFFICIENT_ALLOWANCE statuses)

    encoded in the nonceAndMeta
    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"
    }'
    and
    takerAsset
    contain not plain token addresses, but token address and token type encoded as described in
  • 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.

  • same as with usual "fungible to fungible token" orders
    Data structure in our centralized system
    Data structure in our centralized system
    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"
    }'
    Body parameters
    /* 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();
    {
    	"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
    	"expiry": 1664716033,
    	"makerAsset": "4094980474276800865989028098863468306593436022900",
    	"makerAssetId": "1027",
    	"takerAsset": "990092240248101882666250324982272499898038834061",
    	"takerAssetId": "0",
    	"maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
    	"taker": "0x0000000000000000000000000000000000000000",
    	"makerAmount": "1",
    	"takerAmount": "50",
    	"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c"
    }
    const ERC20 = 0;
    const ERC721 = 2;
    const ERC1155 = 1;
    
    const encodeAddress = (address, assetType) => BigInt(address) | (BigInt(assetType) << BigInt(160));
    encodedAddress = encodeAddress('0xcd494673999194365033d7a287af9f0a3b163874', ERC721);
    {
    	"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"
    	}
    }
    2.
    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.

    /* eslint-disable @typescript-eslint/no-unused-vars */
    import axios from 'axios';
    import { ethers } from 'ethers';
    
    import {
      // swap methods
      constructPartialSDK,
      constructEthersContractCaller,
      constructAxiosFetcher,
    

    Query parameters:

    • chainId:network id (Ethereum Mainnet = 1)

    Body parameters

    Important notice:

    • nonceAndMeta: needs to be encoded as described in:

    Response

    Understand the response by checking our dedicated page:

    order parameters
    sign an object with these parameters
    Data structure in our centralized system
    Data structure in our centralized system
    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,
    
    Query Parameters
    Name
    Type
    Description

    srcToken*

    string

    Source Token Address. Instead Token Symbol could be used for tokens listed in the /tokens endpoint.

    srcDecimals*

    integer

    Source Token Decimals. (Can be omitted if Token Symbol is used in srcToken).

    destToken*

    string

    Destination Token Address. Instead Token Symbol could be used for tokens listed in the /tokens endpoint.

    amount*

    string

    srcToken amount (in case of SELL) or destToken amount (in case of BUY). The amount should be in WEI/Raw units (eg. 1WBTC -> 100000000)

    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.

    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

    • Bad USD price - src or dest tokens don’t have valid usd price

    • 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

    Retrieve Delta price with fallback to Market

    Get Delta Price with fallback to Market

    GET 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.

    This endpoint is also available in . You can find example usage .

    Query Parameters

    Name
    Type
    Description

    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 . Cross-chain orders are not supported in MARKET mode.

    Response

    Fields

    Field
    Type
    Description

    delta Object

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

    Core Fields

    Field
    Type
    Description

    BridgeInfo object

    Field
    Type
    Description

    BridgeFee object

    Field
    Type
    Description

    AvailableBridge object

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

    Field
    Type
    Description

    BridgeParams

    Field
    Type
    Description

    Examples for Successful Responses for each mode.

    Most common fallback reasons and error types

    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.

    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

    The process of composing the order and the payload to POST to API endpoint is pretty much the .

    The only differences are:

    • slightly different route (/ft/p2p/... instead of /ft/orders/... )

    • taker should contain address

    Query parameters:

    • chainId:network id (Ethereum Mainnet = 1)

    Body parameters

    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):

    Response

    Understand the response by checking our dedicated page:

    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
    { 
        "maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
        "taker": "0x0000000000000000000000000000000000000000",
        "nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
        "expiry": 0,
        "makerAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
        "takerAsset": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
        "makerAmount": "10000000000000000",
        "takerAmount": "7775870000000000",
        "signature": "0x43de8dbc8228594171d0ed3e623ca0ab5c24f46bf0575800624ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b"
    }
    {
    	"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"
    	}
    }
    {
        "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"
        }
    }
    {
      "error": "Validation failed with error"
      }
    "makerAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
    "takerAsset": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
    "makerAmount": "10000000000000000",
    "takerAmount": "7775870000000000",
    "signature": "0x43de8dbc8228594171d0ed3e623ca0ab5c24f46bf0575800624ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b"
    }'
    // 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();

    amount*

    string

    srcToken amount (in case of SELL) or destToken amount (in case of BUY). The amount should be in WEI/Raw units (eg. 1WBTC -> 100000000)

    side

    SELL | BUY

    Default: SELL.

    chainId*

    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

    Partner string.

    mode

    ALL | DELTA | MARKET

    Preferred mode for the trade. In case of "all", Delta pricing is returned, with Market as a fallback. Default: ALL. MARKET mode is not supported for cross-chain orders

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

    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 for example of usage of this mode.

    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

    fees

    BridgeFee[]

    Breakdown of fees charged by the bridge protocol. Some bridges might have no fee

    gasCostUSD

    string

    Gas cost estimate in USD for the transaction

    bridgeParams

    BridgeParams[]

    Set of configurations and objects for each protocol variant.

    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.

  • srcToken*

    string

    Source Token Address.

    srcDecimals*

    integer

    Source Token Decimals.

    destToken*

    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*

    integer

    Destination Token Decimals.

    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.

    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

    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.

    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.

    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.

    bridgeInfo

    BridgeInfo

    Bridge metadata (same structure as above)

    bridge

    Bridge

    Protocol configuration for that bridge (same structure as above)

    Velora SDK
    here
    build a swap transaction
    {
      "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"
    }
    {
      "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"
    }
    {
        "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"
        }
    }
    {
        "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"
        }
    }
    {
        "errorType": "UnsupportedToken",
        "details": "Token 0xa4bc2b90743294e5e6fd3321a9a131947f7785db is not supported"
    }

    the intended order taker is encoded in the nonceAndMeta field

    same as with usual non-p2p orders
    Augustus Swapper
    Data structure in our centralized system
    Data structure in our centralized system
    /* 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();
    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",
    

    side

    string

    SELL or BUY. Default: SELL.

    network

    string

    Network ID. (Mainnet - 1, Optimism - 10, BSC - 56, Polygon - 137, Base - 8453, Arbitrum - 42161, Avalanche - 43114, Gnosis - 100, Sonic - 146, Unichain - 130, Plasma - 9745). Default: 1.

    otherExchangePrices

    boolean

    If provided, others object is filled in the response with price quotes from other exchanges (if available for comparison). Default: false

    includeDEXS

    string

    Comma Separated List of DEXs to include. All supported DEXs by chain can be found here eg: UniswapV3, CurveV1

    excludeDEXS

    string

    Comma Separated List of DEXs to exclude. All supported DEXs by chain can be found here eg: UniswapV3, CurveV1

    excludeRFQ

    boolean

    Exclude all RFQs from pricing eg: AugustusRFQ, Hashflow Default: false

    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 and V6 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 and V6

    userAddress

    string

    User's Wallet Address.

    route

    string

    Dash (-) separated list of tokens (addresses or symbols from /tokens) to comprise the price route. Max 4 tokens. *Note: If route is specified, the response will only comprise of the route specified which might not be the optimal route.

    partner

    string

    Partner string.

    destDecimals*

    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

    If the source token is a tax token, you should specify the tax amount in BPS.

    *For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

    **Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

    destTokenTransferFee

    string

    If the destination token is a tax token, you should specify the tax amount in BPS.

    *For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

    **Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

    srcTokenDexTransferFee

    string

    If the source token is a tax token, you should specify the tax amount in BPS. Some tokens only charge tax when swapped in/out DEXs and not on ordinary transfers.

    *For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

    **Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

    destTokenDexTransferFee

    string

    If the destination token is a tax token, you should specify the tax amount in BPS. Some tokens only charge tax when swapped in/out DEXs, not on ordinary transfers.

    *For example: for a token with a 5% tax, you should set it to 500 as [(500/10000)*100=5%]

    **Note: not all DEXs and contract methods support trading tax tokens, so we will filter those that don't.

    version

    number

    To specify the protocol version. Values: 5 or 6.2 Default: 5

    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

    Typescript

    SDK for the ParaSwap API

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

    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)
    { 
        "maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
        "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
        "nonceAndMeta": "7433034152904838547212883274543254857465784035140417181410394112",
        "expiry": 0,
        "makerAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
        "takerAsset": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
        "makerAmount": "10000000000000000",
        "takerAmount": "7775870000000000",
        "signature": "0x43de8dbc8228594171d0ed3e623ca0ab5c24f46bf0575800624ae56723712f807ecaf7dc8edfcf0d4517f80f11bf016bde0a9a20e243eea2bb32e55eadbb6b0d1b"
    }
    {
    	"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"
    	}
    }
    "maker": "0xB4E6f1c1f9Ba3aD97e09603966b4ac773303a8d1",
    "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
    "makerAmount": "1000000000000000000",
    "takerAmount": "8000000000000000000",
    "signature": "0x1647ae642db6e02c39ac80f40b73df032ca43648c2d11c44d5c7437e0c3a151739e54b7d3ea22067226b723ac84ac577a487579b04e7197bc3b13abee5d3952a1c"
    }'
    Features

    Versatility: works with both web3 and ethers without direct dependency

    Canonical: bring only the functions you actually need

    Lightweight: 400B Gzipped for the minimal variant

    Installing 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.

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

    Composed SDK

    Import the necessary functions

    Construct the ParaSwap object

    To approve ParaSwap contracts to swap an ERC20 token

    To get the rate of a token pair

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

    To build a transaction

    To sign a Limit Order

    Playground

    Interact with the ParaSwap SDK in a CodeSandbox playground here

    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:

    Legacy

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

    Or you can use ethers in place of web3

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

    Refer to this README for depecreated documentation 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.

    yarn add @paraswap/sdk
      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);
      }
      // 
      // 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);
      }
    import { constructSDK, constructAxiosFetcher, constructEthersContractCaller } from '@paraswap/sdk';
    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,
    });
    // 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);
    })
    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,
      }
    );
    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();
    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
    
    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);
    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});
    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,
     });
    import { ParaSwap } from '@paraswap/sdk';
    
    const paraswap = new ParaSwap({chainId: 1, fetch: window.fetch});

    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)

    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

    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):

    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):

    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):

    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

    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):

    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

    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):

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

    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:

    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"

    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.

    HTTP method in UPPERCASE (will be GET or POST)

  • 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.

  • 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.

  • 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.

  • 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'));

  • 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

  • "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)

  • "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, for V6 it's either AugustusV6 or Executors). These addresses can be verified in the documentation here or by the API endpoint here.

  • "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 here)

  • "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)

  • 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

  • SDK
    here
    {
      "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": {
        "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": {
        "WETH/USDC": {
          "bids": [
            ["1540", "0.5"],
            ["1500", "1.5"],
            ["1480", "3"]
          ],
          "asks": [
            ["1560", "1"],
            ["1580", "1.5"],
            ["1600", "2"],
            ["1650", "9"]
          ]
        },
        "WETH/USDT": {}
      }
    }
    {
      "makerAsset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "takerAsset": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "takerAmount": "1500000000000000000",
      "userAddress": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
      "takerAddress": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57"
    }
    {
      "order": {
        "nonceAndMeta": "77194726158210796949047323338180021686013833221005105572687668833110133598159",
        "expiry": 1667344557,
        "makerAsset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "takerAsset": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "maker": "0x7777777777777777777777777777777777777777",
        "taker": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
        "makerAmount": "2270000000",
        "takerAmount": "1500000000000000000",
        "signature": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcc"
      }
    }
    {
      "blacklist": [
        "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
        "0x0000000000000000000000000000000000000000"
      ]
    }

    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 :

    Arbitrum: 0x6a000f20005980200259b80c5102003040001068
  • Avalanche: 0x6a000f20005980200259b80c5102003040001068

  • Base: 0x6a000f20005980200259b80c5102003040001068

  • BSC: 0x6a000f20005980200259b80c5102003040001068

  • Gnosis: 0x6A000F20005980200259B80c5102003040001068

  • Optimism: 0x6a000f20005980200259b80c5102003040001068

  • Polygon: 0x6a000f20005980200259b80c5102003040001068

  • Sonic: 0x6a000f20005980200259b80c5102003040001068

  • Unichain: 0x6a000f20005980200259b80c5102003040001068

  • Plasma: 0x6a000f20005980200259b80c5102003040001068

  • Interfaces

    GenericSwapExactAmountIn

    GenericSwapExactAmountOut

    Fee Vault

    • Ethereum: 0x00700052c0608f670705380a4900e0a8080010cc

    • Arbitrum: 0x00700052c0608f670705380a4900e0a8080010cc

    • Avalanche: 0x00700052c0608f670705380a4900e0a8080010cc

    • Base: 0x00700052c0608f670705380a4900e0a8080010cc

    • BSC:

    • Fantom:

    • Gnosis:

    • Optimism:

    • Polygon

    • Sonic:

    • Unichain:

    • Plasma:

    Augustus Registry

    Use AugustusRegistry to verify AugustusSwapper addresses.

    • Mainnet: 0xa68bEA62Dc4034A689AA0F58A76681433caCa663

    • Arbitrum: 0xdC6E2b14260F972ad4e5a31c68294Fba7E720701

    • Avalanche: 0xfD1E5821F07F1aF812bB7F3102Bfd9fFb279513a

    • Base: 0x7e31b336f9e8ba52ba3c4ac861b033ba90900bb3

    • BSC:

    • Fantom:

    • Gnosis:

    • Optimism:

    • Polygon:

    • Sonic:

    • Unichain:

    • Plasma:

    0x6a000f20005980200259b80c5102003040001068
    34KB
    AugustusV6.2.abi.json
    Open
    8KB
    AugustusFeeVault.abi.json
    Open
    // 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;
    }
    
    // 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);
    }
    // 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);
    }
    // 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;
    }
    
    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);
    }
    0x00700052c0608f670705380a4900e0a8080010cc
    0x00700052c0608f670705380a4900e0a8080010cc
    0x00700052c0608F670705380a4900e0a8080010CC
    0x00700052c0608f670705380a4900e0a8080010cc
    0x00700052c0608f670705380a4900e0a8080010cc
    0x00700052c0608f670705380a4900e0a8080010cc
    0x00700052c0608f670705380a4900e0a8080010cc
    0x00700052c0608f670705380a4900e0a8080010cc
    0x05b4486f643914a818ed93afc07457e9074be211
    0x161383b5dAFc1cc05Ec058e5B0b0703BA175bdA6
    0xa1686Ee049A745211D64ef2B305495D9425e7BD3
    0x6e7bE86000dF697facF4396efD2aE2C322165dC3
    0xca35a4866747Ff7A604EF7a2A7F246bb870f3ca1
    0x515D89fB6b472D56Ca065AB21b32975f6ab8da3E
    0xB5253c895361678FF5D0fFDdA81Dd02f1F7a81D6
    0x09920244F4c4f79c4926b6DCD8bE2Efc5CD1224E

    Augustus v5 smart contracts

    Allowance should be given to TokenTransferProxy contract and not to AugustusSwapper, FUNDS MAY BE LOST OTHERWISE!

    AugustusSwapper

    The contract router is responsible for making swaps.

    • Mainnet :

    • Arbitrum:

    • Avalanche:

    • Base:

    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:

    • Arbitrum:

    • Avalanche:

    • Base:

    Augustus Registry

    Use AugustusRegistry to verify AugustusSwapper addresses.

    • Mainnet:

    • Arbitrum:

    • Avalanche:

    • Base:

    AugustusSwapper (implements IParaswap through fallback method)

    ABI (merged AugustusSwapper and IParaswap ABIs)

    IAugustusSwapper

    (Generated from AugustusSwapper ABI using then edited to add FeeStructure)

    IParaswap

    Utils

    Fee Claimer

    • Ethereum:

    • Arbitrum:

    • Avalanche:

    • Base:

    BSC: 0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57

  • Optimism: 0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57

  • Polygon: 0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57

  • BSC: 0x216b4b4ba9f3e719726886d34a177484278bfcae

  • Optimism: 0x216B4B4Ba9F3e719726886d34a177484278Bfcae

  • Polygon: 0x216b4b4ba9f3e719726886d34a177484278bfcae

  • BSC: 0x05b4486f643914a818ed93afc07457e9074be211

  • Optimism: 0x6e7bE86000dF697facF4396efD2aE2C322165dC3

  • Polygon: 0xca35a4866747Ff7A604EF7a2A7F246bb870f3ca1

  • BSC: 0x2DF17455B96Dde3618FD6B1C3a9AA06D6aB89347

  • Fantom: 0x4F14fE8c86A00D6DFB9e91239738499Fc0F587De

  • Optimism: 0xA7465CCD97899edcf11C56D2d26B49125674e45F

  • Polygon: 0x8b5cF413214CA9348F047D1aF402Db1b4E96c06

  • 0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57
    0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57
    0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57
    0x59C7C832e96D2568bea6db468C1aAdcbbDa08A52
    0x216b4b4ba9f3e719726886d34a177484278bfcae
    0x216B4B4Ba9F3e719726886d34a177484278Bfcae
    0x216b4b4ba9f3e719726886d34a177484278bfcae
    0x93aAAe79a53759cD164340E4C8766E4Db5331cD7
    0xa68bEA62Dc4034A689AA0F58A76681433caCa663
    0xdC6E2b14260F972ad4e5a31c68294Fba7E720701
    0xfD1E5821F07F1aF812bB7F3102Bfd9fFb279513a
    0x7e31b336f9e8ba52ba3c4ac861b033ba90900bb3
    34KB
    ParaSwap_ABI.json
    Open
    ABI2Solidity tool
    0xeF13101C5bbD737cFb2bF00Bbd38c626AD6952F7
    0xA7465CCD97899edcf11C56D2d26B49125674e45F
    0xbFcd68FD74B4B458961495F3392Bf96f46A29E67
    0x9aaB4B24541af30fD72784ED98D8756ac0eFb3C7
    pragma solidity 0.7.5;
    
    
    interface ITokenTransferProxy {
    
        function transferFrom(
            address token,
            address from,
            address to,
            uint256 amount
        )
            external;
    }
    
    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);
    }
    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;
    }
    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;
    }
    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;
        }
    }
    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);
    }
    :large_orange_circle: