# Introduction

Project Overview

YetAnotherDeFi, or YAD, is a multichain swap router that aggregates liquidity across all dominant blockchains from all leading DeFi liquidity providers. YAD allows swapping 3,500 tokens over seven blockchains at the best rate with the lowest transaction cost.

Our decentralized, non-custodial, and censorship-resistant swap technology gives you the freedom to swap and send your money whenever and wherever you want, with no borders and no KYC limits.

We’ve developed a gas-optimized smart contract so that you can save your money on transaction fees. Our goal is to provide the widest choice of assets for you to maximize your benefits from every swap.


# Key features

## What problems does YAD solve?

* **Market diversity**\
  There are 300+ DEXs across seven different blockchains operating in DeFi market, each offering different rates and liquidity models. Traders need to constantly monitor and compare multiple DEXs to find the best rate.
* **Fragmented liquidity**\
  Swaps with high volumes or exotic token swaps require deep liquidity, otherwise the swap will cause significant price impact and reduce the outcome. Traders can not use all liquidity locked in the blockchain because it is fragmented across many different pools.
* **High network fees**\
  For small orders, transaction execution fees can significantly reduce the final amount the user receives. Traders need to weigh both the network gas fees and rate differences when comparing various DEXs.

## How does YAD solve these problems?

* **Market aggregation** \
  YAD collects live rates across all available markets, plus YAD uses RFQ mechanics to propose the best rate for the desired trading pair.
* **Order splitting**\
  Large orders can be split up among liquidity pools to reduce their price impact, ensuring the trader a better execution rate.
* **Order routing**\
  YAD aggregates DeFi liquidity pools with different market models and depths in order to find the optimal order route with the best possible execution rate. When the overall market depth for the desired swap pair is low, this route can traverse several pools to provide higher liquidity.
* **Gas-optimized smart contracts**\
  YAD has developed innovative gas-optimized smart contracts so traders can save money on transaction fees.
* **Slippage protection**\
  Users trading on YAD are able to set their own maximum acceptable slippage, known as slippage tolerance. If the execution rate exceeds this set limit, the trade will be reverted.

## Supported chains, tokens and wallets

### Chains

Here's the list of blockchain networks that YAD supports:

<img src="/files/yUCxODq9KE1n3KExKWJC" alt="" data-size="line"> Ethereum

<img src="/files/eCdvVoP6wSAChnujk8aG" alt="" data-size="line"> BSC

<img src="/files/B2F3GEOOQMJ1oF1mMeXp" alt="" data-size="line"> Avalanche

<img src="/files/rXb4qQEp3mHjXWGBiBr6" alt="" data-size="line"> Polygon

<img src="/files/Wmqdp9bHRkxdSAUXTvL0" alt="" data-size="line"> Fantom

<img src="/files/8LfyRrKOc7jLX04KS9qB" alt="" data-size="line"> Optimism

<img src="/files/c0WV8lAJhjwqPNCO4pxX" alt="" data-size="line"> Arbitrum

### Wallets

