exchange.IO("slippage", ...)
Sets the slippage protection of market orders.
exchange.IO(k)
exchange.IO(k, ratio)Examples
Set the slippage protection for market orders.
javascript
function main() {
exchange.IO("slippage", 0.01) // 1%
Log("Slippage:", exchange.IO("slippage"))
}Returns
| Type | Description |
number | Returns the current slippage ratio. |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Fixed as |
ratio | number | No | Slippage ratio, in the range |
See Also
Uniswap / PancakeSwap Aerodrome / Velodrome KyberSwap 1inch exchange.IO exchange.IO("route") exchange.IO("simulate") exchange.IO("deadline") exchange.CreateOrder
Remarks
A market order takes the quote at the time the order is placed, deducts the slippage, calculates the minimum amount to receive and writes it into the on-chain transaction. If the price moves beyond the slippage range by the time the trade executes, the whole transaction is reverted (only the gas fee is lost).
You can also append ;{"slippage":0.01} to the direction parameter of exchange.CreateOrder() to set the slippage for a single order. Limit orders do not use slippage, because the limit price is already the worst execution price.