Prerequisites
Before you begin, ensure that you have:- Obtained an API key for StableFX from Circle
- Obtained testnet USDC in a supported wallet on Arc
- installed cURL on your development machine
StableFX uses a single endpoint for all API requests. The base URL is
https://api.circle.com/. The StableFX API uses your API key for authentication
and to determine which environment to use. The TEST environment executes
against Arc testnet and returns mock data.When developing or testing your integration, you should use your TEST API key.
When you are ready to move to production, just update your code to use your
PROD API key.Part 1: Query for trades
Query for trades with theconfirmed status using the
get all trades endpoint. The
following is an example request:
Part 2: Register your signature
Decide which trades to take from the maker side, and register your signature for those trades.2.1. Get the typed data for the trade
Using theid field from the response in the previous step, get the typed data
for the trade using the
generate trade presign data
endpoint. The following is an example request:
2.2. Sign the typed data
Using your wallet, sign the typed data returned from the previous step.2.3. Submit the signed data
Submit the signed data to the submit a trade signature endpoint. The following is an example request for the signed data:Part 3: Fund the trade
Use the following steps to fund the trade onchain.3.1. Get trades that are ready for funding
Before you send funds onchain, you should confirm that the trade is ready for funding. To do this, call the get all trades endpoint. You should filter the response by thetaker_funded status.
3.2. Get the funding signature data
To use the StableFX API to deliver the funds onchain, you must first sign the funding typed data with an EIP-712 signature. To get the data to sign, call the generate funding presign data endpoint. Your request must include the contract ID of the trade and the side of the trade that you are taking. The following an example request:3.3. Fund the trade with the StableFX API
The StableFX API can handle the onchain transaction for you through the fund trades endpoint. You must submit the maker-specific funding data along with your signature.200 response.
It’s not required to submit the funding transaction through the StableFX API.
You can submit the transaction onchain using your own web3 provider or wallet by
calling the appropriate maker contract methods directly.
Testing trade batches
Note that the query for trades endpoint returns multiple trades. This can be useful for testing a batch integration. If you are testing batching, you need to get thecontractTradeId for each trade that you’d like to fund. You should
complete part 2 for each trade that you’d
like to fund.
Once you have the array of IDs, and your signature is submitted for each trade,
you can use the same fund trades
endpoint to fund multiple trades by submitting the permit2 data for each trade
along with the appropriate signatures.