Swaps

Swaps are the most common way to interact with the PipiSwap protocol. For end users, exchanging is simple: a user selects an ERC-20 token that they own and a token they would like to exchange it for. Running a swap sells the currently held tokens for the proportional amount1 of the desired tokens, minus the swap fee, which is given to liquidity providers2. Swapping with the PipiSwap protocol is a permissionless process.

Note: Using web interfaces (websites) to exchange via the PipiSwap protocol may introduce additional permission structures and may result in different execution behavior compared to using the PipiSwap protocol directly. To learn more about the differences between the protocol and a web interface, see What is PipiSwap?

Swaps using the PipiSwap protocol are different from traditional order book trades in that they are not executed against discrete orders on a first-come, first-served basis; rather, exchanges are executed against a passive pool of liquidity, with liquidity providers earning fees proportional to their committed capital.

Impact on Price In a traditional order book market, a sizable market buy order can exhaust the available liquidity of a previous sell limit order and continue to execute against a subsequent sell limit order at a higher price. The result is that the final execution price of the order is somewhere in between the two limit sell prices against which the order was filled.

Price shock affects the execution price of a trade in a similar way, but is the result of a different dynamic. When using an automated market maker, the relative value of one asset in terms of the other continually changes during the execution of a trade, leaving the final execution price somewhere between where the relative price began and where it ended.

This dynamic affects every exchange that uses the PipiSwap protocol, as it is an inseparable part of the AMM design.

Since the amount of liquidity available at different price points can vary, the price impact for a given exchange size will change relative to the amount of liquidity available at any given point in the price space. The more liquidity that is available at a given price, the smaller the price impact for a given trade size. The lower the liquidity available, the greater the impact on the price.

An approximate3 price hit is anticipated in real-time via the PipiSwap interface, and warnings will appear if an unusually high price hit will occur during a trade. Anyone executing a trade will have the ability to assess the circumstances of the price impact when necessary.

Slippage The other relevant detail to consider when approaching exchanges with the PipiSwap protocol is slippage. Slippage is the term we use to describe alterations to a given price that could occur while a submitted transaction is pending.

When transactions are sent to Ethereum, their execution order is set by the amount of “gas” offered as a fee for executing each transaction. The higher the rate offered, the faster the transaction will be executed. Transactions with a lower gas rate will remain pending for an indefinite amount of time. During this time, the price environment in which the transaction will ultimately be executed will change as other trades will be taking place.

Slippage tolerances establish a margin of change acceptable to the user beyond the impact on price. If the execution price is within the accepted slippage range, for example, %1, the transaction will be executed. If the execution price ends up outside the accepted slippage range, the transaction will fail and the exchange will not occur.

Una situación comparable en un mercado tradicional sería una orden de compra de mercado ejecutada después de un retraso. Se puede conocer el precio esperado de una orden de compra de mercado al

Last updated