Skip to content

fix(suibets): model onchainState to restore accurate order book liquidity - #1583

Merged
realfishsam merged 1 commit into
pmxt-dev:mainfrom
AbhilashG12:fix/suibets-liquidity-mapping
Jul 10, 2026
Merged

fix(suibets): model onchainState to restore accurate order book liquidity#1583
realfishsam merged 1 commit into
pmxt-dev:mainfrom
AbhilashG12:fix/suibets-liquidity-mapping

Conversation

@AbhilashG12

Copy link
Copy Markdown
Contributor

Description

Fixes #1354.

SuiBets updated their live API to nest critical liquidity data inside a new onchainState object. Because PMXT's SuibetsRawOffer interface did not model this nested object, the makerRemaining data was being silently dropped during normalization, resulting in inaccurate size calculations for the order book.

This PR:

  1. Updates the SuibetsRawOffer interface to explicitly model the onchainState payload.
  2. Threads onchainState.makerRemaining through normalizer.ts so order book levels now reflect true resting liquidity rather than placeholder zeroes.
  3. Implements safe fallbacks to prevent NaN pollution if the object is missing.

@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: PASS (NOT VERIFIED)

What This Does

Models SuiBets onchainState on raw offers and uses onchainState.makerRemaining ahead of legacy remainingStake / creatorStake when normalizing market liquidity. SDK consumers should see more accurate market.liquidity when SuiBets returns live on-chain remaining liquidity.

Blast Radius

SuiBets fetch/normalize path only: core/src/exchanges/suibets/fetcher.ts and normalizer.ts. No SDK surface, OpenAPI schema, router, or auth changes.

Consumer Verification

Before (base branch):
Static consumer-path trace: normalizeMarket() computed liquidity from remainingStake ?? creatorStake, so a raw offer with only onchainState.makerRemaining would ignore the live on-chain amount.

After (PR branch):
Static trace: liquidity() now uses offer.onchainState?.makerRemaining ?? offer.remainingStake ?? offer.creatorStake (core/src/exchanges/suibets/normalizer.ts:14-17). I could not verify against the live SuiBets API from the consumer HTTP sidecar path in this run.

Test Results

  • Build: PASS for current main core build during scheduled run
  • Unit tests: PASS for current main core Jest (699 passed, 3 skipped)
  • Server starts: NOT VERIFIED for this PR head
  • E2E smoke: NOT VERIFIED (no live SuiBets consumer call completed)

Findings

No blocking findings.

PMXT Pipeline Check

  • Field propagation (3-layer): N/A (existing liquidity field only)
  • OpenAPI sync: N/A
  • Financial precision: OK (existing mistToSui conversion path is reused)
  • Type safety: OK
  • Auth safety: N/A

Semver Impact

patch -- exchange normalizer bug fix for an existing field.

Risk

Live SuiBets payload shape was not independently fetched; if makerRemaining units differ from legacy mist-denominated stake fields, consumer liquidity would still be wrong.

@realfishsam
realfishsam merged commit d099617 into pmxt-dev:main Jul 10, 2026
5 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.

spec-drift [suibets] HIGH: onchainState nested object unmodelled — makerRemaining liquidity data dropped

2 participants