MasayumeDocs
Open app
For builders

How Masayume uses DreamDEX

Follow the Somnia Markets SDK from a product feature to its exact calls, code and on-chain evidence.

Reviewed 2026-09-07

DreamDEX supplies the event markets that Masayume uses. The Somnia Markets SDK, installed as @somnia-chain/markets-sdk version 0.28.1, connects our TypeScript application to market discovery, books, prices, balances and trading. Masayume adds the user experience, risk checks, agents, X integration and its own contracts around those markets. The configured network is Somnia Shannon testnet, chain 50312.

This guide is an implementation map for judges and developers. Every call below is present in the reviewed application source. It describes the SDK capabilities we use, not every capability the SDK offers. The dependency is pinned in the market package.

Start with the integration boundary

Interactive system map

How Masayume connects to DreamDEX

The SDK supplies market reads; execution follows two authorized paths.

Masayume

Explore each part and its connections. Expand to use more of your screen.

Follow an arrow to explore a connected part.

Selected part · 1 of 6Masayume

Web app · agents · X

What this part does

The web app and operator services use the same market package. Masayume adds product flows, model decisions, risk checks and recovery around DreamDEX markets.

Control & permission Browsing needs no grant. An AI verdict cannot sign or create spending permission.

Outgoing connections

  • From MasayumeMarket readsRead or display
  • From MasayumeAuthorized actionAction or record
Inside the boxMasayume

The web app and operator services use the same market package. Masayume adds product flows, model decisions, risk checks and recovery around DreamDEX markets.

Control & permission Browsing needs no grant. An AI verdict cannot sign or create spending permission.

Somnia Shannon testnet · SDK 0.28.1. Public reads cannot spend; execution uses the selected wallet or grant.
Read the map as text
  1. Masayume Markets SDK reader: Market reads.
  2. Markets SDK reader DreamDEX data: SDK clients.
  3. Masayume Signer + submitter: Authorized action.
  4. Markets SDK reader Signer + submitter: Fresh executable quote.
  5. Signer + submitter Masayume contracts: Vault / ticket route.
  6. Masayume contracts DreamDEX contracts: Orders / oracle / redeem.
  7. Signer + submitter DreamDEX contracts: Direct wallet · SDK trader.

How Masayume connects to DreamDEX

Masayume

Select a part to see what it does and who controls it. The map adapts to the space available.

Follow an arrow to explore a connected part.

Selected part · 1 of 6Masayume

Web app · agents · X

What this part does

The web app and operator services use the same market package. Masayume adds product flows, model decisions, risk checks and recovery around DreamDEX markets.

Control & permission Browsing needs no grant. An AI verdict cannot sign or create spending permission.

Outgoing connections

  • From MasayumeMarket readsRead or display
  • From MasayumeAuthorized actionAction or record
Inside the boxMasayume

The web app and operator services use the same market package. Masayume adds product flows, model decisions, risk checks and recovery around DreamDEX markets.

Control & permission Browsing needs no grant. An AI verdict cannot sign or create spending permission.

Somnia Shannon testnet · SDK 0.28.1. Public reads cannot spend; execution uses the selected wallet or grant.

Read the map as text
  1. Masayume Markets SDK reader: Market reads.
  2. Markets SDK reader DreamDEX data: SDK clients.
  3. Masayume Signer + submitter: Authorized action.
  4. Markets SDK reader Signer + submitter: Fresh executable quote.
  5. Signer + submitter Masayume contracts: Vault / ticket route.
  6. Masayume contracts DreamDEX contracts: Orders / oracle / redeem.
  7. Signer + submitter DreamDEX contracts: Direct wallet · SDK trader.

Download the architecture image (PNG) · Download the vector image (SVG)

The map in three paths:

  • Public reads: Masayume web, agents and X → account-free Markets SDK reader → DreamDEX indexer, chain and price data.
  • Direct wallet: fresh SDK quote → separate signer and checked submitter → SDK trader → DreamDEX orders and settlement.
  • Vault or specialist ticket: fresh market facts → authorized signer → Masayume contracts → DreamDEX orders, redemption or OracleHub resolution, depending on the product. Range and Moonshot use oracle settlement rather than placing a venue order.

