Repository navigation
Conversation
…tchet, clone gate
… uniqueKey as a real field - Trade bounds are validated locally again (negative amountOutMinimum/amountInMaximum throw VALIDATION_ERROR before anything is signed); the live test proves the gateway's BOUNDS_VIOLATION bounce by submitting a raw signed DTO through ChainGateway instead. - confirm() returns the explore row with an enumerable uniqueKey (the row does not echo it); a 200 with a non-object body now throws CONFIRMATION_FAILED instead of returning raw text. - Live stage re-run: Trade 0ced6609… block 2420883; add/collect/remove verified by reads.
Route all reads through the swap backend, harden v2 response and quote validation, preserve submission metadata, and remove retired API surfaces. Update examples and documentation for the current signing, confirmation, and slippage contracts.
Validate and expose the backend pool-summary shape separately from single-pool metadata so the new backend-only pools route is not represented by an unsafe cast.
Cover optional pool-list fields and reject malformed backend rows.
Keep the package version visible on backend HTTP requests.
The header-known short-circuit returned null on the first pending explore poll, so callers lost the indexed confirmation whenever the indexer was a second behind the gateway. transactionId and blockNumber are already exposed on the submission itself; confirm() polls the explore read for the full timeout and its Trade result is non-null.
Author
|
Both adversarial review rounds are addressed on this branch (now at f93c408):
Verification on this exact tree: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves
@gala-chain/gswap-sdkfrom the legacy stack (dexv3 reads, bundler writes, EIP-712 signing — all of which stopped working when legacy became exit-only on 2026-09-01) onto the current GalaChainDex contract. Publishes as1.0.0-rc.1(breaking).Writes go through the Chain Gateway
POST {dexBackend}/v1/chain/asset/dex-contract/{Trade|AddLiquidity|RemoveLiquidity|CollectPositionFees|CreatePool}with the signed v2 DTO; gateway bounces map toGSwapSDKErrorcodes (METHOD_NOT_ALLOWED,SIGNATURE_INVALID,SIGNER_MISMATCH,DTO_INVALID,BOUNDS_VIOLATION,SYMBOL_CONFLICT,RATE_LIMITED,CHAIN_DISPATCH_FAILED).SubmittedTransaction { transactionId, blockNumber, uniqueKey, result, confirm() }.transactionIdandblockNumbercome from the gateway'sx-transaction-id/x-block-numberresponse headers (body fields as fallback);confirm()resolves a Trade againstGET /explore/transaction?uniqueKey=and a liquidity write against the position read, and always waits for the indexed row.SUBMISSION_OUTCOME_UNKNOWN(confirm before retrying), distinct from a pre-submit failure.PendingTransaction,stringsInstructions,positionId,zeroForOne/sqrtPriceLimit, class-keytoken0/token1in write DTOs: deleted, no shims.Signing — one scheme per signer type, EIP-712 retired
PrivateKeySigner: GalaChain-native (@gala-chain/apisignatures.getSignature, bare 130-hex) — resolves the registeredclient|alias.GalaWalletSigner:gala_signChainDto(serializedDto, address, method, 'native')(wallet ≥ 001b9c0), personal-sign fallback for older wallets.BrowserWalletSigner(MetaMask / any EIP-1193): personal-sign withcalculatePersonalSignPrefix— resolves the bareeth|identity (documented).signerPublicKey/signerAddress.v2 DTOs and reads — everything through the swap backend
GET /v2/trade/symbols); fee tiers0|500|3000|10000; spacing-aligned ticks (src/utils/ticks.tsmirrorsgc-math, Decimal-backed and fixture-checked against the backend at the tick boundaries)./v2/trade/*. The SDK never calls a GalaChain gateway directly;gatewayBaseUrland the raw chain-read client are gone.numberis rejected before anything is signed.Review rounds (both adversarial reviews addressed on this branch)
6933a80): tick-math parity with the backend Decimal fixtures, numeric-amount rejection, symbol-cache refresh after a miss and aftercreatePool, request timeouts + abort, signer address normalisation, single-read of error bodies, DTO XOR types, result shapes, liquidity confirmation by position re-read, pending classification (missing route / Retry-After / backoff), package entrypoint smoke, response validation, pagination caps, malformed signatures,npm audit --omit=dev(SECURITY-NOTES.md).62c1314…d44f0ab): large-tick math no longer hangs,process.envoption types accept explicitundefined, backend pool reads are typed and bounded, quote wire shape validated, fake example liquidity page removed and the swap example derivesamountOutMinimumfrom the quote, legacy result types deleted, versionedUser-Agent, browser-safe UUID, exact dependency pins.8666af3:confirm()keeps polling until the trade is indexed instead of returningnullwhen the headers are already known.Quality gates (defi-backend parity)
noUncheckedIndexedAccess,noPropertyAccessFromIndexSignature,noImplicitReturns,noUnused*,exactOptionalPropertyTypes), type-aware ESLint (--max-warnings=0), jscpd threshold 0, c8 ratchet, type-level tests, examples build, packed-tarball require/import smoke —npm run check:allgreen: 102 unit tests, coverage 99.68 / 99.68 / 100 / 95.82.npm run test:live(opt-in,GSWAP_ENV=stage+GSWAP_LIVE_PRIVATE_KEY, serialised on/tmp/swap-e2e-live.lock): quote → swap →confirm()(block 2422335), add / collect / remove liquidity verified by position reads, CreatePool duplicate →SYMBOL_CONFLICT/already-exists, negative bound rejected locally and →BOUNDS_VIOLATIONwhen submitted raw, throwaway signer →CHAIN_DISPATCH_FAILEDinsufficient balance.docs/, Docusaurus) builds clean.Docs
README,
docs/docs/**(getting started, pool concepts, signing/identity, transaction status, error handling, migration 0.x → 1.0), CLI and full-dex examples on the v2 API.Release notes
v1.0.0-rc.1as a pre-release to triggerpublish-npm.yml;lateststays0.0.10until a1.0.0is cut.client|alias resolution.