# Understand AshSwap

Overview of AshSwap and the reasons behind it.

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

AshSwap is the pioneer Stable-swap AMM DEX and Auto-Concentrated Liquidity on the MultiversX blockchain.

Robust and decentralized financial infrastructure is inevitably needed for an ecosystem of decentralized applications to thrive. AshSwap aims to become a financial layer powering development on MultiversX Network.

The current AshSwap version features AMM liquidity pools powered by Stable-swap and Concentrated Liquidity algorithms. The next version will transform AshSwap into a powerful exchange providing various trading products.

Our available features:

* Swap
  * Legacy Swap
  * Aggregator Swap with Dynamic Trade Routing
* Liquidity Provision
* Liquidity Stake - Farming
* AshDAO - Governance
  * Governance Stake
  * Farm Boost
  * Farm Weight Voting
  * Proposal Voting
  * Bribe

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

{% embed url="<https://www.youtube.com/watch?v=3CnBNW-R0mE>" %}


# AshSwap Litepaper

## Decentralized Exchange & Stable-Swap

After months of planning, development, and no lack of shadowing, Maiar Exchange was officially launched on the Elrond blockchain, setting the foundation for later Defi development in November 2021. The Elrond team has good reasons to choose a decentralized exchange (DEX) to be Elrond’s first official decentralized application. Any blockchain that supports Defi has to have (decentralized) exchanges to facilitate trading and capital circulation, just like any traditional economy.

Since the birth of Uniswap in 2018, a myriad of automated market makers (AMMs) has been born to serve different trading purposes. For example, trading speculative assets requires a different mechanism compared to stable assets. From this stems various inventions. One of the most noticeable is Curve Finance (Curve), which has a unique design called the StableSwap invariant. Not only does this appearance reduce the slippage to improve liquidity and reduce slippage for trading between assets with stable prices, but Curve has also grown to be ranked first in TVL on Ethereum and existing on multiple blockchains. This has proven that stable-swap decentralized exchanges are one of the most valuable pieces in the decentralized finance (Defi) ecosystems.

These decentralized exchanges have done wonders to the blockchain and cryptocurrency world. In our view, they (not single-handedly) pull the crypto train to its ATH. They, however, are not perfect and suffer from a similar set of problems, namely impermanent loss (IL), capital inefficiency, and governance token inflation. In this paper, we will examine the problems and take a peek at how AshSwap aims to solve them.

![](/files/04uSph5lgvrWI8JfE187)

### Impermanent Loss

> Impermanent loss(IL) occurs as a result of asset rebalancing by the Automated Market Maker(AMM) as prices of the assets(tokens) in an LP position diverge from their starting ratio to each other. IL is the equity loss of an asset in an LP when compared to simply holding said asset by itself.

Any Defi farmer needs to understand the risk to become a liquidity provider. In a world of volatility like crypto, understanding the market dynamics to prevent losses is as important as knowing how to detect opportunities. Different methods have been adopted, but the most prominent one is single-sided liquidity provision; Bancor, Platypus are of this sort.

Fortunately, in the context of stable-swap, IL is not really a huge issue as prices of the assets in the pools are very unlikely to stay out of peg. Platypus has raised a notable point that even though stable assets’ values are similar, their market liquidity is different.