Product screens and operator services call our @masayume/markets package. That package owns the SDK imports and adapts SDK data into the types used by the rest of the app.

  1. Read: configureMarkets creates one account-free SomniaMarkets runtime per browser tab or server process. Its configuration supplies the chain, indexer, WebSocket, pinned addresses and price feed.
  2. Share: marketsProvider exposes the same market-reading interface to the web app, strategy runner and X executor. React hooks and the book coordinator share live subscriptions.
  3. Sign: createSubmitterSession creates a separate SDK instance for one signer and role. Its nonce queue serializes sends. The public reader never gains that account's authority.
  4. Execute: the common submitter chooses the direct SDK trader or a Masayume contract route, verifies the result and records actual fills.

Follow runtime construction, the shared read interface, signing sessions and order routing. The system map shows the wider app and service boundaries.

Which SDK calls power which features?

The client below is the SDK client returned by our shared runtime. trader belongs to a signing session. File links point to an immutable reviewed commit.

Product needSDK capability usedWhere it connects
Find live and past WindowslistLiveBinaryMarkets, listPastBinaryMarkets, getBinaryMarketMarket discovery groups markets into the lanes shown in the app and scanned by operators.
Read current executable liquiditygetBinaryOrderBook, getBinaryBookParamsBook reads supply depth, tick size, lot size and minimum quantity.
Turn a stake into a bounded quotequoteBinaryStakeOverBook, quoteBinaryOrderOverBookQuote calculation calculates quantity and cost; freshQuoteStake rereads the chain book before execution.
Keep the ticket and charts currentwatchMarket, subscribeLive, getLiveBinaryOrderBookByMarket; SomniaMarketsProvider, useWatchMarket, useLiveBinaryOrderBookByMarket, useLiveStatus, useWatchPrice, useLivePriceBook coordination, ticket hooks and price hooks connect live SDK state to React.
Build price context for charts and agentsgetOpeningPrices, fetchPrice, fetchPriceHistoryPrice adapter provides the opening print, spot/EMA and price path.
Verify the Window and its feesgetMarketOnchain, getMarketFees, getMarketResolutionChain state, fees and resolution support entry checks and outcome display.
Show wallet funds and positionsgetErc20Balance, getNativeBalance, getPortfolio, getVaultBalance, getVaultPayoutFallbacks, getOpenPositionsWithPnL, getBalancesBalance sheet and positions distinguish wallet funds, venue escrow and outcome-token holdings. Our Trading Balance also has its own EventVault reads.
Reconstruct trading historygetUserFills, getRouterActions, getBinaryMarket, getBalancesWallet history paginates records and associates fills with their actual Window.
Build venue activity and reconcile an uncertain direct ordergetFills, getUserFills, getOwnOpenOrdersOnchain, getViemClientVenue scans feed activity statistics. Direct-order recovery checks the receipt, fills and open orders. Vault executions have a separate exact-event recovery path.
Submit a direct wallet ordertrader.placeOrder, ORDER_TYPE.MARKET, autoApproveOrder send sends an immediate-or-cancel order with a protective limit. This is the direct wallet route.
Obtain test collateral or redeem outcomestrader.faucet, trader.redeemTransaction routing uses explicit outcome IDs and checks transaction status. Masayume-contract settlements take their own routes.
Keep identity correct when a pool is reusedmarketKey, outcomeId, decodeOutcomeId, binaryModuleReadAbi, binarySettlementAbiIdentity adapter separates the durable marketId, pool-generation outcome IDs and settlement key.

Test-funds onboarding: the tUSDC mint above remains a wallet-signed SDK call. Masayume's separate STT faucet first sends eligible wallets a bounded native-token top-up through viem/RPC, with durable PostgreSQL reservations. That STT transfer is Masayume infrastructure, not a DreamDEX SDK faucet feature. The wallet guide connects the two prompts, and configuration describes its limits and funding key.

Supporting calls include getErc20Metadata for collateral decimals, getErc20Allowance for funding checks, and getLiveStatus/getWatchStatus for subscription health. The SDK also supplies Shannon chain/address defaults, interval helpers, typed errors and React query keys. Our address check detects drift from the pinned deployment manifest. These primitives are inside the same market package; the contract reference lists the upstream and Masayume-owned addresses separately.

Trace one call from the app to DreamDEX

