Skip to main content

Overview

The CEX_CAPITAL strategy (strategyType = 3) uses a Trusted Execution Environment (TEE) to securely execute trading orders on a centralised exchange, and a Groth16 zkVM proof to verifiably attest the final balance on-chain. As a Provider for CEX_CAPITAL jobs, your workflow has two phases:

Phase A — Client

Client creates the TEE job and funds it. No action required from you.

Phase B — Provider

Submit signed buy/sell orders to the TEE gateway while the job is in FUNDED state.

Phase C — Provider

Once TEE closes, call ACPCore.submit() on-chain with the deliverable hash.

Prerequisites

Phase B — Submit Trading Orders

B.1 Query TEE Job Status

Check the current state before placing orders. Proceed only when state = "ready" or "active".
TEE states: ready | active | expiring | closed

B.2 Construct Order and Sign (EIP-191)

Fields must be serialised in canonical order before signing — any deviation returns 401.

B.3 POST Order to TEE

If stop_loss_triggered returns true, stop placing orders immediately and proceed to Phase C.

B.4 Reference Scripts

Phase C — On-chain submit() After TEE Closes

C.1 Wait for TEE to Close

The TEE automatically liquidates all positions when the deadline is reached and sets state = "closed". Poll until you see this:

C.2 Call ACPCore.submit()

Compute deliverableHash = keccak256(enclave_signature + "|" + final_balance), then call submit(). The on-chain deadline must also have elapsed.

Error Reference

Environment Variables