<img src="/files/17Qv6YxKahwos4siY2qM" alt="" data-size="line"> [Metamask](https://metamask.io/download/)

<img src="/files/3QB40qL8Q5NCp5mwhbQ3" alt="" data-size="line"> [WalletConnect](https://walletconnect.com/)

<img src="/files/vz33SL2VfHKvdtxM92x7" alt="" data-size="line"> [Coinbase Wallet](https://www.coinbase.com/wallet/articles/getting-started-extension)

<img src="/files/EOaXKUIzSqZgWMmNvA6n" alt="" data-size="line"> [Binance Wallet](https://www.bnbchain.org/en/binance-wallet)

![](/files/43NJGtr1f8NHxULbohGX) [Exodus](https://www.exodus.com/)&#x20;

![](/files/Vf9kr9Za8xvM7uGjHIK2) [Trezor](https://trezor.io/trezor-suite)

![](/files/XF9p6a8iMMhvSt0YIrW5) [Noone Wallet](https://noone.io/)

### Tokens

YAD supports any token that operates on one of the blockchain networks we support.

If your token isn't visible when searching through the token list, simply click "Add token" to input its address.&#x20;


# Use cases

Example Use Cases

### Large swaps

Through the use of mechanics such as RFQ, Market Aggregation, Order splitting, and smart multipath routing YAD can easily allow you to make a large swap at the best exchange rate.

<figure><img src="/files/sVEreLxwf9skS6yDQot9" alt=""><figcaption><p>Multipath routing</p></figcaption></figure>

### Casual swaps

If you happen to need to sell your tokens or, for example, convert them to the required currency for an NFT purchase, YAD is a good option for this case too. YAD will figure out the best way for swapping to reduce any additional steps and/or costs for you.

### Buying or selling a rare token

As long as the token you want to buy belongs to a blockchain network that we support, we support that token.

Just paste the token address into the select token menu to find your token.

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


# Getting started

Embarking on your journey into the decentralized finance (DeFi) ecosystem requires setting up a few foundational components. While the world of DeFi offers unparalleled financial freedom and opportunities, it also necessitates a certain level of understanding and preparation to navigate it effectively.

Once set up, you'll need to fund it, connecting you to a vast network of trading possibilities.

The following guides are tailored to assist you at every step. From wallet creation and funding to connecting your wallet and granting the necessary permissions, we've got you covered. And when you're ready to dive deep into trading, our guide on executing swaps will ensure a seamless experience. For those who truly immerse themselves in DeFi, understanding how to monitor transactions using a blockchain explorer becomes second nature—and we'll show you just how to do that.


# Wallet creation

To operate within the DeFi landscape, such as swapping tokens on YAD, you'll first need a secure digital wallet. This wallet not only holds your assets but also acts as your unique identifier in the decentralized world.

## Supported wallets

YAD supports a bunch of popular wallets. Here's the list of wallets that we support:

<img src="/files/17Qv6YxKahwos4siY2qM" alt="" data-size="line"> [Metamask](https://metamask.io/download/)

<img src="/files/3QB40qL8Q5NCp5mwhbQ3" alt="" data-size="line"> [WalletConnect](https://walletconnect.com/)

<img src="/files/vz33SL2VfHKvdtxM92x7" alt="" data-size="line"> [Coinbase Wallet](https://www.coinbase.com/wallet/articles/getting-started-extension)

<img src="/files/EOaXKUIzSqZgWMmNvA6n" alt="" data-size="line"> [Binance Wallet](https://www.bnbchain.org/en/binance-wallet)

![](/files/43NJGtr1f8NHxULbohGX) [Exodus](https://www.exodus.com/)&#x20;

![](/files/Vf9kr9Za8xvM7uGjHIK2) [Trezor](https://trezor.io/trezor-suite)

![](/files/XF9p6a8iMMhvSt0YIrW5) [Noone Wallet](https://noone.io/)

### What is a wallet? <a href="#how_do_i_create" id="how_do_i_create"></a>

Think of your wallet as your home base in an unchartered territory:

* **Safe storage**: Just like you keep your belongings in your home, your wallet is where you store your digital assets.
* **Unique address**: Your home has an address to help others locate it; similarly, your wallet has a unique address to receive funds from your crypto neighbors or communicate in the wider DeFi world.
* **Security is paramount**: Always lock your home's doors to keep intruders out. In the same way, ensure your wallet is secure and protected from potential threats.
* **Don't lose your keys**: You need a key to enter your home. Likewise, you need a private key to access and manage your digital assets in your wallet. Guard it with your life!

### How do I create a wallet? <a href="#how_do_i_create" id="how_do_i_create"></a>

If you're new to crypto, the number of wallet providers may seem intimidating. But don't worry, you can create a wallet for free using any of the above options for free, and can easily export/import it to another whenever you want (continuing the analogy, your home base has wheels and just needs somewhere to plug in).&#x20;

This is possible because Web3 wallets are noncustodial. Noncustodial means that the keys are in your hands, and no one else is responsible. You have full control over the access to your funds, just so long as you have the key.&#x20;

While all of the wallets supported by YAD Finance are safe and easy to use, they each offer various UI/UX configurations and distinct features. You can compare the options to choose which best suits your goals and desires, or click [here](https://metamask.io/download/) to install MetaMask — the most popular option.


# How do I get crypto to start trading?

Once you’ve installed MetaMask and created a wallet, it is necessary to top up your balance. You can buy crypto for fiat on various platforms. For example, you can purchase cryptocurrency within the MetaMask wallet via its payment providers or on any cryptocurrency exchange (e.g., Binance).


# Wallet connection

Once you have created your crypto wallet and topped up its balance, go to the [YAD app](https://app.yad.finance/1/exchange/eth/dai) and make your first swap!

1\) Сlick on the orange button "connect wallet" on the home page of the YAD app.

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

2\) Select your wallet from the list of supported wallets.&#x20;

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

3\) After the previous step, you will be redirected to the wallet, where you will need to select an account to connect to YAD app.

<figure><img src="/files/5XANIY4VPtamKetN194h" alt=""><figcaption></figcaption></figure>

4\) Since this is the first time you're connecting the wallet, you will be asked to grant permission for the YAD to establish a connection.

Click on the "Connect" button to allow your MetaMask wallet to connect to YAD app.

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


# Token approval

## Why do I need to approve the use of my tokens before I can trade them?

If you want to swap your token, keep in mind that YAD's smart contracts, like all others, need to get approval in order to be able to use your tokens to swap them. It is a necessary procedure for all the smart contracts that interact with tokens.

The approval procedure requires you to specify the maximum number of tokens that you allow the smart contract to use. In the wallet form you can set some custom spending cap or use default spending limit, which sets the maximum possible value.

It is also important to note that approval transaction has its own cost, since this is a separate transaction and gas is needed to complete it.&#x20;

{% hint style="info" %}
If in the future you need to increase the allowed spending cap, then you will have to initiate another approval transaction. Therefore, for smart contracts you trust, we recommend using the default spending limit, which sets the maximum possible value. This way you can avoid extra transaction costs.
{% endhint %}

## How do I approve a token?&#x20;

Actually, this procedure is quite easy. Here's a step-by-step guide on how to do this:

1\) First of all, click on the green button to allow to use required token.

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

2\) You will be redirected to your wallet. Here you can enter custom spending cap, but we recommend to use default value for YAD's smart contracts to avoid making extra transactions in the future.

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

3\) You will see the token amount that YAD's contract is allowed to use. Click "Next" to proceed.

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

4\) This is the final step. Click on the "Approve" button to execute an approval transaction.

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

{% hint style="info" %}
If you want to learn more about token approvals and how you can manage the approvals you've already granted, you can read [this article](https://info.etherscan.com/tokenapprovals/) by [Etherscan](https://etherscan.io/).
{% endhint %}


# Making a swap

Once you have approved the use of the token on YAD, it is time to make a swap!

1\) Let's take a look at the settings you can apply to your swap. To open settings, click on the settings icon:

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

2\) Here you can adjust [slippage tolerance](/knowledge-base/basics/what-is-slippage) and [gas price](/knowledge-base/basics/what-is-gas-price).&#x20;

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

3\) Now you are all set, click the “Swap” button.

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

4\) On the next screen you will see your quote once again. Check that everything is correct and click "Confirm swap".

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

5\) You will be redirected to your wallet. Press "Confirm" to make a swap.

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


# How to check your transaction in blockchain

Once a transaction is completed you can click “View on Explorer” to see your transaction status and other details.

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

If you closed that window, don't worry. You can always find your transaction in the blockchain scanner.&#x20;

{% hint style="info" %}
You can find all your transactions on the blockchain scan pages:&#x20;

* Etherium - <https://etherscan.io/>
* BSC - <https://bscscan.com/>
* Avalanche - <https://snowtrace.io/>
* Polygon - <https://polygonscan.com/>
* Fantom - <https://ftmscan.com/>
* Optimism - <https://optimistic.etherscan.io/>
* Arbutrum - <https://arbiscan.io/>
  {% endhint %}

### To find your transaction, follow these steps:

In this example, we will look for a transaction in the Ethereum network and [Etherscan](https://etherscan.io/). For other networks and their scanners, the principle is the same.

1\) Go to the scanner page of the network where the transaction has been made and enter your wallet address in the search box.&#x20;

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

2\) After you paste the wallet address, you will see all transactions your wallet was involved in.\
Click on the one you were looking for.

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

3\) Check the "Status" field.

* If the transaction is still being processed, you will see a "pending" status.&#x20;
* If the transaction is successful, you will see a "success" status.&#x20;
* If the transaction was reverted, you will see the "reverted" status.

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


# Swap modes

At YAD Finance, we understand that flexibility and efficiency are paramount in the rapidly-evolving DeFi landscape. With that in mind, we've tailored our platform to offer two distinct swap modes, each designed to meet the unique needs and preferences of our users:

* **One-Track Swaps:** This mode streamlines the trading experience. Dive into our expansive catalog of decentralized exchanges (DEXs) and let our system identify the optimal path for your transaction. Whether you're trading a popular token or something more niche, One-Track Swaps ensure you receive the best possible rate, all while enjoying a simplified and user-friendly interface.
* **Chain-Hopping Swaps:** Explore the power of cross-chain transactions. Chain-Hopping allows you to seamlessly jump between different blockchain networks, converting your tokens in the process. Using advanced cross-chain technology, this mode ensures a secure and trustless asset transfer, bridging the gap between Ethereum and various L2 networks with remarkable ease.

Explore further into our GitBook to get a deeper understanding of each swap mode and how YAD Finance is revolutionizing the DeFi experience.<br>


# One-Track Swaps

### What is a One-Track Swap?

One-track swaps represent a revolutionary method of exchanging tokens, tailored for swift and effortless trading. It's a feature of the YAD platform that focuses on optimal-route single-chain transactions to enhance the efficiency of the swapping process.

### How a One-Track Swap Works

To truly grasp the mechanics behind one-track swaps, it's beneficial to explore our detailed [architecture section](/architecture). This will provide an in-depth view of how our system has been architected to execute one-track transactions.

### Benefits

* **Market Diversity:** Upon initiating a one-track swap, the system dives deep into its extensive catalog of decentralized exchanges (DEXs). By analyzing various exchange routes, it identifies the most optimal path for the transaction, ensuring the user gets the best possible rate.
* **Smart Routing:** YAD Finance's advanced algorithms can dynamically split transactions into multiple paths. This ensures users always get the best swap rates by capitalizing on different liquidity sources and minimizing slippage.
* **Import Any Token:** One of the standout features of one-track swaps is the ability to handle any token. Users aren't restricted to a predefined list; instead, they can easily import and trade almost any token they desire.
* **Efficiency:** One-track swaps minimize the steps and complexity typically associated with decentralized token exchanges.
* **Cost-Effective:** By pinpointing the best exchange route, users often benefit from competitive rates, leading to potential savings.
* **Flexibility:** The ability to import and trade any token means users aren't constrained by limited options, offering a broad trading horizon.
* **Simplified User Experience:** With fewer steps and a streamlined process, even novice users can navigate the swap process with ease.

### Future Plans

We're never content resting on our laurels. The roadmap for one-track swaps includes:

* **Streamlined Operations:** Soon, users will be able to both swap and send tokens in one consolidated transaction, further simplifying the process and saving valuable time.
* **Integration with More DEXs:** To offer even more comprehensive market diversity, plans are underway to integrate additional decentralized exchanges into the system.


# Chain-Hopping Swaps

### What is a Chain-Hopping Swap?

A chain-hopping swap is a mode that allows users to seamlessly transition from one blockchain network to another, swapping their tokens in the process. This innovative approach enables greater fluidity and flexibility for users to operate across various blockchain ecosystems without the need for multiple steps or complex procedures.

### How Cross-Chain Hopping Works

YAD's cross-chain technology employs a combination of one-track swaps and native bridges. The cornerstone of this process is the native bridge, which forges a connection between Ethereum and L2 blockchains. Smart contracts ensure a secure and trustless asset transfer between these networks. Notably, these smart contracts are operational on both Ethereum and the L2 platform.

Here's a breakdown of the process:

1. **Initiation of Swap:** The YAD app starts a swap process on Ethereum, converting your selected token into one that's compatible with the bridge.
2. **Asset Deposit:** Your converted assets are then securely deposited into the bridge smart contract on Ethereum.
3. **Token Minting on L2:** After this deposit, the bridge smart contract mints an equivalent token on the L2 network. This token stands as a representation of the assets you initially deposited on Ethereum.&#x20;

On average, the whole procedure, from initiation to completion, takes about 30 minutes.

### Benefits of Native Bridges

* **Cost-Efficiency:** Native bridges are notably cost-effective when considering gas expenses. There are no added fees with native bridges, making swaps significantly affordable.
* **Liquidity Flexibility:** With native bridges, there aren't restrictions concerning the liquidity amount you desire to bridge.
* **Trustworthiness:** Native bridges exude reliability. They have been developed by L2 blockchain network proprietors who continually oversee and maintain them. This maintenance is mutually beneficial, as it's advantageous for these proprietors when users transition their liquidity from Ethereum to their respective networks.

### Integrated Native Bridges

Currently, YAD has integrated three native bridges. You can delve deeper into each of them by following the links below:<br>

| Network  | Link                                                                                       |
| -------- | ------------------------------------------------------------------------------------------ |
| Polygon  | <https://wiki.polygon.technology/docs/pos/design/bridge/ethereum-polygon/getting-started/> |
| Arbitrum | <https://docs.arbitrum.io/for-devs/concepts/token-bridge/token-bridge-overview>            |
| Optimism | <https://community.optimism.io/docs/developers/bridge/basics/>                             |

### Future Plans

Looking ahead, YAD aims to:

* Initiate swaps within Layer 2 networks, for instance, moving from Arbitrum to Optimism.
* Integrate bridges for additional networks such as BSC, Avalanche, and others.
* Enable swaps from L2 back to Ethereum.


# Diamond Mode

### What is Diamond Mode?

Diamond Mode is a specialized swap feature on YetAnotherDeFi that guarantees the utmost security and fairness. The name “Diamond Mode” is derived from two defining characteristics:

* **MEV-Protection**: The Diamond Mode ensures that your transactions remain safeguarded against Miner Extractable Value (MEV) attacks. In the crypto world, assets are treasures, and this mode offers diamond-like protection to these treasures.
* **Exclusive Token Selection**: Diamond Mode only supports the most esteemed and trusted tokens for swaps, maintaining the exclusivity and value akin to diamonds.

### Benefits of Diamond Mode

* **MEV Protection**: Ensures that every transaction is executed fairly without external manipulations.
* **Trusted Liquidity**: Diamond Mode might provide more favorable quotes than many mainstream decentralized exchanges.
* **No Slippage**: The price you see is the price you get; there's no fluctuation once quoted.
* **Reduced Gas Fees**: Experience significant savings on transaction costs.

### How Does Diamond Mode Achieve This?

At its core, Diamond Mode is powered by the RFQ (Request For Quote) mechanism. But what exactly is RFQ? It's a private negotiation between the user and a Market Maker.

Here's a step-by-step breakdown:

1. **Quote Request**: You input the price for the token you wish to sell, prompting YetAnotherDeFi to request a quote from a Market Maker.
2. **Quote Confirmation**: If the offered price aligns with your expectations and you confirm the swap, YAD secures a 60-second trade order from the Market Maker.
3. **Signature Authentication**: The trader then signs this trade offer off-chain using the eip-712 signature. This procedure ensures high-level security by hashing and signing structured data, which includes fields like calldata, timestamp, and more. A unique hash is produced from these parameters, which is subsequently signed by the Market Maker's private key. This process ensures that any malicious interference will alter the hash and the signature, causing the transaction to fail.
4. **Transaction Completion**: Once YetAnotherDeFi obtains the signed calldata from the Market Maker, you'll authenticate the transaction in your wallet, followed by YAD initiating it on the blockchain. Voila! The swap is successfully completed.

This RFQ mechanism, essentially a secured private deal, ensures the swap rate remains constant, resulting in zero slippage. Moreover, the inherent security features of this mechanism make it virtually impossible for MEV bots to disrupt your transaction, ensuring unparalleled protection.


# Architecture

High-level overview of the system architecture of YAD Finance

YAD's architecture is centered around smart contracts, which serve to aggregate liquidity and execute transactions. Our design maximizes security and trust by using flash wallets, and a proxy contract is used as the entry point into the system, which then delegate-calls into features and transformers.

1. Proxy\
   The central point of system interaction, handling all entry points. It operates by delegating specific functions to Features, managing the flow and exchange of assets. Each function is handled by a unique implementation contract or 'feature'. The Proxy's main job is to maintain a map of features and their corresponding contracts, rerouting calls to these through its fallback system.<br>
2. Features\
   These are the essential building blocks of the YAD smart contracts, trusted with user allowances. They are executed in the Proxy context via a delegate-call.<br>
3. Flash Wallets\
   Acting as secure escrow accounts, Flash Wallets hold funds for Transformers to work with. Features transfer tokens to these wallets, which in turn delegate calls to Transformers. This secure system ensures Transformers only have access to funds in the Flash Wallet, not user allowances.\
   \
   This type of interaction (with the flash wallet between internal smart-contract and trustless transformers) helps to increase security while internal smart contracts interact with transformers.<br>
4. Transformers\
   These contracts extend the core YAD smart contracts. Operating as trustless extensions, Transformers are approved by the Transformer Deployer. Each Transformer is tied to a specific nonce from the Transformer Deployer. Transformers execute their tasks in the context of the Flash Wallet via delegate-call, improving security during interactions.

<figure><img src="/files/yGBRA1oujsLF47sutgji" alt=""><figcaption><p>Simplified architecture of YAD Finance</p></figcaption></figure>

Our implementation builds upon the proven and audited architecture of the 0x protocol. We opted to retain the transformer components within this structure due to their inherent modularity, offering flexibility in extending the core smart contracts. Importantly, transformers are invoked from the flash wallet, a design choice that reinforces the security of the system by compartmentalizing operations and maintaining strict access controls.

**DEX Scraping and Swap Routing**

YAD's frontend sends API requests to the backend roughly every 10 seconds, and when a user enters the "amount in" into the swap form or changes some parameters in the swap settings, the frontend asks the backend for the best price and route.

Five route options are considered, including the 0x router, the 1inch router, the Odos router, and our own router and RFQ. Our router splits the "amount in" into 5% partitions and then calculates the best route for every partition. The final route takes into account the "amount out" and the gas used for the transaction.


# Smart contracts

How to interact with YAD’s smart contracts

Our smart contracts are designed with a strong emphasis on interoperability, enabling seamless integration into diverse solutions. Accessible via our API, these contracts have been widely adopted by numerous parties to power their unique solutions and business operations, underlining the flexibility and utility of our design. <br>

Our smart contracts offer two distinct usage methods:

1. You can directly utilize our API to acquire calldata and transmit it to our proxy address.
2. Alternatively, developers can construct their own custom smart contract on top of our existing smart contracts. By invoking our API, you can interact with our proxy smart contract and carry out the transaction using the call data you received from our API.

This documentation is an evolving resource and will be updated as YAD's system continues to grow and improve.


# Proxy addresses

| Blockchain network          | Name          | Address                                    |
| --------------------------- | ------------- | ------------------------------------------ |
| Ethereum (chainID = 1)      | exchangeProxy | 0x1AAAd07998466cD3Eb8140827DDdb37570BE1e63 |
| BSC (chainID = 56)          | exchangeProxy | 0x6018B292fDDeAA83BB5d7B85415270B4Fc6d0C12 |
| Avalanche (chainID = 43114) | exchangeProxy | 0x1AAAd07998466cD3Eb8140827DDdb37570BE1e63 |
| Polygon (chainID = 137)     | exchangeProxy | 0x8e4005c5a2F85408A95adF7831F9959edA7d87d1 |
| Fantom (chainID = 250)      | exchangeProxy | 0x1AAAd07998466cD3Eb8140827DDdb37570BE1e63 |
| Optimism (chainID = 10)     | exchangeProxy | 0x1AAAd07998466cD3Eb8140827DDdb37570BE1e63 |
| Arbitrum (chainID = 42161)  | exchangeProxy | 0x1AAAd07998466cD3Eb8140827DDdb37570BE1e63 |


# Request for Quote (RFQ)

The RFQ mode is a special feature of our system that allows users to make swaps through Market Makers instead of DEXs. This method ensures protection against Miner Extractable Value (MEV) and promises a secure trading environment. Furthermore, RFQ trades have 0% slippage, meaning the price at the time of the quote is the price you pay, effectively eliminating price uncertainty during the execution of your trade.&#x20;

Now RFQ is used as a route for swaps along with other routes. In the near future, we will be releasing a new RFQ Mode where all swaps will be sent through RFQ.<br>


# One-Track Swaps API

At YAD, we firmly believe in open-source development as the cornerstone for building a decentralized future. This guiding principle drives us to deliver products that empower and engage developers and users alike. A testament to this commitment is our One-Track Swaps API.

### **Overview**

Our One-Track Swaps API is your gateway to unparalleled DeFi possibilities. With connectivity to over 75 liquidity sources, this API is built to be both robust and versatile. Whether you're aiming to elevate user functionalities or crafting your own decentralized exchange, you'll find all the tools at your disposal. Our goal? To ensure every token swap yields the optimal price, every time.

### **Hypothetical Use Cases**

* **Web3 Wallet Integration**: Web3 wallet providers can seamlessly weave our API into their fabric, enabling swift and easy token swaps for their users.
* **Gaming Integrations**: Elevate in-game purchases by offering swap functionalities. Developers can utilize our API, allowing users to conveniently swap their tokens for the game-specific tokens.
* **Decentralized Exchange Creation:** Developers aspiring to create their own DEX can leverage our API to ensure a smooth and efficient exchange process, backed by a vast network of liquidity sources.
* **Integration into Existing DEX:** For those already operating a decentralized exchange, integrating our liquidity sources can significantly expand exchange opportunities, ensuring improved quotes and a more competitive edge in the market.

### **Benefits of YAD One-track Swaps API**

* **Market-leading Quotes**: With our proprietary algorithms, we unearth intelligent and unconventional routes, ensuring users get the most competitive quotes for their swaps.
* **Low Transaction Costs**: Thanks to our gas-optimized smart contracts combined with pinpoint accurate real-time gas price calculations, unnecessary expenses become a thing of the past.
* **Trust and Security**: The onus of initiating, signing, and sending the transaction remains with the user, reinforcing trust. We value privacy, ensuring no access to users' private keys or funds. Additionally, our smart contracts have undergone rigorous audits to bolster security.
* **Dedicated Support**: Questions? Concerns? Feedback? Our highly-skilled support team is available round-the-clock, ensuring you're never left in the dark. Feel free to reach out to us at <partners@yad.finance>!


# Getting started

1. Read this documentation.
2. Try out YAD API using [Swagger](https://api.yetanotherdefi.com/swagger/index.html) or request examples we provided in this documentation.&#x20;
3. For requests use API url: `https://api.yad.finance`.
4. If you have any questions about partnership with us, feel free to drop us a message at: <partners@yad.finance>

### API key management

1. Kindly note that without an API access key, the number of requests per second is limited, it is suitable for testing and development, but not for production capacity.
2. To obtain the key, please get in touch with <partners@yad.finance>.
3. The given key must be added to the header of each request, parameter {"X-API-Key": "\<key>"}


# Use cases

1. API — provides a list of supported blockchains upon request GET `v1/platforms`.
2. GUI — the user selects a network the exchange is made within. For example, Ethereum, ChainID=1.
3. API — provides a list of blockchain tokens upon request POST `v2/tokens/list`.
4. API (optional) – provides calculated gas price values in GWEI (nAVAX for Avalanche) for fast, medium, low transaction time GET `v1/{chainID}/gasprices` (in the example GET `v1/1/gasprices`).
5. GUI — the user selects the exchange tokens and the sale amount. For example, 1000 USDT to WBTC.
6. GUI — the user sets the slippage tolerance value as a percentage. The recommended value is 1%.
7. GUI (optional) — the user selects the gas price value from #4.
8. API — endpoint GET `v1/{chainID}/price` (GET `v1/1/price`) provides the number of tokens that the user will receive for the purchase (0.05 WBTC).
9. GUI — the user connects the wallet.
10. API — endpoint GET `v1/{chainID}/transaction/allowance` (GET `v1/1/transaction/allowance`) returns the amount of tokens that the exchange smart contract has access to (not required for native coins).
11. GUI — if the value of the sale is greater than the value from #10, the user is prompted to provide access for the tokens exchange (otherwise the exchange transaction will not be processed).
12. API — endpoint GET `v1/{chainID}/transaction/approve` returns the input parameters (calldata) for a transaction to provide access to tokens, and the address of the contract where the transaction should be sent to.
13. GUI — generates an unsigned transaction based on the data from #12 and sends it to the user's connected wallet.
14. WALLET — the user confirms the operation in the wallet, and the wallet then signs the transaction and sends it to the blockchain.
15. GUI — after successful confirmation of the transaction from #14, the user is offered a button to exchange the selected tokens.
16. API — by endpoint GET `v1/{chainID}/quote` (GET `v1/1/quote`) provides the number of the tokens purchased (0.05 WBTC), transaction input parameters.
17. GUI — generates an unsigned transaction based on the data from #16 and sends it to the user's connected wallet.
18. WALLET — the user confirms the operation in the wallet, and the wallet then signs the transaction and sends it to the blockchain.


# Endpoint list

## Get plaftorms

<mark style="color:blue;">`GET`</mark> `v1/platforms`

Provides a list of supported blockchain networks.

**Request sample:**\
`https://api.yad.finance/v1/platforms`

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "platforms": [
    {
      "chainId": 1,
      "name": "Ethereum",
      "shortname": "ETH"
    },
    {
      "chainId": 10,
      "name": "Optimistic Ethereum",
      "shortname": "Optimism"
    },
    {
      "chainId": 56,
      "name": "BNB Smart Chain",
      "shortname": "BSC"
    }
  ]
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

| Name          | Data Type | Description                               |
| ------------- | --------- | ----------------------------------------- |
| **platforms** | `array`   | An array of supported networks.           |
| **chainId**   | `int`     | The blockchain network ID.                |
| **shortname** | `str`     | The short name of the blockchain network. |
| **name**      | `str`     | The full name of the blockchain network.  |

## Get gas prices

<mark style="color:blue;">`GET`</mark> `v1/{chainID}/gasprices`

Provides calculated gas price values in GWEI (nAVAX for Avalanche).

**Request sample:**\
`https://api.yad.finance/v1/1/gasprices`

#### Path Parameters

| Name                                      | Type    | Description                                             |
| ----------------------------------------- | ------- | ------------------------------------------------------- |
| chainId<mark style="color:red;">\*</mark> | Integer | The blockchain ID for which the gas price is requested. |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "baseFee": "13.757",
  "low": "14.757",
  "lowInfo": {
    "price": "14.757",
    "maxPriorityFeePerGas": "0.5",
    "maxFeePerGas": "14.257"
  },
  "medium": "16.757",
  "mediumInfo": {
    "price": "16.757",
    "maxPriorityFeePerGas": "0.55",
    "maxFeePerGas": "15.683"
  },
  "high": "18.757",
  "highInfo": {
    "price": "18.757",
    "maxPriorityFeePerGas": "0.65",
    "maxFeePerGas": "18.535"
  }
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="400: Bad Request Bad Request" %}

{% endtab %}

{% tab title="500: Internal Server Error Internal Server Error" %}

{% endtab %}
{% endtabs %}

<table><thead><tr><th>Name</th><th width="113.66666666666666">Data Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>baseFee</strong></td><td><code>str</code></td><td>Base fee for the next block in blockchain.</td></tr><tr><td><strong>low</strong></td><td><code>str</code></td><td>The gas price at which the transaction is most likely to be accepted not earlier than after block 5. There is a risk of a long transaction confirmation.</td></tr><tr><td><strong>medium</strong></td><td><code>str</code></td><td>The gas price at which the transaction is most likely to be accepted in the next 2-3 blocks.</td></tr><tr><td><strong>high</strong></td><td><code>str</code></td><td>The gas price at which the transaction is most likely to be accepted in the next block.</td></tr><tr><td><strong>lowInfo (mediumInfo / highInfo)</strong></td><td><code>map</code></td><td>Detailed gas price info for EIP-1559.</td></tr><tr><td><strong>price</strong></td><td><code>str</code></td><td>Gas price (for legacy transactions, not EIP-1559).</td></tr><tr><td><strong>maxPriorityFeePerGas</strong></td><td><code>str</code></td><td>Max Priority Fee Per Gas (tips in EIP-1559).</td></tr><tr><td><strong>maxFeePerGas</strong></td><td><code>str</code></td><td>Max Fee Per Gas (for EIP-1559).</td></tr></tbody></table>

## Get on-chain price for pair

<mark style="color:blue;">`GET`</mark> `v1/{chainID}/price`

Returns the best route and exchange offer for pair, no calldata for transaction. Works faster than `/quote`.\
\
**Request sample:**\
`https://api.yetanotherdefi.com/v1/1/price?fromTokenAddress=0xdac17f958d2ee523a2206206994597c13d831ec7&toTokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f&amount=1500000000&slippage=1&gasPrice=16000000000&feeRecipient=0xdac17f958d2ee523a2206206994597c13d831ec7&buyTokenPercentageFee=1&sellTokenPercentageFee=1&rfqOnly=false&withGas=false`

#### Path Parameters

| Name                                      | Type    | Description                                         |
| ----------------------------------------- | ------- | --------------------------------------------------- |
| chainID<mark style="color:red;">\*</mark> | Integer | Blockchain ID. (Supported networks - /v1/platforms) |

#### Query Parameters

| Name                                               | Type    | Description                                                                                                                                                                                                                                                 |
| -------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fromTokenAddress<mark style="color:red;">\*</mark> | String  | Smart contract address of the sale token.                                                                                                                                                                                                                   |
| toTokenAddress<mark style="color:red;">\*</mark>   | String  | Smart contract address of the purchase token.                                                                                                                                                                                                               |
| amount<mark style="color:red;">\*</mark>           | Integer | The amount of sale tokens in decimals of the token (can be taken from the method `/tokens`).                                                                                                                                                                |
| slippage<mark style="color:red;">\*</mark>         | Number  | <p>The amount of slippage allowed during the actual execution of the transaction (10 = 1% slippage). If the price changes by more than this percentage, the transaction will revert. Min = 1 (0.1%), max = 500 (50%).<br><br><em>Default value</em> : 1</p> |
| gasPrice                                           | String  | Gas price value for making a transaction in WEI (nAVAX for Avalanche) (1 GWEI = 1000000000 WEI), default value is the value high from `/gasprices`.                                                                                                         |
| feeRecipient                                       | String  | Wallet address for receiving fees. The commission is paid from the purchase token.                                                                                                                                                                          |
| buyTokenPercentageFee                              | Integer | Percentage of commission from the amount of purchase tokens, is taken in favor of feeRecipient. (10 = 1%, maximum value is 500).                                                                                                                            |
| sellTokenPercentageFee                             | Integer | Percentage of commission from the amount of sale tokens, is taken in favor of feeRecipient. (10 = 1%, maximum value is 500).                                                                                                                                |
| rfqOnly                                            | Boolean | <p>If TRUE: use only RFQ providers for routing.</p><p><br><em>Default value</em> : false</p>                                                                                                                                                                |
| excludeAggregator                                  | String  | Exclude some aggregators from routing (add several parameters for multiple exclude)                                                                                                                                                                         |
| includeAggregator                                  | String  | Include some aggregators from routing (add several parameters for multiple include). This parameter cannot be combined with excludedAggregators.                                                                                                            |
| withGas                                            | Boolean | <p>If TRUE: choose a route based on gas.</p><p></p><p><em>Default value</em> : false</p>                                                                                                                                                                    |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "amount_out_total": "1498367401285001674752",
  "estimate_gas_total": "595785",
  "token_in": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "token_out": "0x6b175474e89094c44da98b954eedeac495271d0f",
  "gas_price": "16000000000",
  "fee_recipient_amount": "1497002",
  "routes": [
    {
      "type": "dex",
      "protocol_name": "eth_odos",
      "percent": 100
    }
  ]
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="204: No Content No Content" %}

