Manage positions outside the order book by splitting collateral into complete
sets of outcome tokens, merging balanced tokens back into collateral, or
redeeming winning tokens after resolution.
Choose an operation based on how you want to change your position:
Choose the integration surface you will use to submit position operations.
TypeScript
Python
API
Solidity
The examples on this page assume you have a SecureClient configured with
either a Relayer API key or a Builder API key.See Wallets and
Authentication for the
complete wallet setup and Relayer authorization flow. The examples on this page assume you have an AsyncSecureClient configured
with either a Relayer API key or a Builder API key.The synchronous SecureClient provides the same methods and supports both
API key types.See Wallets and
Authentication for the
complete wallet setup and Relayer authorization flow. The examples on this page assume you can authenticate Relayer API requests
with either a Relayer API key or a Builder API key. The examples below use
a Relayer API key:See Execute Gasless
Transactions for the
complete wallet setup and Relayer authorization flow. The examples on this page use these Polygon contracts:
Split a Position
Splitting converts pUSD into a complete set of outcome tokens. Every 1 pUSD
produces 1 YES token and 1 NO token.
Before splitting, ensure you have:
- Enough pUSD in the wallet for the amount you want to split.
- Approved the collateral adapter for the market type to spend the wallet’s
pUSD.
TypeScript
Python
API
Solidity
Call splitPosition() on a SecureClient. The client identifies the
market type from the condition ID and selects the correct collateral
adapter.amount is denominated in pUSD base units, so 1_000_000n splits 1 pUSD
into 1 YES token and 1 NO token. wait() returns a TransactionOutcome
after the transaction settles. Call split_position() on an AsyncSecureClient. The synchronous
SecureClient provides the same method. Both clients identify the market
type from the condition ID and select the correct collateral adapter.amount is denominated in pUSD base units, so 1_000_000 splits 1 pUSD
into 1 YES token and 1 NO token. wait() returns a TransactionOutcome
after the transaction settles. Build the splitPosition call, then execute it as a gasless wallet
transaction.Build the Split Call
Select the call target from the market response’s negRisk value:ABI-encode this function call:Place the encoded calldata in the wallet call: Execute the Split
For a Deposit Wallet, include the split call in the signed wallet batch and
submit it with the Relayer API key:See Execute Gasless
Transactions for nonce
creation, wallet-batch signing, and confirmation. Wait for
STATE_CONFIRMED before using the new balances. Splitting pUSD through a collateral adapter follows this flow:
- Approve the collateral adapter to spend the amount of pUSD being split.
- Call the adapter with the market’s condition ID and the amount.
- The adapter executes the underlying CTF operation and mints equal YES and NO
balances atomically.
Approve pUSD
First, call approve() on the pUSD contract. Approve
CtfCollateralAdapter for a standard market or
NegRiskCtfCollateralAdapter for a negative-risk market: Split the Position
Then, call splitPosition() on the same contract you approved:
CtfCollateralAdapter for standard markets or
NegRiskCtfCollateralAdapter for negative-risk markets:The call mints the same amount of YES and NO tokens to the caller.
Merge Positions
Merging converts a complete set of outcome tokens back into pUSD. Every 1 YES
token and 1 NO token returns 1 pUSD.
Before merging, ensure you have:
- Equal amounts of YES and NO tokens.
- Approved the collateral adapter for the market type to transfer the wallet’s
outcome tokens.
TypeScript
Python
API
Solidity
Call mergePositions() on a SecureClient. The client identifies the
market type, selects the correct collateral adapter, and checks the
wallet’s mergeable balance.Pass a base-unit bigint to merge a specific amount. "max" merges the
smaller of the wallet’s YES and NO balances. wait() returns a
TransactionOutcome after the transaction settles. Call merge_positions() on an AsyncSecureClient. The synchronous
SecureClient provides the same method. Both clients identify the market
type, select the correct collateral adapter, and check the wallet’s
mergeable balance.Pass a base-unit int to merge a specific amount. "max" merges the
smaller of the wallet’s YES and NO balances. wait() returns a
TransactionOutcome after the transaction settles. Build the mergePositions call, then execute it as a gasless wallet
transaction.Build the Merge Call
Use CtfCollateralAdapter at
0xAdA100Db00Ca00073811820692005400218FcE1f when negRisk is false, or
NegRiskCtfCollateralAdapter at
0xadA2005600Dec949baf300f4C6120000bDB6eAab when it is true.ABI-encode this function call:Place the encoded calldata in the wallet call: Execute the Merge
For a Deposit Wallet, include the merge call in the signed wallet batch and
submit it with the Relayer API key:See Execute Gasless
Transactions for nonce
creation, wallet-batch signing, and confirmation. Wait for
STATE_CONFIRMED before using the updated balances. Merging outcome tokens through a collateral adapter follows this flow:
- Approve the collateral adapter to transfer the caller’s outcome tokens.
- Call the adapter with the market’s condition ID and the amount to merge.
- The adapter burns equal YES and NO balances and returns pUSD atomically.
Approve Outcome Tokens
First, call setApprovalForAll() on the Conditional Tokens contract.
Approve CtfCollateralAdapter for a standard market or
NegRiskCtfCollateralAdapter for a negative-risk market: Merge the Positions
Then, call mergePositions() on the same contract you approved:
CtfCollateralAdapter for standard markets or
NegRiskCtfCollateralAdapter for negative-risk markets:amount cannot exceed either outcome-token balance. The call returns the
same amount of pUSD to the caller.
Redeem Resolved Positions
Redeeming converts outcome tokens into pUSD after a market resolves. Each
winning token returns 1 pUSD, while losing tokens return 0.
There is no redemption deadline. Winning tokens remain redeemable at any time
after resolution.
Before redeeming, ensure you have:
- A resolved market.
- Outcome tokens for the market.
- Approved the collateral adapter for the market type to transfer the wallet’s
outcome tokens.
TypeScript
Python
API
Solidity
Call redeemPositions() on a SecureClient. The client uses the condition
ID to select the correct collateral adapter for the market type.Redemption has no amount parameter: it redeems the wallet’s balances for
both outcomes. wait() returns a TransactionOutcome after the transaction
settles. Call redeem_positions() on an AsyncSecureClient. The synchronous
SecureClient provides the same method. Both clients use the condition ID
to select the correct collateral adapter for the market type.Redemption has no amount parameter: it redeems the wallet’s balances for
both outcomes. wait() returns a TransactionOutcome after the transaction
settles. Build the redeemPositions call for a resolved market, then execute it as a
gasless wallet transaction.Build the Redemption Call
Use CtfCollateralAdapter at
0xAdA100Db00Ca00073811820692005400218FcE1f when negRisk is false, or
NegRiskCtfCollateralAdapter at
0xadA2005600Dec949baf300f4C6120000bDB6eAab when it is true.ABI-encode this function call:Place the encoded calldata in the wallet call: Execute the Redemption
For a Deposit Wallet, include the redemption call in the signed wallet batch
and submit it with the Relayer API key:See Execute Gasless
Transactions for nonce
creation, wallet-batch signing, and confirmation. Wait for
STATE_CONFIRMED before using the payout. Redeeming outcome tokens through a collateral adapter follows this flow:
- Approve the collateral adapter to transfer the caller’s outcome tokens.
- After resolution, call the adapter with the market’s condition ID.
- The adapter burns both outcome balances and returns the winning payout in
pUSD atomically.
Approve Outcome Tokens
First, call setApprovalForAll() on the Conditional Tokens contract.
Approve CtfCollateralAdapter for a standard market or
NegRiskCtfCollateralAdapter for a negative-risk market: Redeem the Positions
Then, call redeemPositions() on the same contract you approved:
CtfCollateralAdapter for standard markets or
NegRiskCtfCollateralAdapter for negative-risk markets:The call redeems the caller’s full balances for both index sets and returns
only the winning payout.