createTotalis runs every taker flow: it creates the RFQ, picks a quote, gets the signatures it needs, funds
the stake, and follows the trade to the end.
window.ethereum or a wallet client instead
(Wallets and partners).
Open a position
outcome_id order. openPosition:
- Waits for the account stream, then creates the RFQ.
- Collects quotes and picks the best one.
- Has the wallet sign
TakerAccept, plus any funding the vault is short of. - Sends one accept, and recovers it if the answer is lost.
status says what happened:
The result also carries
rfqId, acceptanceId, quoteId, positionId, the signed entry record, and bridged
and bridging for an entry that bridged cash from HyperCore (Entry records).
An accepted entry is not open yet. waitForOperation ends COMMITTED when it opened, or REVERTED or
EXPIRED_UNEXECUTED when nothing traded.
Options
bestQuote() takes the highest payout still before its accept_before. A custom choose may be called again
for a later time, so it must depend only on its arguments. Collection ends early if waiting would lose the quote
or pass quoteTimeoutMs.
Funding comes from free vault cash first, then the wallet, then a bridge of core. 0.05 USDC stays behind for
the bridge’s gas.
Why an entry did not trade
An entry can fail before it is sent, or after it is accepted. Before anything is sent, while it plans the funding,openPosition throws EntryError and cancels the RFQ:
After it is accepted, an operation that ends
REVERTED or EXPIRED_UNEXECUTED traded nothing.
entryFailure names the message to show:
onSigned or onRecord last handed it to you. When the entry bridged and failed,
see If an entry fails after its bridge.
Watch quotes yourself
To show quotes as they arrive instead of lettingopenPosition choose:
[] while the stream is down. A quote is dropped
at its accept_before, and the listener is called again then. To take one, sign and send it as in
Resume and retry.
Settlement
When a position’s markets resolve, Totalis settles it and pays the winnings into the owner’s vault balance. There is nothing to call.Cash out
cashOut requests bids for the position, picks one with bestBid() (by default, the best bid with at least 25
seconds left), has the owner sign it, and sends one accept. It takes choose and collectMs like
openPosition.
Withdraw
withdraw signs the Exit for any part of the amount the wallet is short of, plus the USDC payout, in one go.
It resolves at PAYOUT_COMMITTED. After a restart, waitForWithdrawal(withdrawalId) follows it.
To store the signed request before sending it, signWithdrawal returns { idempotencyKey, account, body } and
sendWithdrawal(signed) sends it.
A withdrawal with an unread balance throws BalanceUnknownError before anything is signed.
To move cash to HyperCore instead, see Move cash to HyperCore.