{% endtab %}
{% endtabs %}

<table><thead><tr><th width="227">Name</th><th width="110.66666666666666">Data type</th><th>Description</th></tr></thead><tbody><tr><td><strong>amount_out_total</strong></td><td><code>str</code></td><td>The amount of purchase tokens in decimals of the token.</td></tr><tr><td><strong>estimate_gas_total</strong></td><td><code>str</code></td><td>The estimated amount of gas that will be used during the transaction.</td></tr><tr><td><strong>token_in</strong></td><td><code>str</code></td><td>Smart contract address of the sale token.</td></tr><tr><td><strong>token_out</strong></td><td><code>str</code></td><td>Smart contract address of the purchase token.</td></tr><tr><td><strong>gas_price</strong></td><td><code>str</code></td><td>Gas price value for a transaction in WEI (nAVAX for Avalanche).</td></tr><tr><td><strong>fee_recipient_amount</strong></td><td><code>str</code></td><td>The amount of purchase tokens in decimals of the token, which will be taken in favor of feeRecipient. The value will be 0 if feeRecipient and buyTokenPercentageFee fields are not specified.</td></tr><tr><td><strong>routes</strong></td><td><code>array</code></td><td>An array of DEXs the transaction will be carried out through.</td></tr><tr><td><strong>type</strong></td><td><code>str</code></td><td>Liquidity source type.</td></tr><tr><td><strong>protocol_name</strong></td><td><code>str</code></td><td>DEX name the transaction will be carried out through.</td></tr><tr><td><strong>percent</strong></td><td><code>int</code></td><td>The percent of amount will be swapped on the current DEX.</td></tr></tbody></table>

## Transaction allowance

<mark style="color:blue;">`GET`</mark> `v1/{chainID}/transaction/allowance`

Checks how many of the user's tokens the exchange smart contract has access to.

