exchange.IO("cancelWait", ...)
Sets how long a cancel waits for its result.
exchange.IO(k)
exchange.IO(k, seconds)Examples
Increase the wait time before cancelling, and handle a failed cancellation.
javascript
function main() {
exchange.IO("cancelWait", 60)
var id = exchange.CreateOrder("ETH_USDC", "buy", 2000, 0.01)
if (id && !exchange.CancelOrder(id)) {
Log("Cancel failed:", GetLastError())
}
Log(exchange.GetOrder(id))
}Returns
| Type | Description |
number | Returns the current wait time in seconds. |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Fixed to |
seconds | number | No | Wait time in seconds. The range is 0 to 600 and the default is 30. Set it to 0 to return as soon as the cancellation transaction is sent. Leave it out to query the current value. |
See Also
Uniswap / PancakeSwap Aerodrome / Velodrome KyberSwap 1inch exchange.IO exchange.IO("receipt") exchange.IO("deadline") exchange.CancelOrder
Remarks
An on-chain cancellation sends a replacement transaction with the same nonce, so there is no way to know whether the original order transaction or the cancellation transaction will be included on-chain first. After exchange.CancelOrder() sends the cancellation transaction, it checks for the result during the wait time. If the cancellation transaction is included first, it returns true. If the original order transaction is included first (filled or failed), it returns false, and you can call GetLastError to see why. If the wait times out, it returns true, which means the cancellation transaction has been submitted. Use the result of exchange.GetOrder to get the final status.
Ethereum mainnet produces a block about every 12 seconds, so the 30-second default is about two to three blocks. Chains with faster block times (Base, Arbitrum, BNB Chain) usually return a result within a few seconds.