# Whitepaper

February, 2024

<figure><img src="/files/2FFwbe0QAImpwhNMct3G" alt=""><figcaption></figcaption></figure>

## 1. Introduction

VulpeFI is committed to transparency, sustainability, and innovation within the decentralized finance (DeFi) space. Through the implementation of a robust token economy model and strategic distribution, we strive to cultivate a dynamic ecosystem that not only empowers users but also propels the future of decentralized finance forward.

As a groundbreaking DeFi project, VulpeFI aims to revolutionize the way users interact with digital assets and decentralized protocols. Our mission is centered around providing a seamless and secure platform that grants users access to a diverse array of financial services while affording them full control over their assets.

This whitepaper serves as a comprehensive guide to the token economy of VulpeFI, offering insights into the distribution of tokens, the allocation of funds, and the overarching strategy behind our token sale. Through transparent communication and a commitment to innovation, we seek to establish VulpeFI as a cornerstone of the decentralized finance landscape.

### 1.1. Supported Networks

VulpeFI protocols are deployed on the following networks:

* [Binance Smart Chain](https://www.bnbchain.org/en)
* [Ethereum Mainnet](https://ethereum.org/)
* [BASE](https://swapbased.finance/#/)
* [Arbitrum](https://arbitrum.foundation)
* [Polygon](https://polygon.technology/)

## 2. Tokenomics VulpeFI

### 2.1. Overview

The Analysis of VulpeFI's tokenomics reveals a carefully planned structure for distributing its tokens during its initial coin offering (ICO).

Firstly, the total amount of tokens available is 400,000,000. This is the basis for allocation into various categories:

* **Pre Sale**: Representing 37.50% of the total number of tokens, this phase reserves a significant portion for investors prior to the general public, possibly offering special conditions.
* **Public Sale**: Most of the tokens, 35.75%, are earmarked for public sale, spread over several rounds, each with an increasing price.
* **Ecosystem**: Reserving 11.25% of the tokens, this category is intended to support the VulpeFI ecosystem, possibly to encourage liquidity and application development.
* **Marketing**: Allocating 10% of the tokens, VulpeFI demonstrates the importance it attaches to publicizing and promoting its platform and products.
* **Developers (Devs)**: The development team receives 3.5% of the tokens, with a 12-month lock-up mechanism and a gradual release schedule, encouraging long-term commitment.
* **Advisors**: Advisors receive 2% of the tokens, also subject to a 12-month lock-up and a gradual release schedule, ensuring their continued involvement and alignment of interests.

Analysis of the ICO results reveals that the final amount raised was 1,220,200 million dollars, with an actual amount raised of 1,057,000 million dollars. This suggests substantial interest in VulpeFI, although the actual amount raised may differ from initial expectations.

In summary, VulpeFI's tokenomics is designed with a comprehensive approach, reserving tokens for different stakeholders and implementing measures to ensure the ongoing engagement of the development team and advisors. The result of the ICO reflects considerable interest in the project, although the discrepancy between the final amount raised and the actual amount raised may require further analysis.

### **2.2. Token Distribution**

<table><thead><tr><th width="352">Distribution</th><th width="215">Amount</th><th>Percentage</th></tr></thead><tbody><tr><td><strong>Total Supply</strong></td><td><strong>400.000.000</strong></td><td><strong>100%</strong></td></tr><tr><td>Pre Sale</td><td>150.000.000</td><td>37.50%</td></tr><tr><td>Public Sale</td><td>143.000.000</td><td>35.75%</td></tr><tr><td>Ecosystem</td><td>45.000.000</td><td>11.25%</td></tr><tr><td>Marketing</td><td>40,000,000</td><td>10%</td></tr><tr><td>Developers (Devs)</td><td>Locked for 12 months, vesting 5% monthly</td><td>3.5%</td></tr><tr><td>Advisors</td><td>Locked for 12 months, vesting 5% monthly</td><td>2%</td></tr></tbody></table>

<figure><img src="/files/EwxJsnQ9i8nIXBqIDYNM" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Developer and advisor tokens are subject to vesting schedules, ensuring alignment of interests and commitment to the long-term success of VulpeFI.
{% endhint %}

## 3. VulpeFI Token

The VulpeFI token is the governance and utility token of the VulpeFI Network. The token is applied in different capacities in the two existing protocols and will be used in the tokenomics of all new protocols released by the VulpeFI Network. VULPEFI Token is a multichain token, currently available on Ethereum and on BNB Chain over a bridge.

VulpeFI serves as a utility token primarily in Fusion mode, where it is employed by resolvers to acquire and prioritize access to swap executions.

The token holds governance authority over all existing and forthcoming protocols within the VulpeFI Network. It plays a pivotal role in the governance modules of the VulpeFI protocols.

Currently, the VulpeFI token is accessible on the Ethereum and Binance Smart Chain (BSC). Integration with the BSC was facilitated via a bridge mechanism, with no additional issuance of tokens.

## 4. VulpeFI dApp

Introducing a web-based platform seamlessly connected to supported blockchains through smart contracts, the VulpeFI dApp provides users with unparalleled access to vast combined liquidity pools and competitive token exchange rates across numerous decentralized exchanges (DEXes).&#x20;

Among its unique features are partial backfilling, allowing users to execute orders with partial fulfillment, and the capability to explore the most advantageous exchange paths among a multitude of liquidity sources. This innovative platform empowers users with enhanced trading capabilities and optimal efficiency in navigating the decentralized financial landscape.

## 5. VulpeFI Aggregation Protocol

The protocol provides combined information services across various exchange protocols and networks. At its core is the VulpeFI v5 smart contract, which verifies transaction execution in real-time.

This robust smart contract ensures the safety of user funds, offering protection even when dealing with potentially risky liquidity sources. Due to the contract's solid base, the protocol can be applied in various combined information services, such as Pathfinder, which is created and managed by VulpeFI Labs.

Our platform strategically divides orders across various decentralized exchanges (DEXes), offering superior rates and minimizing price impact. This functionality is especially attractive to large-scale investors who prioritize optimal trading conditions.

<figure><img src="/files/8Y67u8TvFyZPy4mPr8sA" alt=""><figcaption></figcaption></figure>

## 6. VulpeFI Limit Order Protocol

Our platform comprises a series of smart contracts that empower users to place both limit orders and RFQ (Request For Quote) Orders, which are subsequently executed on-chain. These order types are initially structured off-chain and authenticated in accordance with EIP-712 standards. Notable features include outstanding flexibility and high gas efficiency.&#x20;

The gasless limit order feature plays a pivotal role in reducing the entry barrier for new users of VulpeFI protocols, enabling them to participate in trading activities without the need to manage gas fees upfront. This combination of innovative features ensures a seamless and accessible experience for all users of the VulpeFI ecosystem.

## 7. VulpeFI Mobile Wallet

VulpeFI Wallet simplifies Web3 for users of all skill levels, catering to both beginners and experts. Engineered for user-friendly convenience, it empowers you to concentrate on what's important.

As a non-custodial cryptocurrency wallet, VulpeFI Wallet offers users optimal swap rates and a swift Web3 browsing experience. Accessible on iOS, Android, and as a Browser Extension, it provides seamless accessibility across platforms.

VulpeFI Wallet ensures the security of your funds and keys by rigorously validating and simulating each transaction to protect against malicious threats. Utilizing Secure Enclave technology, it guarantees the safety of your keys, providing an added layer of security.

## 8. VulpeFI GameFI

Engage with diverse Play-to-Earn functionalities within GameFI, where players can earn rewards and assets through active participation in the gaming ecosystem. This encompasses opportunities for in-game accomplishments, resource acquisition, and strategic gameplay contributing directly to tangible rewards.

Dive into the thrill of integrated lottery games within the GameFI ecosystem. Experience regular draws and events where players can test their luck for a chance to win unique in-game items, rare assets, or other valuable rewards, adding an extra layer of excitement to gameplay.

Experience the robust security infrastructure of GameFI, designed to create a safe and reliable gaming environment. From secure asset storage to anti-cheat mechanisms and fraud prevention tools, every aspect is meticulously crafted to safeguard players' assets and uphold the integrity of the gaming ecosystem.

{% hint style="warning" %}
**Disclaimer:** *This whitepaper is for informational purposes only and does not constitute investment advice. Investors should conduct their own research and due diligence before participating in any token sale.*
{% endhint %}


# VulpeFI Overview

## What is the VulpeFI ? <a href="#what-is-the-1inch-network" id="what-is-the-1inch-network"></a>

The VulpeFI (<https://vulpefi.com/>) unites decentralized protocols whose synergy enables the most profitable, fastest and protected operations in the DeFi space, offering access to hundreds of liquidity sources across multiple chains. The VulpeFI Network will launch in Q3 2024 with the release of its Aggregation Protocol v1. It will also launch decentralized applications within its roadmap, to help the entire ecosystem.

* VulpeFI dApp – a web-based application that is connected to supported blockchains through smart contracts. The dApp offers access to deep aggregated liquidity and competitive token swap rates across multiple DEXes, with unique features including partial backfilling and the ability to find the best swap paths across multiple liquidity sources.
* VulpeFI Aggregation Protocol – The VulpeFI API is a state-of-the-art discovery and routing algorithm that offers asset swaps at the best rates on the market. Finding the most efficient paths for a token swap, capable of splitting between different protocols and even different market depths within a protocol in the shortest possible time. &#x20;
* VulpeFI Limit Order Protocol – VulpeFI Limit Order Protocol is a set of smart contracts that allows users to place limit orders, and RFQ Orders, which later can be filled on-chain. Both types of orders are a data structure created off-chain and signed according to EIP-712. Key features of the protocol are extreme flexibility and high gas efficiency. Thanks to the gasless limit order feature, an entry threshold for new users of VulpeFI protocols became significantly lower.&#x20;
* VulpeFI Mobile Wallet – VulpeFI Wallet is a non-custodial crypto wallet with the best swap rates and the fastest web3 browsing experience. Available on iOS, Android and Browser Extension.
* VulpeFi GameFI -  Explore the various Play-to-Earn features within GameFI, where players can earn rewards and assets by actively participating in the game environment. This includes opportunities for in-game achievements, resource gathering, and strategic gameplay that directly contribute to tangible rewards.
* Supported Networks – VulpeFI protocols are deployed on the following Ethereum Virtual Machine (EVM) networks: Ethereum, BowsCoin, Polygon, Arbitrum, BASE.


# Wallet VulpeFI

### Easy to use

Whether you’re a novice or an expert, VulpeFI Wallet simplifies Web3. Tailored for user-friendly convenience, it allows you to concentrate on what truly matters.

### Security

VulpeFI Wallet secures your funds and keys against malicious threats through rigorous validation and simulation of each transaction. The implementation of Secure Enclave technology guarantees the safety of your keys.

### Multi-chain

Interact with any token or dApp on Ethereum, BNB Chain, Polygon, Arbitrum, Optimism, Base, Avalanche, ZKSync Era and others

### Enhanced connectivity

Easily connect to Web3 applications using WalletConnect or in-app Web3Browser

### Instant transaction signing

Regardless of their size, transactions can be instantly approved and signed

### Advanced transaction management

Cancel transactions or adjust gas prices to speed up their execution.

<figure><img src="/files/aEDNuiSPc277qsjJGnTC" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/f2qP6dfcD1xMe2wrP8VZ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/XrChtEVKBmjPanLH81SQ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/tQ88ihVU0U5VV4kcLhsi" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/O7ZbthTIAO17LY1DdaPZ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/GJqrrLVTA74ZPtWt7SJh" alt=""><figcaption></figcaption></figure>


# Wallet auto-connect

### How to implement the wallet auto-connect[​](https://docs.1inch.io/docs/wallet-auto-connect#how-to-implement-the-wallet-auto-connect) <a href="#how-to-implement-the-wallet-auto-connect" id="how-to-implement-the-wallet-auto-connect"></a>

Web3 browser in Vulpe Wallet injects JavaScript code/objects when opening a webpage.

So first it is necessary to find out if the provider has been injected:

```javascript
export function isOneInchWalletProviderInjected(): boolean {
        return Boolean(ethereum?.isOneInchIOSWallet || ethereum?.isOneInchAndroidWallet);
}
```

The next step is to retrieve the net/address, thus it would be classified as a connection.

```javascript
// Retrieving accounts: eth_requestAccounts returns the current one, it gives an array containing single address
const accounts = await ethereum.request({ method: 'eth_requestAccounts' });
```

```javascript
// returns id of the network in hex-format
const currentChain = await ethereum.request({ method: 'eth_chainId' });
```


# Introduction

{% hint style="warning" %}
The api.vulpfi.com public exchange API is under development. The project is in pre-sale model and will soon be launched.
{% endhint %}

The VulpeFI API, is a cutting-edge discovery and routing algorithm, which offers asset exchanges at the best rates on the market. Finds the most efficient paths for a token swap, able to split between different protocols and even different market depths within one protocol in the shortest possible time.

{% hint style="info" %}
**INFO**

If you are an enterprise with significant trading volumes, please **complete this application** so we can assign you a custom API endpoint. The enterprise endpoint will offer significantly better performance across market rates and response times.
{% endhint %}

## Supported Networks/Chains <a href="#supported-networkschains" id="supported-networkschains"></a>

*
* [Binance Smart Chain](https://www.bnbchain.org/en)
* [Ethereum Mainnet](https://ethereum.org/)
* [BASE](https://swapbased.finance/#/)
* [Arbitrum](https://arbitrum.foundation)
* [Polygon](https://polygon.technology/)

***


# Guide


# Quick start

In this guide, we will provide an example token swap of 0.1 VULPEFI for DAI at the best possible rate on the market.

This process includes:

* **Checking allowances**[**​**](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#checking-allowances)
* **Creating the allowance/approval transaction**[**​**](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#creating-the-allowanceapproval-transaction)
* **Making a swap**

{% hint style="success" %}
**TIP**

This example uses Binance Chain network; however, it can be replicated on any network supported by VulpeFI Aggregation Protocol
{% endhint %}

## Checking allowances <a href="#checking-allowances-1" id="checking-allowances-1"></a>

### Step 1: Set Up Your Environment <a href="#step-1-set-up-your-environment" id="step-1-set-up-your-environment"></a>

First, import the necessary Node.js libraries and set up your environment variables.

```javascript
const Web3 = require('web3'); // Import the Web3 library for interacting with Ethereum
const fetch = require('node-fetch'); // Import the fetch library for making HTTP requests

const chainId = 56; // The chain ID for the Binance Smart Chain (BSC)
const web3RpcUrl = 'https://bsc-dataseed.binance.org'; // The URL for the BSC node you want to connect to
const walletAddress = '0x...xxx'; // Set your wallet address (replace '0x...xxx' with your actual wallet address)
const privateKey = '0x...xxx'; // Set the private key of your wallet (replace '0x...xxx' with your actual private key). NEVER SHARE THIS WITH ANYONE!
```

### Step 2: Define Your Swap Parameters <a href="#step-2-define-your-swap-parameters" id="step-2-define-your-swap-parameters"></a>

Next, define the parameters for the swap you want to perform.

```javascript
const swapParams = {
    fromTokenAddress: '0x...xxx', // The address of the token you want to swap from (VULPFI)
    toTokenAddress: '0x...xxx', // The address of the token you want to swap to (DAI)
    amount: '200000000000000000', // The amount of the fromToken you want to swap (in wei)
    fromAddress: 'YOUR_WALLET_ADDRESS', // Your wallet address from which the swap will be initiated
    slippage: 1, // The maximum acceptable slippage percentage for the swap (e.g., 1 for 1%)
    disableEstimate: false, // Whether to disable estimation of swap details (set to true to disable)
    allowPartialFill: false, // Whether to allow partial filling of the swap order (set to true to allow)
};
```

{% hint style="info" %}
**INFO**

* For complete swap parameter descriptions, [**see this page**](/aggregation-protocol/api/swap-params)**.**
* *<mark style="background-color:blue;">amount: '200000000000000000'</mark>*: This value is used because VulpeFI token has 18 decimals as part of the ERC-20 token standard.
  {% endhint %}

### Step 3: Define API URLs and Initialize Web3 Libraries <a href="#step-3-define-api-urls-and-initialize-web3-libraries" id="step-3-define-api-urls-and-initialize-web3-libraries"></a>

Now, define the API URLs and initialize Web3. Web3 is a collection of libraries which allow you to interact with a local or remote Ethereum node, using HTTP, IPC, or WebSocket.

```javascript
const broadcastApiUrl = 'https://gateway.vulpefi.com/v1.1/' + chainId + '/broadcast';
const apiBaseUrl = 'https://api.vulpefi.com/v1/' + chainId;
const web3 = new Web3(web3RpcUrl);
```

### Step 4: Define Helper Functions[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-4-define-helper-functions) <a href="#step-4-define-helper-functions" id="step-4-define-helper-functions"></a>

Define a series of helper functions that will be used to interact with the VulpFI API.

```javascript
// Construct full API request URL
function apiRequestUrl(methodName, queryParams) {
    return apiBaseUrl + methodName + '?' + (new URLSearchParams(queryParams)).toString();
}

function checkAllowance(tokenAddress, walletAddress) {
    return fetch(apiRequestUrl('/approve/allowance', {tokenAddress, walletAddress}))
        .then(res => res.json())
        .then(res => res.allowance);
}
```

### Step 5: Check Token Allowance[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-5-check-token-allowance) <a href="#step-5-check-token-allowance" id="step-5-check-token-allowance"></a>

Use the `checkAllowance` function to check the current allowance of the token.

```javascript
const allowance = await checkAllowance(swapParams.fromTokenAddress, walletAddress);
console.log('Allowance: ', allowance);
```

At this point, you'll have set up your environment, defined your swap parameters, defined your API endpoints, and checked the allowance for the token you are selling.

{% hint style="info" %}
**NOTE**

If you haven't previously approved or swapped this asset using VulpFI Aggregation Protocol, then *<mark style="background-color:yellow;">> Allowance: 0</mark>* will be displayed in the console. This means that the VulpFI router does not have access to swap this token within your wallet.
{% endhint %}

***

## Creating the token allowance (approval) transaction[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#creating-the-token-allowance-approval-transaction) <a href="#creating-the-token-allowance-approval-transaction" id="creating-the-token-allowance-approval-transaction"></a>

In order for the VulpFI aggregation protocol to access tokens in your wallet, you must create an approval transaction. This specifies that the VulpFI router is allowed to swap a specific amount of the token chosen.

{% hint style="danger" %}
**CAUTION**

Approval transactions require payment of a blockchain gas fee! This amount is deducted in the form of native tokens from your wallet.
{% endhint %}

### Step 1:[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-1) <a href="#step-1" id="step-1"></a>

Similar to the Allowance Check, you'll first need to set up your environment, define swap parameters and API endpoints, and initialize Web3 libraries.

```javascript
const Web3 = require('web3');
const fetch = require('node-fetch');

const chainId = 56;
const web3RpcUrl = 'https://bsc-dataseed.binance.org';
const walletAddress = '0x...xxx'; // Set your wallet address
const privateKey = '0x...xxx'; // Set private key of your wallet. Be careful! NEVER share this key with anyone!

const swapParams = {
    fromTokenAddress: '0x...xxx', // VULPFI EXAMPLE
    toTokenAddress: '0x...xxx', // DAI EXAMPLE
    amount: '200000000000000000', //18 decimals (in gwei)
    fromAddress: walletAddress,
    slippage: 1,
    disableEstimate: false,
    allowPartialFill: false,
};

// API endpoints
const broadcastApiUrl = 'https://gateway.vulpfi.io/v1.1/' + chainId + '/broadcast';
const apiBaseUrl = 'https://api.vulpfi.com/v1/' + chainId;
const web3 = new Web3(web3RpcUrl);
```

### Step 2: Implement Helper Functions[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-2-implement-helper-functions) <a href="#step-2-implement-helper-functions" id="step-2-implement-helper-functions"></a>

Implement helper functions to interact with the VulpFI API, including constructing the API request URL, broadcasting raw transactions, signing and sending transactions, and preparing approval transactions considering the gas limit.

```javascript
// Construct full API request URL
function apiRequestUrl(methodName, queryParams) {
    return apiBaseUrl + methodName + '?' + (new URLSearchParams(queryParams)).toString();
}

// Post raw transaction to the API and return transaction hash
async function broadCastRawTransaction(rawTransaction) {
    return fetch(broadcastApiUrl, {
        method: 'post',
        body: JSON.stringify({ rawTransaction }),
        headers: { 'Content-Type': 'application/json' }
    })
        .then(res => res.json())
        .then(res => {
            return res.transactionHash;
        });
}

// Sign and post a transaction, return its hash
async function signAndSendTransaction(transaction) {
    const { rawTransaction } = await web3.eth.accounts.signTransaction(transaction, privateKey);

    return await broadCastRawTransaction(rawTransaction);
}

// Prepare approval transaction, considering gas limit
async function buildTxForApproveTradeWithRouter(tokenAddress, amount) {
    const url = apiRequestUrl(
        '/approve/transaction',
        amount ? { tokenAddress, amount } : { tokenAddress }
    );

    const transaction = await fetch(url).then(res => res.json());

    const gasLimit = await web3.eth.estimateGas({
        ...transaction,
        from: walletAddress
    });

    return {
        ...transaction,
        gas: gasLimit
    };
}
```

### Step 3: Build the Body of the Transaction[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-3-build-the-body-of-the-transaction) <a href="#step-3-build-the-body-of-the-transaction" id="step-3-build-the-body-of-the-transaction"></a>

Prepare the transaction data for approval using the `buildTxForApproveTradeWithRouter` function and store it in `transactionForSign`.

```javascript
const transactionForSign = await buildTxForApproveTradeWithRouter(swapParams.fromTokenAddress);
console.log('Transaction for approve: ', transactionForSign);
```

### Step 4: Confirm and Send the Transaction[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-4-confirm-and-send-the-transaction) <a href="#step-4-confirm-and-send-the-transaction" id="step-4-confirm-and-send-the-transaction"></a>

Prompt the user to confirm the transaction using the `yesno` library. If confirmed, sign and send the transaction. Otherwise, exit without signing.

```javascript
const ok = await yesno({
    question: 'Do you want to send a transaction to approve trade with VulpFI router?'
});

if (!ok) {
    return false;
}

const approveTxHash = await signAndSendTransaction(transactionForSign);
console.log('Approve tx hash: ', approveTxHash);
```

After running this code in the console, you should see something like this:

`> Approve tx hash: 0xc313c133e203fe66b487e27ab0afde71842dc34ab97aca60c147c7662505312a2`

With the transaction hash, you can monitor its execution using the blockchain explorer.

For the Binance Chain, you can use bscscan.com:&#x20;

**BROKEN LINK**

***

## Making the Swap <a href="#making-the-swap" id="making-the-swap"></a>

{% hint style="danger" %}
**CAUTION**

Before proceeding, please confirm that your approval transaction has a status of `Success`!
{% endhint %}

### Step 1: Set Up Environment and Define Swap Parameters[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-1-set-up-environment-and-define-swap-parameters) <a href="#step-1-set-up-environment-and-define-swap-parameters" id="step-1-set-up-environment-and-define-swap-parameters"></a>

```javascript
// Set up environment and import necessary libraries
const Web3 = require('web3');
const fetch = require('node-fetch');

// Define the chain ID and Web3 RPC URL
const chainId = 56;
const web3RpcUrl = 'https://bsc-dataseed.binance.org';

// Set your wallet address and private key
const walletAddress = '0x...xxx';
const privateKey = '0x...xxx';

// Define the swap parameters
const swapParams = {
    fromTokenAddress: '0x...xxx', // VULPEFI EXAMPLE
    toTokenAddress: '0x...xxx', // DAI EXAMPLE
    amount: '200000000000000000',
    fromAddress: walletAddress,
    slippage: 1,
    disableEstimate: false,
    allowPartialFill: false,
};
```

### Step 2: Implement Helper Functions[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-2-implement-helper-functions-1) <a href="#step-2-implement-helper-functions-1" id="step-2-implement-helper-functions-1"></a>

```javascript
// Define the API endpoints for broadcasting and interacting with VulpFeI
const broadcastApiUrl = 'https://gateway.vulpefi.com/v1.1/' + chainId + '/broadcast';
const apiBaseUrl = 'https://api.vulpefi.com/v1/' + chainId;

// Create a new instance of Web3 using the provided RPC URL
const web3 = new Web3(web3RpcUrl);

// Construct the full API request URL based on the method and query parameters
function apiRequestUrl(methodName, queryParams) {
    return apiBaseUrl + methodName + '?' + (new URLSearchParams(queryParams)).toString();
}

// Post a raw transaction to the VulpeFI API and return the transaction hash
async function broadCastRawTransaction(rawTransaction) {
    return fetch(broadcastApiUrl, {
        method: 'post',
        body: JSON.stringify({ rawTransaction }),
        headers: { 'Content-Type': 'application/json' }
    })
        .then(res => res.json())
        .then(res => {
            return res.transactionHash;
        });
}

// Sign and send a transaction using the provided private key
async function signAndSendTransaction(transaction) {
    const { rawTransaction } = await web3.eth.accounts.signTransaction(transaction, privateKey);

    return await broadCastRawTransaction(rawTransaction);
}
```

### Step 3: Build the Body of the Transaction[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-3-build-the-body-of-the-transaction-1) <a href="#step-3-build-the-body-of-the-transaction-1" id="step-3-build-the-body-of-the-transaction-1"></a>

```javascript
// Prepare the transaction data for the swap by making an API request
async function buildTxForSwap(swapParams) {
    const url = apiRequestUrl('/swap', swapParams);

    // Fetch the swap transaction details from the API
    return fetch(url)
        .then(res => res.json())
        .then(res => res.tx);
}

// First, let's build the body of the transaction
const swapTransaction = await buildTxForSwap(swapParams);
console.log('Transaction for swap: ', swapTransaction);
```

### Step 4: Confirm and Send the Transaction[​](https://docs.1inch.io/docs/aggregation-protocol/guide/quick-start#step-4-confirm-and-send-the-transaction-1) <a href="#step-4-confirm-and-send-the-transaction-1" id="step-4-confirm-and-send-the-transaction-1"></a>

```javascript
// Prompt the user to confirm the transaction before signing and sending it
const ok = await yesno({
    question: 'Do you want to send a transaction to exchange with VulpeFI router?'
});

// Confirm that all parameters are specified correctly before signing the transaction
if (!ok) {
    return false;
}

// Sign and send the swap transaction, and retrieve the transaction hash
const swapTxHash = await signAndSendTransaction(swapTransaction);
console.log('Transaction Signed and Sent: ', swapTxHash);
```

After running this code in the console, you should see something like this:

`> Swap tx hash: 0xd991e17cc2b33e6a244fb2a98deb83b4659f94cf867ef7730b614d1feaa7cf94`

Let's check the result of the transaction on the explorer:

**BROKEN LINK**


# API


# Swagger


# Binance Smart Chain

## VulpeFI Swap API <mark style="background-color:purple;">5.2</mark> <mark style="background-color:green;">OAS3</mark>

<https://api.vulpefi.com/swagger/bsc-json>

### Ethereum Network

Using VulpeFI Swap API, you can find the best route to exchange assets and make the exchange.\
\
Step by step:

1. Lookup addresses of tokens you want to swap, for example ‘0xxx’ , ‘0xxxx’ for DAI -> VULPE
2. Check for allowance of 1inch router contract to spend source asset (/approve/allowance)
3. If necessary, give approval for 1inch router to spend source token (/approve/transaction)
4. Monitor the best exchange route using (/quote)
5. When you ready use to perform swap (/swap)

### Swap

{% openapi src="<https://api.1inch.io/swagger/binance-json>" path="/v5.2/56/quote" method="get" %}
<https://api.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/binance-json>" path="/v5.2/56/swap" method="get" %}
<https://api.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/binance-json>" path="/v5.2/56/approve/spender" method="get" %}
<https://api.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/binance-json>" path="/v5.2/56/approve/transaction" method="get" %}
<https://api.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/binance-json>" path="/v5.2/56/approve/allowance" method="get" %}
<https://api.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/binance-json>" path="/v5.2/56/liquidity-sources" method="get" %}
<https://api.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/binance-json>" path="/v5.2/56/tokens" method="get" %}
<https://api.1inch.io/swagger/binance-json>
{% endopenapi %}


# Ethereum Network

## VulpeFI Swap API <mark style="background-color:purple;">1.0</mark>

<https://api.vulpefi.com/swagger/ethereum-json>

### Ethereum Network

Using VulpeFI Swap API, you can find the best route to exchange assets and make the exchange.\
\
Step by step:

1. Lookup addresses of tokens you want to swap, for example ‘0xxx’ , ‘0xxxx’ for DAI -> VULPE
2. Check for allowance of 1inch router contract to spend source asset (/approve/allowance)
3. If necessary, give approval for 1inch router to spend source token (/approve/transaction)
4. Monitor the best exchange route using (/quote)
5. When you ready use to perform swap (/swap)

### Swap

{% openapi src="<https://api.1inch.io/swagger/ethereum-json>" path="/v5.2/1/quote" method="get" expanded="false" fullWidth="false" %}
<https://api.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/ethereum-json>" path="/v5.2/1/swap" method="get" %}
<https://api.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/ethereum-json>" path="/v5.2/1/approve/spender" method="get" %}
<https://api.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/ethereum-json>" path="/v5.2/1/approve/transaction" method="get" expanded="false" %}
<https://api.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/ethereum-json>" path="/v5.2/1/approve/allowance" method="get" %}
<https://api.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/ethereum-json>" path="/v5.2/1/liquidity-sources" method="get" %}
<https://api.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/ethereum-json>" path="/v5.2/1/tokens" method="get" %}
<https://api.1inch.io/swagger/ethereum-json>
{% endopenapi %}


# BASE

## VulpeFI Swap API <mark style="background-color:purple;">1.0</mark>

<https://api.vulpeFI.io/swagger/base-json>

### Ethereum Network

Using VulpeFI Swap API, you can find the best route to exchange assets and make the exchange.\
\
Step by step:

1. Lookup addresses of tokens you want to swap, for example ‘0xxx’ , ‘0xxxx’ for DAI -> VULPE
2. Check for allowance of 1inch router contract to spend source asset (/approve/allowance)
3. If necessary, give approval for 1inch router to spend source token (/approve/transaction)
4. Monitor the best exchange route using (/quote)
5. When you ready use to perform swap (/swap)

### Swap

{% openapi src="<https://api.1inch.io/swagger/avalanche-json>" path="/v5.2/43114/quote" method="get" %}
<https://api.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/avalanche-json>" path="/v5.2/43114/swap" method="get" %}
<https://api.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/avalanche-json>" path="/v5.2/43114/approve/spender" method="get" %}
<https://api.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/avalanche-json>" path="/v5.2/43114/approve/transaction" method="get" %}
<https://api.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/avalanche-json>" path="/v5.2/43114/approve/allowance" method="get" %}
<https://api.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/avalanche-json>" path="/v5.2/43114/liquidity-sources" method="get" %}
<https://api.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/avalanche-json>" path="/v5.2/43114/tokens" method="get" %}
<https://api.1inch.io/swagger/avalanche-json>
{% endopenapi %}


# Arbitrum

## VulpFI Swap API <mark style="background-color:purple;">1.0</mark>

<https://api.vulpefi.com/swagger/arbitrum-json>

### Ethereum Network

Using VulpeFI Swap API, you can find the best route to exchange assets and make the exchange.\
\
Step by step:

1. Lookup addresses of tokens you want to swap, for example ‘0xxx’ , ‘0xxxx’ for DAI -> VULPE
2. Check for allowance of 1inch router contract to spend source asset (/approve/allowance)
3. If necessary, give approval for 1inch router to spend source token (/approve/transaction)
4. Monitor the best exchange route using (/quote)
5. When you ready use to perform swap (/swap)

### Swap

{% openapi src="<https://api.1inch.io/swagger/gnosis-json>" path="/v5.2/100/quote" method="get" %}
<https://api.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/gnosis-json>" path="/v5.2/100/swap" method="get" %}
<https://api.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/gnosis-json>" path="/v5.2/100/approve/spender" method="get" %}
<https://api.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/gnosis-json>" path="/v5.2/100/approve/transaction" method="get" %}
<https://api.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/gnosis-json>" path="/v5.2/100/approve/allowance" method="get" %}
<https://api.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/gnosis-json>" path="/v5.2/100/liquidity-sources" method="get" %}
<https://api.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/gnosis-json>" path="/v5.2/100/tokens" method="get" %}
<https://api.1inch.io/swagger/gnosis-json>
{% endopenapi %}


# Polygon

## VulpeFI Swap API <mark style="background-color:purple;">1.0</mark>

<https://api.vulpefi.com/swagger/polygon-json>

### Ethereum Network

Using VulpeFI Swap API, you can find the best route to exchange assets and make the exchange.\
\
Step by step:

1. Lookup addresses of tokens you want to swap, for example ‘0xxx’ , ‘0xxxx’ for DAI -> VULPE
2. Check for allowance of 1inch router contract to spend source asset (/approve/allowance)
3. If necessary, give approval for 1inch router to spend source token (/approve/transaction)
4. Monitor the best exchange route using (/quote)
5. When you ready use to perform swap (/swap)

### Swap

{% openapi src="<https://api.1inch.io/swagger/polygon-json>" path="/v5.2/137/quote" method="get" %}
<https://api.1inch.io/swagger/polygon-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/polygon-json>" path="/v5.2/137/swap" method="get" %}
<https://api.1inch.io/swagger/polygon-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/polygon-json>" path="/v5.2/137/approve/spender" method="get" %}
<https://api.1inch.io/swagger/polygon-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/polygon-json>" path="/v5.2/137/approve/transaction" method="get" %}
<https://api.1inch.io/swagger/polygon-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/polygon-json>" path="/v5.2/137/approve/allowance" method="get" %}
<https://api.1inch.io/swagger/polygon-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/polygon-json>" path="/v5.2/137/liquidity-sources" method="get" %}
<https://api.1inch.io/swagger/polygon-json>
{% endopenapi %}

{% openapi src="<https://api.1inch.io/swagger/polygon-json>" path="/v5.2/137/tokens" method="get" %}
<https://api.1inch.io/swagger/polygon-json>
{% endopenapi %}


# Swap params

{% hint style="danger" %}
CAUTION

The public Swap API api.vulpefi.com is deprecated. To continue using the Swap API please migrate to the **VULPEFI Developer Portal**
{% endhint %}

## Generate data for calling the VulpeFI router for exchange: [`/api/swap`](/aggregation-protocol/api/swagger/ethereum-network) <a href="#generate-data-for-calling-the-1inch-router-for-exchange-apiswap" id="generate-data-for-calling-the-1inch-router-for-exchange-apiswap"></a>

### Description of query parameters <a href="#description-of-query-parameters" id="description-of-query-parameters"></a>

<table><thead><tr><th width="231">Parameter name</th><th width="104">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>src *</code></td><td>string</td><td>contract address of a token to sell<br>e.g.: <code>0x...xxx example</code></td></tr><tr><td><code>dst *</code></td><td>string</td><td>contract address of a token to buy<br>e.g.: <code>0x...xxx example</code></td></tr><tr><td><code>amount *</code></td><td>integer</td><td><p>amount of a token to sell, set in minimal divisible units </p><p>e.g.:<br><code>1.00 DAI</code> set as <code>1000000000000000000</code><br><code>51.03 USDC</code> set as <code>51030000</code></p></td></tr><tr><td><code>from *</code></td><td>string</td><td>address of a seller, make sure that this address has approved to spend src in needed amount<br>e.g.: <code>0x...xxx example</code></td></tr><tr><td><code>slippage *</code></td><td>number</td><td>limit of price slippage you are willing to accept in percentage, may be set with decimals. &#x26;slippage=0.5 means 0.5% slippage is acceptable. Low values increase chances that transaction will fail, high values increase chances of front running. Set values in the range from 0 to 50</td></tr><tr><td><code>protocols</code></td><td>string</td><td>specify liquidity protocols. If not set, all liquidity protocols will be used; you can disable any protocol by listing all protocols except those you don't need<br>e.g.: <code>&#x26;protocols=</code><br><code>default: all protocols can be used</code></td></tr><tr><td><code>receiver</code></td><td>string</td><td>recipient address of a purchased token<br>if not set, from will receive a purchased token</td></tr><tr><td><code>includeTokensInfo</code></td><td>boolean</td><td>if set to <code>true</code>, response will include from token and to token info<br><code>default: false</code></td></tr><tr><td><code>includeProtocols</code></td><td>boolean</td><td>if set to <code>true</code>, response will include protocols used in the quote<br><code>default: false</code></td></tr><tr><td><code>referrer</code></td><td>string</td><td>referrer's address</td></tr><tr><td><code>fee</code></td><td>number</td><td>this percentage of src token amount will be sent to referrer, the rest will be used as input for a swap<br><code>min: 0;</code> <code>max: 3;</code> <code>default: 0</code><br>example to set a fee to 1.5%: <code>&#x26;fee=1.5</code></td></tr><tr><td><code>gasPrice</code></td><td>string</td><td>VulpeFI takes in account gas expenses to determine exchange route. It is important to use the same gas price on the quote and swap methods.<br>Gas price set in wei: <code>12.5 GWEI</code> set as <code>12500000000</code><br><code>default: "fast" from network</code></td></tr><tr><td><code>permit</code></td><td>string</td><td>https://eips.ethereum.org/EIPS/eip-2612</td></tr><tr><td><code>compatibility</code></td><td>boolean</td><td>If true, the <code>swap</code> function will always be used. This helps when the token being traded has a tax or fee on trade or transfer <code>default: false</code></td></tr><tr><td><code>complexityLevel</code></td><td>string</td><td>maximum number of token-connectors to be used in a transaction. The more is used — the longer route estimation will take, the more complex route might be as a result. If not set, two token-connectors may be used<br><code>min: 0;</code> <code>max: 3;</code> <code>default: 2</code></td></tr><tr><td><code>connectorTokens</code></td><td>string</td><td>token-connectors can be specified via this parameter. The more is set — the longer route estimation will take. If not set, default token-connectors will be used. If a token you want to exchange doesn't have a pool with one of the default token-connectors this parameter will help find the route; should be the same for a quote and swap <code>max: 5;</code><br>e.g.: <code>&#x26;connectorTokens=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, 0x...xxx example</code><br><code>default: list of default token-connectors</code></td></tr><tr><td><code>allowPartialFill</code></td><td>boolean</td><td>if true, the algorithm can cancel part of the route, if the rate has become less attractive. Unswapped tokens will return to the from<br><code>default: true</code></td></tr><tr><td><code>disableEstimate</code></td><td>boolean</td><td>if true, disable most of the checks<br><code>default: false</code></td></tr><tr><td><code>gasLimit</code></td><td>integer</td><td>maximum amount of gas for a swap;<br>should be the same for a quote and swap<br><code>default: 11500000;</code> <code>max: 11500000</code></td></tr><tr><td><code>mainRouteParts</code></td><td>integer</td><td>limit maximum number of main route parts;<br>should be the same for a quote and swap<br><code>default: 20;</code> <code>max: 50</code></td></tr><tr><td><code>parts</code></td><td>integer</td><td>limit maximum number of parts each main route parts can be split into; should be the same for a quote and swap <br><code>default: 20;</code> <code>max: 100</code></td></tr></tbody></table>

### Description of response parameters <a href="#description-of-response-parameters" id="description-of-response-parameters"></a>

**By default only toAmount and the tx object are returned**

<table><thead><tr><th width="232">Parameter name</th><th width="104">Type</th><th>Description</th></tr></thead><tbody><tr><td>fromToken</td><td>string</td><td>parameters of a token to sell</td></tr><tr><td>toToken</td><td>string</td><td>parameters of a token to buy</td></tr><tr><td>fromAmount</td><td>string</td><td>input amount of <code>fromToken</code> in minimal divisible units</td></tr><tr><td>toAmount</td><td>string</td><td>result amount of <code>toToken</code> in minimal divisible units</td></tr><tr><td>protocols</td><td>string</td><td>route of the trade</td></tr><tr><td>from</td><td>string</td><td>transactions will be sent from this address</td></tr><tr><td>to</td><td>string</td><td>transactions will be sent to our contract address</td></tr><tr><td>data</td><td>string</td><td>bytes of call data</td></tr><tr><td>value</td><td>string</td><td>amount of ETH (in wei) will be sent to the contract address</td></tr><tr><td>gasPrice</td><td>string</td><td>gas price in wei</td></tr><tr><td>gas</td><td>string</td><td>estimated amount of the gas limit, increase this value by 25%</td></tr></tbody></table>


# Quote params

## Find the best quote to exchange via VulpeFI router: [`/api/quote`​](/aggregation-protocol/api/swagger/ethereum-network) <a href="#find-the-best-quote-to-exchange-via-1inch-router-apiquote" id="find-the-best-quote-to-exchange-via-1inch-router-apiquote"></a>

### Description of query parameters <a href="#description-of-query-parameters" id="description-of-query-parameters"></a>

<table><thead><tr><th width="227">Parameter name</th><th width="142">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>src *</code></td><td>string</td><td>contract address of a token to sell<br>e.g.: <code>0x...xxx example</code></td></tr><tr><td><code>dst *</code></td><td>string</td><td>contract address of a token to buy<br>e.g.: <code>0x...xxx example</code></td></tr><tr><td><code>amount *</code></td><td>integer</td><td>amount of a token to sell, set in minimal divisible units<br>e.g.:<br><code>1.00 DAI</code> set as <code>1000000000000000000</code><br><code>51.03 USDC</code> set as <code>51030000</code></td></tr><tr><td><code>includeTokensInfo</code></td><td>boolean</td><td>if set to <code>true</code>, response will include from token and to token info<br><code>default: false</code></td></tr><tr><td><code>includeProtocols</code></td><td>boolean</td><td>if set to <code>true</code>, response will include protocols used in the quote<br><code>default: false</code></td></tr><tr><td><code>includeGas</code></td><td>boolean</td><td>if set to <code>true</code>, response will include gas limit anticipated for the quote<br><code>default: false</code></td></tr><tr><td><code>fee</code></td><td>number</td><td>this percentage of <code>src</code> token amount will be sent to <code>referrerAddress</code>,<br>the rest will be used as input for a swap<br><code>min: 0;</code> <code>max: 3;</code> <code>default: 0;</code><br>example to set a fee to 1.5%: <code>&#x26;fee=1.5</code></td></tr><tr><td><code>protocols</code></td><td>string</td><td>specify liquidity protocols to use. If not set, all liquidity protocols will be used<br>e.g.: <code>&#x26;protocols=</code><br><code>default: all protocols can be used</code></td></tr><tr><td><code>gasPrice</code></td><td>string</td><td>VulpeFI takes in account gas expenses to determine exchange route. It is important to use the same gas price<br>on the quote and swap methods<br>gas price set in wei: <code>12.5 GWEI</code> set as <code>12500000000</code><br><code>default: "fast" from the network</code></td></tr><tr><td><code>complexityLevel</code></td><td>string</td><td>maximum number of token-connectors to be used in a transaction. The more is used — the longer route estimation will take, the more complex route might be as a result. If not set, two token-connectors might be used<br><code>min: 0;</code> <code>max: 3;</code> <code>default: 2</code></td></tr><tr><td><code>connectorTokens</code></td><td>string</td><td>token-connectors can be specified via this parameter. The more is set — the longer route estimation will take. If not set, default token-connectors will be used. If token you want to exchange doesn't have a pool with one of the default token-connectors, this parameter will help find the route; should be the same for a quote and swap e.g.:<br><code>&#x26;connectorTokens=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, 0x...xxx example</code><br><code>default: list of default token-connectors</code></td></tr><tr><td><code>gasLimit</code></td><td>integer</td><td>maximum amount of gas for a swap;<br>should be the same for a quote and swap<br><code>default: 11500000;</code> <code>max: 11500000;</code></td></tr><tr><td><code>mainRouteParts</code></td><td>integer</td><td>limit maximum number of main route parts;<br>should be the same for a quote and swap<br><code>default: 20;</code> <code>max: 50;</code></td></tr><tr><td><code>parts</code></td><td>integer</td><td>limit maximum number of parts each main route part can be split into; should be the same for a quote and swap<br><code>default: 20;</code> <code>max: 100;</code></td></tr></tbody></table>

### Description of response parameters <a href="#description-of-response-parameters" id="description-of-response-parameters"></a>

<table><thead><tr><th width="230"></th><th width="139"></th><th></th></tr></thead><tbody><tr><td><code>fromToken</code></td><td>string</td><td>parameters of a token to sell</td></tr><tr><td><code>toToken</code></td><td>string</td><td>parameters of a token to buy</td></tr><tr><td><code>fromAmount</code></td><td>string</td><td>input amount of <code>fromToken</code> in minimal divisible units</td></tr><tr><td><code>toAmount</code></td><td>string</td><td>result amount of <code>toToken</code> in minimal divisible units</td></tr><tr><td><code>protocols</code></td><td>string</td><td>route of the trade</td></tr><tr><td><code>gas</code></td><td>string</td><td>rough estimated amount of the gas limit for used protocols;<br>do not use <code>gas</code> from the quote method as the gas limit of a transaction</td></tr></tbody></table>


# Smart contracts


# Aggregation VulpeFI

## Derives[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#derives) <a href="#derives" id="derives"></a>

* [ClipperRouter](/aggregation-protocol/smart-contracts/clipperrouter)
* [LimitOrderProtocol](/aggregation-protocol/smart-contracts/limitorderprotocol)
* [UnoswapRouter](/aggregation-protocol/smart-contracts/unoswaprouter)
* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/drafts#EIP712)
* [EthReceiver](broken://pages/iW8VH14sl4YfZUdHor2O)
* [Ownable](https://docs.openzeppelin.com/contracts/3.x/api/access#Ownable)
* [Context](https://docs.openzeppelin.com/contracts/3.x/api/utils#Context)

## Functions[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#functions) <a href="#functions" id="functions"></a>

### constructor[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#constructor) <a href="#constructor" id="constructor"></a>

```javascript
function constructor(
  address weth,
  contract IClipperExchangeInterface _clipperExchange
) public
```

**Parameters:**

<table><thead><tr><th width="211">Name</th><th width="229">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>weth</code></td><td>address</td><td></td></tr><tr><td><code>_clipperExchange</code></td><td>contract IClipperExchangeInterface</td><td></td></tr></tbody></table>

### swap[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#swap) <a href="#swap" id="swap"></a>

```javascript
function swap(
  contract IAggregationExecutor caller,
  struct AggregationRouterV4.SwapDescription desc,
  bytes data
) external returns (uint256 returnAmount, uint256 gasLeft)
```

Performs a swap, delegating all calls encoded in `data` to `caller`. See tests for usage examples

**Parameters:**

<table><thead><tr><th width="133">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>caller</code></td><td>contract IAggregationExecutor</td><td>Aggregation executor that executes calls described in <code>data</code></td></tr><tr><td><code>desc</code></td><td>struct AggregationRouterV4.SwapDescription</td><td>Swap description</td></tr><tr><td><code>data</code></td><td>bytes</td><td>Encoded calls that <code>caller</code> should execute in between of swaps</td></tr></tbody></table>

**Return Values:**

<table><thead><tr><th width="184">Name</th><th width="93">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>returnAmount</code></td><td>uint256</td><td>Resulting token amount</td></tr><tr><td><code>gasLeft</code></td><td>uint256</td><td>Gas left</td></tr></tbody></table>

### rescueFunds[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#rescuefunds) <a href="#rescuefunds" id="rescuefunds"></a>

```javascript
function rescueFunds(
  contract IERC20 token,
  uint256 amount
) external
```

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#parameters-2)

| Name     | Type            | Description |
| -------- | --------------- | ----------- |
| `token`  | contract IERC20 |             |
| `amount` | uint256         |             |

### destroy <a href="#destroy" id="destroy"></a>

```
unction destroy(
) external
```

## Events[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#events) <a href="#events" id="events"></a>

### Swapped[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#swapped) <a href="#swapped" id="swapped"></a>

```javascript
event Swapped(
  address sender,
  contract IERC20 srcToken,
  contract IERC20 dstToken,
  address dstReceiver,
  uint256 spentAmount,
  uint256 returnAmount
)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/AggregationRouterV5#parameters-3)

| Name           | Type            | Description |
| -------------- | --------------- | ----------- |
| `sender`       | address         |             |
| `srcToken`     | contract IERC20 |             |
| `dstToken`     | contract IERC20 |             |
| `dstReceiver`  | address         |             |
| `spentAmount`  | uint256         |             |
| `returnAmount` | uint256         |             |


# ClipperRouter

Clipper router that allows to use ClipperExchangeInterface for swaps

## Derives[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#derives) <a href="#derives" id="derives"></a>

* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [EthReceiver](broken://pages/iW8VH14sl4YfZUdHor2O)

## Functions[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#functions) <a href="#functions" id="functions"></a>

### constructor[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#constructor) <a href="#constructor" id="constructor"></a>

```javascript
function constructor(
  address weth,
  contract IClipperExchangeInterface clipperExchange
) public
```

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#parameters)

| Name              | Type                               | Description |
| ----------------- | ---------------------------------- | ----------- |
| `weth`            | address                            |             |
| `clipperExchange` | contract IClipperExchangeInterface |             |

### clipperSwapToWithPermit[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#clipperswaptowithpermit) <a href="#clipperswaptowithpermit" id="clipperswaptowithpermit"></a>

```javascript
function clipperSwapToWithPermit(
  address payable recipient,
  contract IERC20 srcToken,
  contract IERC20 dstToken,
  uint256 amount,
  uint256 minReturn,
  bytes permit
) external returns (uint256 returnAmount)
```

Same as `clipperSwapTo` but calls permit first, allowing to approve token spending and make a swap in one transaction.

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#parameters-1)

| Name        | Type            | Description                                                                                         |
| ----------- | --------------- | --------------------------------------------------------------------------------------------------- |
| `recipient` | address payable | Address that will receive swap funds                                                                |
| `srcToken`  | contract IERC20 | Source token                                                                                        |
| `dstToken`  | contract IERC20 | Destination token                                                                                   |
| `amount`    | uint256         | Amount of source tokens to swap                                                                     |
| `minReturn` | uint256         | Minimal allowed returnAmount to make transaction commit                                             |
| `permit`    | bytes           | Should contain valid permit that can be used in `IERC20Permit.permit` calls. See tests for examples |

### clipperSwap[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#clipperswap) <a href="#clipperswap" id="clipperswap"></a>

```javascript
function clipperSwap(
  contract IERC20 srcToken,
  contract IERC20 dstToken,
  uint256 amount,
  uint256 minReturn
) external returns (uint256 returnAmount)
```

Same as `clipperSwapTo` but uses `msg.sender` as recipient

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#parameters-2)

| Name        | Type            | Description                                             |
| ----------- | --------------- | ------------------------------------------------------- |
| `srcToken`  | contract IERC20 | Source token                                            |
| `dstToken`  | contract IERC20 | Destination token                                       |
| `amount`    | uint256         | Amount of source tokens to swap                         |
| `minReturn` | uint256         | Minimal allowed returnAmount to make transaction commit |

### clipperSwapTo[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#clipperswapto) <a href="#clipperswapto" id="clipperswapto"></a>

```javascript
function clipperSwapTo(
  address payable recipient,
  contract IERC20 srcToken,
  contract IERC20 dstToken,
  uint256 amount,
  uint256 minReturn
) public returns (uint256 returnAmount)
```

Performs swap using Clipper exchange. Wraps and unwraps ETH if required. Sending non-zero `msg.value` for anything but ETH swaps is prohibited

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/ClipperRouter#parameters-3)

| Name        | Type            | Description                                             |
| ----------- | --------------- | ------------------------------------------------------- |
| `recipient` | address payable | Address that will receive swap funds                    |
| `srcToken`  | contract IERC20 | Source token                                            |
| `dstToken`  | contract IERC20 | Destination token                                       |
| `amount`    | uint256         | Amount of source tokens to swap                         |
| `minReturn` | uint256         | Minimal allowed returnAmount to make transaction commit |


# LimitOrderProtocol

## Derives[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#derives) <a href="#derives" id="derives"></a>

* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/drafts#EIP712)
* [EthReceiver](broken://pages/iW8VH14sl4YfZUdHor2O)

## Functions[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#functions) <a href="#functions" id="functions"></a>

### constructor[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#constructor) <a href="#constructor" id="constructor"></a>

```javascript
function constructor(
  address weth
) public
```

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#parameters)

| Name   | Type    | Description |
| ------ | ------- | ----------- |
| `weth` | address |             |

### DOMAIN\_SEPARATOR[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#domain_separator) <a href="#domain_separator" id="domain_separator"></a>

```
function DOMAIN_SEPARATOR(
) external returns (bytes32)
```

### invalidatorForOrderRFQ[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#invalidatorfororderrfq) <a href="#invalidatorfororderrfq" id="invalidatorfororderrfq"></a>

```javascript
function invalidatorForOrderRFQ(
  address maker,
  uint256 slot
) external returns (uint256)
```

Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#parameters-1)

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| `maker` | address |             |
| `slot`  | uint256 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#return-values)

| Name     | Type    | Description                                                 |
| -------- | ------- | ----------------------------------------------------------- |
| `Result` | uint256 | Each bit represents whenever corresponding quote was filled |

### cancelOrderRFQ[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#cancelorderrfq) <a href="#cancelorderrfq" id="cancelorderrfq"></a>

```javascript
function cancelOrderRFQ(
  uint256 orderInfo
) external
```

Cancels order's quote

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#parameters-2)

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `orderInfo` | uint256 |             |

### fillOrderRFQ[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#fillorderrfq) <a href="#fillorderrfq" id="fillorderrfq"></a>

```javascript
function fillOrderRFQ(
  struct LimitOrderProtocolRFQ.OrderRFQ order,
  bytes signature,
  uint256 makingAmount,
  uint256 takingAmount
) external returns (uint256, uint256)
```

Fills order's quote, fully or partially (whichever is possible)

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#parameters-3)

| Name           | Type                                  | Description                          |
| -------------- | ------------------------------------- | ------------------------------------ |
| `order`        | struct LimitOrderProtocolRFQ.OrderRFQ | Order quote to fill                  |
| `signature`    | bytes                                 | Signature to confirm quote ownership |
| `makingAmount` | uint256                               | Making amount                        |
| `takingAmount` | uint256                               | Taking amount                        |

### fillOrderRFQToWithPermit[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#fillorderrfqtowithpermit) <a href="#fillorderrfqtowithpermit" id="fillorderrfqtowithpermit"></a>

```javascript
function fillOrderRFQToWithPermit(
  struct LimitOrderProtocolRFQ.OrderRFQ order,
  bytes signature,
  uint256 makingAmount,
  uint256 takingAmount,
  address payable target,
  bytes permit
) external returns (uint256, uint256)
```

Fills Same as `fillOrderRFQ` but calls permit first, allowing to approve token spending and make a swap in one transaction. Also allows to specify funds destination instead of `msg.sender`

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#parameters-4)

| Name           | Type                                  | Description                                                                                               |
| -------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `order`        | struct LimitOrderProtocolRFQ.OrderRFQ | Order quote to fill                                                                                       |
| `signature`    | bytes                                 | Signature to confirm quote ownership                                                                      |
| `makingAmount` | uint256                               | Making amount                                                                                             |
| `takingAmount` | uint256                               | Taking amount                                                                                             |
| `target`       | address payable                       | Address that will receive swap funds                                                                      |
| `permit`       | bytes                                 | Should consist of abiencoded token address and encoded `IERC20Permit.permit` call. See tests for examples |

### fillOrderRFQTo[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#fillorderrfqto) <a href="#fillorderrfqto" id="fillorderrfqto"></a>

```javascript
function fillOrderRFQTo(
  struct LimitOrderProtocolRFQ.OrderRFQ order,
  bytes signature,
  uint256 makingAmount,
  uint256 takingAmount,
  address payable target
) public returns (uint256, uint256)
```

Same as `fillOrderRFQ` but allows to specify funds destination instead of `msg.sender`

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#parameters-5)

| Name           | Type                                  | Description                          |
| -------------- | ------------------------------------- | ------------------------------------ |
| `order`        | struct LimitOrderProtocolRFQ.OrderRFQ | Order quote to fill                  |
| `signature`    | bytes                                 | Signature to confirm quote ownership |
| `makingAmount` | uint256                               | Making amount                        |
| `takingAmount` | uint256                               | Taking amount                        |
| `target`       | address payable                       | Address that will receive swap funds |

## Events[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#events) <a href="#events" id="events"></a>

### OrderFilledRFQ[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#orderfilledrfq) <a href="#orderfilledrfq" id="orderfilledrfq"></a>

```javascript
event OrderFilledRFQ(
  bytes32 orderHash,
  uint256 makingAmount
)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/LimitOrderProtocolRFQ#parameters-6)

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `orderHash`    | bytes32 |             |
| `makingAmount` | uint256 |             |


# UnoswapRouter

## Derives[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/UnoswapRouter#derives) <a href="#derives" id="derives"></a>

* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [EthReceiver](broken://pages/iW8VH14sl4YfZUdHor2O)

## Functions[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/UnoswapRouter#functions) <a href="#functions" id="functions"></a>

### unoswapWithPermit[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/UnoswapRouter#unoswapwithpermit) <a href="#unoswapwithpermit" id="unoswapwithpermit"></a>

```javascript
function unoswapWithPermit(
  contract IERC20 srcToken,
  uint256 amount,
  uint256 minReturn,
  bytes32[] pools,
  bytes permit
) external returns (uint256 returnAmount)
```

Same as `unoswap` but calls permit first, allowing to approve token spending and make a swap in one transaction.

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/UnoswapRouter#parameters)

| Name        | Type            | Description                                                                                         |
| ----------- | --------------- | --------------------------------------------------------------------------------------------------- |
| `srcToken`  | contract IERC20 | Source token                                                                                        |
| `amount`    | uint256         | Amount of source tokens to swap                                                                     |
| `minReturn` | uint256         | Minimal allowed returnAmount to make transaction commit                                             |
| `pools`     | bytes32\[]      | Pools chain used for swaps. Pools src and dst tokens should match to make swap happen               |
| `permit`    | bytes           | Should contain valid permit that can be used in `IERC20Permit.permit` calls. See tests for examples |

### unoswap[​](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/UnoswapRouter#unoswap) <a href="#unoswap" id="unoswap"></a>

```javascript
function unoswap(
  contract IERC20 srcToken,
  uint256 amount,
  uint256 minReturn,
  bytes32[] pools
) public returns (uint256 returnAmount)
```

Performs swap using Uniswap exchange. Wraps and unwraps ETH if required. Sending non-zero `msg.value` for anything but ETH swaps is prohibited

**Parameters:**[**​**](https://docs.1inch.io/docs/aggregation-protocol/smart-contract/UnoswapRouter#parameters-1)

| Name        | Type            | Description                                                                           |
| ----------- | --------------- | ------------------------------------------------------------------------------------- |
| `srcToken`  | contract IERC20 | Source token                                                                          |
| `amount`    | uint256         | Amount of source tokens to swap                                                       |
| `minReturn` | uint256         | Minimal allowed returnAmount to make transaction commit                               |
| `pools`     | bytes32\[]      | Pools chain used for swaps. Pools src and dst tokens should match to make swap happen |


# Limit order protocol


# Introduction

VulpeFI limit order protocol is a set of smart contracts that work on any supported EVM based blockchains.

Key features of the protocol are **extreme flexibility** and high **gas efficiency** which are achieved by using two different order types - regular *Limit Order* and *RFQ Order*.

Smart Contracts allow users to place limit orders and RFQ Orders, that later could be filled on-chain. Both types of orders are data structures created off-chain and signed according to [EIP-712](https://eips.ethereum.org/EIPS/eip-712).

### I. Limit order[​](https://docs.1inch.io/docs/limit-order-protocol/introduction#i-limit-order) <a href="#i-limit-order" id="i-limit-order"></a>

A limit order is a financial instrument with which you can put up an ERC-20 token for sale at a fixed price.\
For example, you can put up 2 WBTC tokens for sale at the price of 82415 DAI tokens.

The VulpeFI limit order protocol has many tools for flexible trade management:

* Partial fill
* Predicates
* Single cancellation
* Bunch cancellation
* Fullness check
* Validation

> **Note:** For market-making, there are [**RFQ orders**](https://docs.1inch.io/docs/limit-order-protocol/introduction#ii-rfq-order) that have special optimization which does not require a large amount of gas for execution.

#### Limit order execution[​](https://docs.1inch.io/docs/limit-order-protocol/introduction#limit-order-execution) <a href="#limit-order-execution" id="limit-order-execution"></a>

1. VulpeFI users can place their limit orders through the VulpeFI dApp.
2. The signed orders placed by the users can be fetched by anyone using the VulpeFI Limit Orders Liquidity Source API to execute trades by filling the order on-chain.
3. To fill a limit order on-chain, you need to pass the signed order to the `fillOrder` method on the contract. You can find the latest contract addresses here.

   > ***Note:*** Both the buyer and seller of the assets being traded must approve their assets to be used by the VulpeFI limit order contract.
4. The Pathfinder algorithm uses the limit orders placed via the VulpeFI `dApp` and REST API as a liquidity source, making them available for any VulpeFI user to fill. This integration ensures that VulpeFI limit orders are available on the DeFi ecosystem from day one.

**Limit order features**[**​**](https://docs.1inch.io/docs/limit-order-protocol/introduction#limit-order-features)

Limit orders are highly flexible and can be configured with the following features:

1. Order execution predicate: This feature allows you to specify certain conditions to be met before the order can be executed.
   * For example, you can set an expiration time based on a certain timestamp or block number.
   * You can also construct any predicate you want, such as checking that a certain price is higher than the oracle price, to implement stop loss or take profit strategies.
2. Helper function for asset price evaluation.
   * Function that will allow to extract assets price from arbitrary on-chain source
3. Callback: For notifying the maker of the order execution.

### II. RFQ order[​](https://docs.1inch.io/docs/limit-order-protocol/introduction#ii-rfq-order) <a href="#ii-rfq-order" id="ii-rfq-order"></a>

**A request for quotation (RFQ)** is a business process in which a customer requests a quote from a supplier (market-maker) for the purchase of some tokens.

RFQ orders have different use cases, and are dedicated to market-makers in the first place. The typical scenario is following: Market-maker creates a bunch of RFQ Orders, and exposes it via the API. Trader or the platform algorithm ask for market maker quotes. If the quotes match traders' needs, the trader receives signed RFQ order from the market-maker.

**RFQ order features**[**​**](https://docs.1inch.io/docs/limit-order-protocol/introduction#rfq-order-features)

**Gas optimized order** with restricted capabilities suitable **for market-makers**

* Supports expiration time
* Supports cancelation by order id
* RFQ Order could be filled only once
* Partial Fill is possible (once)

### Supported tokens[​](https://docs.1inch.io/docs/limit-order-protocol/introduction#supported-tokens) <a href="#supported-tokens" id="supported-tokens"></a>

* ERC 20
* ERC 721
* ERC 1155
* Other token standards could be supported via external extension

### More resources[​](https://docs.1inch.io/docs/limit-order-protocol/introduction#more-resources) <a href="#more-resources" id="more-resources"></a>

* You can use Limit Orders within the VulpeFI dApp
* Smart Contracts repository
* Utils library repository


# Limit vs. RFQ Orders

The Limit Order Protocol provides users with options to place both Limit orders and Request For Quote (RFQ) orders. Select the appropriate order type based on your specific needs.

### Comparison Table[​](https://docs.1inch.io/docs/limit-order-protocol/types#comparison-table) <a href="#comparison-table" id="comparison-table"></a>

|           Criteria          |                                     Limit Order                                    |                                                     RFQ Order                                                    |
| :-------------------------: | :--------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------: |
|       **Suitable for**      |                                       Traders                                      |                                                   Market Makers                                                  |
| **Flexibility of features** |                 High; includes Order predicates, callbacks. Details                | Limited due to gas optimization; Supports expiration time, partial fills (once), and cancellation by ID. Details |
|        **Execution**        |                      Uses Pathfinder algorithm for liquidity.                      |                      Exposed via API; requires quote requests; optimized for one-time fills.                     |
|   **Key Characteristics**   | Offers at a fixed price (0 slippage); various trading features/tools can be built. |                  Mirrors "request for quotation"; designed for market makers and gas efficiency.                 |

Both order types support ERC20, ERC721, and ERC1155 tokens. Other token standards might be supported in the future.

### More resources[​](https://docs.1inch.io/docs/limit-order-protocol/types#more-resources) <a href="#more-resources" id="more-resources"></a>

**Further Reading**: Explore Limit Order and RFQ Order here.

* Try directly at VulpeFI dApp.
* View the Smart Contracts repository.
* Developers, check out the Utils library repository.


# Smart contracts


# LimitOrderProtocol

Vulpe Limit Order Protocol v2

### Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/LimitOrderProtocol#derives) <a href="#derives" id="derives"></a>

* [OrderRFQMixin](/aggregation-protocol/limit-order-protocol/smart-contracts/orderrfqmixin)
* [OrderMixin](/aggregation-protocol/limit-order-protocol/smart-contracts/ordermixin)
* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [PredicateHelper](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/predicatehelper)
* [NonceManager](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/noncemanager)
* [ChainlinkCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/chainlinkcalculator)
* [AmountCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/amountcalculator)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/utils/cryptography#draft-EIP712)

### Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/LimitOrderProtocol#functions) <a href="#functions" id="functions"></a>

#### DOMAIN\_SEPARATOR[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/LimitOrderProtocol#domain_separator) <a href="#domain_separator" id="domain_separator"></a>

```javascript
function DOMAIN_SEPARATOR(
) external returns (bytes32)
```


# LimitOrderProtocolPro

Vulpe Pro Limit Order Protocol

### Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/LimitOrderProtocolPro#derives) <a href="#derives" id="derives"></a>

* [OrderMixin](/aggregation-protocol/limit-order-protocol/smart-contracts/ordermixin)
* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [PredicateHelper](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/predicatehelper)
* [NonceManager](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/noncemanager)
* [ChainlinkCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/chainlinkcalculator)
* [AmountCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/amountcalculator)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/utils/cryptography#draft-EIP712)

### Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/LimitOrderProtocolPro#functions) <a href="#functions" id="functions"></a>

#### DOMAIN\_SEPARATOR[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/LimitOrderProtocolPro#domain_separator) <a href="#domain_separator" id="domain_separator"></a>

```
function DOMAIN_SEPARATOR(
) external returns (bytes32)
```


# OrderLib

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#functions) <a href="#functions" id="functions"></a>

### makerAssetData[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#makerassetdata) <a href="#makerassetdata" id="makerassetdata"></a>

```javascript
function makerAssetData(
  struct OrderLib.Order order
) internal returns (bytes)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### takerAssetData[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#takerassetdata) <a href="#takerassetdata" id="takerassetdata"></a>

```javascript
function takerAssetData(
  struct OrderLib.Order order
) internal returns (bytes)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters-1)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### getMakingAmount[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#getmakingamount) <a href="#getmakingamount" id="getmakingamount"></a>

```javascript
function getMakingAmount(
  struct OrderLib.Order order
) internal returns (bytes)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters-2)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### getTakingAmount[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#gettakingamount) <a href="#gettakingamount" id="gettakingamount"></a>

```javascript
function getTakingAmount(
  struct OrderLib.Order order
) internal returns (bytes)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters-3)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### predicate[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#predicate) <a href="#predicate" id="predicate"></a>

```javascript
function predicate(
  struct OrderLib.Order order
) internal returns (bytes)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters-4)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### permit[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#permit) <a href="#permit" id="permit"></a>

```javascript
function permit(
  struct OrderLib.Order order
) internal returns (bytes)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters-5)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### preInteraction[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#preinteraction) <a href="#preinteraction" id="preinteraction"></a>

```javascript
function preInteraction(
  struct OrderLib.Order order
) internal returns (bytes)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters-6)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### postInteraction[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#postinteraction) <a href="#postinteraction" id="postinteraction"></a>

```javascript
function postInteraction(
  struct OrderLib.Order order
) internal returns (bytes)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters-7)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### hash[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#hash) <a href="#hash" id="hash"></a>

```javascript
function hash(
  struct OrderLib.Order order
) internal returns (bytes32 result)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderLib#parameters-8)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |


# OrderMixin

Regular Limit Order mixin

## Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#derives) <a href="#derives" id="derives"></a>

* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [PredicateHelper](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/predicatehelper)
* [NonceManager](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/noncemanager)
* [ChainlinkCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/chainlinkcalculator)
* [AmountCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/amountcalculator)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/utils/cryptography#draft-EIP712)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#functions) <a href="#functions" id="functions"></a>

### remaining[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#remaining) <a href="#remaining" id="remaining"></a>

```javascript
function remaining(
  bytes32 orderHash
) external returns (uint256)
```

Returns unfilled amount for order. Throws if order does not exist

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters)

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `orderHash` | bytes32 |             |

### remainingRaw[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#remainingraw) <a href="#remainingraw" id="remainingraw"></a>

```javascript
function remainingRaw(
  bytes32 orderHash
) external returns (uint256)
```

Returns unfilled amount for order

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-1)

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `orderHash` | bytes32 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#return-values)

| Name     | Type    | Description                                                    |
| -------- | ------- | -------------------------------------------------------------- |
| `Result` | uint256 | Unfilled amount of order plus one if order exists. Otherwise 0 |

### remainingsRaw[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#remainingsraw) <a href="#remainingsraw" id="remainingsraw"></a>

```javascript
function remainingsRaw(
  bytes32[] orderHashes
) external returns (uint256[])
```

Same as `remainingRaw` but for multiple orders

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-2)

| Name          | Type       | Description |
| ------------- | ---------- | ----------- |
| `orderHashes` | bytes32\[] |             |

### simulateCalls[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#simulatecalls) <a href="#simulatecalls" id="simulatecalls"></a>

```javascript
function simulateCalls(
  address[] targets,
  bytes[] data
) external
```

Calls every target with corresponding data. Then reverts with CALL\_RESULTS\_0101011 where zeroes and ones denote failure or success of the corresponding call

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-3)

| Name      | Type       | Description                                    |
| --------- | ---------- | ---------------------------------------------- |
| `targets` | address\[] | Array of addresses that will be called         |
| `data`    | bytes\[]   | Array of data that will be passed to each call |

### cancelOrder[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#cancelorder) <a href="#cancelorder" id="cancelorder"></a>

```javascript
function cancelOrder(
  struct OrderLib.Order order
) external
```

Cancels order by setting remaining amount to zero

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-4)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### fillOrder[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#fillorder) <a href="#fillorder" id="fillorder"></a>

```javascript
function fillOrder(
  struct OrderLib.Order order,
  bytes signature,
  bytes interaction,
  uint256 makingAmount,
  uint256 takingAmount,
  uint256 thresholdAmount
) external returns (uint256, uint256)
```

Fills an order. If one doesn't exist (first fill) it will be created using order.makerAssetData

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-5)

| Name              | Type                  | Description                                                                                                        |
| ----------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `order`           | struct OrderLib.Order | Order quote to fill                                                                                                |
| `signature`       | bytes                 | Signature to confirm quote ownership                                                                               |
| `interaction`     | bytes                 | Making amount                                                                                                      |
| `makingAmount`    | uint256               | Taking amount                                                                                                      |
| `takingAmount`    | uint256               | Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount |
| `thresholdAmount` | uint256               |                                                                                                                    |

### fillOrderToWithPermit[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#fillordertowithpermit) <a href="#fillordertowithpermit" id="fillordertowithpermit"></a>

```javascript
function fillOrderToWithPermit(
  struct OrderLib.Order order,
  bytes signature,
  bytes interaction,
  uint256 makingAmount,
  uint256 takingAmount,
  uint256 thresholdAmount,
  address target,
  bytes permit
) external returns (uint256, uint256)
```

Same as `fillOrder` but calls permit first, allowing to approve token spending and make a swap in one transaction. Also allows to specify funds destination instead of `msg.sender`

See tests for examples

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-6)

| Name              | Type                  | Description                                                                                                        |
| ----------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `order`           | struct OrderLib.Order | Order quote to fill                                                                                                |
| `signature`       | bytes                 | Signature to confirm quote ownership                                                                               |
| `interaction`     | bytes                 | Making amount                                                                                                      |
| `makingAmount`    | uint256               | Taking amount                                                                                                      |
| `takingAmount`    | uint256               | Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount |
| `thresholdAmount` | uint256               | Address that will receive swap funds                                                                               |
| `target`          | address               | Should consist of abiencoded token address and encoded `IERC20Permit.permit` call.                                 |
| `permit`          | bytes                 |                                                                                                                    |

### fillOrderTo[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#fillorderto) <a href="#fillorderto" id="fillorderto"></a>

```javascript
function fillOrderTo(
  struct OrderLib.Order order_,
  bytes signature,
  bytes interaction,
  uint256 makingAmount,
  uint256 takingAmount,
  uint256 thresholdAmount,
  address target
) public returns (uint256, uint256)
```

Same as `fillOrder` but allows to specify funds destination instead of `msg.sender`

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-7)

| Name              | Type                  | Description                                                                                                        |
| ----------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `order_`          | struct OrderLib.Order | Order quote to fill                                                                                                |
| `signature`       | bytes                 | Signature to confirm quote ownership                                                                               |
| `interaction`     | bytes                 | Making amount                                                                                                      |
| `makingAmount`    | uint256               | Taking amount                                                                                                      |
| `takingAmount`    | uint256               | Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount |
| `thresholdAmount` | uint256               | Address that will receive swap funds                                                                               |
| `target`          | address               |                                                                                                                    |

### checkPredicate[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#checkpredicate) <a href="#checkpredicate" id="checkpredicate"></a>

```javascript
function checkPredicate(
  struct OrderLib.Order order
) public returns (bool)
```

Checks order predicate

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-8)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

### hashOrder[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#hashorder) <a href="#hashorder" id="hashorder"></a>

```javascript
function hashOrder(
  struct OrderLib.Order order
) public returns (bytes32)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-9)

| Name    | Type                  | Description |
| ------- | --------------------- | ----------- |
| `order` | struct OrderLib.Order |             |

## Events[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#events) <a href="#events" id="events"></a>

### OrderFilled[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#orderfilled) <a href="#orderfilled" id="orderfilled"></a>

```javascript
event OrderFilled(
  address maker,
  bytes32 orderHash,
  uint256 remaining
)
```

Emitted every time order gets filled, including partial fills

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-10)

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `maker`     | address |             |
| `orderHash` | bytes32 |             |
| `remaining` | uint256 |             |

### OrderCanceled[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#ordercanceled) <a href="#ordercanceled" id="ordercanceled"></a>

```javascript
event OrderCanceled(
  address maker,
  bytes32 orderHash,
  uint256 remainingRaw
)
```

Emitted when order gets cancelled

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderMixin#parameters-11)

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `maker`        | address |             |
| `orderHash`    | bytes32 |             |
| `remainingRaw` | uint256 |             |


# OrderRFQMixin

RFQ Limit Order mixin

## Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#derives) <a href="#derives" id="derives"></a>

* [Permitable](broken://pages/DOO2eTZDAe5crCpeY8uu)
* [AmountCalculator](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/amountcalculator)
* [EIP712](https://docs.openzeppelin.com/contracts/3.x/api/utils/cryptography#draft-EIP712)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#functions) <a href="#functions" id="functions"></a>

### invalidatorForOrderRFQ[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#invalidatorfororderrfq) <a href="#invalidatorfororderrfq" id="invalidatorfororderrfq"></a>

```javascript
function invalidatorForOrderRFQ(
  address maker,
  uint256 slot
) external returns (uint256)
```

Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#parameters)

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| `maker` | address |             |
| `slot`  | uint256 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#return-values)

| Name     | Type    | Description                                                       |
| -------- | ------- | ----------------------------------------------------------------- |
| `Result` | uint256 | Each bit represents whether corresponding was already invalidated |

### cancelOrderRFQ[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#cancelorderrfq) <a href="#cancelorderrfq" id="cancelorderrfq"></a>

```javascript
function cancelOrderRFQ(
  uint256 orderInfo
) external
```

Cancels order's quote

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#parameters-1)

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `orderInfo` | uint256 |             |

### fillOrderRFQ[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#fillorderrfq) <a href="#fillorderrfq" id="fillorderrfq"></a>

```javascript
function fillOrderRFQ(
  struct OrderRFQMixin.Order order,
  bytes signature,
  uint256 makingAmount,
  uint256 takingAmount
) external returns (uint256, uint256)
```

Fills order's quote, fully or partially (whichever is possible)

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#parameters-2)

| Name           | Type                       | Description                          |
| -------------- | -------------------------- | ------------------------------------ |
| `order`        | struct OrderRFQMixin.Order | Order quote to fill                  |
| `signature`    | bytes                      | Signature to confirm quote ownership |
| `makingAmount` | uint256                    | Making amount                        |
| `takingAmount` | uint256                    | Taking amount                        |

### fillOrderRFQToWithPermit[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#fillorderrfqtowithpermit) <a href="#fillorderrfqtowithpermit" id="fillorderrfqtowithpermit"></a>

```javascript
function fillOrderRFQToWithPermit(
  struct OrderRFQMixin.Order order,
  bytes signature,
  uint256 makingAmount,
  uint256 takingAmount,
  address target,
  bytes permit
) external returns (uint256, uint256)
```

Fills Same as `fillOrderRFQ` but calls permit first, allowing to approve token spending and make a swap in one transaction. Also allows to specify funds destination instead of `msg.sender`

See tests for examples

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#parameters-3)

| Name           | Type                       | Description                                                                        |
| -------------- | -------------------------- | ---------------------------------------------------------------------------------- |
| `order`        | struct OrderRFQMixin.Order | Order quote to fill                                                                |
| `signature`    | bytes                      | Signature to confirm quote ownership                                               |
| `makingAmount` | uint256                    | Making amount                                                                      |
| `takingAmount` | uint256                    | Taking amount                                                                      |
| `target`       | address                    | Address that will receive swap funds                                               |
| `permit`       | bytes                      | Should consist of abiencoded token address and encoded `IERC20Permit.permit` call. |

### fillOrderRFQTo[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#fillorderrfqto) <a href="#fillorderrfqto" id="fillorderrfqto"></a>

```javascript
function fillOrderRFQTo(
  struct OrderRFQMixin.Order order,
  bytes signature,
  uint256 makingAmount,
  uint256 takingAmount,
  address target
) public returns (uint256, uint256)
```

Same as `fillOrderRFQ` but allows to specify funds destination instead of `msg.sender`

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#parameters-4)

| Name           | Type                       | Description                          |
| -------------- | -------------------------- | ------------------------------------ |
| `order`        | struct OrderRFQMixin.Order | Order quote to fill                  |
| `signature`    | bytes                      | Signature to confirm quote ownership |
| `makingAmount` | uint256                    | Making amount                        |
| `takingAmount` | uint256                    | Taking amount                        |
| `target`       | address                    | Address that will receive swap funds |

## Events[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#events) <a href="#events" id="events"></a>

### OrderFilledRFQ[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#orderfilledrfq) <a href="#orderfilledrfq" id="orderfilledrfq"></a>

```javascript
event OrderFilledRFQ(
  bytes32 orderHash,
  uint256 makingAmount
)
```

Emitted when RFQ gets filled

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/OrderRFQMixin#parameters-5)

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `orderHash`    | bytes32 |             |
| `makingAmount` | uint256 |             |


# helpers


# AmountCalculator

A helper contract for calculations related to order amounts

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#functions) <a href="#functions" id="functions"></a>

### getMakingAmount[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#getmakingamount) <a href="#getmakingamount" id="getmakingamount"></a>

```javascript
function getMakingAmount(
  uint256 orderMakerAmount,
  uint256 orderTakerAmount,
  uint256 swapTakerAmount
) public returns (uint256)
```

Calculates maker amount

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#parameters)

| Name               | Type    | Description |
| ------------------ | ------- | ----------- |
| `orderMakerAmount` | uint256 |             |
| `orderTakerAmount` | uint256 |             |
| `swapTakerAmount`  | uint256 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#return-values)

| Name     | Type    | Description          |
| -------- | ------- | -------------------- |
| `Result` | uint256 | Floored maker amount |

### getTakingAmount[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#gettakingamount) <a href="#gettakingamount" id="gettakingamount"></a>

```javascript
function getTakingAmount(
  uint256 orderMakerAmount,
  uint256 orderTakerAmount,
  uint256 swapMakerAmount
) public returns (uint256)
```

Calculates taker amount

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#parameters-1)

| Name               | Type    | Description |
| ------------------ | ------- | ----------- |
| `orderMakerAmount` | uint256 |             |
| `orderTakerAmount` | uint256 |             |
| `swapMakerAmount`  | uint256 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#return-values-1)

| Name     | Type    | Description         |
| -------- | ------- | ------------------- |
| `Result` | uint256 | Ceiled taker amount |

### arbitraryStaticCall[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#arbitrarystaticcall) <a href="#arbitrarystaticcall" id="arbitrarystaticcall"></a>

```javascript
function arbitraryStaticCall(
  address target,
  bytes data
) external returns (uint256)
```

Performs an arbitrary call to target with data

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#parameters-2)

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `target` | address |             |
| `data`   | bytes   |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/AmountCalculator#return-values-2)

| Name     | Type    | Description                 |
| -------- | ------- | --------------------------- |
| `Result` | uint256 | Bytes transmuted to uint256 |


# ChainlinkCalculator

A helper contract for interactions with [https://docs.chain.link](https://docs.chain.link/)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#functions) <a href="#functions" id="functions"></a>

### singlePrice[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#singleprice) <a href="#singleprice" id="singleprice"></a>

```javascript
function singlePrice(
  contract AggregatorV3Interface oracle,
  uint256 inverseAndSpread,
  uint256 amount
) external returns (uint256)
```

Calculates price of token relative to oracle unit (ETH or USD)

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#parameters)

| Name               | Type                           | Description                                                                                                                                                                                                                                                                                                                            |
| ------------------ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `oracle`           | contract AggregatorV3Interface | concatenated inverse flag and spread. Lowest 254 bits specify spread amount. Spread is scaled by 1e9, i.e. 101% = 1.01e9, 99% = 0.99e9. Highest bit is set when oracle price should be inverted, e.g. for DAI-ETH oracle, inverse=false means that we request DAI price in ETH and inverse=true means that we request ETH price in DAI |
| `inverseAndSpread` | uint256                        |                                                                                                                                                                                                                                                                                                                                        |
| `amount`           | uint256                        |                                                                                                                                                                                                                                                                                                                                        |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#return-values)

| Name     | Type    | Description           |
| -------- | ------- | --------------------- |
| `Amount` | uint256 | *spread* oracle price |

### doublePrice[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#doubleprice) <a href="#doubleprice" id="doubleprice"></a>

```javascript
function doublePrice(
  contract AggregatorV3Interface oracle1,
  contract AggregatorV3Interface oracle2,
  uint256 spread,
  int256 decimalsScale,
  uint256 amount
) external returns (uint256)
```

Calculates price of token A relative to token B. Note that order is important

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#parameters-1)

| Name            | Type                           | Description |
| --------------- | ------------------------------ | ----------- |
| `oracle1`       | contract AggregatorV3Interface |             |
| `oracle2`       | contract AggregatorV3Interface |             |
| `spread`        | uint256                        |             |
| `decimalsScale` | int256                         |             |
| `amount`        | uint256                        |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#return-values-1)

| Name     | Type    | Description                         |
| -------- | ------- | ----------------------------------- |
| `Result` | uint256 | Token A relative price times amount |


# ERC1155Proxy

## Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC1155Proxy#derives) <a href="#derives" id="derives"></a>

* [ImmutableOwner](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/immutableowner)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC1155Proxy#functions) <a href="#functions" id="functions"></a>

### constructor[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC1155Proxy#constructor) <a href="#constructor" id="constructor"></a>

```javascript
function constructor(
  address _immutableOwner
) public
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC1155Proxy#parameters)

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `_immutableOwner` | address |             |

### func\_301JL5R[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC1155Proxy#func_301jl5r) <a href="#func_301jl5r" id="func_301jl5r"></a>

```javascript
function func_301JL5R(
  address from,
  address to,
  uint256 amount,
  contract IERC1155 token,
  uint256 tokenId,
  bytes data
) external
```

Proxy transfer method for `IERC1155.safeTransferFrom`. Selector must match `IERC20.transferFrom`

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC1155Proxy#parameters-1)

| Name      | Type              | Description |
| --------- | ----------------- | ----------- |
| `from`    | address           |             |
| `to`      | address           |             |
| `amount`  | uint256           |             |
| `token`   | contract IERC1155 |             |
| `tokenId` | uint256           |             |
| `data`    | bytes             |             |


# ERC721Proxy

## Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721Proxy#derives) <a href="#derives" id="derives"></a>

* [ImmutableOwner](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/immutableowner)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721Proxy#functions) <a href="#functions" id="functions"></a>

### constructor[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721Proxy#constructor) <a href="#constructor" id="constructor"></a>

```javascript
function constructor(
  address _immutableOwner
) public
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721Proxy#parameters)

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `_immutableOwner` | address |             |

### func\_60iHVgK[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721Proxy#func_60ihvgk) <a href="#func_60ihvgk" id="func_60ihvgk"></a>

```javascript
function func_60iHVgK(
  address from,
  address to,
  uint256 ,
  uint256 tokenId,
  contract IERC721 token
) external
```

Proxy transfer method for `IERC721.transferFrom`. Selector must match `IERC20.transferFrom`. Note that `amount` is unused for security reasons to prevent unintended ERC-721 token sale via partial fill

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721Proxy#parameters-1)

| Name      | Type             | Description |
| --------- | ---------------- | ----------- |
| `from`    | address          |             |
| `to`      | address          |             |
| \`\`      | uint256          |             |
| `tokenId` | uint256          |             |
| `token`   | contract IERC721 |             |


# ERC721ProxySafe

## Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721ProxySafe#derives) <a href="#derives" id="derives"></a>

* [ImmutableOwner](/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/immutableowner)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721ProxySafe#functions) <a href="#functions" id="functions"></a>

### constructor[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721ProxySafe#constructor) <a href="#constructor" id="constructor"></a>

```javascript
function constructor(
  address _immutableOwner
) public
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721ProxySafe#parameters)

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `_immutableOwner` | address |             |

### func\_60iHVgK[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721ProxySafe#func_60ihvgk) <a href="#func_60ihvgk" id="func_60ihvgk"></a>

```javascript
function func_60iHVgK(
  address from,
  address to,
  uint256 ,
  uint256 tokenId,
  contract IERC721 token
) external
```

Proxy transfer method for `IERC721.transferFrom`. Selector must match `IERC20.transferFrom`. Note that `amount` is unused for security reasons to prevent unintended ERC-721 token sale via partial fill

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ERC721ProxySafe#parameters-1)

| Name      | Type             | Description |
| --------- | ---------------- | ----------- |
| `from`    | address          |             |
| `to`      | address          |             |
| \`\`      | uint256          |             |
| `tokenId` | uint256          |             |
| `token`   | contract IERC721 |             |


# ImmutableOwner

A helper contract with helper modifiers to allow access to original contract creator only

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ImmutableOwner#functions) <a href="#functions" id="functions"></a>

### constructor[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ImmutableOwner#constructor) <a href="#constructor" id="constructor"></a>

```javascript
function constructor(
  address _immutableOwner
) public
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ImmutableOwner#parameters)

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `_immutableOwner` | address |             |


# NonceManager

A helper contract for managing nonce of tx sender

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#functions) <a href="#functions" id="functions"></a>

### increaseNonce[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#increasenonce) <a href="#increasenonce" id="increasenonce"></a>

```javascript
function increaseNonce(
) external
```

Advances nonce by one

### advanceNonce[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#advancenonce) <a href="#advancenonce" id="advancenonce"></a>

```javascript
function advanceNonce(
  uint8 amount
) public
```

Advances nonce by specified amount

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#parameters)

| Name     | Type  | Description |
| -------- | ----- | ----------- |
| `amount` | uint8 |             |

### nonceEquals[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#nonceequals) <a href="#nonceequals" id="nonceequals"></a>

```javascript
function nonceEquals(
  address makerAddress,
  uint256 makerNonce
) external returns (bool)
```

Checks if `makerAddress` has specified `makerNonce`

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#parameters-1)

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `makerAddress` | address |             |
| `makerNonce`   | uint256 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#return-values)

| Name     | Type | Description                                                  |
| -------- | ---- | ------------------------------------------------------------ |
| `Result` | bool | True if `makerAddress` has specified nonce. Otherwise, false |

## Events[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#events) <a href="#events" id="events"></a>

### NonceIncreased[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#nonceincreased) <a href="#nonceincreased" id="nonceincreased"></a>

```javascript
event NonceIncreased(
  address maker,
  uint256 newNonce
)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/NonceManager#parameters-2)

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `maker`    | address |             |
| `newNonce` | uint256 |             |


# PredicateHelper

A helper contract for executing boolean functions on arbitrary target call results

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#functions) <a href="#functions" id="functions"></a>

### or[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#or) <a href="#or" id="or"></a>

```javascript
function or(
  address[] targets,
  bytes[] data
) external returns (bool)
```

Calls every target with corresponding data

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#parameters)

| Name      | Type       | Description |
| --------- | ---------- | ----------- |
| `targets` | address\[] |             |
| `data`    | bytes\[]   |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#return-values)

| Name     | Type | Description                                                |
| -------- | ---- | ---------------------------------------------------------- |
| `Result` | bool | True if call to any target returned True. Otherwise, false |

### and[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#and) <a href="#and" id="and"></a>

```javascript
function and(
  address[] targets,
  bytes[] data
) external returns (bool)
```

Calls every target with corresponding data

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#parameters-1)

| Name      | Type       | Description |
| --------- | ---------- | ----------- |
| `targets` | address\[] |             |
| `data`    | bytes\[]   |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#return-values-1)

| Name     | Type | Description                                                  |
| -------- | ---- | ------------------------------------------------------------ |
| `Result` | bool | True if calls to all targets returned True. Otherwise, false |

### eq[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#eq) <a href="#eq" id="eq"></a>

```javascript
function eq(
  uint256 value,
  address target,
  bytes data
) external returns (bool)
```

Calls target with specified data and tests if it's equal to the value

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#parameters-2)

| Name     | Type    | Description   |
| -------- | ------- | ------------- |
| `value`  | uint256 | Value to test |
| `target` | address |               |
| `data`   | bytes   |               |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#return-values-2)

| Name     | Type | Description                                                                |
| -------- | ---- | -------------------------------------------------------------------------- |
| `Result` | bool | True if call to target returns the same value as `value`. Otherwise, false |

### lt[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#lt) <a href="#lt" id="lt"></a>

```javascript
function lt(
  uint256 value,
  address target,
  bytes data
) external returns (bool)
```

Calls target with specified data and tests if it's lower than value

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#parameters-3)

| Name     | Type    | Description   |
| -------- | ------- | ------------- |
| `value`  | uint256 | Value to test |
| `target` | address |               |
| `data`   | bytes   |               |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#return-values-3)

| Name     | Type | Description                                                                        |
| -------- | ---- | ---------------------------------------------------------------------------------- |
| `Result` | bool | True if call to target returns value which is lower than `value`. Otherwise, false |

### gt[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#gt) <a href="#gt" id="gt"></a>

```javascript
function gt(
  uint256 value,
  address target,
  bytes data
) external returns (bool)
```

Calls target with specified data and tests if it's bigger than value

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#parameters-4)

| Name     | Type    | Description   |
| -------- | ------- | ------------- |
| `value`  | uint256 | Value to test |
| `target` | address |               |
| `data`   | bytes   |               |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#return-values-4)

| Name     | Type | Description                                                                         |
| -------- | ---- | ----------------------------------------------------------------------------------- |
| `Result` | bool | True if call to target returns value which is bigger than `value`. Otherwise, false |

### timestampBelow[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#timestampbelow) <a href="#timestampbelow" id="timestampbelow"></a>

```javascript
function timestampBelow(
  uint256 time
) external returns (bool)
```

Checks passed time against block timestamp

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#parameters-5)

| Name   | Type    | Description |
| ------ | ------- | ----------- |
| `time` | uint256 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/PredicateHelper#return-values-5)

| Name     | Type | Description                                                            |
| -------- | ---- | ---------------------------------------------------------------------- |
| `Result` | bool | True if current block timestamp is lower than `time`. Otherwise, false |


# SeriesNonceManager

A helper contract to manage nonce with the series

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#functions) <a href="#functions" id="functions"></a>

### increaseNonce[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#increasenonce) <a href="#increasenonce" id="increasenonce"></a>

```javascript
function increaseNonce(
  uint8 series
) external
```

Advances nonce by one

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#parameters)

| Name     | Type  | Description |
| -------- | ----- | ----------- |
| `series` | uint8 |             |

### advanceNonce[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#advancenonce) <a href="#advancenonce" id="advancenonce"></a>

```javascript
function advanceNonce(
  uint8 series,
  uint8 amount
) public
```

Advances nonce by specified amount

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#parameters-1)

| Name     | Type  | Description |
| -------- | ----- | ----------- |
| `series` | uint8 |             |
| `amount` | uint8 |             |

### nonceEquals[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#nonceequals) <a href="#nonceequals" id="nonceequals"></a>

```javascript
function nonceEquals(
  uint8 series,
  address makerAddress,
  uint256 makerNonce
) external returns (bool)
```

Checks if `makerAddress` has specified `makerNonce` for `series`

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#parameters-2)

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `series`       | uint8   |             |
| `makerAddress` | address |             |
| `makerNonce`   | uint256 |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#return-values)

| Name     | Type | Description                                                  |
| -------- | ---- | ------------------------------------------------------------ |
| `Result` | bool | True if `makerAddress` has specified nonce. Otherwise, false |

## Events[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#events) <a href="#events" id="events"></a>

### NonceIncreased[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#nonceincreased) <a href="#nonceincreased" id="nonceincreased"></a>

```javascript
event NonceIncreased(
  address maker,
  uint8 series,
  uint256 newNonce
)
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/SeriesNonceManager#parameters-3)

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `maker`    | address |             |
| `series`   | uint8   |             |
| `newNonce` | uint256 |             |


# WethUnwrapper

## Derives[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/WethUnwrapper#derives) <a href="#derives" id="derives"></a>

* [PostInteraction](#postinteraction)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/WethUnwrapper#functions) <a href="#functions" id="functions"></a>

### receive[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/WethUnwrapper#receive) <a href="#receive" id="receive"></a>

```javascript
function receive(
) external
```

### postInteraction[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/WethUnwrapper#postinteraction) <a href="#postinteraction" id="postinteraction"></a>

```javascript
function postInteraction(
  address ,
  address ,
  address takerAsset,
  uint256 ,
  uint256 takingAmount,
  bytes interactiveData
) external
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/WethUnwrapper#parameters)

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| \`\`              | address |             |
| \`\`              | address |             |
| `takerAsset`      | address |             |
| \`\`              | uint256 |             |
| `takingAmount`    | uint256 |             |
| `interactiveData` | bytes   |             |


# Interfaces


# IDaiLikePermit

Interface for DAI-style permits

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/IDaiLikePermit#functions) <a href="#functions" id="functions"></a>

### permit[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/IDaiLikePermit#permit) <a href="#permit" id="permit"></a>

```
function permit(
  address holder,
  address spender,
  uint256 nonce,
  uint256 expiry,
  bool allowed,
  uint8 v,
  bytes32 r,
  bytes32 s
) external
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/IDaiLikePermit#parameters)

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `holder`  | address |             |
| `spender` | address |             |
| `nonce`   | uint256 |             |
| `expiry`  | uint256 |             |
| `allowed` | bool    |             |
| `v`       | uint8   |             |
| `r`       | bytes32 |             |
| `s`       | bytes32 |             |


# IWithdrawable

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/IWithdrawable#functions) <a href="#functions" id="functions"></a>

### withdraw[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/IWithdrawable#withdraw) <a href="#withdraw" id="withdraw"></a>

```javascript
function withdraw(
  uint256 wad
) external
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/IWithdrawable#parameters)

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| `wad` | uint256 |             |


# Interaction

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/InteractionNotificationReceiver#functions) <a href="#functions" id="functions"></a>

### fillOrderInteraction[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/InteractionNotificationReceiver#fillorderinteraction) <a href="#fillorderinteraction" id="fillorderinteraction"></a>

```javascript
function fillOrderInteraction(
  address taker,
  address makerAsset,
  address takerAsset,
  uint256 makingAmount,
  uint256 takingAmount,
  bytes interactiveData
) external
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/InteractionNotificationReceiver#parameters)

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `taker`           | address |             |
| `makerAsset`      | address |             |
| `takerAsset`      | address |             |
| `makingAmount`    | uint256 |             |
| `takingAmount`    | uint256 |             |
| `interactiveData` | bytes   |             |


# PostInteraction

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/PostInteractionNotificationReceiver#functions) <a href="#functions" id="functions"></a>

### postInteraction[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/PostInteractionNotificationReceiver#postinteraction-1) <a href="#postinteraction-1" id="postinteraction-1"></a>

```javascript
function postInteraction(
  address taker,
  address makerAsset,
  address takerAsset,
  uint256 makingAmount,
  uint256 takingAmount,
  bytes interactiveData
) external
```

Callback method that gets called after taker transferred funds to maker but before the opposite transfer happened

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/PostInteractionNotificationReceiver#parameters)

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `taker`           | address |             |
| `makerAsset`      | address |             |
| `takerAsset`      | address |             |
| `makingAmount`    | uint256 |             |
| `takingAmount`    | uint256 |             |
| `interactiveData` | bytes   |             |


# PreInteraction

Interface for interactor which acts between `maker => taker` and `taker => maker` transfers.

### Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/PreInteractionNotificationReceiver#functions) <a href="#functions" id="functions"></a>

#### preInteraction[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/PreInteractionNotificationReceiver#preinteraction-1) <a href="#preinteraction-1" id="preinteraction-1"></a>

```javascript
function preInteraction(
  address taker,
  address makerAsset,
  address takerAsset,
  uint256 makingAmount,
  uint256 takingAmount,
  bytes interactiveData
) external
```

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/interfaces/PreInteractionNotificationReceiver#parameters)

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `taker`           | address |             |
| `makerAsset`      | address |             |
| `takerAsset`      | address |             |
| `makingAmount`    | uint256 |             |
| `takingAmount`    | uint256 |             |
| `interactiveData` | bytes   |             |


# Liquidity Source and API


# Ethereum Network

## VulpeFI Orderbook API v3.0 OAS3

<https://limit-orders.vulpefi.com/swagger/ethereum-json>

### Ethereum Network

API for post and select limit orders to the VulpeFI limit orders database.\
The database acts as a source of liquidity for the VulpeFI Aggregation Protocol.\
\
Read more in the offical documentation[ limit-order-protocol-utils](/aggregation-protocol/smart-contracts/limitorderprotocol)

#### Limit Order V3 <a href="#operations-tag-limit_order_v3" id="operations-tag-limit_order_v3"></a>

{% openapi src="<https://limit-orders.1inch.io/swagger/ethereum-json>" path="/v3.0/1" method="post" %}
<https://limit-orders.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/ethereum-json>" path="/v3.0/1/address/{address}" method="get" %}
<https://limit-orders.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/ethereum-json>" path="/v3.0/1/all" method="get" %}
<https://limit-orders.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/ethereum-json>" path="/v3.0/1/count" method="get" %}
<https://limit-orders.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/ethereum-json>" path="/v3.0/1/events/{orderHash}" method="get" %}
<https://limit-orders.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/ethereum-json>" path="/v3.0/1/events" method="get" %}
<https://limit-orders.1inch.io/swagger/ethereum-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/ethereum-json>" path="/v3.0/1/has-active-orders-with-permit/{walletAddress}/{token}" method="get" %}
<https://limit-orders.1inch.io/swagger/ethereum-json>
{% endopenapi %}


# Binance Smart Chain

## VulpeFI Orderbook API v3.0

<https://limit-orders.vulpefi.com/swagger/binance-json>

### Binance Smart Chain Network

API for post and select limit orders to the VulpeFI limit orders database.\
The database acts as a source of liquidity for the VulpeFI Aggregation Protocol.\
\
Read more in the offical documentation[ limit-order-protocol-utils](/aggregation-protocol/smart-contracts/limitorderprotocol)

{% openapi src="<https://limit-orders.1inch.io/swagger/binance-json>" path="/v3.0/56" method="post" %}
<https://limit-orders.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/binance-json>" path="/v3.0/56/address/{address}" method="get" %}
<https://limit-orders.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/binance-json>" path="/v3.0/56/all" method="get" %}
<https://limit-orders.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/binance-json>" path="/v3.0/56/count" method="get" %}
<https://limit-orders.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/binance-json>" path="/v3.0/56/events/{orderHash}" method="get" %}
<https://limit-orders.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/binance-json>" path="/v3.0/56/events" method="get" %}
<https://limit-orders.1inch.io/swagger/binance-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/binance-json>" path="/v3.0/56/has-active-orders-with-permit/{walletAddress}/{token}" method="get" %}
<https://limit-orders.1inch.io/swagger/binance-json>
{% endopenapi %}


# Polygon

## VulpeFI Orderbook API v3.0&#x20;

<https://limit-orders.vulpefi.com/swagger/polygon-json>

### Polygon Network

API for post and select limit orders to the VulpeFI limit orders database.\
The database acts as a source of liquidity for the VulpeFI Aggregation Protocol.\
\
Read more in the offical documentation[ limit-order-protocol-utils](/aggregation-protocol/smart-contracts/limitorderprotocol)

#### Limit Order V3 <a href="#operations-tag-limit_order_v3" id="operations-tag-limit_order_v3"></a>

{% hint style="danger" %}
**Under development**
{% endhint %}


# Avalanche

## VulpeFI Orderbook API v3.0&#x20;

<https://limit-orders.vulpefi.com/swagger/avalanche-json>

### Avalanche

API for post and select limit orders to the VulpeFI limit orders database.\
The database acts as a source of liquidity for the VulpeFI Aggregation Protocol.\
\
Read more in the offical documentation[ limit-order-protocol-utils](/aggregation-protocol/smart-contracts/limitorderprotocol)

{% openapi src="<https://limit-orders.1inch.io/swagger/avalanche-json>" path="/v3.0/43114" method="post" %}
<https://limit-orders.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/avalanche-json>" path="/v3.0/43114/address/{address}" method="get" %}
<https://limit-orders.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/avalanche-json>" path="/v3.0/43114/all" method="get" %}
<https://limit-orders.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/avalanche-json>" path="/v3.0/43114/count" method="get" %}
<https://limit-orders.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/avalanche-json>" path="/v3.0/43114/events/{orderHash}" method="get" %}
<https://limit-orders.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/avalanche-json>" path="/v3.0/43114/events" method="get" %}
<https://limit-orders.1inch.io/swagger/avalanche-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/avalanche-json>" path="/v3.0/43114/has-active-orders-with-permit/{walletAddress}/{token}" method="get" %}
<https://limit-orders.1inch.io/swagger/avalanche-json>
{% endopenapi %}


# Gnosis Chain

## VulpeFI Orderbook API v3.0&#x20;

<https://limit-orders.vulpefi.com/swagger/gnosis-json>

### Gnosis

API for post and select limit orders to the VulpeFI limit orders database.\
The database acts as a source of liquidity for the VulpeFI Aggregation Protocol.\
\
Read more in the offical documentation[ limit-order-protocol-utils](/aggregation-protocol/smart-contracts/limitorderprotocol)

{% openapi src="<https://limit-orders.1inch.io/swagger/gnosis-json>" path="/v3.0/100" method="post" %}
<https://limit-orders.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/gnosis-json>" path="/v3.0/100/address/{address}" method="get" %}
<https://limit-orders.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/gnosis-json>" path="/v3.0/100/all" method="get" %}
<https://limit-orders.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/gnosis-json>" path="/v3.0/100/count" method="get" %}
<https://limit-orders.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/gnosis-json>" path="/v3.0/100/events/{orderHash}" method="get" %}
<https://limit-orders.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/gnosis-json>" path="/v3.0/100/events" method="get" %}
<https://limit-orders.1inch.io/swagger/gnosis-json>
{% endopenapi %}

{% openapi src="<https://limit-orders.1inch.io/swagger/gnosis-json>" path="/v3.0/100/has-active-orders-with-permit/{walletAddress}/{token}" method="get" %}
<https://limit-orders.1inch.io/swagger/gnosis-json>
{% endopenapi %}


# Spot Price aggregator


# Examples

## Single token-to-ETH price usage[​](https://docs.1inch.io/docs/spot-price-aggregator/examples#single-token-to-eth-price-usage) <a href="#single-token-to-eth-price-usage" id="single-token-to-eth-price-usage"></a>

```javascript
const Web3 = require('web3');
const { BigNumber } = require('ethers');

const yourInfuraKey = 'add your key here';
const web3 = new Web3(`https://mainnet.infura.io/v3/${yourInfuraKey}`);

// eslint-disable-next-line max-len
const OffChainOracleAbi = '[{"inputs":[{"internalType":"contract MultiWrapper","name":"_multiWrapper","type":"address"},{"internalType":"contract IOracle[]","name":"existingOracles","type":"address[]"},{"internalType":"enum OffchainOracle.OracleType[]","name":"oracleTypes","type":"uint8[]"},{"internalType":"contract IERC20[]","name":"existingConnectors","type":"address[]"},{"internalType":"contract IERC20","name":"wBase","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"ConnectorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"ConnectorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract MultiWrapper","name":"multiWrapper","type":"address"}],"name":"MultiWrapperUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IOracle","name":"oracle","type":"address"},{"indexed":false,"internalType":"enum OffchainOracle.OracleType","name":"oracleType","type":"uint8"}],"name":"OracleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IOracle","name":"oracle","type":"address"},{"indexed":false,"internalType":"enum OffchainOracle.OracleType","name":"oracleType","type":"uint8"}],"name":"OracleRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"addConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOracle","name":"oracle","type":"address"},{"internalType":"enum OffchainOracle.OracleType","name":"oracleKind","type":"uint8"}],"name":"addOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"connectors","outputs":[{"internalType":"contract IERC20[]","name":"allConnectors","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"srcToken","type":"address"},{"internalType":"contract IERC20","name":"dstToken","type":"address"},{"internalType":"bool","name":"useWrappers","type":"bool"}],"name":"getRate","outputs":[{"internalType":"uint256","name":"weightedRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"srcToken","type":"address"},{"internalType":"bool","name":"useSrcWrappers","type":"bool"}],"name":"getRateToEth","outputs":[{"internalType":"uint256","name":"weightedRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multiWrapper","outputs":[{"internalType":"contract MultiWrapper","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracles","outputs":[{"internalType":"contract IOracle[]","name":"allOracles","type":"address[]"},{"internalType":"enum OffchainOracle.OracleType[]","name":"oracleTypes","type":"uint8[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"removeConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOracle","name":"oracle","type":"address"},{"internalType":"enum OffchainOracle.OracleType","name":"oracleKind","type":"uint8"}],"name":"removeOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract MultiWrapper","name":"_multiWrapper","type":"address"}],"name":"setMultiWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]';
const offChainOracleAddress = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb';
const offChainOracleContract = new web3.eth.Contract(JSON.parse(OffChainOracleAbi), offChainOracleAddress);

const token = {
    address: '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT
    decimals: 6,
};

offChainOracleContract.methods.getRateToEth(
    token.address, // source token
    true, // use source wrappers
).call()
    .then((rate) => {
        const numerator = BigNumber.from(10).pow(token.decimals);
        const denominator = BigNumber.from(10).pow(18); // eth decimals
        const price = BigNumber.from(rate).mul(numerator).div(denominator);
        console.log(price.toString()); // 472685293218315
    })
    .catch(console.log);
```

## Multiple token-to-ETH prices usage[​](https://docs.1inch.io/docs/spot-price-aggregator/examples#multiple-token-to-eth-prices-usage) <a href="#multiple-token-to-eth-prices-usage" id="multiple-token-to-eth-prices-usage"></a>

```javascript
const Web3 = require('web3');
const { BigNumber } = require('ethers');

const yourInfuraKey = 'add your key here';
const web3 = new Web3(`https://mainnet.infura.io/v3/${yourInfuraKey}`);

// eslint-disable-next-line max-len
const MultiCallAbi = '[{"inputs":[{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct MultiCall.Call[]","name":"calls","type":"tuple[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"},{"internalType":"bool[]","name":"success","type":"bool[]"}],"stateMutability":"view","type":"function"}]';
// eslint-disable-next-line max-len
const OffChainOracleAbi = '[{"inputs":[{"internalType":"contract MultiWrapper","name":"_multiWrapper","type":"address"},{"internalType":"contract IOracle[]","name":"existingOracles","type":"address[]"},{"internalType":"enum OffchainOracle.OracleType[]","name":"oracleTypes","type":"uint8[]"},{"internalType":"contract IERC20[]","name":"existingConnectors","type":"address[]"},{"internalType":"contract IERC20","name":"wBase","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"ConnectorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"ConnectorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract MultiWrapper","name":"multiWrapper","type":"address"}],"name":"MultiWrapperUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IOracle","name":"oracle","type":"address"},{"indexed":false,"internalType":"enum OffchainOracle.OracleType","name":"oracleType","type":"uint8"}],"name":"OracleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IOracle","name":"oracle","type":"address"},{"indexed":false,"internalType":"enum OffchainOracle.OracleType","name":"oracleType","type":"uint8"}],"name":"OracleRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"addConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOracle","name":"oracle","type":"address"},{"internalType":"enum OffchainOracle.OracleType","name":"oracleKind","type":"uint8"}],"name":"addOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"connectors","outputs":[{"internalType":"contract IERC20[]","name":"allConnectors","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"srcToken","type":"address"},{"internalType":"contract IERC20","name":"dstToken","type":"address"},{"internalType":"bool","name":"useWrappers","type":"bool"}],"name":"getRate","outputs":[{"internalType":"uint256","name":"weightedRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"srcToken","type":"address"},{"internalType":"bool","name":"useSrcWrappers","type":"bool"}],"name":"getRateToEth","outputs":[{"internalType":"uint256","name":"weightedRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multiWrapper","outputs":[{"internalType":"contract MultiWrapper","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracles","outputs":[{"internalType":"contract IOracle[]","name":"allOracles","type":"address[]"},{"internalType":"enum OffchainOracle.OracleType[]","name":"oracleTypes","type":"uint8[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"connector","type":"address"}],"name":"removeConnector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOracle","name":"oracle","type":"address"},{"internalType":"enum OffchainOracle.OracleType","name":"oracleKind","type":"uint8"}],"name":"removeOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract MultiWrapper","name":"_multiWrapper","type":"address"}],"name":"setMultiWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]';

const offChainOracleAddress = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb';

const multiCallContract = new web3.eth.Contract(JSON.parse(MultiCallAbi), '0xda3c19c6fe954576707fa24695efb830d9cca1ca');
const offChainOracleContract = new web3.eth.Contract(JSON.parse(OffChainOracleAbi));

const tokens = [
    {
        address: '0x6b175474e89094c44da98b954eedeac495271d0f', // DAI
        decimals: 18,
    },
    {
        address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC
        decimals: 6,
    },
    {
        address: '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT
        decimals: 6,
    }, {
        address: '0x111111111117dc0aa78b770fa6a738034120c302', // VULPE
        decimals: 18,
    },
];

const callData = tokens.map((token) => ({
    to: offChainOracleAddress,
    data: offChainOracleContract.methods.getRateToEth(
        token.address,
        true, // use wrapper
    ).encodeABI(),
}));

multiCallContract.methods.multicall(callData).call()
    .then(({
        results,
        success,
    }) => {
        const prices = {};
        for (let i = 0; i < results.length; i++) {
            if (!success[i]) {
                continue;
            }

            const decodedRate = web3.eth.abi.decodeParameter('uint256', results[i]).toString();
            const numerator = BigNumber.from(10).pow(tokens[i].decimals);
            const denominator = BigNumber.from(10).pow(18); // eth decimals
            const price = BigNumber.from(decodedRate).mul(numerator).div(denominator);
            prices[tokens[i].address] = price.toString();
        }
        console.log(prices);
        /*
            {
                '0x6b175474e89094c44da98b954eedeac495271d0f': '527560209915550',
                '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': '507746821617073',
                '0xdac17f958d2ee523a2206206994597c13d831ec7': '529527134930000',
                '0x111111111117dc0aa78b770fa6a738034120c302': '1048752594621361'
            }
         */
    })
    .catch(console.log);
```


# Spot Price Aggregator

![Build Status](https://github.com/1inch/spot-price-aggregator/actions/workflows/test.yml/badge.svg) [![Coverage Status](https://codecov.io/gh/1inch/spot-price-aggregator/branch/master/graph/badge.svg?token=6V7609YJ1Q)](https://codecov.io/gh/1inch/spot-price-aggregator)

The 1inch spot price aggregator is a set of smart contracts that extract price data for tokens traded on DEXes from the blockchain. To avoid price manipulations within a transaction, the spot price aggregator should ONLY be used off-chain. DO NOT use it on-chain. For off-chain usage see [Examples](https://docs.1inch.io/docs/spot-price-aggregator/introduction#examples) section below.

## Wrappers[​](https://docs.1inch.io/docs/spot-price-aggregator/introduction#wrappers) <a href="#wrappers" id="wrappers"></a>

To handle wrapped tokens, such as wETH, cDAI, aDAI etc., the 1inch spot price aggregator uses custom wrapper smart contracts that wrap/unwrap tokens at the current wrapping exchange rate.

## Connectors[​](https://docs.1inch.io/docs/spot-price-aggregator/introduction#connectors) <a href="#connectors" id="connectors"></a>

If no direct liquidity pair exists between two tokens, the spot price aggregator calculates rates for those coins using another token that has pairs with both of them – a connector token.

## Supported Deployments <a href="#supported-deployments" id="supported-deployments"></a>

### Ethereum Mainnet[​](https://docs.1inch.io/docs/spot-price-aggregator/introduction#ethereum-mainnet) <a href="#ethereum-mainnet" id="ethereum-mainnet"></a>

**Oracle** `0x...xxx example`

<details>

<summary>Supported DEXes</summary>

* Chainlink - [0x8606321723D9cA7db708A8b12DAd0A8a83f2F3bD](https://etherscan.io/address/0x8606321723D9cA7db708A8b12DAd0A8a83f2F3bD)
* KyberDMM - [0xE2d0e58302d03F703BD3c5EC2899F4e1af65E18c](https://etherscan.io/address/0xE2d0e58302d03F703BD3c5EC2899F4e1af65E18c)
* Mooniswap - [0x5F6a6428756CfAF96584286Ef9f7411621196f3A](https://etherscan.io/address/0x5F6a6428756CfAF96584286Ef9f7411621196f3A)
* Synthetix - [0xb7EF687B322910f3315F91f9F4B9b4B77219ddb4](https://etherscan.io/address/0xb7EF687B322910f3315F91f9F4B9b4B77219ddb4)
* Uniswap - [0xAdF7CC69626eB6F03F4F613832C84Cf62586A6Bb](https://etherscan.io/address/0xAdF7CC69626eB6F03F4F613832C84Cf62586A6Bb)
* Equalizer - [0xEBA383DA9FCe0Ea0acB59A185A73D48dC089c73F](https://etherscan.io/address/0xEBA383DA9FCe0Ea0acB59A185A73D48dC089c73F)
* ShibaSwap - [0x0fE8bD9CB73ADC66561330B648a8fC62b4F58943](https://etherscan.io/address/0x0fE8bD9CB73ADC66561330B648a8fC62b4F58943)
* SushiSwap - [0x2A45d538f460DDBEeA3a899b0674dA3DFE318faa](https://etherscan.io/address/0x2A45d538f460DDBEeA3a899b0674dA3DFE318faa)
* UniswapV2 - [0xA21E47477DE9BbcDC962ee18a5E7D339c5a16D28](https://etherscan.io/address/0xA21E47477DE9BbcDC962ee18a5E7D339c5a16D28)
* UniswapV3 - [0xE85B42805e046D1933EB8e1C543C4da4E5e8fFa3](https://etherscan.io/address/0xE85B42805e046D1933EB8e1C543C4da4E5e8fFa3)
* Curve - [0x7eE5d607597598e9d642b264b7Ac2703b92Acf9B](https://etherscan.io/address/0x7eE5d607597598e9d642b264b7Ac2703b92Acf9B)
* Pancake 3 - [0xB4039b37d09772801a51764537c167445f52F48b](https://etherscan.io/address/0xB4039b37d09772801a51764537c167445f52F48b)
* Dodo - [0x0A7c4d89e1629f189Eb12dd716B178d1b90D9f66](https://etherscan.io/address/0x0A7c4d89e1629f189Eb12dd716B178d1b90D9f66)
* DodoV2 - [0x03aA019F3B78110e030c34e9fA98047A1f62859A](https://etherscan.io/address/0x03aA019F3B78110e030c34e9fA98047A1f62859A)

</details>

<details>

<summary>Supported wrappers</summary>

* WETH - [0x2b36053EB3BC1D68f51Bb7916D1503D1556f3ffc](https://etherscan.io/address/0x2b36053EB3BC1D68f51Bb7916D1503D1556f3ffc)
* AaveV1 - [0x8C00a411Fe8983525F82CFCe34fe4B092d9E525d](https://etherscan.io/address/0x8C00a411Fe8983525F82CFCe34fe4B092d9E525d)
* AaveV2 - [0x06cC74503B6d1eB6D4d6Bc402f48fC07b804105f](https://etherscan.io/address/0x06cC74503B6d1eB6D4d6Bc402f48fC07b804105f)
* AaveV3 - [0x0c8fc7a71C28c768FDC1f7d75835229beBEB1573](https://etherscan.io/address/0x0c8fc7a71C28c768FDC1f7d75835229beBEB1573)
* Compound - [0x7C327E1Ee66d4cF7F4053387241351FDc95A0c04](https://etherscan.io/address/0x7C327E1Ee66d4cF7F4053387241351FDc95A0c04)
* YVault - [0x9FF110f132d988bfa9bC6a21851Da1aF3aC6EaF8](https://etherscan.io/address/0x9FF110f132d988bfa9bC6a21851Da1aF3aC6EaF8)
* stETH - [0x26daCf7E879b18FE658326ddD3ABC0D6910B3E9F](https://etherscan.io/address/0x26daCf7E879b18FE658326ddD3ABC0D6910B3E9F)
* wstETH - [0x37eB78fE793E89353e46AEe73E299985C3B8d334](https://etherscan.io/address/0x37eB78fE793E89353e46AEe73E299985C3B8d334)
* sDAI - [0xF07317368A4B061dadB8C8239cbfCfd4808B76ce](https://etherscan.io/address/0xF07317368A4B061dadB8C8239cbfCfd4808B76ce)
* CHAI - [0x6fE4926a0fCc78ab764b39f2738e1Dea145d7AC0](https://etherscan.io/address/0x6fE4926a0fCc78ab764b39f2738e1Dea145d7AC0)

</details>

<details>

<summary>Supported connectors</summary>

* ETH - [0x0000000000000000000000000000000000000000](https://etherscan.io/address/0x0000000000000000000000000000000000000000)
* WETH - [0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2](https://etherscan.io/address/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)
* USDC - [0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48](https://etherscan.io/address/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)
* DAI - [0x6B175474E89094C44Da98b954EedeAC495271d0F](https://etherscan.io/address/0x6B175474E89094C44Da98b954EedeAC495271d0F)
* USDT - [0xdAC17F958D2ee523a2206206994597C13D831ec7](https://etherscan.io/address/0xdAC17F958D2ee523a2206206994597C13D831ec7)
* NONE - [0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF](https://etherscan.io/address/0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF)
* WBTC - [0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599](https://etherscan.io/address/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599)
* 3CRV - [0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490](https://etherscan.io/address/0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490)

</details>

<details>

<summary>Prev oracle versions (legacy)</summary>

* May-28-2021 - [0x07D91f5fb9Bf7798734C3f606dB065549F6893bb](https://etherscan.io/address/0x07D91f5fb9Bf7798734C3f606dB065549F6893bb)
* Apr-07-2023 - [0x3E1Fe1Bd5a5560972bFa2D393b9aC18aF279fF56](https://etherscan.io/address/0x3E1Fe1Bd5a5560972bFa2D393b9aC18aF279fF56)
* Jul-13-2023 - [0x52cbE0f49CcdD4Dc6E9C13BAb024EABD2842045B](https://etherscan.io/address/0x52cbE0f49CcdD4Dc6E9C13BAb024EABD2842045B)

</details>

### Binance Smart Chain[​](https://docs.1inch.io/docs/spot-price-aggregator/introduction#ethereum-mainnet) <a href="#ethereum-mainnet" id="ethereum-mainnet"></a>

**Oracle** `0x...xxx example`

<details>

<summary>Supported DEXes</summary>

* ApeSwap - [0xeD55d76Bb48E042a177d1E21AffBe1B72d0c7dB0](https://bscscan.com/address/0xeD55d76Bb48E042a177d1E21AffBe1B72d0c7dB0)
* BakerySwap - [0x82b6B75F5fEabbfD370D45daCEFae3D5c06099DA](https://bscscan.com/address/0x82b6B75F5fEabbfD370D45daCEFae3D5c06099DA)
* BSCswap - [0xD4eFb5998DFBDFB791182fb610D0061136E9DB50](https://bscscan.com/address/0xD4eFb5998DFBDFB791182fb610D0061136E9DB50)
* Demax - [0x7bdc6954e1c7869B4147A320d589689F628E9921](https://bscscan.com/address/0x7bdc6954e1c7869B4147A320d589689F628E9921)
* KyberDMM - [0xE2d0e58302d03F703BD3c5EC2899F4e1af65E18c](https://bscscan.com/address/0xE2d0e58302d03F703BD3c5EC2899F4e1af65E18c)
* Mooniswap - [0x5F6a6428756CfAF96584286Ef9f7411621196f3A](https://bscscan.com/address/0x5F6a6428756CfAF96584286Ef9f7411621196f3A)
* Pancake 1 - [0x1b947aF8b3dd6aa96F8726cd92c894D0Ba6367a3](https://bscscan.com/address/0x1b947aF8b3dd6aa96F8726cd92c894D0Ba6367a3)
* Pancake 2 - [0xB9fa95a38D50c5Bad1eA2b4E85e106Fe886cCb3A](https://bscscan.com/address/0xB9fa95a38D50c5Bad1eA2b4E85e106Fe886cCb3A)
* Pancake 3 - [0xB4039b37d09772801a51764537c167445f52F48b](https://bscscan.com/address/0xB4039b37d09772801a51764537c167445f52F48b)
* Thugswap - [0x7bBc0156c31A19097eEd6B636AA2F4AB8A31BFD9](https://bscscan.com/address/0x7bBc0156c31A19097eEd6B636AA2F4AB8A31BFD9)

</details>

<details>

<summary>Supported wrappers</summary>

* Venus - [0x11DEE30E710B8d4a8630392781Cc3c0046365d4c](https://bscscan.com/address/0x11DEE30E710B8d4a8630392781Cc3c0046365d4c)
* WBNB - [0x54431918cec22932fcf97e54769f4e00f646690f](https://bscscan.com/address/0x54431918cec22932fcf97e54769f4e00f646690f)

</details>

<details>

<summary>Supported connectors</summary>

* NONE - [0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF](https://bscscan.com/address/0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF)
* WBNB - [0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c](https://bscscan.com/address/0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c)
* DAI - [0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3](https://bscscan.com/address/0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3)
* ETH - [0x2170Ed0880ac9A755fd29B2688956BD959F933F8](https://bscscan.com/address/0x2170Ed0880ac9A755fd29B2688956BD959F933F8)
* USDC - [0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d](https://bscscan.com/address/0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d)
* BSC-USD - [0x55d398326f99059fF775485246999027B3197955](https://bscscan.com/address/0x55d398326f99059fF775485246999027B3197955)
* BUSD - [0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56](https://bscscan.com/address/0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56)
* VULPEFI - [0x111111111117dC0aa78b770fA6A738034120C302](https://bscscan.com/address/0x111111111117dC0aa78b770fA6A738034120C302)

</details>

<details>

<summary>Prev oracle versions (legacy)</summary>

* May-28-2021 - [0xfbD61B037C325b959c0F6A7e69D8f37770C2c550](https://bscscan.com/address/0xfbD61B037C325b959c0F6A7e69D8f37770C2c550)
* Apr-06-2023 - [0x27950ecAeBB4462e18e8041AAF6Ea13cA47Af001](https://bscscan.com/address/0x27950ecAeBB4462e18e8041AAF6Ea13cA47Af001)
* Jul-13-2023 - [0x52cbE0f49CcdD4Dc6E9C13BAb024EABD2842045B](https://bscscan.com/address/0x52cbE0f49CcdD4Dc6E9C13BAb024EABD2842045B)

</details>

### Polygon (Matic)[​](https://docs.1inch.io/docs/spot-price-aggregator/introduction#ethereum-mainnet) <a href="#ethereum-mainnet" id="ethereum-mainnet"></a>

**Oracle** `0x...xxx example`

<details>

<summary>Supported DEXes</summary>

* QuickSwap - [0xeec05e0D8F7D3f56CECE2026Feaf41b09B423790](https://polygonscan.com/address/0xeec05e0D8F7D3f56CECE2026Feaf41b09B423790)
* ComethSwap - [0x11BFd590f592457b65Eb85327F5938141f61878a](https://polygonscan.com/address/0x11BFd590f592457b65Eb85327F5938141f61878a)
* DFYN - [0xeD55d76Bb48E042a177d1E21AffBe1B72d0c7dB0](https://polygonscan.com/address/0xeD55d76Bb48E042a177d1E21AffBe1B72d0c7dB0)
* SushiSwap - [0x2A45d538f460DDBEeA3a899b0674dA3DFE318faa](https://polygonscan.com/address/0x2A45d538f460DDBEeA3a899b0674dA3DFE318faa)
* UniswapV3 - [0xE85B42805e046D1933EB8e1C543C4da4E5e8fFa3](https://polygonscan.com/address/0xE85B42805e046D1933EB8e1C543C4da4E5e8fFa3)

</details>

<details>

<summary>Supported wrappers</summary>

* WMATIC - [0xA0446D8804611944F1B527eCD37d7dcbE442caba](https://polygonscan.com/address/0xA0446D8804611944F1B527eCD37d7dcbE442caba)
* AaveV2 - [0x138CE40d675F9a23E4D6127A8600308Cf7A93381](https://polygonscan.com/address/0x138CE40d675F9a23E4D6127A8600308Cf7A93381)
* AaveV3 - [0x0c8fc7a71C28c768FDC1f7d75835229beBEB1573](https://polygonscan.com/address/0x0c8fc7a71C28c768FDC1f7d75835229beBEB1573)

</details>

<details>

<summary>Supported connectors</summary>

* MATIC - [0x0000000000000000000000000000000000000000](https://polygonscan.com/address/0x0000000000000000000000000000000000000000)
* NONE - [0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF](https://polygonscan.com/address/0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF)
* WMATIC - [0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270](https://polygonscan.com/address/0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270)
* USDC - [0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174](https://polygonscan.com/address/0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174)
* WETH - [0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619](https://polygonscan.com/address/0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619)

</details>

<details>

<summary>Prev oracle versions (legacy)</summary>

* May-28-2021 - [0x7F069df72b7A39bCE9806e3AfaF579E54D8CF2b9](https://polygonscan.com/address/0x7F069df72b7A39bCE9806e3AfaF579E54D8CF2b9)
* Apr-05-2023 - [0xf023D71EfB08339EA28F0C186AE130c74D44C58c](https://polygonscan.com/address/0xf023D71EfB08339EA28F0C186AE130c74D44C58c)
* Jul-13-2023 - [0x52cbE0f49CcdD4Dc6E9C13BAb024EABD2842045B](https://polygonscan.com/address/0x52cbE0f49CcdD4Dc6E9C13BAb024EABD2842045B)

</details>