**Request sample:**\
`https://api.yad.finance/v1/1/transaction/allowance?tokenAddress=0xdAC17F958D2ee523a2206206994597C13D831ec7&walletAddress=0x58f58219e2d2598588c1b457bb6da65c34d99310`

#### Path Parameters

| Name                                      | Type    | Description                                                                              |
| ----------------------------------------- | ------- | ---------------------------------------------------------------------------------------- |
| chainID<mark style="color:red;">\*</mark> | Integer | The ID of the blockchain the token is located on (supported networks - `/v1/platforms`). |

#### Query Parameters

| Name                                            | Type   | Description                                                            |
| ----------------------------------------------- | ------ | ---------------------------------------------------------------------- |
| tokenAddress<mark style="color:red;">\*</mark>  | String | Smart contract address of the token for which access is being checked. |
| walletAddress<mark style="color:red;">\*</mark> | String | Wallet of the user for which access is being checked.                  |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```
{
  "remaining": "11579208923731620000"
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

| Name          | Data Type | Description                                                                     |
| ------------- | --------- | ------------------------------------------------------------------------------- |
| **remaining** | `str`     | The number of tokens in decimals of the token the smart contract has access to. |

## Transaction approve

<mark style="color:blue;">`GET`</mark> `v1/{chainID}/transaction/approve`

Generates transaction input parameters to provide access to the user's tokens for the exchange smart contract.

**Request sample:**\
`https://api.yad.finance/v1/1/transaction/approve?tokenAddress=0xdAC17F958D2ee523a2206206994597C13D831ec7&amount=100000000000&gasPrice=100000000000`

#### Path Parameters

| Name                                      | Type    | Description                                                                          |
| ----------------------------------------- | ------- | ------------------------------------------------------------------------------------ |
| chainID<mark style="color:red;">\*</mark> | Integer | ID of the blockchain the token is located on (supported networks - `/v1/platforms`). |

#### Query Parameters

| Name                                           | Type    | Description                                                                                           |
| ---------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
| tokenAddress<mark style="color:red;">\*</mark> | String  | Address of the smart contract of the token for which the access request is generated.                 |
| takerAddress                                   | String  | Address of user’s wallet which will provide approve. When provided the gas will be estimated exactly. |
| amount                                         | integer | The amount of user tokens to which access is granted. By default - infinite number.                   |
| gasPrice                                       | Integer | Cost of gas for an approve transaction. By default: medium                                            |
| contractAddress                                | String  | Contract that we want to give an approval. If not passed, then the default for chain is used.         |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```
{
  "calldata": "0x095ea7b30000000000000000000000001aaad07998466cd3eb8140827dddb37570be1e63000000000000000000000000000000000000000000000000000000174876e800",
  "gas_price": "100000000000",
  "to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "estimate_gas": "48561"
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th>Name</th><th width="169.66666666666666">Data Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>calldata</strong></td><td><code>str</code></td><td>One of the input parameters for processing a transaction providing access to tokens.</td></tr><tr><td><strong>gas_price</strong></td><td><code>str</code></td><td>Gas price value for a transaction in WEI.</td></tr><tr><td><strong>to</strong></td><td><code>str</code></td><td>Address of the smart contract the transaction should be sent to.</td></tr><tr><td><strong>estimate_gas</strong></td><td><code>str</code></td><td>The estimated amount of gas that will be used during the transaction.</td></tr></tbody></table>

## Get on-chain quote for pair

<mark style="color:blue;">`GET`</mark> `v1/{chainID}/quote`

Returns the best exchange offer and input parameters for the transaction.

**Request sample:**\
`https://api.yetanotherdefi.com/v1/1/quote?fromTokenAddress=0xdac17f958d2ee523a2206206994597c13d831ec7&toTokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f&amount=1500000000&slippage=1&gasPrice=16000000000&feeRecipient=0xdac17f958d2ee523a2206206994597c13d831ec7&buyTokenPercentageFee=1&sellTokenPercentageFee=1&skipValidation=true&withGas=false`

#### Path Parameters

| Name                                      | Type    | Description                                                                             |
| ----------------------------------------- | ------- | --------------------------------------------------------------------------------------- |
| chainID<mark style="color:red;">\*</mark> | Integer | ID of the blockchain tokens must be exchanged on (supported networks - `v1/platforms`). |

#### Query Parameters

| Name                                               | Type    | Description                                                                                                                                                                                                        |
| -------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| fromTokenAddress<mark style="color:red;">\*</mark> | String  | Smart contract address of the sale token.                                                                                                                                                                          |
| toTokenAddress<mark style="color:red;">\*</mark>   | String  | Smart contract address of the purchase token.                                                                                                                                                                      |
| takerAddress                                       | String  | The address which will fill the quote. When provided the gas will be estimated and returned.                                                                                                                       |
| amount<mark style="color:red;">\*</mark>           | Integer | The amount of sale tokens in decimals of the token (can be taken from the method `/tokens`).                                                                                                                       |
| slippage<mark style="color:red;">\*</mark>         | Integer | The amount of slippage allowed during the actual execution of the transaction (10 = 1% slippage). If the price changes by more than this percentage, the transaction will revert. Min = 1 (0.1%), max = 500 (50%). |
| gasPrice                                           | String  | Gas price value for making a transaction in WEI (nAVAX for Avalanche) (1 GWEI = 1000000000 WEI), default value is the value high from `/gasprices`.                                                                |
| feeRecipient                                       | String  | Wallet address for receiving fees. The commission is paid from the purchase token.                                                                                                                                 |
| buyTokenPercentageFee                              | Integer | Percentage of commission from the amount of purchase tokens, is taken in favor of feeRecipient. (10 = 1%, maximum value is 500).                                                                                   |
| sellTokenPercentageFee                             | Integer | Percentage of commission from the amount of sell tokens, is taken in favor of feeRecipient. (10 = 1%, maximum value is 500).                                                                                       |
| recipientAddress                                   | String  | <p>Wallet address for receiving purchase tokens.<br>By default: sender address.</p>                                                                                                                                |
| skipValidation                                     | Boolean | <p>If TRUE: skip calldata validation</p><p></p><p><em>Default value</em> : true</p>                                                                                                                                |
| excludeAggregator                                  | String  | Exclude some aggregators from routing (add several parameters for multiple exclude).                                                                                                                               |
| includeAggregator                                  | String  | Include some aggregators from routing (add several parameters for multiple include). This parameter cannot be combined with excludedAggregators.                                                                   |
| withGas                                            | Boolean | <p>If TRUE: choose a quote based on gas.</p><p></p><p><em>Default value</em> : false</p>                                                                                                                           |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "amount_out_total": "1498328896581420449792",
  "estimate_gas_total": "645770",
  "token_in": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "token_out": "0x6b175474e89094c44da98b954eedeac495271d0f",
  "gas_price": "16000000000",
  "fee_recipient_amount": "0",
  "routes": [
    {
      "type": "dex",
      "protocol_name": "eth_odos",
      "percent": 100
    }
  ],
  "calldata": "0x1342555a00000000000000000000000076f4eed9fe41262669d0250b2a97db79712ad85500000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000595157560000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000005124b26ec2d91fba5e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a4f17a454600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000001e42741ef6a26c2eb653000000000000000000000000000000000000000000001e3ab50761655600000000000000000000000000000000000bdc51918c9407d2a7a0f34b68f16c26ea13ac2c9000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000000000000000000000000000000000000059515756000000000000000000000000bdc51918c9407d2a7a0f34b68f16c26ea13ac2c90000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000005f5eedb000000000000000000000000ca188796c709f3e052006a7e1e80b309ddd260ad0000000000000000000000000000000000000000000000000000000000000048010203000d0101010200ff00000000000000000000000000000000000000000048da0965ab2d2cbf1c17c09cfb5cbe67ad5b1406dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a97e0564F0AAC50000",
  "to": "0x1AAAd07998466cD3Eb8140827DDdb37570BE1e63",
  "expiry": 1693494007
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="204: No Content No Content" %}

{% endtab %}
{% endtabs %}

<table><thead><tr><th width="233">Name</th><th width="107.66666666666666">Data type</th><th>Description</th></tr></thead><tbody><tr><td><strong>amount_out_total</strong></td><td><code>str</code></td><td>The amount of purchase tokens in decimals of the token.</td></tr><tr><td><strong>estimate_gas_total</strong></td><td><code>str</code></td><td>The estimated amount of gas that will be used during the transaction.</td></tr><tr><td><strong>token_in</strong></td><td><code>str</code></td><td>Smart contract address of the sale token.</td></tr><tr><td><strong>token_out</strong></td><td><code>str</code></td><td>Smart contract address of the purchase token.</td></tr><tr><td><strong>gas_price</strong></td><td><code>str</code></td><td>Gas price value for a transaction in WEI (nAVAX for Avalanche).</td></tr><tr><td><strong>fee_recipient_amount</strong></td><td><code>str</code></td><td>The amount of purchase tokens in decimals of the token, which will be taken in favor of feeRecipient. The value will be 0 if feeRecipient and buyTokenPercentageFee fields are not specified.</td></tr><tr><td><strong>routes</strong></td><td><code>array</code></td><td>An array of DEXs the transaction will be carried out through.</td></tr><tr><td><strong>type</strong></td><td><code>str</code></td><td>Liquidity source type.</td></tr><tr><td><strong>protocol_name</strong></td><td><code>str</code></td><td>DEX name the transaction will be carried out through.</td></tr><tr><td><strong>percent</strong></td><td><code>int</code></td><td>The percent of amount will be swapped on the current DEX.</td></tr><tr><td><strong>calldata</strong></td><td><code>str</code></td><td>One of the input parameters for processing a transaction for tokens exchange.</td></tr><tr><td><strong>to</strong></td><td><code>str</code></td><td>Smart contract address where input parameters should be sent to.</td></tr><tr><td><strong>expiry</strong></td><td><code>int</code></td><td>Quote expiration time (in unix epoch time format).<br>Applicable for RFQ providers only.</td></tr></tbody></table>

## List tokens

<mark style="color:green;">`POST`</mark> `v2/tokens/list`

Get a list of tokens with filters and pagination.

**Request sample**

cURL:

