Skip to content

Replace starter GraphQL schema with SO4 protocol entities#189

Merged
IbrahimIjai merged 4 commits into
SO4-Markets:mainfrom
0xsteins:main
Jun 23, 2026
Merged

Replace starter GraphQL schema with SO4 protocol entities#189
IbrahimIjai merged 4 commits into
SO4-Markets:mainfrom
0xsteins:main

Conversation

@0xsteins

@0xsteins 0xsteins commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

closes #182

Replaces the starter SubQuery schema (generic accounts, payments, credits,
debits, transfers) with SO4 protocol entities modelling markets, pools,
orders, positions, fees, referrals, and protocol events, and aligns the
indexer mappings with the new transfer entity.

Closes #<ISSUE_NUMBER>

What changed

Schema (apps/s03-indexer/schema.graphql)

  • Market & token metadata: ProtocolContract, Token, Market,
    MarketConfigSnapshot.
  • Liquidity lifecycle: Deposit, Withdrawal, PoolBalanceSnapshot,
    MarketTokenTransfer — covering create / execute / cancel.
  • Trading lifecycle: Order (create / update / freeze / execute /
    cancel), Position, PositionChange (increase / decrease / close),
    Liquidation, AdlEvent.
  • Fees & referrals: FeeClaim, UiFeeAccrual, FundingFeeClaim,
    ReferralCode, TraderReferral, ReferralOwnershipTransfer.
  • Indexed account, market, key, status, ledger, timestamp, and
    transaction-hash fields for app filtering.
  • Protocol-scale values (token amounts, prices, USD 1e30, shares, signed
    deltas) stored as String/BigInt to preserve precision — never
    downcast to JS numbers.
  • Per-entity comments documenting which contract event feeds each entity
    (mkt_new, dep_*, wth_*, ord_*, pos_*, liq_*, adl_*, fee /
    referral events, token / faucet activity).
  • Starter-only entities removed; token/transfer observability retained via
    MarketTokenTransfer.

Mappings (apps/s03-indexer/src/mappings/mappingHandlers.ts)

  • handleEvent now writes MarketTokenTransfer from token / market-token
    transfer events, keeping amounts as decoded strings.
  • Stores canonical case-sensitive Stellar StrKey addresses for
    from / to / account (no lowercasing) so app filters match real
    on-chain accounts.
  • Emits the contract as its canonical C... StrKey so it lines up with the
    configured contract ids and the decoded addresses.
  • Reads the guaranteed event txHash directly; transactionHash is now a
    required field on MarketTokenTransfer.

Verification

bun run --cwd apps/s03-indexer codegen
bun run --cwd apps/s03-indexer build

Generated src/types and project.yaml are gitignored per project
convention (regenerated via the bun scripts), so they are not committed.

0xsteins added 4 commits June 23, 2026 19:37
Decode transfer from/to/account as case-sensitive StrKey values instead of
lowercasing them, so app filters match the real on-chain accounts. Emit the
contract as its canonical C... StrKey to line up with config contract ids and
the decoded addresses, and read the guaranteed event txHash directly so every
MarketTokenTransfer records its transaction hash (now a required field).
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@0xsteins is attempting to deploy a commit to the Ijai's projects Team on Vercel.

A member of the Team first needs to authorize it.

@IbrahimIjai IbrahimIjai merged commit 27f94c2 into SO4-Markets:main Jun 23, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

# 5. Replace the Starter GraphQL Schema With SO4 Protocol Entities

2 participants