- Your YES and NO positions each go down by N.
- N USDC is added to your spendable
balance_safe. - There is no fee. The difference between the 1.00 per pair and what you paid for the two shares is booked as realized P&L on the positions.
mergePositions on the ConditionalTokens contract, signed by your Safe and
relayed gaslessly, the same way as redeeming winnings.
Merges through the relay are being switched on gradually. Where they are not on yet, the
relay refuses a merge with
422 relay.call_not_allowed.When you can merge
While the market isactive, closed, resolving, proposed or escalated. Once the
result is determined, redeem instead: the winning side
pays 1.00 and the losing side 0, which is the same total.
How many pairs
At most your free pairs: the smaller of your YES and NOsellable_volume
(GET /api/v2/atlas/account/positions), less the pairs of your merges that are still
pending. Shares reserved by a resting sell, and shares from a buy that has not settled
on-chain yet, are not free. Cancel a resting sell first if you want to merge those shares.
Your own merges that are not booked or failed yet still count against your shares.
Subtract them from what you offer to sell, or the sale is voided when the merge lands.
Merge, step by step
1
Look up the market's condition
GET /api/v2/atlas/account/wallet/markets/{id} gives the market’s condition_id, with
the usdc_address and conditional_tokens_address you need below.2
Read the nonce
GET /api/v2/atlas/account/wallet/nonce returns { "safe": "0x…", "nonce": "…" }, the
nonce your next Safe transaction must sign. Read it just before signing.3
Build the mergePositions call
Encode
mergePositions(address collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint256[] partition, uint256 amount)
with:collateralToken=usdc_addressparentCollectionId=0x0000…0000(32 zero bytes)conditionId=condition_idpartition=[1, 2](YES and NO)amount= the number of pairs in USDC base units (6 decimals: 10 pairs =10000000)
4
Sign it as a SafeTx
to = conditional_tokens_address, value = 0, operation = 0 (a plain call). Send
the merge as a single call: a merge inside a MultiSend batch is refused. Sign with
your Safe’s owner, as for any relayed call.5
Relay it
POST /api/v2/atlas/account/wallet/relay with the encoded call, your signature and the
nonce. The operator executes it and pays gas.6
Wait for it to be booked
Poll
GET /api/v2/atlas/account/positions/merges/{id} with the merge.id from the
relay answer until state is booked (the USDC is in balance_safe) or failed.The relay call
202 answers { "data": { "relay_id": "…", "state": "pending", "tx": null, "merge": { "id": 312, "state": "submitted" } } }:
the transaction may have been sent and its outcome is not known yet. Poll the merge.
The other refusals and answers are the same as for any relay; see
Relaying a setup call.
Why a merge is refused
Refusals are422 with a code. Nothing is sent and no merge is recorded.
Merge states
waiting_on while confirmed:
inflight: one of your trades on this market is still settling on-chain. The merge waits for it, which takes as long as that settlement.settling: the market is being settled. The merge is booked once that finishes.funding: an earlier transaction of your Safe (the one that brought the shares or the USDC) is not booked yet. The merge waits for it.settlement_rows: the merge landed after the market settled and waits for your settlement to be recorded. It then counts against your winnings: you are paid once, either way.
Your merges
GET /api/v2/atlas/account/positions/merges
Your merges, and any splits of USDC into pairs you sent from your Safe directly, newest
first. Filters: market_id, kind (merge or split), state. Paginated with page and
limit (up to 100), totals in the Page, Per-Page and Total headers.
GET /api/v2/atlas/account/positions/merges/{id}
One record. 404 for an id that is not yours.
proceeds is the USDC credited. A booked merge also appears in your activity:
GET /api/v2/atlas/account/transactions?type=position_merge (type merge on the row, or
split for a split).
Splitting USDC into YES + NO pairs is not offered through the relay.
Related
- Redeeming winnings: after the result is determined
- Balances: where the USDC lands (
balance_safe) - The Safe: the relay endpoint and the SafeTx structure