`curl -X 'POST' \` \
`'https://api.yetanotherdefi.com/v2/tokens/list' \` \
`-H 'accept: application/json' \` \
`-H 'Content-Type: application/json' \` \
`-d '{ "filter": { "symbols": [ "ETH" ] }, "paging": { "page": 1, "page_size": 100 } }'`

#### Request Body

| Name                                   | Type          | Description                                                                                                                                                                                                                                                                                               |
| -------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filter                                 | object        | <p>Filtering occurs with an 'AND' statement between fields and an 'OR' statement between array elements. </p><p></p><p>For example: chain\_ids\[1, 2], names\[asd] == all tokens where chain\_id is "1" or "2" and name equal "asd". </p><p></p><p>Searching by all text filters is case-insensitive.</p> |
| addresses                              | string array  | Token smart contract addresses.                                                                                                                                                                                                                                                                           |
| chain\_ids                             | integer array | Blockchain network IDs.                                                                                                                                                                                                                                                                                   |
| is\_active                             | boolean       | <p>FALSE = the token is rarely used in exchanges on DEXs</p><p></p><p>If null - get only active.</p>                                                                                                                                                                                                      |
| names                                  | string array  | Full names of tokens.                                                                                                                                                                                                                                                                                     |
| symbols                                | string array  | Abbreviated names of tokens.                                                                                                                                                                                                                                                                              |
| paging                                 | object        | An object for adjusting response sizes.                                                                                                                                                                                                                                                                   |
| page<mark style="color:red;">\*</mark> | integer       | <p>Page number. </p><p></p><p>This parameter can be useful when the total sample size of tokens that meet the criteria from the filter exceeds the page size.</p><p></p><p>Can't be less than 1.</p>                                                                                                      |
| page\_size                             | integer       | <p>Response size. For example, "page\_size": 5 == get 5 tokens that meet the filtering conditions.</p><p></p><p>Max 100. If zero - unlitimited page size</p>                                                                                                                                              |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "tokens": [
    {
      "chainId": 1,
      "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "name": "Ethereum",
      "symbol": "ETH",
      "decimals": 18,
      "logoURI": "https://cl.yad.finance/static-files/1i/1/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee/48x48.png",
      "is_active": true,
      "priority": 1,
      "is_rfq_mode": false
    },
    {
      "chainId": 10,
      "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "name": "Ethereum",
      "symbol": "ETH",
      "decimals": 18,
      "logoURI": "https://cl.yad.finance/static-files/1i/10/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee/48x48.png",
      "is_active": true,
      "priority": 1,
      "is_rfq_mode": false
    }
  ]
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

| Name              | Data type | Description                                                                                                                                                                     |
| ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **tokens**        | `array`   | An array of tokens.                                                                                                                                                             |
| **chainId**       | `int`     | The blockchain network ID.                                                                                                                                                      |
| **address**       | `str`     | The token smart contract address.                                                                                                                                               |
| **name**          | `str`     | Full name of the token.                                                                                                                                                         |
| **symbol**        | `str`     | Abbreviated name of the token.                                                                                                                                                  |
| **decimals**      | `int`     | The number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5.05 (505 / 10 \*\* 2). |
| **logoURI**       | `str`     | A link to the token logo.                                                                                                                                                       |
| **is\_active**    | `boolean` | FALSE = the token is rarely used in exchanges on DEXs.                                                                                                                          |
| **priority**      | `int`     | Recommended priority of a token to be shown to the user, based on the popularity of the token.                                                                                  |
| **is\_rfq\_mode** | `boolean` | TRUE = the token is supported by RFQ providers.                                                                                                                                 |


# Cross-Chain Swaps API

At YAD, we envision a boundless decentralized universe, interconnected seamlessly. Taking a massive leap in turning this vision into reality, we proudly introduce our Cross-Chain Swaps API. Built with precision and passion, this tool bridges diverse blockchain ecosystems effortlessly.

### **Overview**

The YAD Cross-Chain Swaps API is a testament to our unwavering commitment to building an integrated DeFi universe. By connecting distinct blockchain territories, we aim to eradicate boundaries and create a singular, cohesive DeFi experience. Dive into a world where every swap, regardless of its origin chain, finds its optimal destination.

### **Hypothetical Use Cases**

* **DApps Integration**: DApp developers can infuse cross-chain functionality, granting users the liberty to operate across various blockchain ecosystems without friction.
* **Wallet Services Upgrade**: Wallet providers can integrate our API to support transactions and swaps between different chains, ensuring their users always have access to the best possible liquidity and rates.
* **Cross-chain Liquidity Pools**: Boost liquidity by offering pools that tap into multiple chains, allowing users to leverage the best of all worlds.
* **Blockchain Interoperability Projects**: Those building solutions to connect various blockchains can make use of our API to smoothen and enhance the cross-chain experience for their users.

### **Benefits of YAD Cross-Chain Swaps API**

* **Seamless Swapping**: Transition between chains fluidly, with the assurance of securing optimal swap rates and minimal slippage.
* **Uncompromised Speed**: Despite the intricacies of cross-chain operations, our API ensures swift and efficient transactions, always keeping pace with your needs.
* **Reliable and Safe**: Trust remains paramount. Our Cross-Chain Swaps API ensures every swap is secure. Plus, our technology is backed by comprehensive audits, reinforcing our commitment to safety.
* **Broadened Horizons**: Our vision extends beyond the current horizons of the DeFi ecosystem. We're actively charting a course towards enhanced functionalities, including initiating swaps within Layer 2 networks and seamlessly integrating bridges for burgeoning networks such as BSC, Avalanche, and more. Moreover, our future roadmap promises the capability to facilitate swaps from L2 networks back to Ethereum, ensuring our users have unparalleled access and flexibility across the blockchain spectrum.
* **24/7 Support**: Our dedicated team is always ready, eager to assist, guide, and ensure your cross-chain endeavors are seamless. Drop us a line at <partners@yad.finance>!


# Getting started

1. Read this documentation.
2. Try out YAD API using [Swagger](https://api.yetanotherdefi.com/swagger/index.html) or request examples we provided in this documentation.&#x20;
3. For requests use API url: `https://api.yad.finance`.
4. If you have any questions about partnership with us, feel free to drop a message at: <partners@yad.finance>

### API key management

1. Kindly note that without an API access key, the number of requests per second is limited, it is suitable for testing and development, but not for production capacity.
2. To obtain the key, please get in touch with <partners@yad.finance>.
3. The given key must be added to the header of each request, parameter {"X-API-Key": "\<key>"}


# Use cases

1. API — provides a list of supported blockchains as well as a list of tokens for a destination network upon request GET `v1/tokens/allForSwapAndBridge`&#x20;
2. API — provides a list of tokens for a “departure” network upon request POST `v2/tokens/list`.
3. API (optional) — provides calculated gas price values in GWEI (nAVAX for Avalanche) for fast, medium, low transaction time GET `v1/{chainID}/gasprices` (in the example GET `v1/1/gasprices` - chainID=fromChainID)
4. GUI — the user selects the networks and tokens the exchange is made between. For example, for an Ethereum -> Polygon swap, the parameters will be:
   1. fromChainID = 1; toChainID = 137
   2. fromTokenAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 (USDC)&#x20;
   3. toTokenAddress = 0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063 (DAI)
5. GUI — the user enters a sale amount.
6. GUI (optional) — the user selects the gas price value from #3.
7. GUI — the user sets the slippage tolerance value as a percentage. The recommended value is 1%.
8. API — endpoint GET `v1/price` provides the number of tokens that the user will receive for the purchase.
9. GUI — the user connects the wallet.
10. API — endpoint GET `v1/{chainID}/transaction/allowance` (GET `v1/1/transaction/allowance`) returns the amount of tokens that the exchange smart contract has access to (not required for native coins, chainID = fromChainID).
11. GUI — if the value of the sale is greater than the value from #10, the user is prompted to provide access for the tokens exchange (otherwise the exchange transaction will not be processed).
12. API — endpoint GET `v1/{chainID}/transaction/approve` returns the input parameters (calldata) for a transaction to provide access to tokens, and the address of the contract where the transaction should be sent to.
13. GUI — generates an unsigned transaction based on the data from #12 and sends it to the user's connected wallet.
14. WALLET — the user confirms the operation in the wallet, and the wallet then signs the transaction and sends it to the blockchain.
15. GUI — after successful confirmation of the transaction from #14, the user is offered a button to exchange the selected tokens.
16. API — by endpoint GET `v1/quote` provides the number of the tokens purchased, transaction input parameters.
17. GUI — generates an unsigned transaction based on the data from #16 and sends it to the user's connected wallet.
18. WALLET — the user confirms the operation in the wallet, and the wallet then signs the transaction and sends it to the blockchain.

{% hint style="info" %}
The endpoints `v1/price` and `v1/quote` can also be used for swaps within the same blockchain network. Just specify the same blockchain identifier for parameters <mark style="color:orange;">fromChainID</mark> and <mark style="color:orange;">toChainID</mark>.
{% endhint %}


# Endpoint list

## A list of tokens and blockchains for bridging

<mark style="color:blue;">`GET`</mark> `v1/tokens/allForSwapAndBridge`

Provides a list of supported blockchains as well as a list of tokens for a destination network.\
\
**Request sample:**\
`https://api.yetanotherdefi.com/v1/tokens/allForSwapAndBridge`

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "1": {
    "10": [
      {
        "chainId": 10,
        "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
        "name": "Ether",
        "symbol": "ETH",
        "decimals": 18,
        "logoURI": "",
        "is_active": false,
        "is_rfq_mode": false
      },
      {
        "chainId": 10,
        "address": "0x50c5725949a6f0c72e6c4a641f24049a917db0cb",
        "name": "Lyra Token",
        "symbol": "LYRA",
        "decimals": 18,
        "logoURI": "https://cl.yad.finance/static-files/1i/10/0x50c5725949a6f0c72e6c4a641f24049a917db0cb/48x48.png",
        "is_active": false,
        "is_rfq_mode": false
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="189">Name</th><th width="156.66666666666666">Data Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>{fromChainID}</strong></td><td><code>map (dictionary)</code></td><td>ChainID of “departure” networks.</td></tr><tr><td><strong>{toChainID}</strong></td><td><code>array</code></td><td>An array of supported tokens for "destination" network.</td></tr><tr><td><strong>chainId</strong></td><td><code>int</code></td><td>The blockchain network ID.</td></tr><tr><td><strong>address</strong></td><td><code>str</code></td><td>The token smart contract address.</td></tr><tr><td><strong>name</strong></td><td><code>str</code></td><td>Full name of the token.</td></tr><tr><td><strong>symbol</strong></td><td><code>str</code></td><td>Abbreviated name of the token.</td></tr><tr><td><strong>decimals</strong></td><td><code>int</code></td><td>The number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2).</td></tr><tr><td><strong>logoURI</strong></td><td><code>str</code></td><td>A link to the token logo.</td></tr><tr><td><strong>is_active</strong></td><td><code>boolean</code></td><td>FALSE = the token is rarely used in exchanges on DEXs.</td></tr><tr><td><strong>is_rfq_mode</strong></td><td><code>boolean</code></td><td>TRUE = the token is supported by RFQ providers.</td></tr></tbody></table>

## Get gas prices

<mark style="color:blue;">`GET`</mark> `v1/{chainID}/gasprices`

Provides calculated gas price values in GWEI (nAVAX for Avalanche).

**Request sample:**\
`https://api.yad.finance/v1/1/gasprices`

#### Path Parameters

| Name                                      | Type    | Description                                             |
| ----------------------------------------- | ------- | ------------------------------------------------------- |
| chainId<mark style="color:red;">\*</mark> | Integer | The blockchain ID for which the gas price is requested. |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "baseFee": "13.757",
  "low": "14.757",
  "lowInfo": {
    "price": "14.757",
    "maxPriorityFeePerGas": "0.5",
    "maxFeePerGas": "14.257"
  },
  "medium": "16.757",
  "mediumInfo": {
    "price": "16.757",
    "maxPriorityFeePerGas": "0.55",
    "maxFeePerGas": "15.683"
  },
  "high": "18.757",
  "highInfo": {
    "price": "18.757",
    "maxPriorityFeePerGas": "0.65",
    "maxFeePerGas": "18.535"
  }
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="400: Bad Request Bad Request" %}

{% endtab %}

{% tab title="500: Internal Server Error Internal Server Error" %}

{% endtab %}
{% endtabs %}

<table><thead><tr><th>Name</th><th width="113.66666666666666">Data Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>baseFee</strong></td><td><code>str</code></td><td>Base fee for the next block in blockchain.</td></tr><tr><td><strong>low</strong></td><td><code>str</code></td><td>The gas price at which the transaction is most likely to be accepted not earlier than after block 5. There is a risk of a long transaction confirmation.</td></tr><tr><td><strong>medium</strong></td><td><code>str</code></td><td>The gas price at which the transaction is most likely to be accepted in the next 2-3 blocks.</td></tr><tr><td><strong>high</strong></td><td><code>str</code></td><td>The gas price at which the transaction is most likely to be accepted in the next block.</td></tr><tr><td><strong>lowInfo (mediumInfo / highInfo)</strong></td><td><code>map</code></td><td>Detailed gas price info for EIP-1559.</td></tr><tr><td><strong>price</strong></td><td><code>str</code></td><td>Gas price (for legacy transactions, not EIP-1559).</td></tr><tr><td><strong>maxPriorityFeePerGas</strong></td><td><code>str</code></td><td>Max Priority Fee Per Gas (tips in EIP-1559).</td></tr><tr><td><strong>maxFeePerGas</strong></td><td><code>str</code></td><td>Max Fee Per Gas (for EIP-1559).</td></tr></tbody></table>

## Get price for pair

<mark style="color:blue;">`GET`</mark> `v1/price`

Returns the best route and exchange offer for pair, no calldata for transaction. Works faster than `/quote`.\
\
**Request sample:**\
`https://api.yetanotherdefi.com/v1/price?fromChainID=1&toChainID=137&fromTokenAddress=0xdac17f958d2ee523a2206206994597c13d831ec7&toTokenAddress=0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063&amount=150&slippage=10&feeRecipient=0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503&sellTokenPercentageFee=10&rfqOnly=false`<br>

#### Query Parameters

| Name                                               | Type    | Description                                                                                                                                                                                                                                                 |
| -------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fromTokenAddress<mark style="color:red;">\*</mark> | String  | Smart contract address of the sale token.                                                                                                                                                                                                                   |
| toTokenAddress<mark style="color:red;">\*</mark>   | String  | Smart contract address of the purchase token.                                                                                                                                                                                                               |
| amount<mark style="color:red;">\*</mark>           | Integer | The amount of sale tokens in decimals of the token (can be taken from the method `/tokens`).                                                                                                                                                                |
| slippage<mark style="color:red;">\*</mark>         | Number  | <p>The amount of slippage allowed during the actual execution of the transaction (10 = 1% slippage). If the price changes by more than this percentage, the transaction will revert. Min = 1 (0.1%), max = 500 (50%).<br><br><em>Default value</em> : 1</p> |
| gasPrice                                           | String  | Gas price value for making a transaction in WEI (nAVAX for Avalanche) (1 GWEI = 1000000000 WEI), default value is the value high from `/gasprices`.                                                                                                         |
| feeRecipient                                       | String  | Wallet address for receiving fees. The commission is paid from the purchase token.                                                                                                                                                                          |
| sellTokenPercentageFee                             | Integer | Percentage of commission from the amount of sale tokens, is taken in favor of feeRecipient. (10 = 1%, maximum value is 500).                                                                                                                                |
| rfqOnly                                            | Boolean | <p>If TRUE: use only RFQ providers for routing.</p><p><br><em>Default value</em> : false</p>                                                                                                                                                                |
| excludeAggregator                                  | String  | Exclude some aggregators from routing (add several parameters for multiple exclude).                                                                                                                                                                        |
| includeAggregator                                  | String  | Include some aggregators from routing (add several parameters for multiple include). This parameter cannot be combined with excludedAggregators.                                                                                                            |
| fromChainID<mark style="color:red;">\*</mark>      | Integer | Source/sell blockchain ID                                                                                                                                                                                                                                   |
| toChainID<mark style="color:red;">\*</mark>        | Intger  | Destination/buy blockchain ID                                                                                                                                                                                                                               |
| onchainExcludeAggregator                           | String  | Exclude some aggregators from on-chain routing (add several parameters for multiple exclude).                                                                                                                                                               |
| onchainIncludeAggregator                           | String  | Include some aggregators from on-chain routing (add several parameters for multiple include). This parameter cannot be combined with onchainExcludeAggregators.                                                                                             |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "amount_out_total": "150513308498454",
  "estimate_gas_total": "500000",
  "token_in": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
  "token_out": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
  "gas_price": "17877704887",
  "bridge_fee": "<nil>",
  "fees": null,
  "routes": [
    {
      "type": "dex",
      "protocol_name": "native_polygon",
      "amount_in": "150",
      "amount_out": "150",
      "percent": 100
    }
  ]
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="204: No Content No Content" %}

