CCXT
About Aftermath CCXT API /api/ccxt/...
CCXT maintains integration docs here: https://docs.ccxt.com/#/exchanges/aftermath
The CCXT section of the Aftermath Finance API provides an easy way for users to read from and write to the Sui blockchain for anything related to the Aftermath Perpetuals exchange. The CCXT endpoints are all prefixed with /api/ccxt; e.g., /api/ccxt/build/createAccount.
Transaction Execution
Using the CCXT API, you can call /api/ccxt/build/* endpoints for several operations and get back the transaction bytes and its signing digest. See the TransactionBuildResponse schema for the data that's returned by all /api/ccxt/build/* endpoints. Then, clients can sign the transaction digest with any of Sui's supported signature scheme.
The transaction bytes and signatures can be sent back to the corresponding /api/ccxt/submit/* endpoint, which will send the authenticated transaction to the Sui network, parse its effects and send them back to the client in an easy-to-understand format.
Why `/api/ccxt/build` endpoints?
Our /api/ccxt/build endpoints provide a convenience service for clients that can't do BCS and/or Blake2b-256 locally. CCXT also implements a uniform interface across many exchanges, alleviating the overhead of integrating a new exchange.
Our CCXT API:
Creates the [
Transaction]Serializes (BCS) the
Transactioninto bytesPrepends an Intent to it (always
[0, 0, 0]for user transactions on Sui)Hashes the bytes with Blake2b-256
Another important aspect of the /api/ccxt/build endpoints is that they will automatically adapt some Move calls depending on the state of the chain, which the service keeps track of internally. This will be used for things like automatically including an oracle update if necessary, but not if the onchain price is fresh enough already.
Is there any way to verify the response of the first API call?
Yes, you can. The TransactionBuildResponse.transactionBytes is the output of step 2 above. You can deserialize into the Transaction if you have access to a BCS implementation (e.g., Rust, Go, Typescript).
Example user flow
Get gas, e.g., from Sui's Discord
Get collateral from our frontend faucet
Create an account using
/api/ccxt/build/createAccountthen/api/ccxt/submit/createAccountCall
/api/ccxt/build/depositthen/api/ccxt/submit/depositinto the account (.type == "account") that's created in the last step/api/ccxt/build/allocatethen/api/ccxt/submit/allocatea certain amount to a market (this should automatically create a position)/api/ccxt/build/createOrdersthen/api/ccxt/submit/createOrders/api/ccxt/build/cancelOrdersthen/api/ccxt/submit/cancelOrders
Last updated