Algofi
Search…
⌃K

Swapping Assets

How to swap assets on the Algofi DEX.

Video: How to swap assets

Basics & Walkthrough

Swaps are the most common way of interacting with the Algofi DEX protocol.
In an order-book exchange, market makers place buy and sell orders which are passively filled by market participants. This is a continuous process of matching buyers with sellers. The Algofi DEX is a decentralized automated market maker (AMM) exchange - trades are executed in a very different way from the traditional order-book approach. With the Algofi DEX, liquidity providers fund dynamic liquidity pools which facilitate the trades from market participants. A user swaps assets by trading against this dynamic liquidity pool.
For end-users, the swapping process is straightforward: The user navigates to app.algofi.org/swap and selects two tokens to trade.
A user can generate a trade quote by navigating to the swap portal, selecting two tokens, and by then entering an amount in either box. The quote is generated directly from data on the Algofi smart contracts.
Example of a swap quote for trading 10 ALGO
The quoted swap will be executed directly on the Algorand blockchain, with the input asset being exchanged for the output asset. The trade quote is determined by the constant product formula.
The constant product formula shown above determines the impact of a trade against a given liquidity pool.

Price Impact

Price impact can first be understood in the context of a traditional order-book market. In this context, a large buy order will fill a sequence of limit-sell orders at a higher and higher prices. This will result in an average trade price that lies somewhere between the cheapest and most expensive limit orders filled.
Price impact also exists in an automated market, but in this context it is determined by the amount of liquidity that has been pooled. A given trade will change the price of one asset in terms of the other, according to the constant product formula. This will result in an average price that lies somewhere between the initial price and the final price. Trade impact can be measured by comparing the output price with the initial price, as the price always moves against the trader.
The approximate price impact is estimated in the quote interface to the right of "PRICE IMPACT".

Slippage

Slippage occurs when a trade executes prior to your submitted transaction that results in a new execution price. This could occur because another trade was executed within the same block, or it could occur because a trade was executed between quote generation and trade execution.
The slippage tolerance specifies the maximum adverse variation from the quoted execution price. The swap will execute as long as the execution price remains within the range specified by the slippage tolerance. The swap will not occur if the execution price lies outside of the range specified by the slippage parameter, e.g. the transaction will fail.