Skip to content

fix(sep40): normalize Gate.io and CEX sources to legal Soroban symbols (#755) - #806

Open
Lkshayyadav wants to merge 1 commit into
Divinity-Labs:mainfrom
Lkshayyadav:fix/issue-755-gateio-venue-symbol
Open

Lkshayyadav wants to merge 1 commit into
Divinity-Labs:mainfrom
Lkshayyadav:fix/issue-755-gateio-venue-symbol

Conversation

@Lkshayyadav

Copy link
Copy Markdown

Description

Closes #755

When Gate.io (or any off-chain centralized exchange whose identifier contains characters outside [A-Za-z0-9_]) reports price points that contribute to an aggregate price, the SEP-40 oracle publisher previously failed symbol validation because Soroban symbols only allow alphanumeric characters and underscores up to 32 bytes (^[A-Za-z0-9_]+$).

Changes Made

  1. Venue Symbol Registry (src/ingest/venues/symbols.ts):

    • Implemented VENUE_SOURCE_TO_SYMBOL mapping canonical stored source names to legal on-chain symbols (e.g. Gate.io -> Gate_io).
    • Added resolveVenueSymbol(sourceOrName: string): string | null used across callers.
    • Declared symbol property on VenueAdapter (KUCOIN_SYMBOL = KuCoin, GATEIO_SYMBOL = Gate_io).
  2. Publisher Robustness (src/publish/sep40.ts):

    • venuesToSpecArg() resolves venue sources to legal on-chain symbols before asserting ScSymbol validity.
    • If an unmapped / unknown source contains invalid characters, it is safely skipped rather than permanently blocking publication of the pair.
    • Preserves strict assertion if venue name exceeds MAX_SYMBOL_LENGTH (no doomed transaction writes).
    • Throws clear error if an aggregate has zero publishable venues.
  3. Registry Invariant Test (src/__tests__/venueAdapters.test.ts):

    • Added registry validation test ensuring every adapter in allVenueAdapters maps to a unique, legal Soroban symbol (^[A-Za-z0-9_]+$, length <= 32).
  4. Test Coverage (src/__tests__/sep40Publisher.test.ts, src/__tests__/sep40Encoding.test.ts):

    • Tested that a pair with a recent Gate.io row publishes successfully on chain with venue Gate_io.
    • Tested handling of unknown sources with invalid characters (skipped without blocking).
    • Tested handling of unknown sources with valid symbol syntax (accepted).
  5. Documentation (docs/sep40-oracle-publisher.md):

    • Documented the inclusion of off-chain venues in venues: Vec<Symbol> and the symbol normalization rule in Section 1.4.1.

Verification

  • npx tsc --noEmit: 0 errors
  • npm test (vitest): 159 test files passed, 1953 tests passed (0 failed)

Divinity-Labs#755)

- Map off-chain venue sources (e.g. Gate.io -> Gate_io) to legal Soroban symbols via venue symbol registry.
- Enforce symbol format (alphanumeric + underscore, <= 32 chars) across all adapters.
- Skip unknown sources with invalid characters with a warning rather than permanently blocking pairs.
- Add venueAdapters symbol validation test and sep40 encoding/publisher tests.
- Document off-chain venue inclusion in docs/sep40-oracle-publisher.md.

Closes Divinity-Labs#755
@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Lkshayyadav Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

One Gate.io row in the last hour stops a pair from being published on chain

1 participant