privium.cancel seals a cancel Intent that burns a resting order’s nonce, so what remains of the order never fills. Like every Intent it is signed by the auth key with no wallet prompt, and nothing lands on chain.
const { openOrders } = await privium.openOrders()
for (const order of openOrders) {
const submission = await privium.cancel(BigInt(order.nonce))
if (submission.state === 'unsent') await submission.retry()
}
Parameters#
| Parameter | Type | Meaning |
|---|---|---|
orderNonce |
bigint |
The resting order's nonce: its Submission.nonce, or BigInt(order.nonce) from openOrders. |
expirySlot |
bigint (optional) |
The slot the cancel expires at; it never expires when absent. |
The order’s nonce is in its own Submission as nonce, and in every open order openOrders recovers, on any device.
What it does#
- Registers the account with the enclave before the instance’s first Intent (The one signature).
- Reads
GET /v1/configfor the active enclave key (The enclave key). - Builds a cancel Intent with a fresh nonce of its own, the target
orderNonceand the expiry, signs it underprivium/extended-intent/v2, pads it to the 4,096 bytes every extended Intent takes and seals it to the active enclave key. - Submits it with
POST /v1/intakeand opens the replies.
The enclave takes the order out of its book at once and releases its reservation. Acceptance consumes the cancel’s own nonce and burns the order’s: the order’s own sealed bytes sent again are answered with its cancelled result, and it never fills (Nonces and replay).
Returns#
A Submission. The order’s OrderResult in state cancelled arrives in results, and on watchFills of an instance that has not already taken it (Order tracking). An unreachable intake leaves the submission unsent for retry().
Errors#
| Code | Stage | Message |
|---|---|---|
PROGRAM_UNAVAILABLE |
read | The enclave quote has not been indexed yet. Retry when its attestation is available. |
CONFIGURATION_REQUIRED |
read | The API changed its Pool program. Reconnect explicitly. |
DECRYPTION_FAILED |
read | This envelope cannot be opened by this account. |
INTAKE_UNAVAILABLE |
send | The account registration is sealed and the intake is unreachable. |
Intake’s other errors throw ApiClientError (POST /v1/intake lists them). A target that is no longer open, an order already filled, expired or cancelled, is refused with ORDER_NOT_CANCELLABLE, HTTP 409, which leaves nothing to retry (Refusals).