{% endtab %}
{% endtabs %}

<table><thead><tr><th width="227">Name</th><th width="110.66666666666666">Data type</th><th>Description</th></tr></thead><tbody><tr><td><strong>amount_out_total</strong></td><td><code>str</code></td><td>The amount of purchase tokens in decimals of the token.</td></tr><tr><td><strong>estimate_gas_total</strong></td><td><code>str</code></td><td>The estimated amount of gas that will be used during the transaction.</td></tr><tr><td><strong>token_in</strong></td><td><code>str</code></td><td>Smart contract address of the sale token.</td></tr><tr><td><strong>token_out</strong></td><td><code>str</code></td><td>Smart contract address of the purchase token.</td></tr><tr><td><strong>gas_price</strong></td><td><code>str</code></td><td>Gas price value for a transaction in WEI (nAVAX for Avalanche).</td></tr><tr><td><strong>bridge_fee</strong></td><td><code>str</code></td><td>Bridge protocol fee.</td></tr><tr><td><strong>fees</strong></td><td><code>array</code></td><td>Partner's fee.</td></tr><tr><td><strong>amount</strong></td><td><code>str</code></td><td>The amount of sell tokens in decimals of the token, which will be taken in favor of feeRecipient. The value will be 0 if feeRecipient and sellTokenPercentageFee fields are not specified.</td></tr><tr><td><strong>recipient</strong></td><td><code>str</code></td><td>Wallet address for receiving fees. The commission is paid from the purchase token.</td></tr><tr><td><strong>token</strong></td><td><code>str</code></td><td>Address of fee token.</td></tr><tr><td><strong>routes</strong></td><td><code>array</code></td><td>An array of DEXs the transaction will be carried out through.</td></tr><tr><td><strong>type</strong></td><td><code>str</code></td><td>Liquidity source type.</td></tr><tr><td><strong>protocol_name</strong></td><td><code>str</code></td><td>DEX name the transaction will be carried out through.</td></tr><tr><td><strong>percent</strong></td><td><code>int</code></td><td>The percent of amount will be swapped on the current DEX.</td></tr></tbody></table>

## Transaction allowance

<mark style="color:blue;">`GET`</mark> `v1/{chainID}/transaction/allowance`

Checks how many of the user’s tokens the exchange smart contract has access to.

**Request sample:**\
`https://api.yad.finance/v1/1/transaction/allowance?tokenAddress=0xdAC17F958D2ee523a2206206994597C13D831ec7&walletAddress=0x58f58219e2d2598588c1b457bb6da65c34d99310`

#### Path Parameters

| Name                                      | Type    | Description                                                                              |
| ----------------------------------------- | ------- | ---------------------------------------------------------------------------------------- |
| chainID<mark style="color:red;">\*</mark> | Integer | The ID of the blockchain the token is located on (supported networks - `/v1/platforms`). |

#### Query Parameters

| Name                                            | Type   | Description                                                            |
| ----------------------------------------------- | ------ | ---------------------------------------------------------------------- |
| tokenAddress<mark style="color:red;">\*</mark>  | String | Smart contract address of the token for which access is being checked. |
| walletAddress<mark style="color:red;">\*</mark> | String | Wallet of the user for which access is being checked.                  |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```
{
  "remaining": "11579208923731620000"
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

| Name          | Data Type | Description                                                                     |
| ------------- | --------- | ------------------------------------------------------------------------------- |
| **remaining** | `str`     | The number of tokens in decimals of the token the smart contract has access to. |

## Transaction approve

<mark style="color:blue;">`GET`</mark> `v1/{chainID}/transaction/approve`

Generates transaction input parameters to provide access to the user's tokens for the exchange smart contract.

**Request sample:**\
`https://api.yad.finance/v1/1/transaction/approve?tokenAddress=0xdAC17F958D2ee523a2206206994597C13D831ec7&amount=100000000000&gasPrice=100000000000`

#### Path Parameters

| Name                                      | Type    | Description                                                                          |
| ----------------------------------------- | ------- | ------------------------------------------------------------------------------------ |
| chainID<mark style="color:red;">\*</mark> | Integer | ID of the blockchain the token is located on (supported networks - `/v1/platforms`). |

#### Query Parameters

| Name                                           | Type    | Description                                                                                           |
| ---------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
| tokenAddress<mark style="color:red;">\*</mark> | String  | Address of the smart contract of the token for which the access request is generated.                 |
| takerAddress                                   | String  | Address of user’s wallet which will provide approve. When provided the gas will be estimated exactly. |
| amount                                         | integer | The amount of user tokens to which access is granted. By default - infinite number.                   |
| gasPrice                                       | Integer | Cost of gas for an approve transaction. By default: medium                                            |
| contractAddress                                | String  | Contract that we want to give an approval. If not passed, then the default for chain is used.         |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```
{
  "calldata": "0x095ea7b30000000000000000000000001aaad07998466cd3eb8140827dddb37570be1e63000000000000000000000000000000000000000000000000000000174876e800",
  "gas_price": "100000000000",
  "to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "estimate_gas": "48561"
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th>Name</th><th width="169.66666666666666">Data Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>calldata</strong></td><td><code>str</code></td><td>One of the input parameters for processing a transaction providing access to tokens.</td></tr><tr><td><strong>gas_price</strong></td><td><code>str</code></td><td>Gas price value for a transaction in WEI.</td></tr><tr><td><strong>to</strong></td><td><code>str</code></td><td>Address of the smart contract the transaction should be sent to.</td></tr><tr><td><strong>estimate_gas</strong></td><td><code>str</code></td><td>The estimated amount of gas that will be used during the transaction.</td></tr></tbody></table>

## Get quote for pair

<mark style="color:blue;">`GET`</mark> `v1/quote`

Returns the best exchange offer and input parameters for the transaction.\
\
**Request sample:**\
`https://api.yetanotherdefi.com/v1/quote?fromChainID=1&toChainID=137&fromTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&toTokenAddress=0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063&takerAddress=0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503&amount=150&slippage=10&feeRecipient=0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503&sellTokenPercentageFee=10&rfqOnly=false&skipValidation=true`<br>

#### Query Parameters

| Name                                               | Type    | Description                                                                                                                                                                                                                                                 |
| -------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fromTokenAddress<mark style="color:red;">\*</mark> | String  | Smart contract address of the sale token.                                                                                                                                                                                                                   |
| toTokenAddress<mark style="color:red;">\*</mark>   | String  | Smart contract address of the purchase token.                                                                                                                                                                                                               |
| amount<mark style="color:red;">\*</mark>           | Integer | The amount of sale tokens in decimals of the token (can be taken from the method `/tokens`).                                                                                                                                                                |
| slippage<mark style="color:red;">\*</mark>         | Number  | <p>The amount of slippage allowed during the actual execution of the transaction (10 = 1% slippage). If the price changes by more than this percentage, the transaction will revert. Min = 1 (0.1%), max = 500 (50%).<br><br><em>Default value</em> : 1</p> |
| gasPrice                                           | String  | Gas price value for making a transaction in WEI (nAVAX for Avalanche) (1 GWEI = 1000000000 WEI), default value is the value high from `/gasprices`.                                                                                                         |
| feeRecipient                                       | String  | Wallet address for receiving fees. The commission is paid from the purchase token.                                                                                                                                                                          |
| sellTokenPercentageFee                             | Integer | Percentage of commission from the amount of sale tokens, is taken in favor of feeRecipient. (10 = 1%, maximum value is 500).                                                                                                                                |
| rfqOnly                                            | Boolean | <p>If TRUE: use only RFQ providers for routing.</p><p><br><em>Default value</em> : false</p>                                                                                                                                                                |
| excludeAggregator                                  | String  | Exclude some aggregators from routing (add several parameters for multiple exclude).                                                                                                                                                                        |
| includeAggregator                                  | String  | Include some aggregators from routing (add several parameters for multiple include). This parameter cannot be combined with excludedAggregators.                                                                                                            |
| fromChainID<mark style="color:red;">\*</mark>      | Integer | Source/sell blockchain ID                                                                                                                                                                                                                                   |
| toChainID<mark style="color:red;">\*</mark>        | Intger  | Destination/buy blockchain ID                                                                                                                                                                                                                               |
| onchainExcludeAggregator                           | String  | Exclude some aggregators from on-chain routing (add several parameters for multiple exclude).                                                                                                                                                               |
| onchainIncludeAggregator                           | String  | Include some aggregators from on-chain routing (add several parameters for multiple include). This parameter cannot be combined with onchainExcludeAggregators.                                                                                             |
| takerAddress<mark style="color:red;">\*</mark>     | String  | The address which will fill the quote. When provided the gas will be estimated and returned.                                                                                                                                                                |
| recipientAddress                                   | String  | Percentage of commission from the amount of sell tokens, is taken in favor of feeRecipient. (10 = 1%, maximum value is 500).                                                                                                                                |
| skipValidation                                     | Boolean | <p>If TRUE: skip calldata validation</p><p></p><p><em>Default value</em> : true</p>                                                                                                                                                                         |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "amount_out_total": "244624",
  "estimate_gas_total": "348908",
  "token_in": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  "token_out": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
  "gas_price": "32853665207",
  "bridge_fee": "<nil>",
  "fees": null,
  "routes": [
    {
      "type": "dex",
      "protocol_name": "native_polygon",
      "amount_in": "150",
      "amount_out": "244624",
      "percent": 100
    }
  ],
  "calldata": "0xb6aa8d2d00000000000000000000000047ac0fb4f2d84898e4d9e7b4dab3c24507a6d503000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000096000000000000000000000000000000000000000000000000000000000003b201000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000008900000000000000000000000000000000000000000000000000000000000007c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000604415565b0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000096000000000000000000000000000000000000000000000000000000000003b1ff00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000960000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000096000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000003556e69737761700000000000000000000000000000000000000000000000000000000000000000000000000000000096000000000000000000000000000000000000000000000000000000000003b20000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c0a47dfe034b400b47bdad5fecda2621de6c4d950000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e11c8364F9E5EE0000",
  "to": "0x1AAAd07998466cD3Eb8140827DDdb37570BE1e63",
  "value": "150"
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="204: No Content No Content" %}

{% endtab %}
{% endtabs %}