Consider a BTC UP ticket for one active Window:

  1. The market adapter discovers the Window and its opening print through SDK reads.
  2. Live book subscriptions update the ticket. The SDK's quote helpers translate the requested tUSDC stake into outcome quantity, cost and a protective price.
  3. On confirmation, the submitter checks fresh chain state, fees, funding, expiry and a fresh quote. A cached screen value is not sufficient permission to send.
  4. A direct wallet route calls trader.placeOrder. A Trading Balance or delegated route calls Masayume's EventVault writer instead; its on-chain venue gateway reaches DreamDEX's market and order-book contracts.
  5. The result records the transaction and actual cost/quantity from execution evidence. A submitted transaction, an unfilled order and a filled position have different states.
  6. At resolution, the owner or the authorized settlement path redeems the held outcome tokens. A grant's proceeds return to available Trading Balance; settlement does not silently renew its spending budget.

The two execution paths meet the same venue, but the JavaScript SDK does not implement our Solidity permission logic. Follow the vault adapter into VenueGateway for that contract-to-contract connection.

How agents and X reuse the integration

Momentum and AI agents use the same market discovery, price feed, opening prints and executable quotes. readAgentContext combines those SDK-backed reads into a fresh model input, including normalized price units and both sides' costs. The language-model call, decision journal and strategy risk rules belong to Masayume. A model verdict still needs to pass the trade gates.

Both strategy execution and X execution submit through this route:

route: { kind: "vault-grant", grantId }

That is an excerpt of the route shape, not a standalone trading script. A strategy uses a STRATEGY grant; X uses a separate EXECUTOR grant. The X account-to-wallet link identifies whose permission to inspect. It does not itself authorize spending.

Read agent context, subscriber execution, strategy settlement and X execution. The agent architecture and X architecture explain their database and recovery responsibilities.

How the specialist products connect

These are Masayume contracts and rules using DreamDEX infrastructure. They are not additional features supplied by the TypeScript SDK.

ProductConnection to DreamDEXRead more
ParlayIts reserve reads the underlying Windows' resolved outcomes and applies the multi-leg payout rules.Parlay and event contracts
Range and MoonshotRangeReserve reads the Window's numeric OracleHub answer and compares it with the chosen band. Moonshot uses the Range path; it does not place a directional CLOB order.Range settlement, Moonshot
BoostLeverageReserve finances actual outcome-token purchases and manages close, knock-out and settlement.Leverage
EarnMarketMakerVault holds capital and inventory; the maker service manages bounded venue quotes.Market making
Private modePrivateDesk funds separate slots holding venue positions; the desk's owner/claim association is an additional trust boundary.Private architecture
DuelGameArena buys and redeems picks through the venue and records match accounting. Room messages are separate from chain results.Game architecture
Practice and arcadeLocal simulation or server-verified scores; these are not proof that an SDK order or on-chain payout occurred.Practice, Candle Hop

Our directly integrated Somnia tools are the Markets SDK, DreamDEX contracts/indexer, RPC/WebSocket and price-feed/OracleHub paths described here. The reviewed application does not make a separate direct Reactor or Somnia Data Streams SDK call. Upstream automation is not presented as an application-owned integration.

Follow the live evidence

The 6–7 September 2026 rehearsal used faucet assets only. These dated records demonstrate specific paths, not a promise of future returns or current service health.

ScenarioActual resultEvidence
X commandOne BTC UP fill, 0.908520 tUSDC actual spend; matching sender/hash image delivered.Transaction, image reply
AI strategyA real model decision produced an ETH UP fill; it lost and settled for zero payout.Fill, settlement
Corrected Momentum strategyETH DOWN settled for 1.661 tUSDC; a new BTC Window fill followed.Settlement, subsequent fill
MoonshotA winning numeric-price ticket paid 2.000132 tUSDC through RangeReserve.Claim

The acceptance ledger preserves failures, the invalid pre-fix Momentum signal, test/deployment revisions and evidence limits. Source links currently require repository access; the public guide, transaction links and demo can be read independently.

Read this with an AI tool

Use llms.txt for the documentation index, this guide as Markdown, or llms-full.txt for all guide text with canonical URLs and source notes. The correct index filename is lowercase llms.txt.

For upstream reference material, see DreamDEX Event Contracts documentation and its llms.txt. The call-site map above is verified against Masayume's installed SDK version and source, independently of changes to upstream documentation.

Source notes

This guide follows the application code reviewed on 2026-09-07. Links point to that reviewed commit and require repository access. GitHub may show 404 if you are signed out or do not have access.

On this page