Type/to search
Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Capability Matrix
Centralized Exchanges
Decentralized Exchanges (DEX)
Prediction Markets
Securities and Futures
On-chain & Custom

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

TypeDescription

number

Returns the current slippage ratio.

Arguments

NameTypeRequiredDescription

k

string

Yes

Fixed as slippage, which sets the slippage protection for market orders.

ratio

number

No

Slippage ratio, in the range [0, 0.5). The default value is 0.005 (i.e. 0.5%). If this parameter is omitted, the current slippage ratio is returned.

See Also

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.