<table><thead><tr><th width="227">Name</th><th width="110.66666666666666">Data type</th><th>Description</th></tr></thead><tbody><tr><td><strong>amount_out_total</strong></td><td><code>str</code></td><td>The amount of purchase tokens in decimals of the token.</td></tr><tr><td><strong>estimate_gas_total</strong></td><td><code>str</code></td><td>The estimated amount of gas that will be used during the transaction.</td></tr><tr><td><strong>token_in</strong></td><td><code>str</code></td><td>Smart contract address of the sale token.</td></tr><tr><td><strong>token_out</strong></td><td><code>str</code></td><td>Smart contract address of the purchase token.</td></tr><tr><td><strong>gas_price</strong></td><td><code>str</code></td><td>Gas price value for a transaction in WEI (nAVAX for Avalanche).</td></tr><tr><td><strong>bridge_fee</strong></td><td><code>str</code></td><td>Bridge protocol fee.</td></tr><tr><td><strong>fees</strong></td><td><code>array</code></td><td>Partner's fee.</td></tr><tr><td><strong>amount</strong></td><td><code>str</code></td><td>The amount of sell tokens in decimals of the token, which will be taken in favor of feeRecipient. The value will be 0 if feeRecipient and sellTokenPercentageFee fields are not specified.</td></tr><tr><td><strong>recipient</strong></td><td><code>str</code></td><td>Wallet address for receiving fees. The commission is paid from the purchase token.</td></tr><tr><td><strong>token</strong></td><td><code>str</code></td><td>Address of fee token.</td></tr><tr><td><strong>routes</strong></td><td><code>array</code></td><td>An array of DEXs the transaction will be carried out through.</td></tr><tr><td><strong>type</strong></td><td><code>str</code></td><td>Liquidity source type.</td></tr><tr><td><strong>protocol_name</strong></td><td><code>str</code></td><td>DEX name the transaction will be carried out through.</td></tr><tr><td><strong>percent</strong></td><td><code>int</code></td><td>The percent of amount will be swapped on the current DEX.</td></tr><tr><td><strong>calldata</strong></td><td><code>str</code></td><td>One of the input parameters for processing a transaction for tokens exchange.</td></tr><tr><td><strong>to</strong></td><td><code>str</code></td><td>Smart contract address where input parameters should be sent to.</td></tr><tr><td><strong>value</strong></td><td><code>str</code></td><td>ETH value that must be transferred along with the transaction in order for it to be successful.</td></tr></tbody></table>

## List tokens

<mark style="color:green;">`POST`</mark> `v2/tokens/list`

Get a list of tokens with filters and pagination.

**Request sample**

cURL:

`curl -X 'POST' \` \
`'https://api.yetanotherdefi.com/v2/tokens/list' \` \
`-H 'accept: application/json' \` \
`-H 'Content-Type: application/json' \` \
`-d '{ "filter": { "symbols": [ "ETH" ] }, "paging": { "page": 1, "page_size": 100 } }'`

#### Request Body

| Name                                   | Type          | Description                                                                                                                                                                                                                                                                                               |
| -------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filter                                 | object        | <p>Filtering occurs with an 'AND' statement between fields and an 'OR' statement between array elements. </p><p></p><p>For example: chain\_ids\[1, 2], names\[asd] == all tokens where chain\_id is "1" or "2" and name equal "asd". </p><p></p><p>Searching by all text filters is case-insensitive.</p> |
| addresses                              | string array  | Token smart contract addresses.                                                                                                                                                                                                                                                                           |
| chain\_ids                             | integer array | Blockchain network IDs.                                                                                                                                                                                                                                                                                   |
| is\_active                             | boolean       | <p>FALSE = the token is rarely used in exchanges on DEXs</p><p></p><p>If null - get only active.</p>                                                                                                                                                                                                      |
| names                                  | string array  | Full names of tokens.                                                                                                                                                                                                                                                                                     |
| symbols                                | string array  | Abbreviated names of tokens.                                                                                                                                                                                                                                                                              |
| paging                                 | object        | An object for adjusting response sizes.                                                                                                                                                                                                                                                                   |
| page<mark style="color:red;">\*</mark> | integer       | <p>Page number. </p><p></p><p>This parameter can be useful when the total sample size of tokens that meet the criteria from the filter exceeds the page size.</p><p></p><p>Can't be less than 1.</p>                                                                                                      |
| page\_size                             | integer       | <p>Response size. For example, "page\_size": 5 == get 5 tokens that meet the filtering conditions.</p><p></p><p>Max 100. If zero - unlitimited page size</p>                                                                                                                                              |

{% tabs %}
{% tab title="200: OK OK" %}
{% tabs %}
{% tab title="Example" %}

```json
{
  "tokens": [
    {
      "chainId": 1,
      "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "name": "Ethereum",
      "symbol": "ETH",
      "decimals": 18,
      "logoURI": "https://cl.yad.finance/static-files/1i/1/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee/48x48.png",
      "is_active": true,
      "priority": 1,
      "is_rfq_mode": false
    },
    {
      "chainId": 10,
      "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "name": "Ethereum",
      "symbol": "ETH",
      "decimals": 18,
      "logoURI": "https://cl.yad.finance/static-files/1i/10/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee/48x48.png",
      "is_active": true,
      "priority": 1,
      "is_rfq_mode": false
    }
  ]
}
```

{% endtab %}

{% tab title="Schema" %}

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

| Name              | Data type | Description                                                                                                                                                                     |
| ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **tokens**        | `array`   | An array of tokens.                                                                                                                                                             |
| **chainId**       | `int`     | The blockchain network ID.                                                                                                                                                      |
| **address**       | `str`     | The token smart contract address.                                                                                                                                               |
| **name**          | `str`     | Full name of the token.                                                                                                                                                         |
| **symbol**        | `str`     | Abbreviated name of the token.                                                                                                                                                  |
| **decimals**      | `int`     | The number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5.05 (505 / 10 \*\* 2). |
| **logoURI**       | `str`     | A link to the token logo.                                                                                                                                                       |
| **is\_active**    | `boolean` | FALSE = the token is rarely used in exchanges on DEXs.                                                                                                                          |
| **priority**      | `int`     | Recommended priority of a token to be shown to the user, based on the popularity of the token.                                                                                  |
| **is\_rfq\_mode** | `boolean` | TRUE = the token is supported by RFQ providers.                                                                                                                                 |


# Widget

The YAD Widget is your gateway to seamless integration with YAD Finance. Designed as a lightweight version of the YAD Multichain Swap Router, it's tailored to be adaptive across devices, platforms, and interfaces. The beauty of the YAD Widget lies in its simplicity: It can be embedded into your platform swiftly using a preconfigured iFrame.

### Why choose the YAD Widget?

* **Versatility**: Whether you run a platform, website, or even a blog, the YAD Widget is designed to fit right in. Its adaptive design can adjust anywhere between 280 to 1180 pixels in width.
* **Effortless swaps**: Users can perform swaps with the same ease as they would with YAD's main app, all without ever leaving your platform.
* **Monetize your platform**: Set your own commissions and earn from transactions made through your widget.
* **Quick deployment:** The entire process is streamlined to ensure you're up and running in just a few minutes.


# API key management

To optimize your experience and interaction with Yad Finance's platform, it's essential to understand our API key management system. This key not only enhances your access capabilities but also ensures seamless integration for both developmental and production purposes. Below are some crucial details about our API key management:

* **Limited access without a key**: While you can make requests without an API key, the number of requests per second will be limited. This is ideal for developmental and testing phases but not recommended for full-scale production.
* **Obtaining a key**: To get your API access key, simply reach out to us at <partners@yad.finance>.
* **Key integration**: Ensure that the provided key is added to the header of each request using the parameter {"X-API-Key": "\<key>"}.

For partnership inquiries or any other questions, don't hesitate to contact us at <partners@yad.finance>.


# Integration flow

## Widget configuration via URL parameters

To configure your widget, utilize the following URL structure:

```
https://widget.yad.finance/{chainId}/exchange/{symbolFrom}/{symbolTo}?
theme={theme}&
feeRecipient={feeRecipient}&
feePercentage={feePercentage}&
isLockNetwork={isLockNetwork}&
isLockFromToken={isLockFromToken}&
isLockToToken={isLockToToken}
```

In the provided URL structure, various parameters allow for customization and configuration of the widget. The table below breaks down each parameter, providing a description, its default value, and the range of possible values for clarity and easy reference.

<table data-header-hidden><thead><tr><th width="185"></th><th></th><th width="207"></th><th></th></tr></thead><tbody><tr><td><strong>Parameters</strong></td><td><strong>Description</strong></td><td><strong>Default values</strong></td><td><strong>Possible values</strong></td></tr><tr><td><em>chainId</em></td><td>The blockchain network ID.</td><td>1 (Ethereum)</td><td>1 - Ethereum<br>10 - Optimism<br>56 - BSC<br>137 - Polygon<br>250 - Fantom<br>43114 - Avalanche<br>42161 - Arbitrum</td></tr><tr><td><em>symbolFrom</em></td><td>Default sell token symbol or token contract address from selected chainId.</td><td>Native coin of selected chainID.</td><td>You can find more options <a href="https://github.com/Yet-Another-Defi/api-integration#get-v1chainidtokens">here</a> or insert your own token address.</td></tr><tr><td><em>symbolTo</em></td><td>Default buy token symbol or token contract address from selected chainId.</td><td>DAI</td><td>You can find more options <a href="https://github.com/Yet-Another-Defi/api-integration#get-v1chainidtokens">here</a> or insert your own token address.</td></tr><tr><td><em>theme</em></td><td>Dark or Light mode.</td><td>Derived from browser theme</td><td>“dark”, “light”</td></tr><tr><td><em>feeRecipient</em></td><td>Wallet address for receiving fees. The commission is paid from the purchase token.</td><td>null (no fees)</td><td>EVM address (in lowercase or uppercase)</td></tr><tr><td><em>feePercentage*</em></td><td>Percentage of commission from the amount of purchase tokens, taken in favor of feeRecipient.<br><br>*When fees are enabled, the displayed purchase amount will already have the transaction fee deducted.</td><td>0 (no fees)</td><td>(10 = 1%, maximum value is 500)</td></tr><tr><td><em>isLockNetwork</em></td><td>If true, user cannot change selected network.</td><td>false</td><td>true, false</td></tr><tr><td><em>isLockFromToken</em></td><td>If true, user cannot change selected sell token.</td><td>false</td><td>true, false</td></tr><tr><td><em>isLockToToken</em></td><td>If true, user cannot change selected buy token.</td><td>false</td><td>true, false</td></tr></tbody></table>

## Integrating the YAD Widget

To embed the YAD Widget on your website, follow the steps below:

### **Choose your widget type**

**Vertical widget:** Suitable for widths between 280-416 px.

```
<div id="yad-widget">
    <iframe src="https://widget.yad.finance/1/ETH/DAI" title="yad-widget" height="508" width="416" style="border-radius:20px"></iframe>
</div>
```

**Horizontal widget:** Optimized for a width of 1180 px.

```
<div id="yad-widget">
    <iframe src="https://widget.yad.finance/1/ETH/DAI" title="yad-widget" height="212" width="1180" style="border-radius:20px"></iframe>
</div>
```

**Flexible widget:** The widget will automatically adjust its orientation based on the width size. If the width is less than 1180, the widget will display vertically; otherwise, it will be horizontal.

```
<div id="yad-widget">
    <iframe src="https://widget.yad.finance/1/ETH/DAI" title="yad-widget" height="212" width="1180" style="border-radius:20px"></iframe>
</div>
```

### **Implement URL configuration within widget code**

Replace the `src` attribute value in the `<iframe>` tag in the widget-type codes above with the URL structure specifying your chosen parameters, as detailed in the table above.

For vertical and horizontal widgets, replacing the `src` attribute with your preconfigure URL structure is the only necessary step.&#x20;

To complete the implementation of a flexible widget, add the following scripts:

1. In the `<head>` section of your HTML:

<pre><code><strong>&#x3C;script type="text/javascript" src="https://widget.yad.finance/widget.min.js">&#x3C;/script>
</strong></code></pre>

2. At the bottom of the `<body>` section:

```
<script defer> 
    const yadWidget = new YadWidget(); 
    yadWidget.init();
