Split Tokens
Splitting takes USDC.e out of your wallet and mints an equal number of Yes and No tokens for a given market condition. Every $1 of USDC.e yields 1 Yes token and 1 No token.
$100 USDC.e --> 100 Yes tokens + 100 No tokensEndpoint
Section titled “Endpoint”POST https://api.openfish.fun/ctf/splitRequires L2 authentication (HMAC signature in request headers).
Request Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
conditionId | string | Yes | The market’s condition ID (hex, 0x-prefixed) |
amount | string | Yes | Amount of USDC.e to split (human-readable) |
Example Request
Section titled “Example Request”curl -X POST https://api.openfish.fun/ctf/split \ -H "Content-Type: application/json" \ -H "OPENFISH-API-KEY: your-api-key" \ -H "OPENFISH-SIGNATURE: ..." \ -H "OPENFISH-TIMESTAMP: ..." \ -H "OPENFISH-PASSPHRASE: ..." \ -d '{ "conditionId": "0xabc123...def456", "amount": "100" }'Response
Section titled “Response”{ "success": true, "conditionId": "0xabc123...def456", "amount": "100", "tokens": [ "71321045679252212594626385532706912750332728571942532289631379312455583992563", "52114319501245915516055106046884209969926127482827954674443846427813813222426" ], "txHash": "0x9f8e...7d6c"}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
success | boolean | Whether the operation completed |
conditionId | string | The condition ID that was split |
amount | string | Amount of USDC.e consumed |
tokens | string[] | Token IDs of the minted outcome tokens (Yes, No) |
txHash | string | On-chain transaction hash (present only in onchain mode) |
How It Works
Section titled “How It Works”- The server validates your L2 authentication headers.
- It confirms your USDC.e (collateral) balance covers the requested amount.
- Your USDC.e balance is debited.
- Both outcome token balances are credited by the same amount.
- The operation is logged for the data server (activity tracking).
- When the server runs in
onchainsettlement mode, asplitPositiontransaction is submitted to the CTF ERC1155 contract via the relayer.
The ledger updates first, then the on-chain transaction follows. If the on-chain call fails, the ledger changes are rolled back automatically (USDC re-credited, outcome tokens re-debited), and the caller receives an error.
On-Chain Mode
Section titled “On-Chain Mode”When settlement_mode is set to onchain, the server constructs and submits a real Ethereum transaction:
function splitPosition( address collateralToken, // USDC.e bytes32 parentCollectionId, // 0x000...000 bytes32 conditionId, // market condition uint256[] partition, // [1, 2] for binary uint256 amount // in 6-decimal base units) external;The partition [1, 2] represents the two binary outcomes (Yes at index 0, No at index 1).
Rust SDK Example
Section titled “Rust SDK Example”use openfish_client_sdk::ClobClient;
#[tokio::main]async fn main() -> anyhow::Result<()> { let clob = ClobClient::authenticated( "https://api.openfish.fun", "your-api-key", "your-api-secret", "your-passphrase", );
let condition_id = "0xbd31dc8a20211944f6b70f31557f1001557b59905b7738480ca09bd4532f84af";
let result = clob.ctf_split(condition_id, "500").await?;
println!("Split {} USDC.e into tokens:", result.amount); for token_id in &result.tokens { println!(" - {}", token_id); }
if let Some(tx) = &result.tx_hash { println!("On-chain tx: https://polygonscan.com/tx/{}", tx); }
Ok(())}Error Cases
Section titled “Error Cases”| Error | Cause |
|---|---|
conditionId and amount required | Missing or empty fields in the request body |
insufficient USDC | Your collateral balance is below the requested amount |
invalid JSON | Malformed request body |
401 Unauthorized | Invalid or missing L2 authentication headers |
Next Steps
Section titled “Next Steps”- Merge Tokens — Reverse a split by returning both tokens for USDC.e.
- CTF Overview — Understand the full token lifecycle.