x/binary reference
x/binary lists, prices, halts, resolves and settles every chain market: standalone binary
markets, IPO events (a binary, calls, puts and S), and private companies (the perpetual, its
index and its ladder of expiries). Protos: dydxprotocol/binary/{binary,event,company,query,tx,genesis}.proto.
Records
BinaryMarket
One record per chain market (binary, call, put and company perpetual), keyed by perpetual id.
| Field | Meaning |
|---|---|
perpetual_id, clob_pair_id, market_id | The perpetual, its book and its oracle market |
ticker, question, rules_url | What it asks and where its rules are |
resolution_time | From this time it may resolve No (an event's deadline) |
admin, resolve_delay_seconds | Who may halt and resolve besides governance, and the least time between the halt and the admin's resolve |
status | MARKET_STATUS_TRADING, _HALTED, _RESOLVING, _RESOLVED_YES, _RESOLVED_NO |
halted_height, halted_time, halted_open_interest | The halt |
outcome, resolved_at | OUTCOME_YES or OUTCOME_NO |
event_id | The event, for an event's markets |
payout_per_share | What one contract pays (a PERP: w = |u − M|) |
settled_*, phase | The payout's progress and totals: holders, long and short shares, paid, collected, shortfall |
company_id, settle_reference_price, final_value, payers_long | A company perpetual: M, u, which side pays |
settled_payee_deficit, settled_payee_pool, settled_withheld, perp_scan_*, perp_payer_burden | A company perpetual's settlement accounting |
Event
| Field | Meaning |
|---|---|
id, company, ticker_base, rules_url | The event |
resolution_time | The deadline |
admin, resolve_delay_seconds | As for a market |
status | EVENT_STATUS_TRADING, _HALTED, _RESOLVING, _RESOLVED_YES, _RESOLVED_NO |
halted_height, halted_time, outcome, resolved_by, resolved_at | The halt and resolution |
final_market_cap, basic_shares_outstanding, ipo_close_price_micro_usd, source_url | A Yes resolution: cap = shares × close / 10⁹, in micro-$B |
binary_perpetual_id, option_perpetual_ids, implied_market_id | Its markets: the binary, calls and puts, S |
call_margin_ppm, call_min_margin_ppm | The event's call margin rates |
company_id | The company, for a company expiry; 0 otherwise |
ImpliedPrice
event_id, market_id, reference_cap, value (S), last_update_height, stale,
stale_since_height, hold_reason, strikes_used, params (ImpliedPriceParams),
binary_price (p, ppm), binary_price_reference, depth_used.
Company and CompanyIndex
Company: id, name, ticker_base, status (COMPANY_STATUS_*), template
(CompanyTemplate), perp_perpetual_id, perp_clob_pair_id, index_market_id,
expiry_event_ids, ipo_event_id, final_value, settled_by, settle_reason, source_url,
ladder_retry_after_height, ladder_deferred_since_height.
CompanyIndex: company_id, market_id, params (CompanyIndexParams), value (I),
mode (INDEX_MODE_BLENDED, _FALLBACK, _HELD), stale, stale_since_height,
hold_reason, last_update_height, blend_raw (B), weights (ExpiryWeight: event_id,
s, p_ppm, depth, weight, share_ppm), fallback_ema (E), book_twap_mid,
premium_ppm, premium_valid, impact_bid, impact_ask, has_blended,
reentry_ramp_until_height.
The parameters' defaults and bounds are in the parameter reference.
Queries
gRPC dydxprotocol.binary.Query/ | REST | CLI dydxprotocold q binary |
|---|---|---|
AllMarkets | /dydxprotocol/binary/market | list-markets |
Market | /dydxprotocol/binary/market/{perpetual_id} | show-market [perpetual-id] |
AllEvents | /dydxprotocol/binary/event | list-events |
Event | /dydxprotocol/binary/event/{event_id} | show-event [event-id] |
ImpliedPrice | /dydxprotocol/binary/implied_price/{event_id} | show-implied-price [event-id] |
AllCompanies | /dydxprotocol/binary/company | list-companies |
Company | /dydxprotocol/binary/company/{company_id} | show-company [company-id] |
CompanyIndex | /dydxprotocol/binary/company_index/{company_id} | show-company-index [company-id] |
Messages
| Message | Signer | Does |
|---|---|---|
MsgCreateBinaryMarket | governance | Lists a standalone binary market |
MsgHaltBinaryMarket | admin or governance | Halts a standalone binary market |
MsgResolveBinaryMarket | admin or governance | Resolves it Yes or No |
MsgUpdateBinaryMarketAdmin | admin or governance | Replaces its admin |
MsgCreateEvent | governance | Lists an IPO event: binary, calls, puts, S |
MsgAddEventStrikes | governance | Lists more strikes on a trading event |
MsgUpdateStrikeParams | governance | Changes a call's open interest cap, price cap and margin rates |
MsgUpdateImpliedPriceParams | governance | Changes an event's implied price parameters |
MsgHaltEvent | admin or governance | Halts every market of an event (for a company expiry before its deadline: the IPO) |
MsgResolveEvent | admin or governance | Resolves an event: Yes with shares, close and source, or No |
MsgUpdateEventAdmin | admin or governance | Replaces an event's admin |
MsgCreateCompany | governance | Lists a company: perpetual, index, insurance fund, three expiries |
MsgUpdateCompanyParams | governance | Changes a company's template, index parameters, caps and funding bound |
MsgSettleCompanyPerp | governance | Settles a company's perpetual at a value or at the index |
MsgUpdateCompanyAdmin | admin or governance | Replaces a company's admin and its unresolved expiries' |
"Governance" is the x/gov module account as authority or signer, through a proposal
(governance). The admin's messages are ordinary transactions:
dydxprotocold tx binary halt-event 3 --from ADMIN --chain-id firstaccess-testnet-1 \
--node https://rpc.testnet.firstaccess.exchange:443 --gas auto --gas-adjustment 1.5 \
--gas-prices 25000000000adv4tnt
# Yes: shares, close in micro-dollars, source; cap = shares x close / 1e9 micro-$B
dydxprotocold tx binary resolve-event 3 yes --shares 1000000000 --close-micro 55000000 \
--source-url https://www.sec.gov/... --from ADMIN ...
dydxprotocold tx binary resolve-event 1 no --from ADMIN ...
dydxprotocold tx binary update-event-admin 3 dydx1NEW... --from ADMIN ...
dydxprotocold tx binary update-company-admin 1 dydx1NEW... --from ADMIN ...halt-market, resolve-market and update-admin do the same for a standalone binary market;
they refuse an event's markets (ErrEventMarket) and a company perpetual.
MsgResolveEvent
| Field | Meaning |
|---|---|
signer | The event's admin or the governance module account |
event_id | The event |
outcome | OUTCOME_YES (any time after the halt) or OUTCOME_NO (from the deadline) |
basic_shares_outstanding | Yes only: basic shares outstanding on IPO day |
ipo_close_price_micro_usd | Yes only: the IPO-day closing price per share, micro-dollars |
source_url | Where both were read |
The rest of the messages' fields are listed with their bounds in the parameter reference.
Events
Emitted by x/binary (attributes include perpetual_id, event_id, company_id, signer,
values and reasons):
| Area | Event types |
|---|---|
| Standalone markets | binary_market_halted, binary_market_resolving, binary_market_resolved, binary_market_admin_updated, binary_settlement_failed |
| Events | binary_event_created, binary_event_strikes_added, binary_strike_params_updated, binary_implied_params_updated, binary_event_halted, binary_event_resolving, binary_event_resolved, binary_event_admin_updated |
| Prices | implied_price_updated, implied_price_held, call_mark_updated, call_mark_skipped, binary_price_skipped |
| Settlement | settlement_haircut, settlement_pool_deficit |
| Companies | company_created, company_params_updated, company_admin_updated, company_index_updated, company_index_held, company_index_near_cap, company_ladder_listed, company_ladder_listing_failed, company_ladder_deferred, company_expiry_auto_halted, company_ipo_halted, company_settlement_pending, company_settling, company_settled, company_settlement_replaced, company_settlement_needs_governance |
Errors
Codespace binary:
| Code | Error | Message |
|---|---|---|
| 1 | ErrMarketNotFound | binary market not found |
| 2 | ErrInvalidMarket | invalid binary market |
| 3 | ErrNotAdmin | signer is neither the market's admin nor governance |
| 4 | ErrAlreadyResolved | market is already resolved |
| 5 | ErrTooEarlyToResolveNo | market cannot resolve No before its resolution time |
| 6 | ErrInvalidOutcome | outcome must be Yes or No |
| 7 | ErrSettlementImbalanced | settlement payouts do not sum to zero |
| 8 | ErrNotTrading | market is not trading |
| 9 | ErrNotHalted | market must be halted before it resolves |
| 10 | ErrResolveInHaltBlock | market resolves only from the block after its halt |
| 11 | ErrInvalidAdmin | invalid admin address |
| 12 | ErrTickerInMarketMap | ticker is in the market map |
| 13 | ErrVaultExists | a vault already exists for the new order book |
| 14 | ErrResolveDelay | the admin resolves only once the market's resolve delay has passed since its halt |
| 15 | ErrSettlementIncomplete | the shares paid out differ from the open interest at the halt |
| 17 | ErrEventNotFound | event not found |
| 18 | ErrInvalidEvent | invalid event |
| 19 | ErrInvalidImpliedPriceParams | invalid implied price params |
| 20 | ErrInvalidStrike | invalid strike |
| 30 | ErrEventMarket | the market belongs to an event: halt, resolve and re-admin the event |
| 31 | ErrEventNotTrading | event is not trading |
| 32 | ErrEventNotHalted | event must be halted before it resolves |
| 33 | ErrEventResolved | event is already resolved |
| 34 | ErrTooManyEvents | too many trading events |
| 35 | ErrTooManyStrikes | too many strikes on the event |
| 36 | ErrInvalidResolution | invalid event resolution |
| 37 | ErrSettlementShortfall | a fully backed short could not pay what it owed |
| 38 | ErrCompanyNotFound | company not found |
| 39 | ErrInvalidCompany | invalid company |
| 40 | ErrInvalidCompanyTemplate | invalid company template |
| 41 | ErrInvalidCompanyIndexParams | invalid company index params |
| 42 | ErrInvalidCompanyDeadlines | a company's first deadlines are 3, UTC, on day 1 to 28, strictly increasing, in different months |
| 43 | ErrTooManyCompanies | too many active companies |
| 44 | ErrCompanyNotActive | company is not active |
| 45 | ErrCompanyTickerConflict | ticker overlaps a company's ticker base |
| 46 | ErrInvalidCompanySettle | invalid company perpetual settlement |
| 47 | ErrCompanySettled | company's perpetual is already settling or settled |
| 48 | ErrCompanyInsuranceSeed | could not seed the company perpetual's insurance fund |
| 49 | ErrCompanyLadderListing | could not list a company expiry |
| 53 | ErrRequiresGovernance | only governance may resolve this value: it settles the company perpetual outside the admin's band |
Related errors elsewhere: x/perpetuals 20010 ErrPremiumVoteForChainMarket, 20011
ErrInvalidCompanyPerp; x/clob's price band refusal, for example "order price 40000000
subticks outside the band [45000000, 55000000] of clob pair 0: price outside the band around
the market's oracle price".