Skip to content

fix(baozi): correct error code mappings from current IDL#1118

Open
AbhilashG12 wants to merge 1 commit into
pmxt-dev:mainfrom
AbhilashG12:fix/baozi-error-codes
Open

fix(baozi): correct error code mappings from current IDL#1118
AbhilashG12 wants to merge 1 commit into
pmxt-dev:mainfrom
AbhilashG12:fix/baozi-error-codes

Conversation

@AbhilashG12

Copy link
Copy Markdown
Contributor

Description

Fixes #1077 : incorrect error code mappings in Baozi exchange to match the current Solana program IDL.

Problem

The Baozi program was upgraded and error codes were renumbered. Current errors.ts uses old codes:

Error Current Code Correct Code
BettingClosed 6018 6013
BettingFrozen 6040 6014
BetTooLow 6020 6023
BetTooHigh 6041 6024

Impact

  • ❌ Users see wrong error messages
  • ❌ BetTooLow shows as unknown error
  • ❌ Poor debugging experience

Solution

Updated the error code mappings:

// Before
6018: BettingClosed, 6020: BetTooLow, 6040: BettingFrozen, 6041: BetTooHigh

// After  
6013: BettingClosed, 6023: BetTooLow, 6014: BettingFrozen, 6024: BetTooHigh

The Baozi Solana program was upgraded and error codes were renumbered.

Changes:
- BettingClosed: 6018 → 6013
- BettingFrozen: 6040 → 6014
- BetTooLow: 6020 → 6023
- BetTooHigh: 6041 → 6024

These mappings now match the current on-chain program.
Added IDL version comment for future reference.

Fixes pmxt-dev#1077
@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: PASS (NOT VERIFIED)

What This Does

This updates Baozi's Solana/Anchor program error-code mapping for closed/frozen betting and min/max bet-size failures. SDK consumers should get the same PMXT error classes/messages for the current program codes instead of generic Baozi program errors.

Blast Radius

Baozi error translation only: core/src/exchanges/baozi/errors.ts. No unified response schemas, SDK shims, router, or auth paths are changed.

Consumer Verification

Before (base branch):
From the patch, the old map handled 6018, 6020, 6040, and 6041. Current program errors 6013, 6014, 6023, and 6024 would fall through to the generic BadRequest("Baozi program error <code>: ...") path in extractAnchorError().

After (PR branch):
After building pmxt-core, I exercised baoziErrorMapper.mapError(new Error("Transaction simulation failed: custom program error: 0x...")) for the changed codes:

6013 BadRequest Betting is closed
6014 BadRequest Betting is frozen
6023 InvalidOrder Bet amount too small
6024 InvalidOrder Bet amount too large
6018 BadRequest Baozi program error 6018: Transaction simulation failed: custom program error: 0x1782
6020 BadRequest Baozi program error 6020: Transaction simulation failed: custom program error: 0x1784
6040 BadRequest Baozi program error 6040: Transaction simulation failed: custom program error: 0x1798
6041 BadRequest Baozi program error 6041: Transaction simulation failed: custom program error: 0x1799

I did not submit a live Baozi transaction to trigger these program errors through the full sidecar trading path, so this is class-level verification rather than end-to-end consumer verification.

Test Results

  • Build: PASS (npm run build --workspace=pmxt-core)
  • Unit tests: Core Jest PASS (27 suites passed, 652 tests passed); full npm test ends NOT VERIFIED because this runner lacks Python pytest
  • Server starts: PASS during npm test
  • E2E smoke: NOT VERIFIED (no live Baozi transaction/error reproduction)

Findings

No blocking findings.

PMXT Pipeline Check

  • Field propagation (3-layer): N/A
  • OpenAPI sync: N/A
  • Financial precision: N/A
  • Type safety: OK
  • Auth safety: N/A

Semver Impact

patch -- error mapping correction with no public method/signature change.

Risk

I verified the mapper behavior for the new numeric codes, but I could not independently verify the current Baozi IDL/on-chain program code assignments from this checkout, and I did not exercise a real transaction failure through the sidecar.

@AbhilashG12

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

I understand the verification couldn't include live Baozi transactions.

The error code mappings are based on the current Baozi program IDL. The changes are:

  • BettingClosed: 6018 → 6013
  • BettingFrozen: 6040 → 6014
  • BetTooLow: 6020 → 6023
  • BetTooHigh: 6041 → 6024

Class-level verification (as you performed) confirms the mapper works correctly for these codes.

This PR is ready to merge. The live Baozi verification can be done later by someone with test SOL.

Thank you for the thorough review! 🙏

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.

baozi — errors.ts maps 6 error codes to wrong IDL values; BetTooLow/BetTooHigh/BettingFrozen/BettingClosed all point to wrong codes

2 participants