> Impermanent Loss remains < 2% as long as the relative prices of the asset in your LP pair stay within 50% of your entry! *Source:* [*Alpaca Finance*](https://docs.alpacafinance.org/alpaca-academy/lesson-5-the-truth-about-impermanent-loss-and-common-misunderstandings)

It is very unlikely this event (50% change in the relative prices of stablecoins in the pool) will happen. If it does, we crypto community has a much bigger issue to deal with than impermanent loss.

![](/files/vPJj5nK5UqCGijG987b2)

### Capital Inefficiency

AMMs mark a new page in the development of decentralized finance as people now are able to trade their assets in a completely decentralized way. There now are no intermediaries standing between users, only smart contracts, making trading trustless, and cheap. To achieve that, there need to be people who first put up capital to create liquidity and facilitate the trades, hence the name liquidity providers (LPs). This, however, poses another problem of capital inefficiency because a large amount of capital sits idle in those pools waiting to be traded. This leads to either LPs moving their capital around trying to get the most out of it, or their money is stuck in the pool and out of circulation.

![](/files/dFSfXV6kFazk4uMNQFvY)

### Governance Token Inflation

To attract enough capital to make the liquidity pools tradeable, many protocols employ a method named liquidity mining. The name might stem from the mining process of Bitcoin where miners are rewarded when they provide computing power to help run the blockchain. In DEXs, users are rewarded with governance tokens. This is helpful in some cases like if you are bootstrapping your protocol or want to launch an infamous “vampire attack” (what Sushiswap does to Uniswap). Sometimes, the APY for those farms can go up to 5 or 6 figures, but there is no free meal.

The resultant problem is often users end up with so many tokens without anything to do except for voting in unestablished DAOs, so most likely users will dump their tokens in the open market, hurting the project and its investors.

## AshSwap

AshSwap is a decentralized AMM following the stable-swap model built on the Elrond Blockchain. AshSwap uses the same formulas invented by Curve Finance but introduces some new concepts to improve user experience, increase capital efficiency, and create a more robust token model.

**Terms:**

* ASH: the governance token of AshSwap
* veASH: vote-escrow ASH, a concept of Curve. AshSwap does not have any voting mechanism at the beginning, but we keep the naming convention for the sake of consistency.

### 1. Trading Fee

No project wants users to sell their tokens, so they either lock tokens (for seed or private sales), or direct users to staking. By doing so, a part of the token supply will be taken out of circulation and reduce sell pressure. The staking use case is likely to create the inflation problem that will be considered in the latter part of the paper, so we need to have a more sustainable incentivization mechanism.

AshSwap divides the fees collected into 2 parts. 50% will go to the LP token holders where the trades were performed and the other half will go to veASH holders. This encourages users to stake the governance token to earn parts of the revenue of the protocol.

![](/files/X8971iFrR4b83hAwVa5V)

### 2. Liquid Liquidity Provision

Liquid Liquidity Provision (LLP) is a new concept that AshSwap introduces in which users do not have to give up their liquidity but exchange it instead. This also adds more use cases to the ASH token and increases revenue for both LPs and AshSwap. Sounds good? But how does it work?

#### Collateralized Stablecoin

One of the most prevalent forms of stablecoins is crypto-back stablecoin. Some examples are DAI (MakerDAO) and MIM (Abracadabra.money). Because the underlying collateral is speculative assets, a prerequisite in those protocols is liquidation. When the underlying assets fell under a certain price, liquidators will step in, liquidate the position, burn some of the stablecoins to keep their pegs.

The most recent crash (January 2022) in crypto witnessed a very big liquidation of 600 million being liquidated on MakerDAO, causing the price of ETH to crash by a few hundred dollars in a matter of hours as all of the collateral was sold on the open market. And history shows that there were times the liquidation failed to work if the price falls too low, too fast. Also, liquidator bots are software and sometimes they do fail.

`AshSwap does not eliminate the possibility of having this kind of operation in the future, but a lot of research and considerations are needed to make sure things work.`

#### Introduce a new Stablecoin

LP tokens of stable-swap exchanges have a very unique characteristic that at the end of the day, the collateral’s underlying value does not change much. Leveraging this, AshSwap allows users to mint a new type of stablecoins - `AOC` - using their LP tokens as collateral. This means users can provide liquidity to the DEX, receive the same amount of stablecoin, and put them to work to get yield in other protocols.

One question arises from such an act, who will be entitled to the trading fee rewarded to the LP tokens? It’s the users, in one way or another.

#### Speculate on LPs

When a user decides to mint AOC, he has to pay a maximum amount of 1% fee in the form of ASH tokens, but he has the right to choose how much ASH fee he wants to pay. The fee will be proportional to the percentage of the trading fee of the LP he decides to share with AshSwap.

If he is a hard-core farmer and wants to earn yields for a long time, he should pay all the 1% ASH fee, double his asset, and double (depending on the effectiveness of his decisions) his yields. The fee will then be used to reward ASH stakers or burned to make the ASH token scarce.

On the other hand, if he only needs AOC for a short while and the 1% fee makes it not worth it, he can give part (or all) of the trading fee to AshSwap during that time to reduce the fee. The trading fee will be used to buy back ASH on AMMs (like Maiar) and distribute to ASH stakers or burned.

In either case, the ASH holders, the speculator, and AshSwap all win.

#### AOC Adoption

Let’s take an example.

`Alice needs AOC, and she has 200 USDC. Alice can go to USDC/USDT pool, swap 100 USDC to 100 USDT, add liquidity, and use the LP as collateral and mint 200 AOC while giving a 100% trading fee to AshSwap. Although there are quite some actions needed, the whole process can be simplified as a simple swap from 200 USDC to 200 AOC.`

By swapping to AOC, Alice gives AshSwap $200 worth of fee-bearing LP tokens. The fee will then be swapped to ASH and distributed to other ASH holders in one way or another. This means the more AOC gets used, the more LP tokens AshSwap has, creating a positive feedback loop that benefits all the people involved.

#### Listing Partnership

In the future, many projects will be listed on Maiar Exchange against stablecoins like USDC. If there are 100 projects, and each project has a liquidity pool that is worth 1 million dollars, it’s 50 million dollars worth of stablecoins put in 100 pools.

Instead of adding stablecoins straight to the pool, 50 million can be added to the stablecoin pool of AshSwap. The LP tokens are given to AshSwap to mint 50 million AOC (either pay ASH fee or not) which is then used as liquidity on Maiar Exchange. This brought benefits to all parties:

* AshSwap pool’s liquidity is deepened, traders can trade larger volumes with less slippage
* AshSwap receives some LP tokens, thus increasing its revenue
* veASH holders have more yields
* Projects still have token/stablecoin pool while enjoying the trading fee & ASH farming reward. Projects and AshSwap can also be coordinated to give them a better rate than normal LPs.

### 3. Social Mining

In a normal liquidity mining model, users are rewarded with governance tokens and trading fees for providing liquidity. The amount of reward they can get is proportional to the capital they put in. This is good for people with big wallets, but for retail investors with three figures in their account, juicy yield farming might not be able to cut it. Yet retail has many powers that have not been mined (or rewarded), such as enthusiasm and network effects.

To incentivize retail, we want to integrate multiple products into our ecosystem that do not require users to put up a large amount of capital but still provide good rewards.

#### Gaming

Exchanges have a great utility in Defi, there is no doubt about that, but they have trouble keeping the users. Users often come to the exchanges to trade or check their rewards. To be fair, exchanges are not that fun to hang around. AshSwap since the very beginning has always wanted to counter this; we want to create an exchange that is not only useful but also easy and fun to use.

Gaming is very well suited for this job. Anyone who wants to contribute to the product and wants to earn some rewards on performing some actions to complete quests provided by AshSwap. These quests can be dropped announced or unannounced, so who wants to play has to pay attention. This helps increase the engagement and the network effects of the product.

Nevertheless, there’s one problem with this. Because we pay users to perform such actions, we do not know for sure if someone would create thousands of wallet addresses and spam the game for reward. Thanks to blockchain and NFTs, we have the solution.

#### NFTs

At some point in the near future, we will allow users to mint NFTs. Owning these NFTs means you are a part of AshSwap community and earn your rights to participate in our activities like Gaming, and later Governance (will be revealed later).

NFTs projects often find it hard to add use cases to their NFTs. JPEGs and art are all good, but when NFTs are embedded in a strong ecosystem with multiple use cases, it can go a longer way.

![](/files/xuw0jlQYAdLgCRa8Od8x)

### 4. Roadmap

{% content-ref url="/pages/SHiAzjwdDcq0ZslMRxkS" %}
[AshSwap Roadmap](/getting-started/ashswap-roadmap)
{% endcontent-ref %}


# AshSwap Tokenomics

Last update: Oct 10th, 2022

### Token Metrics

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

* 10% of ASH tokens were issued for a Private Sale and 100 million tokens will be sold to strategic and financial investors.
* 7% of ASH tokens were sold during our Public Sale on Maiar Launchpad.
* The Farming allocation is 38% and will be reserved for Farming rewards.
* The Liquidity allocation is 15% and will be used for providing liquidity to the pools on our protocol.
* The Community allocation is 8%, which is mainly dedicated to the adoption and growth that the projects will need throughout the entire journey.
* 2% of ASH tokens will be reserved for Advisory shares, to key ambassadors, advisors, and partners who participated in the development of Ashswap.
* 15% of ASH tokens will be allocated to the Team, it incentivizes the current and future team members for their determination and engagement in revolutionizing the Elrond Blockchain by rewarding them; this allocation will be fully unlocked in 4.5 years.

### Use of funds

The AshSwap team plans to allocate the proceeds of the ASH token sale as follows:

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

All funds are held in a multisig cold wallet controlled by the core team. Any movements of funds require at least 3 out of 4 signatures from the management & security team.

### Unlock & Vesting

To have a better look over the detailed vesting schedule, [click here](https://docs.google.com/spreadsheets/d/1Ty37h2Zuprx8RecnujQsaxNSEPTDpNsCky9J4JNYwXo/edit?usp=sharing).

AshSwap will implement an unlocking and vesting mechanism to create a safe and trusted investment environment. This will open up clarity for the following investors involved and also demonstrate the commitment of the partners already involved in AshSwap. You can check the details of the token vesting schedule below.

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

### Circulating Supply Graph

This graph intends to showcase the initial distribution of the ASH token at its launch and throughout its lifecycle.

<figure><img src="/files/4ocMzYNFQNHN606BzNX3" alt=""><figcaption></figcaption></figure>

**$LKASH 101:**

* $LKASH tokens are non-transferrable.
* Can be exchanged for $ASH with a 1:1 ratio after 3 months counted from the TGE.
* Can be used for adding liquidity and farms.
* Can't be used for [`meta-staking on Maiar Exchange`](https://maiar.exchange/metastaking).


# AshSwap Fees

### Deposit/Withdraw

The fee is zero if you want to withdraw or deposit tokens with an ideal amount.

### Swap

| Pool           | Fee                                     |
| -------------- | --------------------------------------- |
| USDC-USDT-BUSD | 0.05%                                   |
| BUSD-WEGLD     | 0.2% -> 0.4% (based on pool's reserves) |
| USDT-ASH       | 0.2% -> 0.4% (based on pool's reserves) |
| Other pools    | 0.05%                                   |


# AshSwap Roadmap

We will update our progress here

## **2023:**

### Q1 & Q2:

* AshDAO - ✅
* Concentrated Liquidity Pools - ✅
* Mainnet Launch - ✅
* Bribe - ✅
* Lending / Liquid Staking Pools - 🛠 In Progress

### Q3:

* Aggregator V2
  * Backend is written in Rust
  * Multiple types of concentrated liquidity & limit orders support
* Perpetual Futures Exchange Devnet
* Liquidity Protocol Devnet

### Q4:

* Enhanced Aggregator integration
* AshSwap Rebranding
* NFT Loyalty Program
* Perpetual Futures Exchange Audit and Mainnet
* Liquidity Protocol Mainnet

### Ongoing R\&D

* Leveraged Trading
* Derivatives
* Decentralized Stablecoin
* Sovereign Shard
* NFTs & Gamification

## **2022:**

### Q1:

* Litepaper Publishing ✅
* All features on Testnet ✅
  * Swap ✅
  * Liquidity Provision ✅
  * Liquidity Staking (Mining) ✅
  * Governance Staking ✅

### Q2:

* Testnet yield contest - Battle of Yields version AshSwap ✅
* Update UI UX of features on Testnet ✅

### Q3:

* New feature: Yield Boost ✅
* AshSwap API ✅

### Q4:

* Private Sale ✅
* AshSwap Battle of Yields - Round 2 ✅
* TGE (Token Generation Event) ✅
* Maiar Listing - Public Sale ✅


# AshSwap Token

ASH token and how it works within the AshSwap Protocol and Platform.

### Native Token - ASH

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

ASH is the native token of AshSwap. It serves as the entry for extended features and incentivizes liquidity providers on the platform.

**ASH Token Utility:**

* **Revenue Sharing**
* **DAO Voting Right**
* **Farming Yield Boosting**
* **Stablecoin Minting Fee (coming)**

This helps:

* Reduce selling pressure & create constant buying pressure
* Bring benefits to long-term holders
* Create revenue stream

{% embed url="<https://explorer.multiversx.com/tokens/ASH-a642d1>" %}
ASH Contract on MultiversX
{% endembed %}

By locking ASH for a certain amount of time in Governance Staking, users get veASH in return and have multiple benefits.

### Obtaining ASH

* ASH can be obtained by participating in Liquidity Staking (Farming) program on AshSwap and Metastaking program on xExchange.
* ASH is currently listed on [**xExchange**](https://xexchange.com/swap) (ASH/EGLD) and AshSwap’s concentrated liquidity pool (ASH/USDT).

{% content-ref url="/pages/RpJksuZNaqoprGWOmXLS" %}
[Governance - AshDAO](/ashswap-dex/governance-ashdao)
{% endcontent-ref %}

### Governance Token - veASH

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

ve stands for Voting Escrow, a system for temporarily locking up tokens (such as veCRV for Curve; or veASH for AshSwap). Take veASH as an example, the veToken serves the following purposes:

* Earn 50% of the trading across all pools on the exchange[AshSwap Litepaper](/getting-started/understand-ashswap/ashswap-litepaper)
* Be able to [boost farming yields](/ashswap-dex/governance-ashdao/farm-boost), by up to 250%
* Have Voting Power in AshDAO in which users can participate in governing specific metrics in AshSwap products<br>
* [Earn Bribe](/ashswap-dex/governance-ashdao/bribe) while voting in AshDAO

{% hint style="info" %}
As AshSwap evolves and more products are developed, veASH holders will continue to benefit from those greatly.
{% endhint %}

[How to claim trading fees](/ashswap-dex/governance-ashdao)


# Understand AshPerp

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

AshPerp is the first decentralized perpetual trading platform on the MultiversX network, developed as a DeFi module alongside AshSwap. It offers high-leverage trading (up to 100x), supports various asset pairs, and aims to meet the demand for decentralized futures trading on MultiversX.

{% content-ref url="/pages/JXML7tD0UAygRvnUadEh" %}
[Why AshPerp?](/getting-started/understand-ashperp/why-ashperp)
{% endcontent-ref %}

{% content-ref url="/pages/05FNJ8cYr3ixYRKWhFk0" %}
[AshPerp Key Technologies](/getting-started/understand-ashperp/ashperp-key-technologies)
{% endcontent-ref %}

{% content-ref url="/pages/HyAqZQ9WOK4gHX0tqmRu" %}
[How AshPerp Works](/getting-started/understand-ashperp/how-ashperp-works)
{% endcontent-ref %}

{% content-ref url="/pages/2nDgIO073ec16pfuapC4" %}
[AshPerp Terms](/getting-started/understand-ashperp/ashperp-terms)
{% endcontent-ref %}


# Why AshPerp?

<figure><img src="/files/6p1tgcRubn4SpvHcqC5z" alt=""><figcaption></figcaption></figure>

### The First Perpeptual DEX on MultiversX

As reported by [Token Terminal](https://tokenterminal.com/terminal/markets/derivatives), major Decentralized Perpetuals DEXs have recorded over $1.5 billion in trading volumes, generating nearly $700k in fees daily. The realm of Derivatives and Perpetual Trading stands out as one of the most growing sectors within the DeFi ecosystem.On MultiversX network, AshPerp stands as the first protocol to introduce this approach. This pioneering position signifies our innovation and leadership in the MultiverX DeFi space, which offers traders the advantage of early adoption.

### The One-stop DeFi Hub on MultiversX

* AshSwap aims to become a comprehensive MultiversX One-stop DeFi Hub, where users can fulfill their DeFi journey with our top-notch set of products, including Stable-swap, Liquidity Mining, DAO, and now Perps DEX.
* A value-added ecosystem for ASH tokens and veASH holders

### Technical Advances

* **Fully** **Decentralized Trading**
  * AshPerp operates as a fully decentralized platform, enabling traders to open long and short positions via smart contracts. This means it's **YOUR TRADE, YOUR DECISION.** We are unable to make any alterations to your active trades without your approval through the smart contract, except for the cases where your position requires liquidation.
  * Self-custody offers traders autonomy and control over assets, bolstering security and transparency. By minimizing reliance on third-party custodians, traders gain clearer insights into their portfolio while enhancing overall control and security. This approach provides a solid foundation for navigating the complexities of financial markets.
* **Synthetic Approach to Support Multiple Assets and High Leverage**
  * Leverages on AshPerp are based on USDC collaterals and synthetic by Perpetual Vault, which means we do not require the underlying tokens in multiple-assets liquidity pools. This unique feature makes AshPerp versatile and suitable for MultiversX, especially where on-chain crypto assets are limited.
  * Traders can access high-leverage trading opportunities across diverse asset classes. This level of leverage allows traders to amplify their potential returns and diversify their asset portfolio effectively.
* **Safe Vault Operation**
  * The Perpetual Vault will absorb 70% of negative P\&L and borrowing fees. The remaining portion is allocated to the insurance fund, serving as a protective layer in the event of significant positive P\&L. This approach helps to stabilize the value of apUSDC, preventing a downward trend.
  * The insurance fund is overseen by admin who can make deposits into and withdrawals from the Vault at any time to maintain a healthy and well-functioned Vault. Withdrawn funds can be utilized in various advantageous strategies, including ASH buy-back, depositing in treasury, and allocating resources for product R\&D.
  * To make a withdrawal from the Vault, users must submit a request, followed by a 7-day cooling-off period and a subsequent 2-day redemption window. Although this schedule is subject to change, users have the option to instantly exchange apUSDC at market rates on AshSwap.


# AshPerp Key Technologies

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

### Synthetic Architecture

Makes AshPerp more capital-efficient and allows for low trading fees and a wide range of leverages and pairs for perpetual trading.

* Leverage: AshPerp enables users to trade assets with leverage of up to 100x (crypto) (leverage on other assets will be updated).
* Asset Support: AshPerp allow users to trade on a wide range of cryptocurrency pairs. We also plan to include forex, non-native tokens on MultiversX, and other securities in the future.

### Perpetual Vault

The vault serves as the counterparty to all trades made on the platform:

* When traders win (positive PnL), their winnings are received from the vault.
* When traders lose (negative PnL), their losses are sent to the vault.

{% content-ref url="/pages/m0BCZmnjOjjM4ARMuQHk" %}
[Perpetual Vault](/ashperp/perpetual-vault)
{% endcontent-ref %}

### Matching Bots

* Matching bots get prices from the oracle bots and execute Limit, Stop Limit, Take Profit, Stop Loss, and Liquidation orders. You can collaborate to strengthen the legitimacy and credibility of AshPerp, but please keep in mind that operating a Matching bot entails using EGLD to cover transaction fees.

### One-Click Trading (1CT)

* One-click trading (1CT) enhances the trading experience by automating the process of modifying orders or positions with linked triggers, allowing users to enjoy the seamless and high-performance trading typical of centralized exchanges (CEXs) while maintaining self-custody.&#x20;
* By eliminating the need to sign multiple transactions for each modification, 1CT offers near-instant trade execution, reducing the hesitation and delays associated with waiting for transaction approvals. This innovation replicates the ease and efficiency of trading on CEXs, fostering a more intuitive and confidence-inspiring trading environment.

{% content-ref url="/pages/uIulu6VI27N5wJWZVTOj" %}
[One-click Trading (1CT)](/ashperp/one-click-trading-1ct)
{% endcontent-ref %}


# How AshPerp Works

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

* Trades are opened with USDC collateral, regardless of the trading pair.&#x20;
* The leverage is synthetic and backed by our Vault. USDC is taken from the vault to pay for the traders’ profits or sent to the vault if the PnL is negative.

{% content-ref url="/pages/joSQfuxEM8ubYNU7gSjP" %}
[AshPerp Oracle](/getting-started/understand-ashperp/ashperp-oracle)
{% endcontent-ref %}

{% content-ref url="/pages/m0BCZmnjOjjM4ARMuQHk" %}
[Perpetual Vault](/ashperp/perpetual-vault)
{% endcontent-ref %}

## Trading Parameters

| Parameter              | Metric  |
| ---------------------- | ------- |
| Min Position Size      | 1000    |
| Max Collateral         | 5000    |
| Max OI                 | Dynamic |
| Min Leverage           | 2       |
| Max Leverage           | 100     |
| Max Positions per Pair | 3       |
| Maximum SL             | 80%     |
| Maximum TP             | 900%    |

## Trading Flow

Currently, AshPerp only supports those types of orders:

* **Market:** To be used to open a trade immediately. It will open at the market price + spread.
* **Limit**: To be used when you want to go long at a lower price than present, or to go short if the price reaches a higher price than present. The execution price is the determined limit price + spread.
* **Stop:** To be used when you want to go long if the price reaches a higher price than present, or to go short if the price reaches a lower price than present. You might want to use this to long a breakout, or short a breakdown. The execution price is the determined stop price + spread.

### Open a market order

* When a user creates a market order, their order is sent to the AshPerp’s servers.
* The price will be fulfilled off-chain via our oracle system, and the fulfilled order is sent to the trading contract afterwards.
* A small fee will be charged for opening an order.

### Open a limit / stop order

* Users initiate a trade by sending their order to the Trading Contract and paying the associated gas fee. Our Matching bots then receive the order and wait until the price aligns with the user's specified price.
* When the price meets the user's criteria, the Matching bots sign off on this price and forward it to the Trading Engine. The Trading Engine, in turn, contacts the oracle bots to gather their signatures and confirm the price. Following this verification, the Trading Engine proceeds to submit the transaction to our Trading Contract. Before opening the order, the Trading Contract conducts a final verification of the price.
* A small fee will be charged for opening an order.

### Close an order

* When a user closes their order, the close order awaits fulfillment through the price feed system, after which the callback is triggered to officially close it.
* A small fee will be charged for closing an order.

### Update Take Profit / Stop Loss Price

* Users can modify the take profit (TP) or stop loss (SL) price of an order, and the new parameters will be stored in the contract.

### Take Profit / Close Stop Loss

* When an order reaches the take profit or stop loss condition, Matching bots will initiate the order and submit a request to our system to **close the order**.
* When the price meets the TP/SL price, the Matching bots sign off on this price and forward it to the Trading Engine. The Trading Engine, in turn, contacts the oracle bots to gather their signatures and confirm the price. Following this verification, the Trading Engine proceeds to submit the transaction to our Trading Contract. Before opening the order, the Trading Contract conducts a final verification of the price.
* A small fee will be charged for closing an order.

### Adjust Leverage

* Adjusting the leverage of your order keeps the position size constant; only the amount of collateral is altered to match the new leverage setting. Currently, AshPerp permits only a reduction in leverage. To lower the leverage, traders must add a proportional amount of collateral to the position.
* This adjustment in collateral affects the Liquidation Price accordingly.

### Liquidations

* When an order reaches the liquidation price, Matching bots will initiate the order and send a request to our system to **liquidate the order**. The Liquidation Price Distance is calculated as follows:

$$
LiquidationPriceDistance=\frac{OpenPrice\*(Collateral\*90%-BorrowFee)\*Leverage}{Collateral}
$$

* The **liquidation price** is determined as follows:
  * For Long positions: Open Price - Liquidation Price Distance
  * For Short positions: Open Price + Liquidation Price Distance.
* When the price meets liquidation price, the Matching bots sign off on this price and forward it to the Trading Engine. The Trading Engine, in turn, contacts the oracle bots to gather their signatures and confirm the price. Following this verification, the Trading Engine proceeds to submit the transaction to our Trading Contract. Before opening the order, the Trading Contract conducts a final verification of the price.
* A small fee will be charged when your order is liquidated.


# AshPerp Oracle

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

We currently use services provided by [Pyth Network](https://twitter.com/PythNetwork'), a reputable and widely-used oracle source across numerous blockchains, offering reliable data. Nevertheless, to ensure continuity in case of maintenance or downtime at Pyth, we also maintain an alternative system that involves fetching prices from centralized exchanges. This dual approach ensures consistent and accurate price fetching, bolstering our system's resilience and reliability.

* Each of the oracle nodes take the median price from **10** **CEX APIs** (Binance, Bitfinex, [Crypto.com](http://Crypto.com), Gemini, Huobi, Kraken, OKX, Crypto-compare, Gate, and MEXC) and send the result to the aggregator contract. For each median price it receives from our nodes, the aggregator contract double-checks with the corresponding Hatom Price Feed to filter for outliers.
* If there is a difference of more than a certain threshold (10%), it rejects the node answer and waits for the next answer. Once the prices reach proper condition, the aggregator takes the median price again and sends the final result to the trading contract to execute the order.

### Lookback

**Lookback** empowers AshPerp to retroactively examine recent price data instead of solely relying on the current price data.

1. **Guaranteed Orders:** This feature ensures that all limit, stop, stop-loss, and take-profit orders are executed at the price determined by the trader. The only exception is in cases of market gaps during open/close times, where it uses the first available post-gap market price.
2. **Zero Slippage Market Orders:** Market orders now utilize the exact price from the transaction's timestamp, eliminating the slippage that previously occurred due to oracle latencies relying solely on the current price.
3. **Guarding Against Volatility and Chain Disruptions:** This feature guarantees that orders are executed at the correct price, even during periods of chain congestion or potential chain downtime. It protects traders from missed orders and price volatility.


# AshPerp Fee

### Fee Structure

Latest updated: May 30, 2024

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

AshPerp fee structure includes:

* Open market fee: 0.05% OI
* Close TP/SL fee: 0.05% OI
* Liquidation fee: 5% of collateral
* Close market fee: 0.05% OI

{% content-ref url="/pages/1LgEPYAJgKNjowbEwEKA" %}
[Borrowing Fee](/getting-started/understand-ashperp/ashperp-terms/borrowing-fee)
{% endcontent-ref %}


# AshPerp Terms

Explain the new terms on AshPerp

{% content-ref url="/pages/1LgEPYAJgKNjowbEwEKA" %}
[Borrowing Fee](/getting-started/understand-ashperp/ashperp-terms/borrowing-fee)
{% endcontent-ref %}

{% content-ref url="/pages/ypQ0sN7LWbUgdopxVlIt" %}
[Spread](/getting-started/understand-ashperp/ashperp-terms/spread)
{% endcontent-ref %}

<table><thead><tr><th>Terms</th><th>Explanation</th><th data-hidden></th></tr></thead><tbody><tr><td><strong>Market Order</strong></td><td>An order to buy or sell a perpetual contract at the current market price, executed immediately.</td><td></td></tr><tr><td><strong>Limit Order</strong></td><td>An order to buy or sell a perpetual contract at a specific price or better. It is only executed when the market reaches the specified price.</td><td></td></tr><tr><td><strong>Open Interest (OI)</strong></td><td><p></p><p>Open interest is a critical metric that helps traders and analysts gauge market activity and sentiment. It represents the total number of outstanding contracts that have been entered into but not yet closed or settled by an offsetting trade. In other words, open interest tells you how many active positions exist in the market.</p><ul><li>When a trader opens a new long position, it increases open interest by one.</li><li>When a trader opens a new short position, it also increases open interest by one.</li><li>When a trader closes an existing position (either long or short), it decreases open interest by one.</li></ul></td><td></td></tr><tr><td><strong>Liquidation</strong></td><td>When a trader's position is forcibly closed by the exchange due to insufficient margin to cover potential losses.</td><td></td></tr><tr><td><strong>Margin</strong></td><td>The collateral or initial deposit required to open and maintain a leveraged position in a perpetual contract.</td><td></td></tr><tr><td><strong>Leverage</strong></td><td>The use of borrowed funds to increase the size of a trading position, allowing traders to amplify potential profits or losses.</td><td></td></tr><tr><td><strong>Positions</strong></td><td><p></p><p>In perpetual trading, traders can take either long or short positions.</p><ul><li>A <strong>long position</strong> means a trader is buying the perpetual contract with the expectation that the underlying asset's price will rise, allowing them to profit.</li><li>A <strong>short position</strong> means a trader is selling the perpetual contract with the expectation that the underlying asset's price will fall, enabling them to profit.</li></ul></td><td></td></tr><tr><td><strong>TP/SL Order</strong></td><td><p></p><ul><li><strong>Take Profit Order:</strong> A predetermined price level at which a trader intends to automatically close a position to secure profits.</li><li><strong>Stop-Loss Order:</strong> A predetermined price level at which a trader intends to automatically close a position to limit losses.</li></ul></td><td></td></tr><tr><td><strong>Oracle</strong></td><td>A trusted source of external data, often used to provide price information for derivatives contracts on DEXs.</td><td></td></tr></tbody></table>


# Borrowing Fee

## **Understanding Borrowing Fees**

Borrowing fees apply to positions with the highest open interest in a trading pair. For instance, consider a scenario where there is $10 million in long open interest and $5 million in short open interest. In such a case, only the long positions are subject to borrowing fees, while the short positions incur no fees.

### Advantages

1. **Improved Protocol Efficiency:** This fee model guarantees 100% efficiency by adding borrowing fees directly to the vault's PnL, enhancing the protocol's financial health.
2. **Stronger Vault Security:** Borrowing fees reinforce vault over-collateralization, boosting safety for liquidity providers' capital.
3. **Incentivized Exposure Management:** The fee model discourages excessive exposure by imposing negative incentives, promoting cautious trading behavior.
4. **Advanced Risk Management:** By analyzing individual pairs and correlated assets, the fee framework effectively mitigates overall platform risk.
5. **Increased Revenue Potential:** Aligning fee structures optimizes revenue by leveraging open interests and trading volume scaling.
6. **Enhanced Scaling:** Better management of price exposure risks enables higher maximum open interests without increasing TVL, facilitating smoother scaling.

## **Borrowing Fee APR**

The Borrowing Fee APR is calculated to determine the fee for borrowing in a specific trading pair or a correlated group of pairs, assuming the vault is utilized to its maximum capacity. The formula is:

$$
BorrowingFee APR=\frac{VolatilityFactor}{MaxVaultExposure} \*MarketFactor
$$

Where:

* **Volatility Factor**: This is the volatility coefficient. A higher volatility implies a more expensive borrowing rate.
* **Max Vault Exposure (%)**: This index reflects the system's asset resilience, indicating the amount of assets available to cover traders' profits. If this value is low, Borrowing Fee APR tends to be higher, and vice versa.
* **Market Factor**: Within a group, this index is determined by looking at how the volatility of pairs within that group is correlated. It helps reduce the Borrowing Fee APR at the group level, enabling more trading activities within popular or divergent groups, ultimately fostering increased trading efficiency.
  * If pairs are more similar, the index is higher, and vice versa.&#x20;
  * The index for a pair always remains at 1.

From the Borrowing Fee APR, the **Borrowing Fee Per Hour (%)** can be computed by taking into account the Net OI and Max OI of an asset pair/group.

$$
BorrowingFeePerHour (%) = \frac{BorrowingFeeAPR(%)}{8760} \* \frac{NetOI}{MaxOI}
$$

The **Hourly Borrowing Fee** that has to be paid per hour can be calculated as follows:

$$
HourlyBorrowingFee = BorrowingFeePerHour(%)\*PositionSize
$$

## Pair Borrowing Fee

* The borrowing fee is only charged on the dominant side of an asset pair. For example, if the total OI (Long) of BTC/USD is higher than that of Short positions, traders that placed Long orders have to cover the borrowing fees.

## Group Borrowing Fee

> <mark style="color:blue;">**It's essential to emphasize that each trading pair is uniquely assigned to only one group.**</mark>

* We categorize asset pairs into groups:
  * Group 1 (BTC, ETH)
  * Group 2 (EGLD)
  * Group 3 (SOL)
* The Net OI across all asset pairs is used to determine which side (Long or Short) incurs the borrowing fees. The logic is similar to Pair Borrowing fee

## Final Borrowing Fee

* The final borrowing fee paid by the user at any point in time is determined by the maximum of the pair borrowing fee and the group borrowing fee.
* **For example, consider these statistics:**

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

* **Pair Borrowing Fee** has to be paid by traders taking Long positions (because the Long OI is higher for BTC/USD pair)
* **Group Borrowing Fee**, however, has to be paid by traders taking Short positions (because the Net OI shows that there are more Short OI than Long OI in group 1)

All in all, both sides (Long and Short) have to pay for borrowing fees in this case.

* The borrowing fee accrues each time a block is processed. Consequently, if you're incurring a borrowing fee, the longer your order remains active, the greater the accumulated fee becomes. Please pay attention to the **Hourly Borrowing APR** on the trading interface and adjust your strategy to avoid exorbitant borrowing fees.


# Spread

## Fixed Spread

The implementation of spreads serves to deter the manipulation of oracles, enabling the exchange to include tokens with lower market caps.&#x20;

Note that the spread differs across each trading pair, with those having lower liquidity, particularly smaller pairs, experiencing larger spreads. Consequently, using an NFT is particularly more effective for these types of pairs.

## Dynamic Spread

Dynamic Spread is an additional charge over the fixed spread for a pair, if it exists. This variable spread depends on factors such as the open interest in the pair, the size of the trade being executed, and whether the trade is a long or a short.&#x20;

The primary aim of this parameter is to mitigate the risk of manipulation in spot oracle prices, thus facilitating the inclusion of pairs with lower liquidity than previously possible.&#x20;

The impact of this price change will vary for each pair and will differ based on the trade direction, whether it's a long or a short. For each trading pair, there are two key parameters to consider: the 1% depth above market price for long positions, and the 1% depth below market price for short positions.

$$
Dynamic Spread(%)=\frac{OI(long/short)+\frac{NewTradeOI}{2}}{1%Depth(above/below)}
$$

This means that the initial price for any trade will match the current market price of the pair. However, this price might be slightly increased for trades aiming to buy (longs) or decreased for trades aiming to sell (shorts), depending on how many people are trading that pair.&#x20;

Also, it's important to remember that this extra price adjustment (known as price impact or spread) doesn't apply when you're closing a trade.

## Slippage

* Due to market volatility, the execution price might largely differ from the market price at the time a market order is placed. To address this concern, traders have the option to establish a slippage threshold for their market orders to mitigate significant disparities between the intended and actual execution prices.
* For example: setting a slippage of 1% means when the oracle price has been filled and the execution price (spread included) is larger than the market price when the order was initiated by 1% or more, the order will not be fulfilled.

## Max Spread

* Traders can also configure maximum spread for their limit/stop orders to prevent similar price deviation.
* For example: setting a max spread of 1% means when the oracle price has been filled and the execution price (spread included) is larger than the determined limit/stop price by 1% or more, the order will not be fulfilled.

<details>

<summary>What are the spread for asset pairs on AshPerp?</summary>

A fixed spread of 0.04% is applied for BTC/USD and ETH/USD. Dynamic spread is applied for other asset pairs.

</details>


# Net PnL

#### Net PnL vs. PnL

PnL (Profit and Loss) represents the financial outcomes, either losses or gains, resulting from trading activities.

$$
%PnL=\frac{(ClosePrice-OpenPrice)\*Leverage}{OpenPrice}\*100%
$$

$$
PnL=Collateral\*%PnL
$$

Net PnL refers to the remaining amount obtained after subtracting all fees and expenses from the total PnL

$$
NetPnL=PnL-BorrowingFee-CloseFee-LiquidationFee
$$

$$
BorrowingFee=BorrowingFeeAPR\*PositionSize
$$

* The PnL and real-time borrowing fee are displayed on the **Position** tab. If you see positive PnL but it is smaller than the accrued borrowing fee, your Net PnL is actually negative.
* The Net PnL can be seen once you have closed the order (see tab **History**). We will also include the fee breakdown on the **History** tab so you can understand how your final PnL is calculated.

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

{% content-ref url="/pages/U8q9eak0p6FbyDnGjeUI" %}
[AshPerp Fee](/getting-started/understand-ashperp/ashperp-fee)
{% endcontent-ref %}

{% content-ref url="/pages/1LgEPYAJgKNjowbEwEKA" %}
[Borrowing Fee](/getting-started/understand-ashperp/ashperp-terms/borrowing-fee)
{% endcontent-ref %}

*


# Connect a Wallet

Step 1: Choose the “Connect Wallet” button on the top right corner of <https://app.ashswap.io/>

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

Step 2: Connect your wallet with AshSwap Dapp

* [MultiversX DeFI Wallet Extension](https://chrome.google.com/webstore/detail/multiversx-defi-wallet/dngmlblcodfobpdpecaadgfbcggfjfnm)
* [xPortal App](https://xport.al/app)
* Ledger Wallet
* MultiversX Web Wallet

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

> Update on Aug 08, 2023: AshSwap is now fully supporting MultiversX Guardians; users with Guardians enabled can sign Tx without any problem


# Swap

AshSwap uses two algorithms invented by Curve Finance for its liquidity pools.

* Stable-swap algorithm for pegged assets
* Concentrated liquidity with dynamic pegging for volatile assets

### Stable-swap

This algorithm is designed to exchange pegged assets. The most obvious use case is for stablecoins. This is also designed to accommodate more than two tokens in one pool. Our core pool is one having the three most popular centralized stablecoins - USDC/UDST/BUSD.

Further applications are for different wrapped versions of the same tokens or yield-bearing tokens. Liquid staking tokens and lending tokens are of this type.

### Concentrated Liquidity

Concentrated liquidity pools enhance ers' capital efficiency and the dynamic pegging mechanism reduces the impermanent loss of the liquidity provision for volatile assets.

AshSwap currently has pools powered by this technology on Mainnet:

* EGLD/BUSD
* ASH/USDT
* and so on

Further research and verification on impermanent loss implications and comparisons with other AMM algorithms are being conducted by the team and will be released in the future.

AshSwap provides 2 types of swap: Aggregator Swap & Legacy Swap

By default, you will swap via [AshSwap Aggregator](https://medium.com/@ashswap/ashswap-aggregator-get-better-access-to-liquidity-and-pricing-83a510253eb7) in order to optimize the swap rate with our Dynamic Route Trading.

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

### GUIDE

{% content-ref url="/pages/sYd9vlvgpNT3Sr0Kz6Ff" %}
[Swap Guide](/aggregator/swap-guide)
{% endcontent-ref %}

Read more:

{% embed url="<https://medium.com/@ashswap/ashswap-aggregator-get-better-access-to-liquidity-and-pricing-83a510253eb7>" %}

{% content-ref url="/pages/6dhFVLw7MQvFVfwD9k1G" %}
[Dynamic Aggregator](/resources/ashswap-academy/dynamic-aggregator)
{% endcontent-ref %}

Open-sourced repo of Aggregator:

{% content-ref url="/pages/3prNUJuZctIP363fDXu3" %}
[Broken mention](broken://pages/3prNUJuZctIP363fDXu3)
{% endcontent-ref %}

### FAQ

<details>

<summary>Tx Failed, slippage too high, what can i do?</summary>

![](/files/ActK7Ycs2xgyNpg6Uhh2)

You just need adjust your slippage tolerance to a higher number and try again, by default it's 0.1%&#x20;

![](/files/PfJRY5J7m17Q95sY0um5)

</details>

<details>

<summary>My swap ratio is not 1:1, e.g. EGLD &#x3C;> JWLEGLD</summary>

![](/files/yluoWZtKDGKF1EMoMRld)

When users sell/buy too many of the same token, the pool becomes unbalanced. The stable pools are designed to hold the peg event even if the ratio is imbalanced; when LPs withdraw, they will receive tokens in a different ratio, but they will receive about the same amount of underlying token; this ensures your value will remain consistent.

</details>


# Liquidity Provision

How to become a liquidity provider. One step closer to financial empowerment.

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

[**Liquidity Providers (LPs)**](https://medium.com/ashswap/tagged/defi-101) make the trades possible on AMM DEXs. By depositing to a chosen pool, you provide liquidity for the tokens listed in the pool and become an LP.&#x20;

LPs on AshSwap earn 50% of the trading fees and can put their LP tokens to use by farming ASH tokens with the possibility of boosting their yield up to 2.5 times.

{% content-ref url="/pages/exFWp5g49MLU5q46j0Pb" %}
[Liquidity Provision Guide](/ashswap-dex/liquidity-provision/liquidity-provision-guide)
{% endcontent-ref %}

Read more:

{% content-ref url="/pages/vFIWs13W8ofcxMf8h0l7" %}
[What is LP Token?](/resources/ashswap-academy/what-is-lp-token)
{% endcontent-ref %}


# Liquidity Provision Guide

## Add Liquidity

**Step 1:** Start by choosing one of the pools listed on the [Pool page](https://app.ashswap.io/pool). Each pool has its respective trading APR depending on the volume traded in such pool.

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

<figure><img src="/files/6A1Ut6QOmDiJGyzhxJhQ" alt=""><figcaption></figcaption></figure>

**Step 2:** Click `Deposit` to start adding liquidity to the pool. The window below will appear.

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

**Step 3:** Input the amount of token you wish to add to the pool.

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

By turning off the **Balanced Deposit** feature, you can add liquidity on the side, the protocol will automatically balance your deposit through automatic swaps, and you will incur a small swap fee and price slippage.

<figure><img src="/files/4EtH5sctkJSSiM2jOStj" alt=""><figcaption></figcaption></figure>

**Step 4:** Finally, click **Confirm** and sign the Transaction in your wallet.

**Pro tip:**

After depositing, you can click the `Your Pools` button to filter and see which pools you are on. Your estimated rewards are shown in the UI.

<figure><img src="/files/4zHvpWgdkcEnPcEd5SMo" alt=""><figcaption></figcaption></figure>

After adding tokens into the pools, you will receive LP tokens as proof for providing liquidity to the pool. Now it is where the fun begins - put your LP-tokens and earn more by conducting [Liquidity Staking](https://docs.ashswap.io/guides/liquidity-staking).

## Withdraw Liquidity

Should you wish to withdraw liquidity, enter your desired withdrawal amount? We will simulate the impact of your withdrawal on the panel on the right. Keep in mind that your farming reward will be taken out at the same time as your liquidity.

**Step 1:** Select the Pool you want to withdraw liquidity from then click Withdraw

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

**Step 2:** Input the amount of token you want to Withdraw and click **Withdraw**

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

After confirming the transaction in your wallet, the withdrawal result should display a variety of tokens from the pool, similar to when you add tokens to the pool.


# Liquidity Staking

## Understand the Total APR of Farms

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

`Total APR = Token rewards + Trading APR`

*Token rewards* is [ASH Emission](/ashswap-dex/governance-ashdao/farm-weight-voting)

*Trading APR* is estimated growth of your deposit over a year, based on trading activity in the past 24 hours.

According to the image above we have an estimated range of APR from 61.47% to 153.29%:

* 61.47% is the current APR for all users who have staked their LP tokens on that farm without Yield Boost.
* 153.29% is the maximum APR after [Yield Boosting](https://docs.ashswap.io/guides/yield-boost) (x2.5 times max) has been applied.

To start liquidity staking, you first need to have LP tokens. Go to [**Add / Remove Liquidity**](https://docs.ashswap.io/guides/add-remove-liquidity) to learn more.

By staking LP tokens, you can farm ASH with the possibility to boost your yield by up to 250%. A guide on how to yield boost can be found in [**yield boost.**](/ashswap-dex/governance-ashdao/farm-boost)

### **Multi-reward**

The multi-reward of a farm will be initiated when an individual or organization contacts AshSwap and requests the addition of their token to the whitelist. If their request is approved, the farm that was requested to be added to the whitelist will become eligible for multi-reward. LPs can receive more than one token reward when farming in these designated farms.

{% content-ref url="/pages/iuQ83XzgFyeYO9vDuIOp" %}
[Liquidity Staking Guide](/ashswap-dex/liquidity-staking/liquidity-staking-guide)
{% endcontent-ref %}


# Liquidity Staking Guide

## **Stake LP tokens**

**Step 1:** Choose [**The Farm**](https://app.ashswap.io/farm) in which you want to stake your LP Tokens and click **Deposit**. Stats on Emission APR, Total LP staked, and the Total liquidity of the pool are shown in each pool. These numbers affect the ASH reward you get.

<figure><img src="/files/7de0bHgKernOBBIT6Ny0" alt=""><figcaption></figcaption></figure>

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

**Step 2:** Put in the amount of LP tokens you wish to stake. An estimated ASH reward per day will be shown in the right panel.

Once you are happy, click **Confirm** and verify the transaction in your wallet.

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

## **Unstake LP Tokens**

You can choose to unstake all or part of your staked LP tokens. A simulation of how much less ASH you earn per day as a result of the unstaking event will be shown on the right panel. Please remember that you will also get your ASH reward at the same time as your LP tokens.

**Step 1:** Choose the Farm you want to unstake your LP Tokens and click **Unstake**

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

**Step 2:** Input the amout of LP Tokens you want to unstake and click Unstake

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

## **Claim ASH Reward**

There are two ways to claim your ASH reward

* Click the **Claim** button in each pool to claim your ASH reward separately.

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

* If you are farming in multiple farms, you can claim your ASH reward in all farms by clicking the **Claim Reward** button in the **Your Reward** section.

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

**Pro tip:** You can maximize your yields by using the [**Farm Boost**](/ashswap-dex/governance-ashdao/farm-boost) feature to boost your ASH incentive you can get up to 2.5x<br>

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

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

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


# Governance - AshDAO

Everything you need about AshSwap Governance

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

### **veASH Utilities**

ve stands for Voting Escrow, a system for temporarily locking up tokens (such as veCRV for Curve; or veASH for AshSwap). \
\
Governance staking is another way for ASH holders to benefit from holding ASH tokens. In simple terms, Governance Staking means you can stake (or lock) ASH to get more rewards. The main advantages of staking ASH are:

1. Share 50% of the trading volume across all trading pools paid in LP-tokens of the main stablecoin pool.
2. Boost your ASH Emission APR across *all* your LP pools by up to 250%.
3. Vote in the AshDAO to govern emissions and other metrics.

**What happens if more people lock their ASH?**

That will reduce your percentage of veASH (your capacity) compared to the total diluted veASH, and consequently, the amount of rewards you receive from revenue sharing will also be reduced.

With veASH in your hand, you can now participate in below interesting sections:

{% content-ref url="/pages/V736eQetgljqTd9pqeRo" %}
[Governance Staking](/ashswap-dex/governance-ashdao/governance-staking)
{% endcontent-ref %}

{% content-ref url="/pages/fSmS5NkmU2IOEFMEWosz" %}
[Farm Boost](/ashswap-dex/governance-ashdao/farm-boost)
{% endcontent-ref %}

{% content-ref url="/pages/Yuk2lNI7FIvTnNcPPjo5" %}
[Farm Weight Voting](/ashswap-dex/governance-ashdao/farm-weight-voting)
{% endcontent-ref %}

{% content-ref url="/pages/hSog2mECRXdtgXnNAa9Y" %}
[AshDAO Proposal](/ashswap-dex/governance-ashdao/ashdao-proposal)
{% endcontent-ref %}

{% content-ref url="/pages/4SAlVHHnYrKzphozSuGK" %}
[Bribe](/ashswap-dex/governance-ashdao/bribe)
{% endcontent-ref %}


# Governance Staking

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

### Voting power

veASH refers to escrowed ASH, a holding mechanism enabling users to secure their ASH for varying durations in order to enhance their voting influence. Users have the flexibility to lock their ASH for as short as a week and as long as four years. As users extend the duration of their voting escrow, their stake increases, leading to a greater allocation of voting power.

### Voting Cycle (epoch)

An epoch will last for one week, starting from 00:00 on Thursday until 23:59 on the following Wednesday

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

### Governance Stake ratio

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

By locking ASH, you can earn 50% of the trading fees across all pools at AshSwap & 50% of Platform fee on AshPerp. Your reward will be denominated in the form of an LP token from the main pool, which you can swap back to a stablecoin or any token of your choice.

Governance Staking Reward formula (on AshSwap):

```jsx
Your Governance Staking Reward (AshSwap) = 50% Trading Fee x  your veASH Share 
```

You can collect your % share on the [Governance Dashboard](https://app.ashswap.io/gov/).

\*Note: Your snapshot capacity will be taken at the start of the epoch and will be used to calculate the rewards you will receive in the previous epoch. Therefore, if you apply the formula using a different percentage capacity at another time, there is a significant possibility that the calculated result will be inaccurate.

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

[Weekly Governance Earnings](https://app.ashswap.io/gov) show the summary of fee distributed to veASH holders (50% AshSwap trading fee + 50% AshPerp platform fee)

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

**Note:**

* Your reward will be updated at 00:00 every Thursday on **AshSwap Mainnet** (and every 30 minutes on **AshSwap Devnet)**.
* If you do not see your reward at 00:00 Thursday or you see the Harvest button light up but the reward is still $0.00, it could be because your reward is too small to appear on the UI.
* Your veASH weight gradually decreases as your escrowed tokens approach their lock expiry.\
  \
  *Does it mean users will lose money every day?*\
  Of course not, when your veASH decreases to 0. It also means that the lock period of your ASH is over. You can withdraw your staked ASH right away. However, If you want to keep your veASH stays on the maximum, just extend your lock period.


# Governance Staking Guide

### 1. Stake ASH to get veASH

Visit <https://app.ashswap.io/gov> and choose Stake Management

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

Input the ASH amount you want to stake & choose the lock duration

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

Note that the ratio from ASH to veASH is as below

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

{% hint style="info" %}
Your locked ASH will not be eligible for withdrawal before the locked period, hence, kindly review your stake info carefully before comfirming the Tx
{% endhint %}

If you have more ASH, either by buying ASH or [**Harvesting**](/ashswap-dex/liquidity-staking) from your staked LP pool, you can choose to lock them to boost your reward even more. You can also choose to extend your lock period for the current locked ASH.

Once you are happy with your choice, click *Stake* and confirm the transaction in your wallet.

### **2. Claim Governance reward**

By locking ASH, you can earn from 50% of the trading fees across all pools at AshSwap. Your reward will be denominated in the form of LP token of the main pool, which you can swap back to a stablecoin or any tokens of your choice.

Your LP-token reward is shown in the UI. Click *`Harvest`* to claim your reward.

Governance Staking Reward formula:

```jsx
Your Governance Staking Reward = 50% Trading Fee x  your veASH Capacity 
```

For example:

This week we have a total of $200 trading fee. The reward for veASH holders is 50% of the total trading fee and our veASH capacity is 1%. Enter the formula:

Your Governance Staking Reward value = $100 x 1% = $1

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

**Note:**

* Your reward will be updated at 00:00 every Thursday on **AshSwap Mainnet** (and every 30 minutes on **AshSwap Devnet)**.
* If you do not see your reward at 00:00 Thursday or you see the Harvest button light up but the reward is still $0.00, it could be because your reward is too small to appear on the UI.
* Your veASH weight gradually decreases as your escrowed tokens approach their lock expiry.\
  \
  *Does it mean users will lose money everyday?*\
  Of course not, when your veASH decreases to 0. It also means that the lock period of your ASH is over. You can withdraw your staked ASH right away. However, If you want to keep your veASH stays on the maximum, just extend your lock period.


# Farm Boost

How you will interact with AshSwap’s new feature: Farm Boost, or Yield Boosting

{% hint style="info" %}
The **Farm Boost** feature of AshSwap allows users to significantly boost their earnings up to 250% from liquidity staking by owning veASH.&#x20;
{% endhint %}

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

## Description

The **Yield Boost** feature of AshSwap allows users to significantly boost their earnings from liquidity staking by owning veASH. To better understand how this works, let’s first touch on the concept of **Pool Weight** and how your rewards are calculated.

## Pool Weight

### Liquidity Pool

When you add your tokens to a [liquidity pool](https://medium.com/ashswap/liquidity-pool-what-is-it-486ba7d1241a), you own a portion, a percentage of that pool, and you are entitled to part of the trading fees.

![](/files/e8UrLIvf1Tbrd0hxNooS)

In the liquidity pools of decentralized exchanges (DEXs), because they distribute trading fees on a pro-rata basis, they need to know how much fees should be distributed to each liquidity provider (LP). For example, if Alice owns $10 of a pool of $100, she earns ten cents on every dollar of the trading fee. DEXs do it by having a total weight of the pool and proportionally assigning a weight to Alice. In this particular example of liquidity pools, the weights are token values.

> 💡 *Note that all calculations in this article are arbitrary and serve as the foundation for understanding. They do not represent any actual implementation of any specific AMM.*

The formula for calculating a person’s portion of a pool is as followed.

$$
P\_u=\frac{W\_u}{W}
$$

In which `W_u` is the weight (token value) of the LP in the liquidity pool, and `W` is the total weight of all LPs. The trading fee distributed to that user is:

$$
Fee\_u = Fee \cdot P\_u = Fee \cdot \frac{W\_u}{W}
$$

### Liquidity Mining

This is a concept that people often find hard to grasp. To attract more people to add tokens to the pool, DEXs reward LPs with DEX tokens. The more tokens a pool has, the greater the pool’s liquidity is. DEXs in this sense **mine** liquidity out of their LPs. So when you hear the word “mining” in a blockchain context, you can understand it by finding out who mines something out of which/whom.

Let’s look at the Maiar Exchange and its MEX token. At the time of writing, Maiar is distributing about 60,000 MEX tokens every block to the LPs of the EGLD/USDC pool, thereby providing LPs with a 34% yield on their pooled tokens.

![](/files/Ejciuqsyl9Q4lg8dp1QC)

But **Liquidity Mining** has 6 syllables and doesn’t sound familiar. People, therefore, often refer to this as **Farming** because, from the user's perspective, they are rewarded by putting their capital to work, just like how farming is.

![](/files/IPGOQ4oF96z3HadpNRCc)

Bob is a user and he wants to farm, the way he does it is to first add his tokens to the pool and become an LP. He then receives some LP Tokens in return as proof, and now he can lock/stake his liquidity (LP tokens) in the farms to start getting some yields. This is why we call this step “Liquidity Staking” at AshSwap. At this point, I know you start cursing. Yes, it isn’t very clear but they all mean the same thing. **Farming = Liquidity Mining = Liquidity Staking**.

### Farming Rewards

Similar to how liquidity pools distribute fees, farms also use the same mechanism to calculate users’ rewards. A farmer’s reward is proportional to his weight in the farm.

$$
Reward\_u = Reward \cdot \frac{W\_u}{W}
$$

## Yield Boosting

### Boosting

At AshSwap (similar to Curve), veASH is incorporated in the way the pool weight is calculated such that the user’s veASH holding can boost his pool weight up to 250%.

$$
W\_u = min(0.4I\_u + 0.6I\frac{w\_u}{w},I\_u)
$$

`Wu` is the user’s weight in the farm.

`Iu` and `I` are the numbers of LP tokens of the user and the total number of LP tokens in the farm, respectively. Read [this article](https://medium.com/ashswap/what-is-lp-token-6003a43d146) if you don’t know what the LP token is.

`wu` is the user’s holding of veASH, and `w` is the total veASH there is.

$$
I = \sum I\_u
$$

$$
w = \sum w\_u
$$

This looks confusing, but not really. Let me walk you through each part of this formula. First, let’s look at the addition part.​

$$
0.4I\_u + 0.6W\frac{w\_u}{w}
$$

​`0.4Iu` means if you don’t have any veASH, your maximum weight is 0.4 of your LP tokens. Wait, we’re not taking anything away from you. Assume that all farmers don’t have veASH, the weight of everyone is multiplied by 0.4, so your portion in the pool remains the same. It is only different when we add the veASH part.

The second addend is the ratio of your veASH to the total veASH normalized by the total LP tokens. But isn’t it that the result can increase to be more than 250% of `Iu` as `W` can be very large and `wu/w` has the maximum value of 1? That’s why we have the `min` operator. When the result of the addition becomes larger than `Iu`, your weight is `Iu`.

> All of this can be understood as your weight is defined as 40% by your number of LP tokens in the farm and 60% by your number of veASH.

![The differences between farmers with the same LP tokens but different veASH holdings.](/files/ipzJODNXDDBqb1sn5ThK)

### Why have this?

The most dangerous thing that can happen to a token is people can’t do anything with it except for selling. The ultimate goal of designing token economics of a product is to create as much utility as possible for your token. By deeply integrating veASH and Governance Staking into the process of liquidity mining, we can create a more positive feedback loop, thereby bringing more incentives to people who buy/hold/stake ASH.

### Max Boost?

This is a common misconception of this mechanism of Curve, which is often people think they can boost their yield up to 250%, but in fact, they are only able to boost their weight.

![Max boost is 2.13x, even when your CRV is unrealistically large.](/files/rL3aCQC7ZWeGviP0w1w6)

Boosting your yield to 250% means your weight has to increase by 2.5 times with respect to the total weight of the pool. Let’s look at the proof showing this is not possible.

After boosting, your maximum weight is `Iu`, and the total pool weight is `W`. Your portion in the pool is now `Iu/W`.

If your weight is not boosted (no veASH), it is `0.4Iu`, and the total weight without your boost is `W-0.6Iu`. Your portion in the pool is `0.4Iu/(W-0.6Iu)`.

Divide the boosted weight to the unboosted one, and we have:

$$
\frac{\frac{I\_u}{W}}{\frac{0.4I\_u}{W-0.6I\_u}}
$$

$$
\= \frac{I\_u}{W}\cdot \frac{W-0.6I\_u}{0.4I\_u}
$$

$$
\= \frac{W-0.6I\_u}{0.4W}
$$

$$
\= 2.5-1.5\frac{I\_u}{W}
$$

This means you can only have close (never equal) to a 250% boosted yield if your portion of the pool is very small. This is not a bad thing, it’s just how the math works.

### Optimal Choice

From the equation (1), the boost by veASH is `<=0.6Iu`. Therefore, the optimal veASH is:

$$
0.6I\frac{w\_u}{w}=0.6I\_u
$$

$$
\Leftrightarrow I\frac{w\_u}{w}=I\_u
$$

$$
\Leftrightarrow \frac{w\_u}{w}=\frac{I\_u}{I}
$$

This means the maximum boost happens when the ratio of your veASH to total veASH equals the ratio of your LP tokens in the farm to the farm’s LP tokens. If you only have stake in one farm and want to increase your yield, you should consider either staking ASH for veASH or increasing your LP tokens in the farm. Sometimes it is cheaper to stake more LP tokens than to stake ASH.

However, veASH is not only used for yield boosting but has other benefits:

1. Your veASH can boost all of your farms, not just one.
2. You are shared with 50% of the trading fees from all pools of AshSwap.
3. You earn voting right later in the DAO and can direct more ASH emissions to the pool you are in.
4. Other projects can bribe you to vote for them in the DAO, so you can earn more with their bribes.
5. veASH will have more and more use cases in the later features of AshSwap.

It is a lot to wrap your head around, but you should take all this into account when calculating your potential rewards and making your decisions.

## Tokenization of Farming Position

This is our improvement compared to the existing implementation of Curve by leveraging Elrond's Meta-ESDT tokens. This brings more utility to ASH. I will write more about this in the next article of the "Deep Dives" series.

Learn how to get veASH by going to [**Governance Stake**](/ashswap-dex/governance-ashdao) guide.

If you already have veASH, you can go to [**Liquidity Stake**](/ashswap-dex/liquidity-staking). You will find a list of all your farms and their associated yield boosts under the *Farm Boost* section.

{% content-ref url="/pages/4W9bot1svfM7KBbR0r0B" %}
[Farm Boost Guide](/ashswap-dex/governance-ashdao/farm-boost/farm-boost-guide)
{% endcontent-ref %}


# Farm Boost Guide

Visit Farm Boost page at <https://app.ashswap.io/gov/boost/> and your current farms will appear

<figure><img src="/files/6C2Ov4Od3XpoYHAhv4hS" alt=""><figcaption></figcaption></figure>

A couple of data points are shown here: Current Boost | New Boost | Max boost range

By default, all of your veASH will be consumed for boosting up your position.

The Calculator feature allows you to simulate your yield boost by adjusting the parameters. Experiment with different input values to find the best strategy to maximize your return!

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

Last, to officially apply the potential boost as shown in the progress bar, click *Confirm new Boost.*

> If you are farming in more than one pool, your veASH will boost the emission across ALL your pools, not just one! For example, if you have 1000 veASH and participate in 3 pools as LP, each pool will receive a boost of 1000 veASH.

Here are a few things to keep in mind:

* Your Governance veASH will NOT be affected after using available veASH for boosting.
* If you want to have more veASH for boosting, move to [**Governance Stake**](/ashswap-dex/governance-ashdao) and lock more ASH.

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


# Farm Weight Voting

AshSwap DAO, or AshDAO as we like to call it, is a place for veASH holders to vote for specific metrics of AshSwap. The goal is to allow the community to govern the underlying protocol and create more utility for veASH holders.

### Voting Power

Voting power is represented by the number of veASH one has. The more veASH, the higher the voting weight.

### Token Emission Voting

AshSwap has a fixed amount of total ASH emissions to farms, but the DAO decides the distribution ratio between farms. Every week at Thursday 00:00 UTC, users can vote. If one has already voted, he does not need to vote again if he does not want to change his vote. The more vote a farm has, the more ASH that farm receives.

For example, if the ASH emission is 300,000 ASH/week and the farm weights of the pools are:

* USDC/USDT/BUSD: 50%
* ASH/USDT: 30%
* EGLD/BUSD: 20%

The rewards distribution are:

* USDC/USDT/BUSD: 150,000 ASH/week
* ASH/USDT: 90,000 ASH/week
* EGLD/BUSD: 60,000 ASH/week

This is an implicit yield boost for veASH holders in addition to the primary Yield Boost mechanism. Why is that? If you are an LP in a pool and have veASH, you can vote for the pools you are in to direct more rewards to your pools and further increase your yields.

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

### ASH Farms

Even though AshSwap allows projects to create their liquidity pools and farms, it does not mean every farm will receive ASH rewards. For the farms to receive ASH rewards, they must be included in the list of ASH farms. Projects can create proposals to include their farms; if the majority of veASH holders vote in favor, the farms will be included and receive ASH rewards. How much ASH the farms receive again depends on the result of \[Token Emission Voting].

This leads us to the [Bribe](/ashswap-dex/governance-ashdao/bribe) mechanism.

{% content-ref url="/pages/Db3k0hRHeeLTvVFzTP7s" %}
[Farm Weight Voting Guide](/ashswap-dex/governance-ashdao/farm-weight-voting/farm-weight-voting-guide)
{% endcontent-ref %}


# Farm Weight Voting Guide

### 1. Set your Farm Weight Vote

* Go to the [Farm Weight Voting](https://app.ashswap.io/stake/gov/farmweight/) screen and check the information (your Power status, Bribe Reward,..)
* Choose a farm that you want to vote for
* Enter the proportion of Voting Power that you want to vote for that farm and declear your vote

<figure><img src="/files/9dOKW2Yfvu9vQGZ5v7up" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Please notice that you will only be able to change your vote 10 days after your previous one.
{% endhint %}

### **2. Change your Farm Weight Vote**

* Choose the farm where you want to change your previous vote
* Choose the new percentage of your voting power
* Check the vote change information carefully
* Click "Confirm" and Sign the Tx on your Wallet

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


# AshDAO Proposal

<figure><img src="/files/59mBVx0JVnBnrGKTrljq" alt=""><figcaption></figcaption></figure>

### What's on AshDAO Proposal?

AshDAO Proposal allows users to submit proposals for changes to the protocol, ensuring that we continually evolve to meet users’ needs. Those who hold veASH tokens can leverage their voting power to have a say in their earnings on AshSwap according to their strategies and preferences.

**Gauge relative Weight formula:**

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

* Proposal Type:
  * Whitelist farm to receive ASH farm: Proposal to decide whether a farm is listed in ASH Farm Controller.
  * Start/Stop ASH reward for a farm: Proposal to stop or start distributing ASH reward for a farm.
* Farm Address: choose which farm you want to make an effect

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

{% content-ref url="/pages/KB4cGNs5Vo07zVcQdK60" %}
[AshDAO Proposal Guide](/ashswap-dex/governance-ashdao/ashdao-proposal/ashdao-proposal-guide)
{% endcontent-ref %}


# AshDAO Proposal Guide

### 1. Create a proposal

There are certain criteria that need to be met for a user to create a proposal.

* The user must have a minimum of 50,000 veASH at the time of proposal creation.
* The user should have yet to create any proposals within the last seven days.

For a proposal to be listed on AshDAO, its owner must first initiate a discussion on the [**AshSwap forum**](https://github.com/ashswap/ash-proposals/issues/new/choose). The proposal’s URL should start with: <https://github.com/ashswap/ash-proposals/issues/new/choose>

Visit the Proposal Voting page and click Create Proposal

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

Choose your Proposal Action:

* Proposal Type:
  * Whitelist farm to receive ASH farm: Proposal to decide whether a farm is listed in ASH Farm Controller.
  * Start/Stop ASH reward for a farm: Proposal to stop or start distributing ASH reward for a farm.
* Farm Address: choose which farm you want to make an effect

<figure><img src="/files/lQp6fgR6VDw6OFW8dGlv" alt=""><figcaption><p>Step 1/2: Choose Proposal Type, Farm Address</p></figcaption></figure>

Fill in your Proposal Info:

* Proposal Title: A short summary of your proposal with a limit of 120 characters.
* Proposal Description: describe the detail of your proposal here in Markdown format, this section has a limit of 520 characters.
* Link to Description:
  * for a proposal to be listed on AshDAO, its owner must first initiate a discussion on the [AshSwap forum](https://github.com/ashswap/ash-proposals/issues/new?assignees=\&labels=proposal\&template=governance-proposal.md\&title=%5BPROPOSAL%5D).
  * the proposal’s URL should start with: [http://github.com/ashswap/ash-proposals/issues](http://github.com/ashswap/ash-proposals/issues*)

<figure><img src="/files/Bgs9tfyUiQfPBIMNwdYL" alt=""><figcaption><p>Step 2/2: Fill in Proposal Title, Description, Link to Description</p></figcaption></figure>

After filling in the necessary information, click Done & Create and confirm on your wallet, then wait for a while till the proposal appears in the AshDAO interface.

#### (Optional) Create a Bribe for your proposal

After your proposal is created, you can create a Bribe to attract more users to vote for your proposal

<figure><img src="/files/1p2EPpdO6xrFjtKWK0tO" alt=""><figcaption></figcaption></figure>

### 2. Vote for a proposal

Choose the proposal you want to vote on with the status Active

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

Check the description carefully and choose your vote: Support, or Against; choose the percent of Voting Power you want to vote for, then confirm the transaction on your wallet.

Please notice that you can only vote in 1 time, it’s unable to undo.

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

### Proposal’s Life Circle on Mainnet

* Pending: Until the next Thursday
* Active: 7 days
* Approved: 14 days before expired

**Notice:** a voting epoch happens from 0:00 UTC Thursday to 0:00 UTC next Thursday (7 days)

### Proposal’s Life Circle on Devnet

* Pending:  Until the next 30 mins or 60 mins
* Active: 24h&#x20;
* Approved: maximum 90 mins before expired

### Proposal’s “Passed” Status Requirements

A proposal will need to meet 2 criteria to be counted as “passed”:

* Support (50% required): the support vote needs to be higher than 50 % of the total vote
* Quorum: (>30% required): a proposal needs to have at least 30% voting power joining the vote compared to the total voting power.

Those criteria will change depending on each type of proposal

> Please notice that your Voting Power gradually decreases from the middle of a voting epoch (12 pm Sunday) as the proposal voting time approaches its end.
>
> `your Voting Power = min(veASH, 2`*`veASH`*`(endTime - now)/voteTime)`


# Bribe

### What is Bribe?

Bribes are offered to individuals with voting power to influence the outcome of a vote. This involves two parties:

* The person or project offering the bribe (the "briber") aims to increase their voted veASH on AshSwap DAO without directly buying or owning veASH voting power.
* The individuals accepting the bribe (the "bribe takers") are a group of veASH holders who agree to trade their current voting power for valuable assets, such as stablecoins or other tokens.

### Bribe Types

There are 2 types of Bribe available on AshDAO: Farm Weight Voting Bribe and Proposal Voting Bribe

1. **Farm Weight Voting Bribe (or Farm Bribe)**

<figure><img src="/files/1I91C4bUSsPzk7djBkcq" alt=""><figcaption></figcaption></figure>

&#x20;After voting for the desired farm to receive bribes, your votes will be retained for subsequent epochs until you unvote them. You will be eligible to receive your bribes in the next epoch.

*Farm Weight Voting Bribe Formula*

```
Bribe = Total Treasures * Your Capacity of X farm in Farm Weight Voting
```

These are some criteria you need to check:

* Total Treasures: the amount of the pool’s bribe.
* Capacity: the ratio of your veASH weight votes for the X farm over its total veASH weight votes.
* Available Until: the last day you can claim your current reward.

**Note:** If you forget to claim your reward within the DAO cycle (7 days), your reward will return to the Total rewards pool and be divided equally among other participants in the next DAO cycle.

2. **Proposal Voting Bribe (or Proposal Bribe)**

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

You can utilize your total veASH amount to vote simultaneously for multiple different proposals. After each voting epoch, your votes will be revoked. You will be eligible to receive rewards when those proposals are approved. For instance, if you possess a total of 10,000 veASH and there are 5 proposals, you can vote with 10,000 veASH for proposal 1, another 10,000 veASH for proposal 2, and similarly distribute them across proposals 3, 4, and 5.&#x20;

*Proposal Voting Bribe Formula:*

```
Bribe = Total Treasures * (Your total veASH / Total veASH vote yes)
```

{% content-ref url="/pages/zbs5HJFrZBskHNrTs7j5" %}
[Bribe Guide](/ashswap-dex/governance-ashdao/bribe/bribe-guide)
{% endcontent-ref %}


# Bribe Guide

### 1. **How to Receive Bribe on AshSwap**

If you're looking to receive rewards on AshSwap, you can participate in the Bribe feature. Here's how you can get started:

#### **Step 1: Visit the Farm Weight Voting page**

To begin, head over to the [**Farm Weight Voting page**](https://app.ashswap.io/stake/gov/farmweight/) and select the farm that you want to vote for.

<figure><img src="/files/9dOKW2Yfvu9vQGZ5v7up" alt=""><figcaption></figcaption></figure>

The total amount of bribes for each pool will be displayed in the Bribe column on the interface's right side. The amount of Bribe you are eligible to receive is proportional to the ratio of Your voted veASH to the Total voted veASH of each pool.

Let's move on to Step 2 to see how much bribe you can get.

#### **Step 2: Claim your Bribe rewards**

Once you've voted for a farm, you can then proceed to claim your Bribe rewards by visiting the [**Bribe page**](https://www.notion.so/d508cee798634e78b15ce0d7e6b4541e).

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

{% code overflow="wrap" %}

```markup
Your Bribe = Total Treasures * Your Capacity of X farm in Farm Weight Voting
```

{% endcode %}

These are some criteria you need to check:

* Total Treasures: the amount of the pool’s bribe.
* Capacity: the ratio of your veASH weight votes for the X farm over its total veASH weight votes.
* Available Until: the last day you can claim your current reward.

Simply click the "Claim" button to receive your reward after the current voting cycle ends (every Thursday).

**Note:** If you forget to claim your reward within the DAO cycle (7 days), your reward will return to the Total rewards pool and be divided equally among other participants in the next DAO cycle.

To better understand how Bribe rewards work, refer to the example below:

{% hint style="info" %}
A DAO cycle begins at 00:00 UTC every Thursday with a 7-day duration. For instance, let's say it's Week 1, Week 2 and Week 3. Here's how the Bribe rewards work:

* The Total Bribe of USDT/ASH farm is currently 0.
* Week 1: On Friday, user Alice creates a Bribe for USDT/ASH Pool with a 5,000 USDC reward. Alice’s 5,000 USDC Bribe reward is added to the Total Rewards pool of USDT/ASH farm. User Bob and Chad (along with other participants) vote for the USDT/ASH farm to receive the reward.
* Week 2: At 00:00 Thursday, the Total rewards pool is distributed to participants who voted for the USDT/ASH farm last week. However, some participants forget to claim their reward, and by the end of the DAO cycle, 2,000 USDC rewards remain unclaimed.
* Week 3: The 2,000 USDC reward left will be returned to the Total rewards pool and combined with other Bribe rewards.
  {% endhint %}

### **2. How to Create Bribes**

If you're interested in creating Bribes to incentivize participants to vote for your farm, here's how you can get started:

* **Step 1: Visit the** [**Bribe page**](https://app.ashswap.io/stake/gov/bribe/) and click on the "Create Bribe" button.
* **Step 2: Select a farm and reward token,** then select the farm that you want to offer rewards for and choose the reward token. Input the number of rewards that you want to offer and then confirm it.

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

Your bribe has been successfully created at this point and is now ready to be distributed to users who voted for your farm in the subsequent DAO cycle.

Let's get the word out to vote for your farm, shall we?

> **Note:** Once you create a Bribe, you cannot undo your action or request a refund. Additionally, the "Create Bribe" action is separate from the “Voting” action, which means that after creating a Bribe for a farm, you can also vote for that farm and receive your created Bribe. The reward from the Bribe you created will be estimated at $ and combined with other Bribe rewards created by others to be shown in the Total rewards section.


# Understand Aggregator

The first Dynamic Trading Route Aggregator on MultiversX

> AshSwap began as a stable-swap AMM DEX and has since grown to become one of the top two most dominating DEXes on MultiversX, with over [**$5 million in TVL**](https://defillama.com/chain/MultiversX?tvl=true) (Total Value Locked). Our ultimate goal is to become a DeFi layer on MultiversX, where we will provide all advanced features to help DeFi users maximize profits and improve liquidity.

As part of our ongoing efforts to build new products on AshSwap, we are excited to announce **AshSwap Aggregator**, the first **Dynamic Route Trading DEX Aggregator on MultiversX**.

Let’s look at how AshSwap Aggregator gives you better access to liquidity and price.

<figure><img src="https://miro.medium.com/v2/resize:fit:630/1*gGV47hHRhtXVevITiGURxg.jpeg" alt="" height="397" width="700"><figcaption></figcaption></figure>

## Demand for DEX aggregation on MultiversX <a href="#id-7731" id="id-7731"></a>

MultiversX, a young blockchain network supporting more and more decentralized financial operations, permits users to exchange tokens and other digital assets. The need for DEX aggregators on the MultiversX blockchain will grow exponentially along with the MultiversX DEX trading volume, including AshSwap. Therefore, an efficient DEX aggregator will bring great benefits to the prospering MutliversX ecosystem.

AshSwap DEX Aggregator aims to serve as the go-to trading portal on MultiversX by ensuring a seamless, efficient, and secure trading experience. Thanks to our Dynamic Trade Routing, Each user will receive a full package of information on prices, slippage, and gas fees via the most optimal route.

## What is a DEX Aggregator? <a href="#id-5a23" id="id-5a23"></a>

The only challenge that DEXs face is the lack of liquidity for smaller tokens and pricing. To solve this particular issue, DEX Aggregators are created. These aggregators are also called Liquidity Aggregators.

In simple terms, DEX aggregators are the financial protocols that give traders/investors easy access to various trading pools using a single dashboard. They rely on a complicated algorithm that considers multiple factors before selecting the best possible route for a specific token swap across the available platforms.

In the world of decentralized finance (DeFi), we have two eras of aggregator systems:

### Static Trade Routing <a href="#id-2131" id="id-2131"></a>

Aggregators help users find the best paths for swapping tokens. Users can choose the desired path, and the system usually presents them with sorted results, highlighting the most favorable options.

DEXes such as Uniswap V2 and PancakeSwap also use this routing model. In the MultiversX ecosystem, you must be familiar with this type of routing in JEXchange.

<figure><img src="https://miro.medium.com/v2/resize:fit:630/0*tuWZWnnI8fibnCqL" alt="" height="305" width="700"><figcaption></figcaption></figure>

### Dynamic Trade Routing <a href="#id-5bd5" id="id-5bd5"></a>

This is an improvement over Static Trade Routing. After finding all possible paths, the aggregator system distributes the input token amount across different paths to achieve the best possible price. Unlike Static Trade Routing, which relies on a single path, Dynamic Trade Routing provides better outcomes by leveraging multiple paths.

This type of routing has been implemented on many leading multi-chain DEX aggregators, such as 1inch, ParaSwap, and KyberSwap.

> &#x41;***shSwap is the early adopter to bring it to MultiversX.***

<figure><img src="https://miro.medium.com/v2/resize:fit:630/1*tanZsRL_DneCffa8OSAamw.png" alt="" height="452" width="700"><figcaption></figcaption></figure>

## AshSwap Aggregator: A gateway to better liquidity and pricing <a href="#d026" id="d026"></a>

### Dynamic Trade Routing Scheme <a href="#id-81d7" id="id-81d7"></a>

In a DEX, when attempting to swap a large amount of *Token A* for *Token B* using a single path, the price of *Token B* increases proportionally due to the depletion of liquidity along that path. Dynamic Trade Routing addresses this issue by dividing the large token amount into smaller portions and executing swaps across multiple paths. As a result, the price of Token B increases less compared to the previous approach.

AshSwap Aggregator has Dynamic Trade Routing, aggregating fractured liquidity across DEXs, enabling users to source the most capital-efficient liquidity to support their trades. Your trade on AshSwap is split into smaller trade sizes.

> For example, if you want to make a 1000 wEGLD-BUSD trade, it may distribute your trade into a 950 wEGLD-BUSD trade on AMM1, 30 wEGLD-BUSD trade on AMM2, and the rest on the third route.

The percent distribution of the swap is dynamically determined to give you the best price. Trade splitting helps get better prices for large trades and trades with tokens where shallow liquidity is spread out across several DEXes. You can see exactly which DEXs were involved in the trade and the amount split between them.

<figure><img src="https://miro.medium.com/v2/resize:fit:630/1*GxB0XcMCeXTlIxCNTwPPzQ.jpeg" alt="" height="314" width="700"><figcaption></figcaption></figure>

## Other key benefits of AshSwap Aggregator <a href="#d509" id="d509"></a>

### Market listing <a href="#id-916c" id="id-916c"></a>

At the moment, AshSwap Aggregator is supporting two DEXs: AshSwap and xExchange, and tokens that are available in AshSwap pools (xEGLD, wEGLD, ASH, USDT, BUSD, USDC, UTK, HTM, sEGLD, HsEGLD)

However, the system is designed to be modular and extensible, allowing for the inclusion of more new DEXes and strategies to continuously improve the search for the best price; thus, we will support more tokens and markets in the future.

### Swap in a single transaction <a href="#id-18f5" id="id-18f5"></a>

We have worked to optimize the AshSwap Aggregator so that it all fits within the transaction limits and that swapping can be done in one transaction. This is important to handle cases where the price of the token you are buying has changed and no longer fits your slippage limit. If the aggregator cannot make the trade with your slippage limit, it will roll back the transaction and return an error.

### Friendly UI <a href="#bfdb" id="bfdb"></a>

We aim to make the UI as intuitive and user-friendly as possible. The user interface of the AshSwap Aggregator remains the same as the Swap's but with a twist. We have added a window showing detailed aggregator routing. Now, users can see the entire amount split and the exchanges involved in the routing.

<figure><img src="https://miro.medium.com/v2/resize:fit:630/1*tJIgY5LDCJ7zuUsurBIz8w.png" alt="" height="997" width="700"><figcaption></figcaption></figure>

> ***Notice:** The screenshots used in this post are for demonstration purposes only. Values are not accurately presented.*

## To sum up <a href="#b9b9" id="b9b9"></a>

AshSwap is delivering a sustainable liquidity infrastructure for DeFi on MultiversX. As a liquidity hub, AshSwap Aggregator connects liquidity from various protocols and sources to provide the best token rates to traders with minimal slippage.

## For Aggregator Integration

Please kindly check our [SDKs](https://docs.ashswap.io/developers/sdks) page for further information

###


# Feature Updates

Development history of AshSwap's Aggregator

## Version 2.1

#### Updated on April 25, 2024

#### Features

* Automatic listing newly-created pools on xExchange, OneDex, and AshSwap.&#x20;
* To be featured on the aggregator, pools must maintain a Total Value Locked (TVL) exceeding $500. Any previously listed pool that falls below this threshold will be removed.

#### Additional information

* There is a maximum delay of 1 hour from the time a pool meets the listing criteria until it is listed.


# Swap Guide

A step-by-step guide to swap assets on AshSwap.

## Aggregator Swap Guide

[**AshSwap DEX Aggregator**](/resources/ashswap-academy/dynamic-aggregator) aims to serve as the go-to trading portal on MultiversX by ensuring a seamless, efficient, and secure trading experience. Thanks to our Dynamic Trade Routing, Each user will receive a full package of information on prices, slippage, and gas fees via the most optimal route.

**How to use Aggregator?**

When you utilize the Swap functionality, the Aggregator is always applied as part of the process. Therefore, there will be no change in how Swap is operated compared to the standard procedure.

**Step 1:** Connect your Wallet

{% content-ref url="/pages/e98y5U29WnJQKryTyydb" %}
[Connect a Wallet](/ashswap-dex/connect-a-wallet)
{% endcontent-ref %}

**Step 2:** Choose the asset and input the amount you want to swap

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

**Step 3:** Swap your asset with an optimized cost by AshSwap Aggregator

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

### Search Token

**Step 1:** Click on the token box as shown below

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

**Step 2:** Input the token name which you want to trade and choose the token you are looking for&#x20;

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

## Swap Details

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

### Fees

Which liquidity providers earn from successful transactions. Don't worry, It's small.

### Price Impact

Making a trade shifts the ratio of tokens in the pool, causing this change in price per token.

### Minimum Received

The minimum amount you would get after subtracting fees and maximum slippage being reached.

### Slippage Tolerance

You can change this in settings to either make sure you get the amount you want, or your transaction will not be reverted.


# Aggregator Integration

How projects and protocols can integrate AshSwap Aggregator or be integrated.

## Integrators

AshSwap welcomes everyone who wants to integrate our Aggregator, yet there are a few "soft" rules:

* Users must be informed that the AshSwap Aggregator API is in use, such as mention us in your announcement of new features and applications.
* A phrase such as "Powered by AshSwap Aggregator" on Integrator's UI is an extremely kind &#x20;
* Avoid modifying the AshSwap Aggregator smart contract, whether it be within the SDK or not.&#x20;
* AshSwap reserves the prerogative to withhold assistance from unscrupulous individuals.

## DEXs

[Contact](/resources/links-and-contact) us regarding the integration of your DEX pools/markets with AshSwap Aggregator.

## UI Providers

AshSwap SDK provides developers with an SDK to integrate AshSwap pools, farms, and aggregators: <https://www.npmjs.com/package/@ashswap/ash-sdk-js>.


# Adding Fees

There are no protocol fees for AshSwap Aggregator or platform fees on AshSwap UI, however, UI providers may implement platform fees. If a platform fee is set, AshSwap will take 10% of the platform fees charged by integrators.

## Overall

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

{% hint style="info" %}
[Contact](/resources/links-and-contact) us to establish fees for your platforms.
{% endhint %}

## SDK Configuration

First, register with us the wallet you use for collecting the fees and the fees you would like to set for your platform. Then, use that wallet as the `protocol` argument in your integration.

{% code lineNumbers="true" %}

```javascript
const swapWithPaths = async () => {
    const integrator = 'erd...'; // your fee wallet
    const agService = new Aggregator({chainId: ChainId.Mainnet, protocol: integrator});

    // use the response to display on the UI
    const sorswap = await agService.getPaths('EGLD', 'ASH-a642d1', 1e18);
    
    if (!sorswap) throw new Error(`Could not find any paths for EGLD to ASH`);
    const interaction = await agService.aggregateFromPaths(sorswap, 100);
    // remember to set the sender (caller) before sending the tx
    const tx = interaction.withSender(new Address('erd...')).check().buildTransaction();
    
    // sign and send tx to the network
    // sendTransactions({
    //     transactions: [tx],
    // })
}
```

{% endcode %}

{% hint style="info" %}
More examples can be found here: <https://github.com/ashswap/ash-sdk-js/blob/feat/ag-v1_2/example/aggregator.ts>
{% endhint %}

## CLI

### Query Fee Percentage

100% equals 100,000 in the smart contract. If your fee is 0.1%, the result is 100.

{% code overflow="wrap" %}

```bash
mxpy contract query erd1qqqqqqqqqqqqqpgqcc69ts8409p3h77q5chsaqz57y6hugvc4fvs64k74v --proxy https://gateway.multiversx.com --function getProtocolFeePercent --arguments 0x$(mxpy wallet bech32 --decode [YOUR FEE WALLET])
```

{% endcode %}

### Query Claimable Fees

{% code overflow="wrap" %}

```bash
mxpy contract query erd1qqqqqqqqqqqqqpgqcc69ts8409p3h77q5chsaqz57y6hugvc4fvs64k74v --proxy https://gateway.multiversx.com --function getClaimabeProtocolFee --arguments 0x$(mxpy wallet bech32 --decode [YOUR FEE WALLET]) 0 100
```

{% endcode %}

Fees are taken from token inputs, so over time, fees can consist of multiple tokens, so we allow you to query by indexes. The numbers `0` and `100` at the end of the query are the start index and end index, respectively.

### Claim Fees

Claim all fees available in the smart contracts.

{% code overflow="wrap" %}

```bash
mxpy contract call erd1qqqqqqqqqqqqqpgqcc69ts8409p3h77q5chsaqz57y6hugvc4fvs64k74v --proxy=https://gateway.multiversx.com --chain=1 --gas-limit=600000000 --pem=[YOUR FEE WALLET PEM FILE] --recall-nonce --send --wait-result --function=claimProtocolFee --arguments 0x$(mxpy wallet bech32 --decode [YOUR FEE WALLET])
```

{% endcode %}

When the number of fee tokens is too large, to make sure the transaction doesn't go over the gas limit or it doesn't make sense economically to claim small fee tokens, you can claim fees by tokens.

{% code overflow="wrap" %}

```bash
mxpy contract call erd1qqqqqqqqqqqqqpgqcc69ts8409p3h77q5chsaqz57y6hugvc4fvs64k74v --proxy=https://gateway.multiversx.com --chain=1 --gas-limit=600000000 --pem=[YOUR FEE WALLET PEM FILE] --recall-nonce --send --wait-result --function=claimProtocolFeeByTokens --arguments 0x$(mxpy wallet bech32 --decode [YOUR FEE WALLET]) 0x$(echo -n "WEGLD-bd4d79" | xxd -p -u | tr -d '\n') 0x$(echo -n "USDC-c76f1f" | xxd -p -u | tr -d '\n')
```

{% endcode %}

`WEGLD-bd4d79` and `USDC-c76f1f` are the tokens you want to claim.

{% hint style="info" %}
Contract function signatures can be found here: <https://github.com/ashswap/ash-aggregator-sc/blob/main/dex/aggregator/src/lib.rs>
{% endhint %}


# Trade

## Trading Parameters

| Parameter              | Metric  |
| ---------------------- | ------- |
| Min Position Size      | 1000    |
| Max Collateral         | 5000    |
| Max OI                 | Dynamic |
| Min Leverage           | 2       |
| Max Leverage           | 100     |
| Max Positions per Pair | 3       |
| Maximum SL             | 80%     |
| Maximum TP             | 900%    |

## Trading Flow

Currently, AshPerp only supports those types of orders:

* **Market:** To be used to open a trade immediately. It will open at the market price + spread.
* **Limit**: To be used when you want to go long at a lower price than present, or to go short if the price reaches a higher price than present. The execution price is the determined limit price + spread.
* **Stop:** To be used when you want to go long if the price reaches a higher price than present, or to go short if the price reaches a lower price than present. You might want to use this to long a breakout, or short a breakdown. The execution price is the determined stop price + spread.

### Open a market order

* When a user creates a market order, their order is sent to the AshPerp’s servers.
* The price will be fulfilled off-chain via our oracle system, and the fulfilled order is sent to the trading contract afterwards.
* A small fee will be charged for opening an order.

### Open a limit / stop order

* Users initiate a trade by sending their order to the Trading Contract and paying the associated gas fee. Our Matching bots then receive the order and wait until the price aligns with the user's specified price.
* When the price meets the user's criteria, the Matching bots sign off on this price and forward it to the Trading Engine. The Trading Engine, in turn, contacts the oracle bots to gather their signatures and confirm the price. Following this verification, the Trading Engine proceeds to submit the transaction to our Trading Contract. Before opening the order, the Trading Contract conducts a final verification of the price.
* A small fee will be charged for opening an order.

### Close an order

* When a user closes their order, the close order awaits fulfillment through the price feed system, after which the callback is triggered to officially close it.
* A small fee will be charged for closing an order.

### Update Take Profit / Stop Loss Price

* Users can modify the take profit (TP) or stop loss (SL) price of an order, and the new parameters will be stored in the contract.

### Take Profit / Close Stop Loss

* When an order reaches the take profit or stop loss condition, Matching bots will initiate the order and submit a request to our system to **close the order**.
* When the price meets the TP/SL price, the Matching bots sign off on this price and forward it to the Trading Engine. The Trading Engine, in turn, contacts the oracle bots to gather their signatures and confirm the price. Following this verification, the Trading Engine proceeds to submit the transaction to our Trading Contract. Before opening the order, the Trading Contract conducts a final verification of the price.
* A small fee will be charged for closing an order.

### Adjust Leverage

* Adjusting the leverage of your order keeps the position size constant; only the amount of collateral is altered to match the new leverage setting. Currently, AshPerp permits only a reduction in leverage. To lower the leverage, traders must add a proportional amount of collateral to the position.
* This adjustment in collateral affects the Liquidation Price accordingly.

### Liquidations

* When an order reaches the liquidation price, Matching bots will initiate the order and send a request to our system to **liquidate the order**. The Liquidation Price Distance is calculated as follows:

$$
LiquidationPriceDistance=\frac{OpenPrice\*(Collateral\*90%-BorrowFee)\*Leverage}{Collateral}
$$

* The **liquidation price** is determined as follows:
  * For Long positions: Open Price - Liquidation Price Distance
  * For Short positions: Open Price + Liquidation Price Distance.
* When the price meets liquidation price, the Matching bots sign off on this price and forward it to the Trading Engine. The Trading Engine, in turn, contacts the oracle bots to gather their signatures and confirm the price. Following this verification, the Trading Engine proceeds to submit the transaction to our Trading Contract. Before opening the order, the Trading Contract conducts a final verification of the price.
* A small fee will be charged when your order is liquidated.

{% content-ref url="/pages/OYBcl2a48vhv529MzkdM" %}
[Trade Guide](/ashperp/trade/trade-guide)
{% endcontent-ref %}


# Trade Guide

## How to open a position?

**Step 1:** Choose a pair in which you want to open a position

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

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

**Step 2:** Choose order type

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

* **Market:** To be used to opening a trade immediately. It will open at the market price (+ spread).
* **Limit:** To be used when you want to go long at a lower price than present, or to go short if the price reaches a higher price than present. The execution price is the determined limit price + spread.
* **Stop:** To be used when you want to go long if the price reaches a higher price than present, or to go short if the price reaches a lower price than present. You might want to use this to long a breakout, or short a breakdown. The execution price is the determined stop price + spread.

**Step 3:** Choose a position type

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

**Step 4:** Enter the remaining fields for your order

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

* Collateral
* Leverage
* Take profit
* Stop loss

**Step 5:** Review your order and open your position

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

## How to cancel an order?

**Step 1:** Open your orders list

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

**Step 2:** Choose the order you want to cancel and click on the X button, then confirm the transaction

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

## How to close a position?

**Step 1:** Open your positions list

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

**Step 2:** Choose the position you want to cancel and click on the X button, then confirm the transaction

<figure><img src="/files/7FrsMCJdXj6Xc9sKjLL4" alt=""><figcaption></figcaption></figure>

## How to adjust a position?

**Step 1:** Open your positions list

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

**Step 2:**  Choose the position you want to adjust and click on the adjust button; adjust your position, then click update or ESC if you don't want to make an adjust

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

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


# Perpetual Vault

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

The vault serves as the counterparty to all trades made on the platform:

* When traders win (positive PnL), their winnings are received from the vault.
* When traders lose (negative PnL), their losses are sent to the vault.

### **Insurance Fund**

<figure><img src="/files/0lToJxMfSgTNALZ1XOdE" alt=""><figcaption></figcaption></figure>

* The **Insurance Fund** acts as a protective layer for the vault in case of positive PnL, aiming to minimize the downward price trend of apUSDC.
* This fund is managed by an administrator, allowing them to withdraw from and deposit into the vault at any time. Withdrawals from the **Insurance Fund** can be flexibly used for beneficial strategies, such as buying back ASH, sending to the treasury, and allocating for product R\&D.

### Value of apUSDC

$$
apUSDC = 1+ \frac{(PnL - insurance + fee)}{VaultTotalSupply}
$$

$$
APR(30D) = \frac{(\frac{apUSDC\_{CurrentPrice}}{apUSDC\_{LastMonthPrice}}-1)}{30}*365*100%
$$

$$
APR(7D) = \frac{(\frac{apUSDC\_{CurrentPrice}}{apUSDC\_{LastWeekPrice}}-1)}{7}*365*100%
$$

$$
APR(1D) =(\frac{apUSDC\_{CurrentPrice}}{apUSDC\_{YesterdayPrice}}-1)*365*100%
$$

**According to the formula:**

* **If PnL > 0**: The vault records a loss, and 100% of this loss is allocated to the reserve, with a priority to use funds from the insurance fund first.
* **If PnL < 0**: The vault records a profit, and 100% minus a certain percentage (x%) is allocated to the reserve, where x% is distributed to the insurance fund. The administrator can deposit or withdraw from the insurance fund at any time.
* **Fees:** Trading fees that are allocated to the Vault (if any) will be reflected in the apUSDC price as per the outlined formula.
* **Order Execution**: Every order that is opened or closed, involving money being received or transferred from the vault, directly reflects on the apUSDC price through PnL and fees (if any)

#### **Withdrawing from the Vault:**

* To initiate a withdrawal, a request must be made, followed by a 7-day cooldown period and a 2-day redemption window after the cooldown ends. This timeframe can be subject to changes.
* The apUSDC price will fluctuate according to market conditions throughout the cooldown period, and the withdrawal exchange rate is fixed at the moment of redemption (during the 2-day window).
* Users can still trade apUSDC on DEXs to avoid the cooldown period. There will be an apUSDC/USDC pool created on AshSwap for this purpose.

{% content-ref url="/pages/OmcPE38nEW56REvEuxZV" %}
[Vault Guide](/ashperp/perpetual-vault/vault-guide)
{% endcontent-ref %}

### FAQ

<details>

<summary>Why is the APR 0%? Does that mean I'm not gaining money or even losing money?</summary>

During periods of high volatility, the price of apUSDC can experience significant short-term decreases, leading to a reduced APR. It's crucial to recognize that this reflects only a temporary measure of apUSDC's performance, analyzed on daily, weekly, and monthly intervals. Such fluctuations do not automatically equate to a financial loss. Instead, if the value of apUSDC at the point of withdrawal exceeds its value at the time of your initial deposit, you will realize a financial gain.

</details>

<details>

<summary>Why do I have to wait for several days to claim back my fund?</summary>

The primary objective is to mitigate the occurrence of front-running profit and loss fluctuations, while also guaranteeing sufficient liquidity for the exchange.

</details>

<details>

<summary>How can I check my profits for being an LP for the Perpetual Vault?</summary>

You can evaluate the price of apUSDC at the time of your deposit against its present value.

The real-time profit value will be available soon.

</details>


# Vault Guide

## How to deposit?

**Step 1:** Choose Vault, then choose deposit

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

**Step 2:** Enter the token amount you want to deposit

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

**Step 3:** Click deposit button

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

## How to withdraw?

> Kindly notice that:
>
> * To initiate a withdrawal, a request must be made, followed by a 7-day cooldown period and a 2-day redemption window after the cooldown ends. This timeframe can be subject to changes.
> * The apUSDC price will fluctuate according to market conditions throughout the cooldown period, and the withdrawal exchange rate is fixed at the moment of redemption (during the 2-day window).
> * Users can still trade apUSDC on DEXs to avoid the cooldown period. There will be an apUSDC/USDC pool created on AshSwap for this purpose.

**Step 1:** Choose Vault, then choose withdraw

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

**Step 2:** Enter the token amount you want to withdraw

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

**Step 3:** Click request queue button

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

Then wait until the Claim Button is on; please kindly claim your part before the clock run out.

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


# One-click Trading (1CT)

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

### What is 1CT?

One-click trading (1CT) allows users to tap into the seamless experience of a CEX, unlocking the full performance of trading.

Without 1CT, users must sign multiple transactions when modifying an order or position with linked triggers. With 1CT, the process is automated delivering the trading experience more akin to a CEX but with self-custody.

The release of 1CT emulates the familiar trading experience of CEXs, where users can log in and start trading until they finish their trading affairs. The near-instant trade execution of 1CT imbues confidence into those fleeting pauses of apprehension preceding every trade instead of idling while you wait for an approval transaction to confirm.

### How 1CT works?

1CT does this through the use of two new mechanisms:

* 1CT wallet
  * AshPerp uses a derived externally owned account (EOA) wallet for submitting trading transactions. **It relies on the following sequence:**
    * Trader provides a 4 digit PIN.
    * Trader signs a prefixed message of the PIN using their wallet.
    * AshPerp generates a **Secp256k1** key pair using the signed message as a seed.
    * AshPerp encrypts and stores the key material on the local device.
  * Once a trader creates a 1CT wallet, they must grant it permission to trade on their behalf by approving it as a delegate.
* Trade delegation
  * AshPerp smart contracts support a delegation feature, allowing EOAs to submit transactions on behalf of other EOAs. To delegate trading to another EOA, a trader must approve the address as a delegate through the trading contract. A delegation wallet only needs gas funds for submitting transactions, as collateral and PnL are tied to the trader address.

### How to use 1CT?

* **Step 1:** Connect your wallet

Currently on Devnet we are supporting the MultiversX DeFi Wallet Extension, for further guide, please kindly [check here](https://docs.ashswap.io/ashswap-feature/connect-a-wallet).

* **Step 2:** Enable 1CT

<figure><img src="/files/9iO4gtFbIFBJf0yTFF3R" alt=""><figcaption><p>Click Enable 1CT</p></figcaption></figure>

* **Step 3:** Setup 1CT with your 4 digit number PIN CODE

<figure><img src="/files/nCPf1qquz4AE0IpTBXiK" alt=""><figcaption><p>Fill in your PIN CODE</p></figcaption></figure>

<figure><img src="/files/hBeMMAnU4uP0tNu8FiXz" alt=""><figcaption><p>Click Approve</p></figcaption></figure>

* **Step 4:** Deposit your token to 1CT wallet and start your trading journey

<figure><img src="/files/tz5YYlbEkiMzxSXIImGv" alt=""><figcaption><p>1CT is on, click Deposit to move your token to 1CT wallet</p></figcaption></figure>

<figure><img src="/files/CjBMY9IcDfafOa1FTWs3" alt=""><figcaption><p>Choose the Amount and click Confirm</p></figcaption></figure>

### FAQ

<details>

<summary>I don't see the Tx confirm when using 1CT</summary>

This is due to the authority you've already granted to your 1CT wallet. 1CT aims to provide an experience comparable to that of a centralized exchange (CEX), yet it's essential to meticulously review the order details before sending it.

</details>

<details>

<summary>I don't want to use 1CT anymore. How can I go back to trading directly from my wallet?</summary>

There are 2 ways you can do that:

1/ Switch off the toggle from "One click trading - ON" to "One click trading - OFF"&#x20;

![](/files/TzgmGU64E1W05bKqqAQo)

2/ Click Reset and confirm, you can always re-activate the 1CT wallet at your will

![](/files/pwfJXCQ1a0ARzD2GBcp6)

</details>

<details>

<summary>I turned on 1CT, but can not create Tx, why?</summary>

Remember to deposit EGLD to your 1CT Wallet for gas fees

</details>


# Referral

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

### **The More, The Merrier**

Don’t just trade alone! Bring your friends to AshPerp to earn rebates and win prizes in the Referral Program. Plus, your friends will get a 10% discount on open fees.

{% hint style="info" %}
Let's visit <https://ashperp.trade/referral> and get your code!
{% endhint %}

There are two parties who will benefit from this program:

* **Referrals**: who are invited to AshPerp using a referral code
  * Each referral is linked to only one referral code, which cannot be changed.
  * Referrals will enjoy a 10% discount on open fees when initiating trades on AshPerp.
* Referrers: who share their referral codes to invite friends to join AshPerp
  * There's no limit to the number of referrals you can invite.
  * Referrers will earn rebates from their referrals' open fees, with the amount depending on their achieved tier.

### What are the benefits of Referrers and Referrals?

You can earn Discount / Rebate based on Open Fees

<figure><img src="https://miro.medium.com/v2/resize:fit:720/format:webp/1*kbLCSBWZFo8P48iEBCzIRA.jpeg" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}

* **Trading Fee Discount:** This is benefit that traders receive when becoming referral of a referrer, the amount will be determined based on referrer’s tier.
* **Referrer Rebate:** This is the commission that a referrer receives for referring new users to AshPerp, retrieved from the open fees of each order opened by the referrals.
  {% endhint %}

Tiers will be tracked based on the following rule:

* **Tier 0**: Anyone can create a Tier 0 code (default).
* **Tier 1:** You should have a minimum of 5 active users utilizing your referral codes each cycle, with a combined volume of at least $1 million.
* **Tier 2:** You should have a minimum of 10 active users utilizing your referral codes each cycle, with a combined volume of at least $3 million.
* **Tier 3:** You should have a minimum of 20 active users utilizing your referral codes each cycle, with a combined volume of at least $10 million.

User’s Referral tier will be validated and updated every AshSwap's Cycle

* AshSwap’s Cycle: 00:00 UTC Thursday - 00:00 next Thursday
* **Trading Volume of Referrals**, **Rebates Paid** and **Number of Active Referrals** will be reset to 0 at the beginning of a Cycle

{% content-ref url="/pages/MX6hqfPbrvDnv62161z7" %}
[Referral Guide](/ashperp/referral/referral-guide)
{% endcontent-ref %}

### FAQ

<details>

<summary>What criteria determine if a referral is "active"?</summary>

That user will need to have at least 1 order per Cycle (00:00 Thursday - 00:00 next Thursday)

</details>


# Referral Guide

### How to refer friends

* Connect your wallet
* In the top right corner, next to the "Connect wallet" button, you'll see your current referral benefits. Click here to access the referral page <https://ashperp.trade/referral>.

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

* Go to the **"Referral Details"** tab, select "Refer new user to earn rebates," and then click "Refer now."

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

* Share your referral code on Twitter and Telegram by clicking social buttons, or download the QR code to share it directly with friends.

<figure><img src="/files/1RH5ZBGDg9ypPgLQeNQN" alt=""><figcaption></figcaption></figure>

* Keep an eye on your referral journey to maintain a high tier and maximize rebate earnings.
* You can claim your rebates at any time.
* Under **"Your Stats",** monitor the trading activities of your referrals, including their address, trade initiation, entry date, weekly trading volume, and rebates paid to you.

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

* Visit <https://bop.ashswap.io/analytics> to see your rank on the **Referral Leaderboard** in the Battle of Perps.

### How to redeem a referral code

* Click on any referral link, or scan QR code to enter Battle Of Perps.
* Connect your wallet.
* Click on the pop-up blue line stating ***"Redeem referral code XXYYZZ and get a 10% trading fee discount."*** This line will disappear after successful redemption or after 7 days if not redeemed.

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

* In the **"Referral Details"** tab, click "Redeem Now".

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

* Click "CONFIRM", and confirm the transaction in your wallet. That's it! Now, you're all set to open trades on AshPerp.

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


# AshGuard NFTs

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

## What Is AshGuard NFT Collection?

[**AshGuard NFT**](https://ashguard.xyz/) is a trading utility NFT collection for use on AshPerp. By staking these NFTs, users can access tier-based perks, including fee rebates, spread discounts, and potential community rewards during trades on AshPerp.

[**AshPerp**](https://perp.ashswap.io/perpetual) itself is **the first perpetual DEX on the MultiversX network**, built as part of the AshSwap DeFi Hub. It offers perpetual leveraged trading up to 100x, supports a variety of asset pairs, and caters to the growing demand for decentralized futures trading within MultiversX.The official Mainnet launch of AshPerp is expected in early March 2024.

## The Utilities Of AshGuard NFT

<figure><img src="https://blog.ashswap.io/wp-content/uploads/2024/01/ashguard-utility.png" alt=""><figcaption></figcaption></figure>

More than mere collectibles, AshGuard wields the might of utility NFTs, blending captivating visuals and DeFi prowess.

* For AshPerp users: When you stake AshGuard with AshPerp, you are entitled for **open fee rebates** and get **discounts on fixed spreads**, scaled by NFT tiers.

The higher your tier, the greater the benefits, allowing you to trade more effectively with superior execution prices and reduced fees. Plus, you can stack these rebates with a 10% discount from our Referral Program, saving up to 60% on fees.

* For NFT enthusiasts: AshGuard NFTs are not just your average utility NFTs; each one is uniquely crafted, blending Norse inspiration with a modern anime style that sets them apart.
* Thanks to the exclusive merging mechanism, AshGuard NFTs are upgradable for increased trading benefits, leading to a higher value.
* Staking AshGuard NFTs positions you favorably for upcoming community rewards.
* There are five tiers of NFTs, each representing a unique species (Orc, Elf, Beast, Ninja and Paladin); the higher the tier, the more significant your advantages.

## Merging Mechanism <a href="#id-3bd1" id="id-3bd1"></a>

<figure><img src="https://blog.ashswap.io/wp-content/uploads/2024/01/ashguard-merging.png" alt=""><figcaption></figcaption></figure>

**AshGuard NFT Tier 4 (Ninja)** and **Tier 5 (Paladin**) cannot be minted directly on launch. To get these advanced NFTs, you’ll need to either combine lower-tier ones on AshPerp, purchase them from a secondary marketplace, like [XOXNO](https://xoxno.com/), or receive them from other owners.How merging works:

* Combine two NFTs of the same tier (as per the table above) and pay a merging fee in ASH tokens.
* We will send a higher-tier NFT to your wallet.

## How to Mint and Merge AshGuard NFTs <a href="#id-35a5" id="id-35a5"></a>

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

You can check the step-by-step guide article [here](https://medium.com/@ashswap/a-step-by-step-guide-on-how-to-mint-and-merge-ashguard-nfts-2d905ccbbe0d).


# AshGuard Staking Guide

<figure><img src="https://blog.ashswap.io/wp-content/uploads/2024/01/ashguard-utility.png" alt=""><figcaption></figcaption></figure>

* NFT stake page: [https://ashperp.trade/nft](https://devnet-alpha.ashperp.trade/nft)
* You are only able to stake 1 AshGuard NFT
* Please note that there will be a one-day cooldown period before you can withdraw your NFT after staking it.

### How to Stake your NFT

* Step 1: Connect your wallet
* Step 2: Choose the NFT you want to stake

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

* Step 3: Click the Claim button & Check the NFT benefits

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


# AshGuard Merge Guide

By merging 2 same-tiered NFTs, you can upgrade your AshGuard to 1-tier higher NFT. This upgrade feature is available at the same time as you mint new NFTs. (Details on the [**benefits of each tier.**](https://blog.ashswap.io/ashguard-nft-collection/))

The merging mechanism is as below:

<figure><img src="https://miro.medium.com/v2/resize:fit:700/0*TBX7se4SonbdSQWU" alt="" height="397" width="700"><figcaption></figcaption></figure>

1. Visit <https://ashguard.xyz/> and connect your wallet.
2. Navigate to the “Merge” section and select two NFTs of the same tier that you wish to merge.

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*3cUvNlI44BMnTMTesuSDZA.png" alt="" height="285" width="700"><figcaption></figcaption></figure>

3\. Press the “Merge” button to initiate the process. This will require you to have some $ASH tokens to cover the merging fees. For specific fee details, please refer to the above image.

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*DLt5Nq8gnAoowubNmDlfpA.jpeg" alt="" height="413" width="700"><figcaption><p>Choose the NFTs you want to merge</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*wgqtt7YF3Pk9DDEN4fjXXg.jpeg" alt="" height="338" width="700"><figcaption><p>Click the button and wait for your new AshGuard NFT</p></figcaption></figure>

4\. Confirm the transaction through your wallet. Your new NFT will be delivered to your wallet shortly after the transaction is completed successfully.


# Smart Contracts

The architecture and functionalities of AshSwap smart contracts.

{% hint style="info" %}
The smart contracts of AshSwap have not been public. We plan to make it open source in the future after having all the security audits in place.
{% endhint %}

### Overview

#### Pool Contracts

The Pool Contract acts as an AMM for trading tokens. The AMM is based on Curve's algorithm used for the stable coin. Fee contains two types of fees: trading fee and admin fee.

The trading fee will stay in the liquidity pool to leverage LP holder interest. The admin fee will be sent to the veASH holder.

#### [Router Contract](https://explorer.multiversx.com/accounts/erd1qqqqqqqqqqqqqpgqjtlmapv42pcga5nglgfrnpqvkq06wdqx4fvsvw6xpt)

Manager of Pool Contracts. All Pool Contracts will be deployed through the router. Currently, only the admin (owner) can interact with it.

Another function of the Router is collecting the admin fee from pools and transfer to the Fee Distributor Contract.

This contract may also be referred to as our **Factory Contract.**

#### Farm Contract

The Farm Contract is a contract where users can lock their LP token to receive ASH.

Following Maiar Exchange, the farm position is represented by Farm Token, which is a Semi-Fungible Token. The reasoning behind this is that to calculate the reward for the token owner without storing anything on a smart contract.

#### Voting Escrow Contract (DAO)

Contract where users can lock their ASH token for pre-set periods to gain veASH (Votes). Votes have weight depending on time. A user who has veASH can receive an admin fee from Pool Contract as their reward.

Besides that, they can use their veASH as a voting weight in the DAO voting system.

#### Fee Distributor Contract

The contract contains the admin fee that is collected from Pools and distribute it into veASH owner.


# Pool Router

## Contract Interface

### Get pool addresses

Returns all pool's addresses of AshSwap.

```rust
#[view(getAllPoolAddresses)]
fn get_all_pool_addresses(&self) -> MultiValueEncoded<ManagedAddress>
```

### Get pool tokens

Return tokens of AshSwap's pools

```rust
#[view(getAllPoolTokens)]
fn get_all_pool_tokens(&self) -> MultiValueEncoded<PoolTokens<Self::Api>>
```


# Stable Pool

This pool type contain stable tokens

## Contract Interface

### 1. Notations & Structs

#### 1.1. PoolResultType

```rust
pub type PoolResultType<BigUint> = ManagedVec<BigUint, EsdtTokenPayment<BigUint>>;
```

#### 1.2. TokenAttributes

```rust
pub struct TokenAttributes<M: ManagedTypeApi> {
    pub reserve: BigUint<M>,
    pub rate: BigUint<M>,
}
```

#### 1.3. AddLiquidityAttributes

```rust
pub struct AddLiquidityAttributes<M: ManagedTypeApi> {
    pub token: TokenIdentifier<M>,
    pub attribute: TokenAttributes<M>,
    pub amount_added: BigUint<M>,
    pub total_fee: BigUint<M>,
    pub admin_fee: BigUint<M>,
}
```

#### 1.4. AddLiquidityEvent

```rust
pub struct AddLiquidityEvent<M: ManagedTypeApi> {
    lp_token_amount: BigUint<M>,
    lp_token_supply: BigUint<M>,
    tokens: ManagedVec<M, AddLiquidityAttributes<M>>,
}
```

#### 1.5. RemoveLiquidityAttributes

```rust
pub struct RemoveLiquidityAttributes<M: ManagedTypeApi> {
    pub token: TokenIdentifier<M>,
    pub attribute: TokenAttributes<M>,
    pub amount_removed: BigUint<M>,
}
```

#### 1.6. RemoveLiquidityEvent

```rust
pub struct RemoveLiquidityEvent<M: ManagedTypeApi> {
    lp_token_amount: BigUint<M>,
    lp_token_supply: BigUint<M>,
    tokens: ManagedVec<M, RemoveLiquidityAttributes<M>>,
}
```

#### 1.7. RemoveLiquidityOneCoinEvent

```rust
pub struct RemoveLiquidityOneCoinEvent<M: ManagedTypeApi> {
    lp_token_amount: BigUint<M>,
    lp_token_supply: BigUint<M>,
    total_fee: BigUint<M>,
    admin_fee: BigUint<M>,
    token_out: RemoveLiquidityAttributes<M>,
}
```

#### 1.8. ExchangeAttributes

```rust
pub struct ExchangeAttributes<M: ManagedTypeApi> {
    pub token: TokenIdentifier<M>,
    pub attribute: TokenAttributes<M>,
    pub final_amount: BigUint<M>,
}
```

#### 1.9. ExchangeEvent

```rust
pub struct ExchangeEvent<M: ManagedTypeApi> {
    total_fee: BigUint<M>,
    admin_fee: BigUint<M>,
    token_in: ExchangeAttributes<M>,
    token_out: ExchangeAttributes<M>,
}
```

### 2. Write functions

#### 2.1. Add liquidity

```rust
#[payable("*")]
#[endpoint(addLiquidity)]
fn add_liquidity(&self, mint_amount_min: BigUint, lp_token_receiver: &ManagedAddress) -> PoolResultType<Self::Api>

```

#### 2.2. Remove liquidity

```rust
#[payable("*")]
#[endpoint(removeLiquidity)]
fn remove_liquidity(&self, token_amount_min: MultiValueEncoded<BigUint>) -> PoolResultType<Self::Api>
```

#### 2.3. Exchange

```rust
#[payable("*")]
#[endpoint(exchange)]
fn exchange(&self, token_out: TokenIdentifier, amount_out_min: BigUint) -> PoolResultType<Self::Api>
```

`token_out`: The token id that you want to receive after exchanging.

`amount_out_min`: The minimum amount of `token_out` that you will receive. If the pool returns an amount that is smaller than `amount_out_min` the transaction will be reverted.

### 3. Read functions

#### 3.1. Estimate the exchange output

```rust
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, TypeAbi, Clone, ManagedVecItem)]
pub struct TokenAttributes<M: ManagedTypeApi> {
    pub reserve: BigUint<M>,
    pub rate: BigUint<M>,
}

#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, TypeAbi, Clone, ManagedVecItem)]
pub struct ExchangeAttributes<M: ManagedTypeApi> {
    pub token: TokenIdentifier<M>,
    pub attribute: TokenAttributes<M>,
    pub final_amount: BigUint<M>,
}

#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, TypeAbi, Clone)]
pub struct ExchangeResultType<M: ManagedTypeApi> {
    pub total_fee: BigUint<M>,
    pub admin_fee: BigUint<M>,
    pub token_in: ExchangeAttributes<M>,
    pub token_out: ExchangeAttributes<M>,
}

#[view(estimateAmountOut)]
fn get_amount_out(&self, token_in: &TokenIdentifier, token_out: &TokenIdentifier, amount_in: BigUint) -> ExchangeResultType<Self::Api>
```

#### 3.2. Estimate add liquidity

```rust
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, TypeAbi, Clone)]
pub struct AddLiquidityResultType<M: ManagedTypeApi> {
    pub mint_amount: BigUint<M>,
    pub tokens: ManagedVec<M, AddLiquidityAttributes<M>>,
}

#[view(estimateAddLiquidity)]
fn pool_add_liquidity(&self, token_amount_added: &ManagedVec<BigUint>) -> AddLiquidityResultType<Self::Api>
```

#### 3.3. Estimate remove liquidity

```rust
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, TypeAbi, Clone)]
pub struct RemoveLiquidityResultType<M: ManagedTypeApi> {
    pub burn_amount: BigUint<M>,
    pub tokens: ManagedVec<M, RemoveLiquidityAttributes<M>>,
}

#[view(estimateRemoveLiquidity)]
fn pool_remove_liquidity(&self, burn_amount: BigUint) -> RemoveLiquidityResultType<Self::Api>
```

#### 3.4. Get AMP factor

```rust
#[view(getAmpFactor)]
fn get_amp_factor(&self) -> u64
```

#### 3.5. Get pool state

```rust
#[derive(TopEncode, TopDecode, PartialEq, TypeAbi, Debug)]
pub enum State { Inactive, Active, ActiveNoSwaps }

#[view(getState)]
fn state(&self) -> State;
```

#### 3.6. Get LP token identifier

```rust
#[view(getLpTokenIdentifier)]
fn get_lp_token_identifier(&self) -> TokenIdentifier
```

#### 3.7. Get LP token supply

```rust
#[view(getTotalSupply)]
fn get_lp_token_supply(&self) -> BigUint
```

#### 3.8. Get pool tokens

```rust
#[view(getTokens)]
fn get_tokens(&self) -> ManagedVec<TokenIdentifier>
```

#### 3.9. Get token balances

```rust
#[view(getBalances)]
fn get_balances(&self, token: &TokenIdentifier) -> BigUint
```

#### 3.10. Get swap fee

```rust
#[view(getSwapFeePercent)]
fn swap_fee_percent(&self) -> u64;
```

#### 3.11. Get admin fee

```rust
#[view(getAdminFeePercent)]
fn admin_fee_percent(&self) -> u64;
```

### 4. Events

#### 4.1. Add liquidity

```rust
#[event("add_liquidity")]
fn add_liquidity_event(
    &self,
    #[indexed] timestamp: u64,
    #[indexed] caller: &ManagedAddress,
    add_liquidity_event: &AddLiquidityEvent<Self::Api>,
);
```

#### 4.2. Remove liquidity

```rust
#[event("remove_liquidity")]
fn remove_liquidity_event(
    &self,
    #[indexed] timestamp: u64,
    #[indexed] caller: &ManagedAddress,
    remove_liquidity_event: &RemoveLiquidityEvent<Self::Api>,
);
```

#### 4.3. Remove liquidity one coin

```rust
#[event("remove_liquidity_one_coin")]
fn remove_liquidity_one_coin_event(
    &self,
    #[indexed] timestamp: u64,
    #[indexed] caller: &ManagedAddress,
    remove_liquidity_one_coin_event: &RemoveLiquidityOneCoinEvent<Self::Api>,
);
```

#### 4.4. Exchange

```rust
#[event("exchange")]
fn exchange_event(
    &self,
    #[indexed] timestamp: u64,
    #[indexed] caller: &ManagedAddress,
    exchange_event: &ExchangeEvent<Self::Api>,
);
```


# Crypto Pool

This pool type will contain not-equivalent-value tokens

## Contract Interface

### 1. Notations & Structs

#### 1.1. PoolResultType

```rust
pub type PoolResultType<BigUint> = ManagedVec<BigUint, EsdtTokenPayment<BigUint>>;
```

#### 1.2. AddLiquidityEvent

```rust
pub struct AddLiquidityEvent<M: ManagedTypeApi> {
    pub token_amounts: ManagedVec<M, BigUint<M>>,
    pub fee: BigUint<M>,
    pub lp_token_supply: BigUint<M>,
    pub lp_token_amount: BigUint<M>,
}
```

#### 1.3. RemoveLiquidityEvent

```rust
pub struct RemoveLiquidityEvent<M: ManagedTypeApi> {
    pub token_amounts: ManagedVec<M, BigUint<M>>,
    pub lp_token_supply: BigUint<M>,
    pub lp_token_amount: BigUint<M>,
}
```

#### 1.4. TokenExchangeEvent

```rust
pub struct TokenExchangeEvent<M: ManagedTypeApi> {
    pub sold_id: TokenIdentifier<M>,
    pub tokens_sold: BigUint<M>,
    pub bought_id: TokenIdentifier<M>,
    pub tokens_bought: BigUint<M>,
}
```

### 2. Write functions

#### 2.1. Add liquidity

```rust
#[payable("*")]
#[endpoint(addLiquidity)]
fn add_liquidity(&self, min_mint_amount: BigUint, opt_receiver: OptionalValue<ManagedAddress>) -> BigUint;
```

#### 2.2. Remove liquidity

```rust
#[payable("*")]
#[endpoint(removeLiquidity)]
fn remove_liquidity(&self, min_amounts: ManagedVec<BigUint>, opt_receiver: OptionalValue<ManagedAddress>) -> ManagedVec<BigUint>
```

#### 2.3. Exchange

```rust
#[payable("*")]
#[endpoint(exchange)]
fn exchange(&self, min_dy: BigUint) -> BigUint;
```

`dy`: the minimum amount of the output token

### 3. Read functions

#### 3.1. Estimate the return of exchanging

```rust
#[view(estimateAmountOut)]
fn get_dy(self, i: usize, j: usize, dx: BigUint) -> MultiValue2<BigUint, BigUint>
```

`dx`: input token amount

`i`: input token index

`j`: output token index

#### 3.2. Get pool state

```rust
#[derive(TopEncode, TopDecode, PartialEq, TypeAbi, Debug)]
pub enum State { Inactive, Active, ActiveNoSwaps }

#[view(getState)]
fn state(&self) -> State;
```

#### 3.3. Get LP token identifier

```rust
#[view(getLpTokenIdentifier)]
fn get_lp_token_identifier(&self) -> TokenIdentifier
```

#### 3.4. Get LP token supply

```rust
#[view(getLpTokenSupply)]
fn get_lp_token_supply(&self) -> BigUint
```

#### Get pool tokens

```rust
#[view(getTokens)]
fn get_tokens(&self) -> ManagedVec<TokenIdentifier>
```

#### 3.5. Get token balances

```rust
#[view(getBalances)]
fn get_balances(&self) -> ManagedVec<BigUint>
```

### 4. Events

#### 4.1. Token exchange

```rust
#[event("token_exchange")]
fn token_exchange_event(
    &self,
    #[indexed] buyer: ManagedAddress<Self::Api>,
    token_exchange_event: &TokenExchangeEvent<Self::Api>,
);
```

#### 4.2. Add liquidity

```rust
#[event("add_liquidity")]
fn add_liquidity_event(
    &self,
    #[indexed] provider: ManagedAddress<Self::Api>,
    add_liquidity_event: &AddLiquidityEvent<Self::Api>,
);
```

#### 4.3. Remove liquidity

```rust
#[event("remove_liquidity")]
fn remove_liquidity_event(
    &self,
    #[indexed] provider: ManagedAddress<Self::Api>,
    remove_liquidity_event: &RemoveLiquidityEvent<Self::Api>,
);
```


# Liquidity Staking (Farming)

## Contract Interface

### 1. Notations & Structs

#### 1.1. Payment

`EnterFarmResultType` = `EsdtTokenPayment`

FARM token: a Meta-ESDT token representing the farming position.

#### 1.2. FarmTokenAttributes&#x20;

```rust
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, TypeAbi, Clone, ManagedVecItem, Debug)]
pub struct FarmTokenAttributes<M: ManagedTypeApi> {
    pub reward_per_share: BigUint<M>,
    pub slope_used: BigUint<M>,
    pub booster: ManagedAddress<M>,
    pub initial_farm_amount: BigUint<M>,
    pub initial_farming_amount: BigUint<M>,
    pub reward_tokens: ManagedVec<M, RewardTokens<M>>,
}

fn get_farm_token_attributes<T: TopDecode>(&self, token_id: &TokenIdentifier, token_nonce: u64) -> T {
    let token_info = self.blockchain().get_esdt_token_data(&self.blockchain().get_sc_address(), token_id, token_nonce);
    token_info.decode_attributes()
}
```

Get attributes of Farm MetaESDT token.

#### 1.3. InteractFarmEvent

```rust
#[derive(TypeAbi, TopEncode)]
pub struct InteractFarmEvent<M: ManagedTypeApi> {
    farm_supply: BigUint<M>,
    reward_reserve: BigUint<M>,
    slope_boosted: ManagedVec<M, KeyValue<M>>,
}
```

### 2. Write functions

#### 2.1. enterFarm

Start farming.

Attached tokens:

* LP tokens from Ashswap’s pools
* old FARM tokens: if you attach multiple FARM tokens, they will be automatically merged with the new FARM token (like mergeFarmTokens).

Return: ManagedVec\<EsdtTokenPayment>

* A new Farm token
* Reward tokens from `old FARM tokens` above.

```rust
#[payable("*")]
#[endpoint(enterFarm)]
fn enter_farm(&self, self_boost: &bool) -> ManagedVec<EsdtTokenPayment<Self::Api>>
```

#### 2.2. exitFarm

Claim reward + withdraw LP token. You can only exit one farm using one FARM token per transaction.

Attached token: FARM token received from `enterFarm` function.

Return: ManagedVec\<EsdtTokenPayment>

* 1st `EsdtTokenPayment`: LP token
* 2nd `EsdtTokenPayment`: Reward token

```rust
#[payable("*")]
#[endpoint(exitFarm)]
fn exit_farm(&self) -> ManagedVec<EsdtTokenPayment<Self::Api>>
```

#### 2.3. claimRewards

Claim rewards (ASH token) without withdrawal. You can only claim rewards from one FARM token in one transaction.

Return: ManagedVec\<EsdtTokenPayment>

* 1st `EsdtTokenPayment`: LP token
* 2nd `EsdtTokenPayment`: Reward token

```rust
#[payable("*")]
#[endpoint(claimRewards)]
fn claim_rewards(&self, self_boost: &bool) -> ManagedVec<EsdtTokenPayment<Self::Api>>
```

### 3. Read functions

#### 3.1. getState

Get the current state of a farm.&#x20;

```rust
#[derive(TopEncode, TopDecode, PartialEq, TypeAbi, Clone, Copy)]
pub enum State { Inactive, Active }

#[view(getState)]
fn state(&self) -> State;
```

#### 3.2. getRewardPerShare

Return:

* `BigUint` - the number of ASH tokens received each block per FARM token.

```rust
#[view(getRewardPerShare)]
fn reward_per_share(&self) -> SingleValueMapper<BigUint>;
```

#### 3.3. getFarmTokenSupply

Return:

* `BigUint` - the total supply of the FARM token.

```rust
#[view(getFarmTokenSupply)]
fn farm_token_supply(&self) -> BigUint;
```

#### 3.4 calculateRewardsForGivenPosition

Get your current reward from a farm.

Params:

* `amount: BigUint` - your FARM token’s balance
* `attributes: FarmTokenAttributes`

  Note: The struct is decoded from FARM token’s attributes.

```rust
#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, TypeAbi, Clone, ManagedVecItem, Debug)]
pub struct FarmTokenAttributes<M: ManagedTypeApi> {
    pub reward_per_share: BigUint<M>,
    pub slope_used: BigUint<M>, // slope that user used to boost in this farm token.
    pub booster: ManagedAddress<M>,
    pub initial_farm_amount: BigUint<M>,
    pub initial_farming_amount: BigUint<M>,
    pub reward_tokens: ManagedVec<M, RewardTokens<M>>,
}

#[view(calculateRewardsForGivenPosition)]
fn calculate_rewards_for_given_position(&self, amount: BigUint, attributes: FarmTokenAttributes<Self::Api>) -> BigUint
```

### 4. Events

#### 4.1. Interact farm event

Event for `enterFarm`, `exitFarm`, `claimRewards`

```rust
#[event("interact_farm_event")]
fn interact_farm_event(
    &self,
    #[indexed] caller: &ManagedAddress,
    #[indexed] timestamp: u64,
    interact_farm_event: InteractFarmEvent<Self::Api>,
);
```


# Governance Staking

Each governance staking position is represented by a `Lock`. You can either add more tokens to the lock (stake more) or extend the lock time of the position. Each wallet can only have one lock, so if you want to have a shorter lock time for your ASH tokens, you have to use another wallet.

There are two contracts:

1. Vote-escrowed: Handle staking
2. Fee Distributor: Distribute rewards

## Vote-escrowed

### 1. Write Functions

#### 1.1. create\_lock

Create a lock for the sender.

```rust
#[payable("*")]
#[endpoint]
fn create_lock(&self, unlock_time: u64)
```

Params:

* `unlock_time: u64` - the timestamp of the unlock time. If the timestamp does not match the points of time (the interval between is 7 days on Mainnet), it will be rounded down to the closest point.

Attached tokens:

* ASH

#### 1.2. increase\_amount

There is no param needed as each wallet has only one lock. It will be retrieved from the sender's address.

```rust
#[payable("*")]
#[endpoint]
fn increase_amount(&self)
```

Attached tokens:

* ASH

#### &#x20;1.3. increase\_unlock\_time

Extend the lock time for a lock.

```rust
#[endpoint]
fn increase_unlock_time(&self, unlock_time: u64)
```

Params:

* `unlock_time: u64` - new timestamp for the unlock time, similar to that of `create_lock`

#### 1.4. withdraw

Withdraw locked ASH tokens.

```rust
#[endpoint]
fn withdraw(&self)
```

### 2. Read Functions

#### 2.1. getUserBalanceAtTs

Get the veASH balance of a user at one point in time.

```rust
#[view(getUserBalanceAtTs)]
fn get_user_balance_at_ts(&self, addr: &ManagedAddress, t: u64) -> BigUint
```

Params:

* `addr: &ManagedAddress` - wallet address
* `t: u64` - timestamp

Return:

* `BigInt` - veASH balance

#### 2.2. getTotalSupplyAtBlock

Get the total supply of veASH at a certain block.

```rust
#[view(getTotalSupplyAtBlock)]
fn get_total_supply_at_block(&self, _block: u64) -> BigUint
```

Params:

* `block: u64`

Return:

* `BigInt`: total veASH supply

#### 2.3. getTotalSupplyAtTs

Get the total supply of veASH at a certain block.

```rust
#[view(getTotalSupplyAtTs)]
fn get_total_supply_at_ts(&self, t: u64) -> BigUint
```

Params:

* `ts: u64: timestamp in second`

Return:

* `BigInt`: total veASH supply

#### 2.4. getTotalLocked

Get the total number of ASH tokens locked.

```rust
#[view(getTotalLocked)]
fn supply(&self) -> BigUint
```

Return:

* `BigUint`

#### 2.5. getUserLocked

Get the total number of ASH tokens locked and the unlock time of a specific wallet.

```rust
struct LockedBalance<M: ManagedTypeApi> {
    pub amount: BigUint<M>,
    pub end: u64,
}

#[view(getUserLocked)]
fn get_user_locked(&self, address: &ManagedAddress) -> LockedBalance<Self::Api>

```

Params:

* `addr: &ManagedAddress`

Return:

* `LockedBalance`

## Fee Distributor

### 1. Write functions

#### 1.1. claim

Claim reward tokens to an address.

```rust
#[endpoint]
fn claim(&self, addr: &ManagedAddress) -> BigUint
```

Params:

* `addr: &ManagedAddress` - the address to send the reward tokens to.

### 2. Read Functions

#### 2.1. getClaimableAmount

Get the claimable reward amount.

```rust
#[view(getClaimableAmount)]
fn get_claimable_amount(&self, addr: &ManagedAddress) -> BigUint
```

Params:

* `addr: &ManagedAddress`

Return: `BigUint`

#### 2.2. token

Get the reward token.

Return: `TokenIdentifier`


# SDKs

What you need to build your product on top of AshSwap.

### MultiversX in Rust - erdrs <a href="#elrond-in-rust-erdrs" id="elrond-in-rust-erdrs"></a>

[https://crates.io/crates/elrond-sdk-erdrscrates.io](https://crates.io/crates/elrond-sdk-erdrs) Developed by [Bicarus Labs](https://bicarus.io/), the team behind AshSwap, [erdrs](https://crates.io/crates/elrond-sdk-erdrs) allows you to interact with MultiversX and its smart contracts in Rust.

***

### SDK Description

* A javascript SDK to help developers interact directly with AshSwap’s smart contracts.
* Link: <https://www.npmjs.com/package/@ashswap/ash-sdk-js>&#x20;
* Open-sourced

***

### Aggregator Integration

{% content-ref url="/pages/9bKk2UkFEZSeTfsmdQTE" %}
[Aggregator Integration](/aggregator/aggregator-integration)
{% endcontent-ref %}


# Links & Contact

Where you can find us.

## AshSwap

* Websit&#x65;**:** <https://ashswap.io>
* Dap&#x70;**:** <https://app.ashswap.io>
* Analyti&#x63;**:** <https://app.ashswap.io/analytics/overview>

## AshPerp

* Dapp: <https://ashperp.trade/>
* Analytics: <https://ashperp.trade/analytics>
* AshGuard: <https://ashguard.xyz/>

## Contact

* **Cooperate:** <https://u4xtuh1hoqs.sg.larksuite.com/share/base/form/shrlgPZmcctjImtJyEpA8ImrIff>
* **Twitter:**&#x20;
  * [https://twitter.com/ash\_swap](https://twitter.com/@ash_swap)
  * <https://twitter.com/ash_perp>
* **Discord:** <https://discord.gg/TQYwyFE5JS>
* **Telegram:** <https://t.me/ashswapglobal>
* **Medium:** <https://medium.com/@ashswap>
* **Support Ticket:** [**https://app.ashswap.io/support**](https://app.ashswap.io/support)
* **Email:** <hello@ashswap.io>
* **CEO Telegram:** <https://t.me/neildotvn> (only for project collaboration discuss)


# Devnet

## AshSwap Devnet

* **Link:** <https://devnet.ashswap.io/>
* **dEGLD Faucet:** <https://r3d4.fr/faucet> (only for claiming gas fee)

## AshPerp Devnet

Currently available only on the desktop version + MultiversX DeFi Wallet Extension ([LINK](https://chrome.google.com/webstore/detail/multiversx-defi-wallet/dngmlblcodfobpdpecaadgfbcggfjfnm))

{% hint style="info" %}
Devnet Token:

* claim at <http://r3d4.fr/faucet>
* Network: devnet NEW
* Asset: **USDC-377a09**
* Do not forget to claim dEGLD first as gas fee
  {% endhint %}

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

* Link: <https://perp-devnet.ashswap.io/>
* Noticeable parameters:
  * 3 trades / pair / wallet
  * Maximum Stop Loss = 80%
  * Maximum Profit = 900%
  * Max leverage = x100
  * Minimum position size = $100
* To understand how AshPerp works, check this: [LINK](https://docs.ashswap.io/getting-started/understand-ashperp)


# Faucets

If you're on Devnet and do not have the tokens, we have you covered.

To be able to test AshSwap, you need both, our faucets for tokens and MultiversX's faucet for transaction fees.

Update on JAN 05, 2023:

* AshSwap Devnet official faucet: <https://faucet-devnet.ashswap.io/>
* You will need to have dEGLD as a gas fee before claiming the AshSwap faucet, link: <https://r3d4.fr/faucet>

> Do not forget to choose "Devnet" on the Network list.

## dEGLD Faucet - gas fee

Go to <https://r3d4.fr/faucet> and paste your wallet address, choose Devnet network, click Submit, and you have enough dEGLD for many transactions. So easy, I sometimes wish this is real EGLD.

<figure><img src="/files/pnuhLp8CkKy19X4Qjt49" alt=""><figcaption><p>As much xEGLD as you want</p></figcaption></figure>

In case the r3d4 faucet does not work properly, let's visit <https://wallet.elrond.com/unlock/walletconnect>, connect your devnet wallet & claim the dEGLD there.

## AshSwap Devnet Faucet

🔗 <https://faucet-devnet.ashswap.io/>

You can claim the assets every 24 hours

<figure><img src="/files/M1mRD9I5oRHM0wu6tMmO" alt=""><figcaption><p>Choose your assets: Tether or USD Coin, and, Ren BTC or Wrapped BTC</p></figcaption></figure>

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

Now you're good to go. Have fun using AshSwap!


# Audit Report

Security Audit Report AshSwap Smart Contracts

## Runtime Audit **Delivered: January 11th, 2023**

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

## Runtime Verification Audit Report

{% embed url="<https://github.com/runtimeverification/publications/blob/main/reports/smart-contracts/AshSwap.pdf>" fullWidth="false" %}

## Arda Audit **Delivered: June 17th, 2023**

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

## Arda Verification Audit Report

{% embed url="<https://arda.run/audits/ashswap>" %}


# AshSwap Academy


# Decentralized Finance (DeFi)? — What is it?

![s](/files/JnlWVmD06OcemK9THqrE)

## What is Decentralized Finance (DeFi)? <a href="#id-10ad" id="id-10ad"></a>

Before getting to DeFi, we should start with CeFi — Centralized Finance.

### What is CeFi? <a href="#id-683e" id="id-683e"></a>

Before DeFi was introduced, CeFi (Centralized Finance) was the standard for trading cryptos, it handles a stronghold over the cryptocurrency industry. These institutions offer a variety of services in addition to crypto trading, such as lending, borrowing, margin trading, and many more other services.

In CeFi, crypto trade orders are handled through a central exchange; funds are managed by the fund managers and professionals that work on the development & operational processes of these entities, which means you do not own a private key that provides you access to your wallet.

When participating in the CeFi, users need to trust third parties. That’s because users can only trade cryptocurrencies available on the CeFi platform & make transactions with the fee offered by that platform. You will only have limited access to what goes on with your wallet. It’s similar to what you experience when working with a bank.

### What is DeFi? <a href="#e10d" id="e10d"></a>

DeFi stands for Decentralized Finance, which is a financial system in which all financial institutions and financial instruments are operated **in a decentralized way**. In other words, DeFi is a financial system where **no central authority is needed**.

Decentralized Finance aims to create a fair financial structure in which everyone can participate, even individuals without a bank account can use blockchain technology and DeFi. All the activities are not conducted by a central organization but automatically by the Smart Contracts (SC) of Blockchain.

The benefit of using DeFi over CeFi is that you have full control over your assets and own the key to your wallet.

![](/files/skAmfr7T5XCuiWLfWRYW)

## Benefits Of DeFi <a href="#id-299a" id="id-299a"></a>

Traditional financial system is administrative & expensive to run, the transaction process takes time,… DeFi came to tackle a large number of these issues; some of its benefits are:

### Trustless & Transparent <a href="#id-020d" id="id-020d"></a>

Thanks to smart contacts, each transaction can be completed & every single operation is directly recorded on the blockchain. With the blockchain explorers, anyone with an internet connection can check & verify what’s happening.

For example, when you make a transaction on [**AshSwap**](https://ashswap.io/) like swapping/ providing liquidity/ staking assets, you can find details of it on [**Elrond Explorer**](https://explorer.elrond.com/) because AshSwap is built on the [**Elrond blockchain**](https://elrond.com/).

And yet, you can still benefit from anonymity since the accounts you find are just a string of numbers and letters representing their public address.

These, and the fact that smart contracts don’t execute if their rules are not met, make the whole system trustless.

That’s how you’re in complete control of your assets; in DeFi.

### Permission-less <a href="#id-3a82" id="id-3a82"></a>

DeFi welcomes everybody to the financial system regardless of their pay, race, culture, wealth, or geographic area. The requirement is a mobile phone, or a computer with an internet connection.

To use CeFi’s services, consumers must first undergo a know-your-customer (KYC) process, which requires them to give personal information or make a financial deposit.

### Innovation opportunity <a href="#id-67c7" id="id-67c7"></a>

With more and more dApps — decentralized applications — appearing and rising rapidly today, we can see that smart contracts can be used to code pretty much anything. Besides, developers can freely expand on top of existing protocols, customize interfaces, and integrate third-party apps.

### DeFi Applications in the Real World <a href="#id-43cc" id="id-43cc"></a>

dApps could be the best way to prove that blockchain technology is not only about crypto trading and investing but also bring cryptos to the real world, allowing the creation of complete businesses.

There are several use cases of DeFi we could see today, such as:

* If a foreign worker wants to send a huge amount of money across borders to their families using banking services, the fee he/ she has to pay is extortionate, while Decentralized Finance services come with the potential to cut down these costs by more than 50%
* Loans are another area where we can see the advantages of DeFi. It is very hard for the unbanked to borrow money because of their lack of credit score or a bad history with a banking institution, the DeFi platforms help connect borrowers with lenders & help reduce the credit check process.
* In the case when the bank has to be closed due to some unexpected reasons such as war, your asset is frozen & you are not able to withdraw, DeFi can solve this problem because you are in full control of your own crypto assets — in a simple way. Your key — your money.

By removing inaccuracies and middlemen, enhancing transparency, and reducing central control in the picture, DeFi is creating a promising future for finance

## Challenges with DeFi <a href="#id-29dc" id="id-29dc"></a>

Despite the fast-growing speed from 2020 till now, DeFi still has many challenges to solve:

* **Transaction Costs:** Ethereum is one of the first movers and was considered the home of major DeFi protocols; but the problem is that with so many DeFi activities on a single network-Ethereum, there is a corresponding rise in transactions fees due to the high traffic on Ethereum network and the scaling limitations frequently lead to spiking gas charges. Other blockchains like Solana, Avalanche, and Elrond,… capitalize on Ethereum’s weakness to offer faster and cheaper solutions; and even with Ethereum, they are finding solutions to optimize the Transaction Costs with their Ethereum 2.0 roadmap.
* **Liquidity:** the low liquidity is also a challenge for DeFi protocols, different models have been adopted to help solve this problem such as incentivizing token holders to deposit their tokens in the asset pools and earn rewards generated from the trading activities, another solution is DEX aggregators ([Arda](https://arda.run/), 1Inch Exchange, ParaSwap,…) which using complicated algorithm to get the best prices for users by access liquidity from different DEXs, not only a single DEX, allows users to access a wide range of trading pools through a single interface.
* **Interoperability:** there are many different Blockchain networks at this time with different designs, asset definitions, and access controls,… which is also a pain point for users in DeFi because of the difficulty in moving value from one blockchain to another, making it necessary to bridge blockchain networks for them to interact. This limits the potential for protocols to maximize functionality and scalability.
* **Threat from hackers:** while hacking is also a risk in traditional finance, DeFi’s extended technological architecture, with multiple potential weak points, increases the so-called attack surface available to sophisticated hackers, especially with the blockchain bridge, there were many reports like the attack to Horizon bridge on June 2022, Ronin bridge hack on March 2022
* **DeFi Regulation:** because DeFi protocols run on smart contract codes, and no legally recognized centralized entities can be held responsible for smart contract code problems, which leads to the lack of regulatory presence within the DeFi ecosystem, this is a significant problem to the mainstream adoption of DeFi. At this time, regulatory bodies are continuously making efforts to understand the DeFi space further to enable them to adopt effective regulatory architectures.

Users still need to take responsibility to take care of their privacy by understanding and securely handling cryptocurrencies with the process of multi-factor authentication.

Also, there have been far too many security & economic-related incidents, DeFi users also need to keep themselves updated with the new knowledge and the understanding of platforms they are interacting with.

## Final Thought <a href="#dd86" id="dd86"></a>

Blockchain technology has managed to give people a Decentralized Finance with many of being advantages: trustless, permissionless, transparent, thereby having full control over their financial lives. DeFi is constantly improving itself to better meet users’ needs.

And if you want to keep up with the updates in the DeFi space, let’s take a look at our [**DeFi Handbook**](https://medium.com/@ashswap/defi-handbook-introduction-to-decentralized-finance-dc05e7f0849a) as a takeaway, and follow our **AshSwap DeFi 101** series to have all the info you need.

Thank you for spending time reading our article.

AshSwap team.


# DeFi Components. What are they?

![](/files/CXcHI1oomGBKx16jd6le)

## What is DeFi? <a href="#ce80" id="ce80"></a>

[DeFi](https://medium.com/@ashswap/decentralized-finance-defi-what-is-it-cf8f3b3c728b) (Decentralized Finance) is a decentralized financial system that eliminates the control of banks, and financial institutions over money, financial products, and financial services.

## The values of DeFi <a href="#id-5e00" id="id-5e00"></a>

### *The value DeFi brings to users* <a href="#f67e" id="f67e"></a>

* Easy to access and use by everyone
* Easy to store assets on digital wallets with high security
* Transfer and receive money fast
* By applying Blockchain technology, DeFi helps users remove control from third parties

### Many other components are developed based on DeFi, such as: <a href="#c0f4" id="c0f4"></a>

* Stablecoins
* Decentralized exchanges
* Stableswap
* Liquidity mining
* Decentralized lending & borrowing
* Margin trading/derivatives
* Aggregator

These components provide a lot of new utilities to users and usher in a decentralized financial future. With the development of DeFi now gradually expanding and attracting more users worldwide, the prospect of DeFi becoming a significant threat to centralized finance is not so unrealistic.

## Components of DeFi <a href="#id-7832" id="id-7832"></a>

### Stablecoins <a href="#d496" id="d496"></a>

Stablecoin is a cryptocurrency pegged to a stable asset such as (Gold, silver, diamond, oil, …) or fiat (Euro, Dollar). Backed by tangible assets, stablecoins have a stable value over time and have minimal price fluctuations.

### Decentralized exchanges <a href="#id-9f05" id="id-9f05"></a>

A decentralized exchange is a peer-to-peer marketplace where cryptocurrency transactions occur.

The primary purpose of decentralized exchanges (DEX) is to provide solutions and promote direct transactions without going through 3rd parties such as banks and financial institutions. Since 2020, many DEXs have emerged and become famous, such as Uniswap, Sushiswap, Pancakeswap, and Curve.

As of June 2022, the DeFi market is currently locking $76.64b out of circulation. At present, DeFi is proving its position and opening up opportunities for more emphatic development in the future, so the opportunity for DEXs to come later is still huge, like AshSwap, KyberSwap, Platypus, and Wombat Exchange.

Although the same decentralized exchange, each name mentioned above solves and optimizes a different aspect, more specifically:

* KyberSwap: KyberSwap is an automated market maker, providing swap across multiple exchanges for traders, and maximizing earnings for liquidity providers.
* Platypus: A whole new kind of AMM for stableswap lower slippage, simpler UX.
* Wombat Exchange: Swap stablecoins at minimal slippage and stake at maximum yield.
* AshSwap: The very first decentralized exchange following the stable-swap model on the Elrond blockchain. Providing a stablecoins swap solution with lower slippage with optimized UX and maximizing yields for liquidity providers.

**What is StableSwap?**

Stablecoins are an indispensable component in DeFi, but to participate in all DeFi products, we may need to own more than one type of Stablecoin. It will be difficult when we have to hoard many types of Stablecoins, your assets will be scattered, and it will be difficult for you to make the most of your capital when participating in the market.

Stableswap was born to solve that problem; many decentralized exchanges now offer Swap solutions with low transaction fees and slippage, so you can easily convert Stablecoins to serve many needs of use.

![](/files/RDoRZ5v4QDAS4yeyxose)

**Liquidity mining**

Liquidity mining is a term that refers to making profits from DeFi platforms by providing liquidity to those DeFi platforms.

![](/files/hJeAtuSjfjaNVsaR7tXb)

More specifically, when you provide liquidity for a cryptocurrency pair in the pool of the DeFi platform, you will get back LP Tokens. If you stake that LP Token, you will get rewards on that DeFi platform; the more liquidity you provide, the more rewards you get.

![](/files/mSxMHTdgxcvVp81BSXgV)

### Decentralized lending & borrowing <a href="#ca8d" id="ca8d"></a>

Different from traditional borrowing and lending. Decentralized lending & borrowing on DeFi platforms aims to provide loans without intermediaries. And borrowers can get a loan through P2P decentralized platforms. In addition, DeFi lending protocols allow lenders to gain profit from their supply of the cryptocurrency.

### Margin trading/derivatives <a href="#a202" id="a202"></a>

In traditional finance, a derivative is a financial transaction contract between two or more parties based on the future value of an underlying asset. That is, people will trade on the importance of another entity, not directly owning it. Profits are generated based on the spread and price movements of the underlying asset.

A derivative is a type of contract whose value is a derivative of the performance of an underlying entity such as an asset, commodity, index, or interest rate. In DeFi, decentralized derivatives are derivatives of the performance of the underlying crypto-assets and are used as a financial tool to help users hedge against the possibility of substantial price fluctuations from the crypto market.

### Aggregator <a href="#a23f" id="a23f"></a>

Low liquidity is a [challenge for DeFi protocols](https://medium.com/@ashswap/decentralized-finance-defi-what-is-it-cf8f3b3c728b), different models have been adopted to help solve this problem, such as incentivizing token holders to deposit their tokens in the asset pools and earn rewards generated from the trading activities; another solution is DEX aggregators (Arda, 1Inch Exchange, ParaSwap,…) which using complicated algorithm to get the best prices for users by liquidity from different DEXs, not only a single DEX, allows users to access a wide range of trading pools through a single interface.

The role of the Aggregator was born to save users time and increase the efficiency of cryptocurrency transactions.

## **Summary** <a href="#id-0869" id="id-0869"></a>

DeFi is a financial revolution that is in the early stages of development and will be able to expand dramatically in the future. DeFi offers an open financial platform where third parties no longer dominate participants.

And if you want to keep up with the updates in the DeFi space, let’s take a look at our DeFi Handbook Free Ebook as a takeaway, and follow our AshSwap DeFi 101 series to have all the info you need.


# DeFi Handbook — Introduction to Decentralized Finance

![](/files/CspR7hRd0i6sXNu3sXwf)

We want to start this article with a screenshot from CZ — the “You-Know-Who”

> It’s always a build market

The crypto markets are in a bear market. There’s no way to sugarcoat the fact that we are having a difficult time. However, this is also a chance for us to focus on building, learning, and preparing for the next cycle.

As a DeFi protocol, we want our users to know more knowledge about the crypto world, especially about DeFi; hence, with the support from Istari Vision, we already created a takeaway handbook in PDF version with the target to provide you an overview about the DeFi world.

The handbook content is divided into 3 main parts:

1. **Understanding DeFi**

* Centralized vs. Decentralized Finance
* Smart Contracts
* Validation of transactions
* Stablecoins
* Decentralized Autonomous Organization (DAO)
* History of DeFi

2\. **Diving into DeFi**

* What can you do with DeFi?
* What are AMMs?
* What is Liquidity Pool?
* What is Yield Farming?
* What is Impermanent Loss?

3\. **DeFi applications**

* Decentralized Exchanges (DEX)
* Derivatives
* Trading → Swapping
* Governance
* Lending & Borrowing

Besides, we are planning to make an articles series called AshSwap DeFi 101 where we have more deep-dive content about the terms & everything related to DeFi & Elrond blockchain, so do not hesitate to subscribe to our Medium page for receiving notifications about our new posts.

👉 Download the handbook here: <https://docsend.com/view/2c54amkdet6i6gqh>


# What is LP Token?

To better understand AshSwap's features, you need to first know a core concept of DEXs, the LP token. What is it and what is it used for?

![](/files/SaC1Qsp6QY3VxhkaX4np)

## LP Token <a href="#id-8102" id="id-8102"></a>

The concept of LP token is simple, but it’s often associated with some strange numbers that make it hard to grasp.

Here I added 100 USDC to the USDC/USDT pool and received 97.09 LPT-999601 tokens.

![](/files/pJz7kOK0gYze8mhUHjbJ)

You don’t need to know where the number 97.09 comes from. What you need to know is when you decide to become a Liquidity Provider (LP) by adding your tokens to a liquidity pool of AshSwap, you receive back some LP tokens as the representation of your proportion of the pool. LP tokens are just normal ESDT tokens and are only minted for LPs, so you can easily calculate your proportion by dividing the number of your LP tokens by the total supply of the LP tokens.

Let’s continue with the above example. Thanks to the Elrond Explorer, the total supply of the token can easily be found on the [token page](https://devnet-explorer.elrond.com/tokens/LPT-999601).

![](/files/AcUcs2lzvVzQgjXwEUtx)

My percentage is 97.07 / 29,499,914 \* 100% \~ 0.00033%. This means I’m entitled to 0.00033% of all the trading fees collected in that pool.

## Withdrawing Liquidity <a href="#id-3ff0" id="id-3ff0"></a>

Because liquidity pools contain multiple tokens and the ratios of the tokens are constantly changed under the market’s supply and demand as users trade with the pools, you almost certainly do not get back your original tokens but only the same percentage of the pool.

Let’s say the pool originally has 1000 USDC and 1000 USDT and you own 10% (100 USDC and 100 USDT). After some time, assuming no one adds or removes liquidity, the pool now has 1100 UDSC and 900 USDT. When you withdraw, you still get 10% but the tokens are different (110 USDC and 90 USDT).

Impermanent Loss is a consequence of this behavior, and the risk is proportionally distributed to all liquidity providers. This is less significant in the context of a stable-swap like AshSwap, but you need to pay more attention when participating in unstable DEXs like the Maiar Exchange.

## Transferring LP Tokens <a href="#id-482c" id="id-482c"></a>

Your LP position is solely represented by your LP tokens, and it has nothing to do with your wallet address. If you transfer the LP tokens to other people, they will have the right to withdraw your tokens from the pool. So why do this at all? Why don’t we just save the value in the smart contracts?

Because this unlocks a lot of possibilities for other protocols to be built on top of DEXs. This deserves another article on its own, but the most popular use case is auto-compounding. On the Elrond Network, [Arda](https://arda.run/compound) provides this service. You can of course do it by yourself, but it takes time, calculations, and transaction fees. By putting all LP tokens together, they can optimize the compounding time using complex algorithms and save tons of transaction fees by sending only one transaction for everyone instead of each person having to send a transaction on his own.

## What’s next? <a href="#id-0f7e" id="id-0f7e"></a>

Now you have a solid understanding of how LP tokens work. Stay tuned for the next deep dive into the technical details of Yield Boost.


# Dynamic Aggregator

## AshSwap Aggregator: A gateway to better liquidity and pricing <a href="#d026" id="d026"></a>

### Dynamic Trade Routing Scheme <a href="#id-81d7" id="id-81d7"></a>

In a DEX, when attempting to swap a large amount of *Token A* for *Token B* using a single path, the price of *Token B* increases proportionally due to the depletion of liquidity along that path. Dynamic Trade Routing addresses this issue by dividing the large token amount into smaller portions and executing swaps across multiple paths. As a result, the price of Token B increases less compared to the previous approach.

AshSwap Aggregator has Dynamic Trade Routing, which aggregates fractured liquidity across DEXs and thereby enables users to source the most capital-efficient liquidity to support their trades. Your trade on AshSwap is split into smaller trade sizes.

> For example, if you want to make a 1000 wEGLD-BUSD trade, it may distribute your trade into a 950 wEGLD-BUSD trade on AMM1, 30 wEGLD-BUSD trade on AMM2, and the rest on the third route.

The percent distribution of the swap is dynamically determined to give you the best price. Trade splitting helps get better prices for large-sized trades and trades with tokens where there is shallow liquidity spread out across a number of DEXes. You can see exactly which DEXs were involved in the trade and the amount split between them.

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

## Other key benefits of AshSwap Aggregator <a href="#d509" id="d509"></a>

### Market listing <a href="#id-916c" id="id-916c"></a>

At the moment, AshSwap Aggregator is supporting two DEXs: AshSwap and xExchange, and tokens that are available in AshSwap pools (xEGLD, wEGLD, ASH, USDT, BUSD, USDC, UTK, HTM, sEGLD, HsEGLD)

However, the system is designed to be modular and extensible, allowing for the inclusion of more new DEXes and strategies to continuously improve the search for the best price; thus, we will support more tokens and markets in the future.

### Swap in a single transaction <a href="#id-18f5" id="id-18f5"></a>

We have worked to optimize the AshSwap Aggregator so that it all fits within the transaction limits and that swapping can be done in one transaction. This is important to handle cases where the price of the token you are buying has changed and no longer fits your slippage limit. If the aggregator cannot make the trade with your slippage limit, it will roll back the transaction and return an error.

### Friendly UI <a href="#bfdb" id="bfdb"></a>

We aim to make the UI as intuitive and user-friendly as possible. The user interface of the AshSwap Aggregator remains the same as the Swap's, but with a twist. We have added a window showing detailed aggregator routing. Now, users can see the entire amount split and the exchanges involved in the routing.

<figure><img src="/files/3FQvxf4wcBZOInHD3lpz" alt=""><figcaption></figcaption></figure>

***Notice:** The screenshots used in this post are for demonstration purposes only. Values are not accurately presented.*

## To sum up

AshSwap is delivering a sustainable liquidity infrastructure for DeFi on MultiversX. As a liquidity hub, AshSwap Aggregator connects liquidity from various protocols and sources to provide the best token rates to traders with minimal slippage.<br>


# Popular Error Message

Please check the Explorer page for the error message if your Transactions are not processed, and compare the results to the information in the table below.

<table><thead><tr><th width="210">Error Message</th><th width="377">Reason</th><th width="305">Solution</th></tr></thead><tbody><tr><td>Lower than minimum</td><td>The token amount that was calculated on the UI was not the same as the token amount that you would receive after sending the Tx. There was a difference between the two, and if your slippage was too low, the amount that you could receive was outside of the range that was calculated, and the Tx would have failed.</td><td>Adjust the slippage (in the Swap page) and redo the aciton</td></tr><tr><td>Withdrawal resulted in fewer coins than expected</td><td>Before the time that transactions could be processed, the token that was stored in the pool was updated. Because of this, the amount of output that the user receives is less than what was anticipated, and as a result, the transaction does not successfully safeguard the user's money.</td><td>Redo the action</td></tr><tr><td>Computed amount out lesser than minimum amount out</td><td>Before the transaction is processed, there were already some changes made to the tokens in the pool. Because of this, the amount of output that was received was less than what was anticipated, which means that the transaction did not succeed in safeguarding the user's money.</td><td>Adjust the slippage threshold appropriately (if the market is experiencing high traffic, for example, you should raise the maximum amount of slippage allowed to a high value in order to guarantee that tx will be executed), and then redo the action.</td></tr><tr><td>Withdraw old tokens first</td><td>Staked ASH in governance has an expired unlock; the user must unlock the stake first before adding a lock.</td><td>Unlock your old governance-locked ASH first</td></tr></tbody></table>


