Skip to content

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 tokens
POST https://api.openfish.fun/ctf/split

Requires L2 authentication (HMAC signature in request headers).

FieldTypeRequiredDescription
conditionIdstringYesThe market’s condition ID (hex, 0x-prefixed)
amountstringYesAmount of USDC.e to split (human-readable)
Terminal window
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"
}'
{
"success": true,
"conditionId": "0xabc123...def456",
"amount": "100",
"tokens": [
"71321045679252212594626385532706912750332728571942532289631379312455583992563",
"52114319501245915516055106046884209969926127482827954674443846427813813222426"
],
"txHash": "0x9f8e...7d6c"
}
FieldTypeDescription
successbooleanWhether the operation completed
conditionIdstringThe condition ID that was split
amountstringAmount of USDC.e consumed
tokensstring[]Token IDs of the minted outcome tokens (Yes, No)
txHashstringOn-chain transaction hash (present only in onchain mode)
  1. The server validates your L2 authentication headers.
  2. It confirms your USDC.e (collateral) balance covers the requested amount.
  3. Your USDC.e balance is debited.
  4. Both outcome token balances are credited by the same amount.
  5. The operation is logged for the data server (activity tracking).
  6. When the server runs in onchain settlement mode, a splitPosition transaction 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.

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).

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(())
}
ErrorCause
conditionId and amount requiredMissing or empty fields in the request body
insufficient USDCYour collateral balance is below the requested amount
invalid JSONMalformed request body
401 UnauthorizedInvalid or missing L2 authentication headers
  • Merge Tokens — Reverse a split by returning both tokens for USDC.e.
  • CTF Overview — Understand the full token lifecycle.