</script>
```


# Security

The design of our architecture maximizes trust and security. Furthermore, we implemented the following measures to attain the safest swap experience for our users.

## Multisignature

Multisignature, or multisig, is a digital signature scheme that requires multiple parties to authorize a transaction or access to funds. In the context of our crypto project, it means that multiple private keys must be used to validate and execute transactions within our smart contracts. By leveraging multisig, we eliminate the reliance on a single private key, which can be vulnerable to unauthorized access or compromise.

### Benefits of Multisignature

Implementing multisignature within our smart contracts brings several key advantages, including:

#### Enhanced Security

Multisig serves as a significant security measure by reducing the risk of unauthorized transactions or malicious activities. Since multiple private keys are required to authorize any transaction, attackers would need to compromise multiple keys simultaneously, significantly raising the bar for potential security breaches.

#### Shared Control

Multisig allows for shared control and decision-making among authorized parties. For instance, in the case of a multi-member organization or a joint account, consensus among the authorized participants is necessary to execute a transaction. This shared control not only distributes responsibility but also minimizes the possibility of a single point of failure.

#### Protection Against Insider Threats

Multisig acts as a safeguard against insider threats. Even if one of the authorized parties turns malicious, collusion with other participants would be required to perform unauthorized actions. This added layer of security reduces the potential damage caused by internal bad actors.

#### Securing Smart Contracts

By integrating multisig across all our smart contracts, we ensure the highest level of protection for the assets and functionalities governed by these contracts. Unauthorized modifications or fraudulent actions become significantly more challenging, as they require the approval of multiple authorized parties.

## No KYC

We are committed to adhering to all applicable legal and regulatory requirements while ensuring that our no KYC policy aligns with the principles of DeFi. While KYC may be necessary in certain traditional financial systems, we firmly believe in providing a secure, privacy-focused DeFi experience that empowers individuals to have full control over their financial activities.

### Benefits of No KYC policy

#### Preserving User Privacy

By not requiring KYC, we prioritize the privacy and autonomy of our users. User identities and personal information are not collected or stored, ensuring a higher level of privacy. Users can freely engage with YAD platform without disclosing sensitive personal data, preserving their financial sovereignty.

#### Reducing Targeted Attacks

Our no KYC policy minimizes the risk of targeted attacks against individuals or centralized databases that typically hold KYC information. Without a centralized repository of user data, the risk of data breaches and the exposure of personal information is significantly reduced.

#### Enhancing Security Through Decentralization

With our no KYC policy, we embrace the decentralized nature of blockchain technology. User information remains distributed across the blockchain network, eliminating a central point of failure that could compromise the security and privacy of our users. This distributed approach enhances the overall security of our DeFi ecosystem.

#### Mitigating Identity Theft

By eliminating the requirement for KYC, we mitigate the risk of identity theft. Users can transact and engage with decentralized financial services without exposing personally identifiable information that could potentially be exploited by malicious actors.

## Non-custodial architecture

YAD is a non-custodial DApp, designed to prioritize user control and security within the decentralized ecosystem. As a non-custodial platform, we ensure that users maintain full control over their assets and private keys. This approach offers several significant benefits in terms of security:

#### Enhanced Asset Security&#x20;

By being non-custodial, we eliminate the need for users to entrust their assets to a centralized third-party entity. Users retain sole ownership and control over their funds, mitigating the risk of theft, loss, or mismanagement associated with traditional custodial services.

#### Reduced Counterparty Risk&#x20;

Our non-custodial approach significantly reduces counterparty risk. Users are not required to rely on a single central entity to safeguard their funds. Instead, they manage their assets directly through their private keys, minimizing the potential for external vulnerabilities or breaches that could compromise their holdings.

#### Protection against Hacks and Breaches

Being non-custodial inherently reduces the attractiveness of our platform as a target for hackers. Since we do not hold user funds, potential attackers have no centralized point to focus their efforts on. This decentralized security model enhances the overall resilience of our platform and safeguards user assets.

#### Privacy and Anonymity

Our non-custodial DApp prioritizes user privacy and anonymity. Users are not required to provide personal information or undergo identity verification, allowing them to engage in transactions without compromising their privacy. This approach ensures that sensitive user data is not susceptible to breaches or misuse.

#### Alignment with Decentralized Principles

Our non-custodial approach aligns with the core principles of decentralization, promoting self-sovereignty and eliminating the need for intermediaries. By empowering users with control over their assets, we foster a more trustless and transparent ecosystem, reducing the dependency on centralized entities.


# Smart contract audit

YAD underwent an in-depth smart contract audit by Scalable Solutions, a renowned entity in the blockchain security sector. With a decade-long tenure in the cybersecurity domain, Scalable Solutions has garnered acclaim in the development of non-custodial wallets, pioneering DeFi protocols, state-of-the-art trading venues, and now in the audit of intricate smart contracts.<br>

To read the audit report in full, a PDF is [available for download](https://main.scalablesolutions.io/security_audit#yad) on Scalable Solutions' website.

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

### Audit Background

The audit’s epicenter revolved around an exhaustive analysis of YAD’s router’s primary smart contracts. This exercise pinpointed several nominal issues, which were duly rectified. These encompassed informational gaps such as undocumented functions in the codebase and three low-priority advisories pertaining to contracts interacting with other aggregators. Additionally, post-swap token dispatch to the correct contracts was brought into the limelight.

The prime intention behind this meticulous audit was to unearth vulnerabilities within the aggregator’s foundational smart contracts and to suggest feasible mitigation strategies. It is imperative to underscore that the smart contracts under review were deemed devoid of exploitable loopholes, validating their robustness against potential adversarial actions.

A notable observation by Scalable Solutions pertained to the Uniswap function encapsulated within a proxy contract, positing a theoretical scenario where an antagonist could emulate the swap. However, in YAD’s architectural design, this proxy contract is not the custodian of the sender’s assets. Consequently, rectifying this would inadvertently inflate the contract's operational costs.

### YAD's Commitment

YetAnotherDeFi (YAD) endeavors to revolutionize the DEX aggregator arena, leveraging a slew of mechanisms. It meticulously curates liquidity data from an array of sources, thereby proffering the most economical quotation. Moreover, it meticulously divides orders across multiple pools to minimize price fluctuations, while concurrently facilitating user-driven slippage thresholds. Complementing this, it rigorously examines market price variations to furnish users with the most streamlined trading pathway.

### Audit Report Overview

The audit undertook an exhaustive evaluation of several project-specific smart contracts crafted to bolster the capabilities of the 0x protocol. These ancillary contracts introduce advanced interfaces, streamlining interactions with decentralized exchanges (DEX). The overarching goal was to assess these contracts in terms of security, reliability, and functional finesse.

#### Scope

The audit encapsulated a detailed assessment of an array of smart contracts:

* SailFlashWallet.sol: Facilitates instantaneous trades by permitting users to loan assets from liquidity providers sans upfront collateral.
* AnyRecipientFeature.sol: Augments token dispatch flexibility, allowing tokens to be sent to any designated recipient.
* SailAdapterFeature.sol: Acts as a bridge, ensuring smooth interactions between the 0x protocol and myriad exchange frameworks.
* SailUniswapV3Feature.sol: Enables harmonization with the Uniswap V3 protocol, enriching liquidity management and diversifying trading strategies.
* SailArbitrumMigration.sol & SailMigration.sol: Streamlines asset migration processes and manages the deployment & feature registration within the 0x protocol.
* SailRFQTransformer.sol: Aids in the RFQ order process, facilitates external contract calls, and offers backup routes during contingencies.

The audit remit encompassed an evaluation of these contracts' codebases, their adherence to industry best practices, and pinpointing potential risks integral to their deployment. This endeavor sought to accentuate the 0x protocol's capabilities, elevating the user's experience in the DEX milieu.

\ <br>


# Further support

How to Request Further Support

If you have some questions about using YAD, feel free to contact us by email:

<support@yad.finance>

If you would like to share feedback, suggestions for improvement, etc., please contact us at this email:

<info@yad.finance>

If you would like to get your custom API key or have some questions about the partnership with us, please use this email:

<partners@yad.finance>


# Glossary

<table><thead><tr><th width="178">Nerd word</th><th>Definition</th></tr></thead><tbody><tr><td><strong>Feature</strong></td><td>These are the essential building blocks of the YAD smart contracts, trusted with user allowances. They are executed in the Proxy context via a delegate-call.</td></tr><tr><td><strong>Flash Wallet</strong></td><td><p>Acting as a secure escrow account, Flash Wallet holds funds for Transformers to work with. Features transfer tokens to these wallets, which in turn delegate calls to Transformers. </p><p></p><p>This secure system ensures Transformers only have access to funds in the Flash Wallet, not user allowances.<br><br>This type of interaction (with the flash wallet between internal smart-contract and trustless transformers) helps to increase security while internal smart contracts interact with transformers.</p></td></tr><tr><td><strong>Multisig</strong></td><td><p>Multisig (short for "Multisignature") is a security feature commonly used in cryptocurrency and blockchain technology. </p><p></p><p>It involves requiring multiple signatures or approvals from different authorized parties to authorize a transaction or access digital assets. By distributing control among trusted participants, multisig enhances security and mitigates the risk of unauthorized or fraudulent activities. </p><p></p><p>This mechanism is widely employed for securing funds in wallets, facilitating governance decisions, enabling escrow services, and smart contract management, among other use cases.</p></td></tr><tr><td><strong>Proxy</strong></td><td><p>The central point of system interaction, handling all entry points. It operates by delegating specific functions to Features, managing the flow and exchange of assets. </p><p></p><p>Each function is handled by a unique implementation contract or "feature". The Proxy's main job is to maintain a map of features and their corresponding contracts, rerouting calls to these through its fallback system.</p></td></tr><tr><td><strong>RFQ</strong></td><td><p>RFQ (i.e., Request for Quote) is a trading mechanism integrated into our swap router. When certain transactions are routed through RFQ, it means that users have the opportunity to obtain a personalized quote from market makers for their specific swap. </p><p></p><p>RFQ brings several advantages, including 0% slippage, which ensures that the trade is executed at the quoted price without any additional costs. Moreover, it provides protection from MEV (Miner Extractable Value) attacks, safeguarding users against potential front-running and other unfair practices.</p></td></tr><tr><td><strong>Transformers</strong></td><td>These contracts extend the core YAD smart contracts. Operating as trustless extensions, Transformers are approved by the Transformer Deployer. Each Transformer is tied to a specific nonce from the Transformer Deployer. Transformers execute their tasks in the context of the Flash Wallet via delegate-call, improving security during interactions.</td></tr></tbody></table>


# Basics


# What is gas price?

Once the transaction is initiated, you'll need to wait for its validation and inclusion to a block. The average time depends on the network congestion and the amount of gas you’ve paid.&#x20;

One can also specify the gas price in the [settings](/getting-started/making-a-swap). This indicator determines how much you’re ready to pay for the gas. The more gas you pay, the faster the transaction will be executed. In some cases speeding up transactions might be useful as it will decrease the risk of slippage.

## What happens if gas price is too low?

If the gas price is set too low, then miners may not be incentivized to include the transaction in the block since they can earn more by including transactions with higher gas prices. In this case, the transaction will remain in the mempool (i.e., a pool of unprocessed transactions waiting to be added to the blockchain) until a miner chooses to include it or until it expires.&#x20;

If a transaction expires, it is reverted and the transaction amount is returned to the user, but the gas fee is burned.

{% hint style="success" %}
To protect our users from having their transaction reverted due to a gas price that is set too low, we constantly monitor the gas price and limit the gas price that users can set for their transactions to prevent them from being reverted.
{% endhint %}


# What is price impact?

{% hint style="info" %}
When a large transaction is executed on a blockchain, it can cause a significant change in the price of the asset being traded. This is called price impact.
{% endhint %}

If the market has a large amount of liquidity, a single transaction is unlikely to have a significant impact on the price. However, if the market has low liquidity, a large transaction can cause the price to move significantly.

{% hint style="warning" %}
If you make a swap with rare tokens for a large amount, it may have a significant price impact.
{% endhint %}

But you don't have to worry, you will know about the impact on the price before you make a swap. In case of a significant price impact, you will see the percentage of influence next to a yellow or red warning triangle.

<figure><img src="/files/uFZGBP97wZhJunFWEH7g" alt=""><figcaption><p>A transaction can cause price impact if the market has low liquidity</p></figcaption></figure>


# What is slippage?

Slippage is the difference between a trade’s expected price and the actual price at which the trade is executed. It occurs because of a lag, since validation and transaction completion take some time, and the exchange rate might change within this period.&#x20;

You can adjust the settings to set a slippage tolerance, thus determining the percentage of negative price changes you’re ready to take. Otherwise, the transaction will not be completed. In this case, you will still have to pay the transaction cost, but the swap will not be executed.

Slippage can be both positive when price change is favorable for users and negative when price change is unfavorable for users.

## What is positive slippage?

Positive slippage for a buyer occurs when a buy order is executed at a price that is lower than the expected price, resulting in a better-than-expected price for the buyer.

However, slippage is generally more common in volatile markets, where prices can move quickly, and liquidity is limited. In more stable markets with high liquidity, slippage is less likely to occur.

## What is negative slippage?

Negative slippage is the opposite: It occurs when a buy order is executed at a price that is higher than the expected price, resulting in a worse-than-expected price for the buyer.

{% hint style="info" %}
To reduce the risk of experiencing significant negative slippage during a swap, you can adjust the slippage tolerance in the swap settings.
{% endhint %}

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


# What is the fee structure?

The YAD platform does not charge any fees on its DEX transactions. However, the YAD DEX-Router directs these transactions through other DEXs like Uniswap, Curve, SushiSwap, 1inch, etc., which can charge fees. The quoted amount provided by the YAD widget includes these fees as part of the total cost.

## How does YAD makes revenue?

YAD earns revenue from keeping a positive slippage on swaps. It is important to note that we start taking it on swaps with a total amount exceeding $200. On smaller amounts, the positive slippage goes to the user completely.

{% hint style="info" %}
To learn more about positive slippage and slippage in general, check out [this page](/knowledge-base/basics/what-is-slippage).
{% endhint %}


