@gala-chain/gswap-sdk 1.2.0-rc.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -10
- package/dist/browser/classes/dex_fees.js.map +1 -1
- package/dist/browser/classes/gateway.js.map +1 -1
- package/dist/browser/classes/gdex_stream.js.map +1 -1
- package/dist/browser/classes/gswap.js.map +1 -1
- package/dist/browser/classes/gswap_sdk_error.js.map +1 -1
- package/dist/browser/classes/shadow_submit.js +1 -1
- package/dist/browser/classes/shadow_submit.js.map +1 -1
- package/dist/browser/classes/signers.js.map +1 -1
- package/dist/browser/classes/submitted_transaction.js.map +1 -1
- package/dist/browser/utils/chain_dto_signing.js.map +1 -1
- package/dist/browser/utils/classification.js.map +1 -1
- package/dist/browser/utils/dto_builders.js.map +1 -1
- package/dist/browser/utils/eip712.js.map +1 -1
- package/dist/browser/utils/transport.js +1 -1
- package/dist/browser/utils/transport.js.map +1 -1
- package/dist/browser/utils/validation.js.map +1 -1
- package/dist/browser/version.js +1 -1
- package/dist/browser/version.js.map +1 -1
- package/dist/index.cjs +102 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +132 -19
- package/dist/index.d.ts +132 -19
- package/dist/index.mjs +102 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -177,9 +177,12 @@ export interface QuoteResult {
|
|
|
177
177
|
token1Symbol: string;
|
|
178
178
|
tokenInIsToken0: boolean;
|
|
179
179
|
feeTier: number;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
/** Pool price before the trade, token out per token in (always set by `Quoting`). */
|
|
181
|
+
currentPrice: BigNumber;
|
|
182
|
+
/** Pool price after the trade, in the same orientation (always set by `Quoting`). */
|
|
183
|
+
newPrice: BigNumber;
|
|
184
|
+
/** `(newPrice - currentPrice) / currentPrice` as a fraction (`-0.01` is 1% adverse), always set by `Quoting`. */
|
|
185
|
+
priceImpact: BigNumber;
|
|
183
186
|
}
|
|
184
187
|
/** The executed trade as reported by the ApplyRequests result (contract Trade response). */
|
|
185
188
|
export interface TradeExecution {
|
|
@@ -1311,6 +1314,11 @@ export declare const gswapErrorTemplates: { readonly [C in GSwapErrorCode]: stri
|
|
|
1311
1314
|
export declare function renderGSwapErrorTemplate(template: string, params: Readonly<Record<string, unknown>>): string;
|
|
1312
1315
|
//#endregion
|
|
1313
1316
|
//#region src/types/token.d.ts
|
|
1317
|
+
/**
|
|
1318
|
+
* The four parts of a GalaChain token class key, as the chain keys a token (for example
|
|
1319
|
+
* `GALA|Unit|none|none` is collection `GALA`, category `Unit`, type `none`, additionalKey `none`).
|
|
1320
|
+
* It carries no trading symbol: a collection and a symbol disagree for many tokens.
|
|
1321
|
+
*/
|
|
1314
1322
|
export interface GalaChainTokenClassKey {
|
|
1315
1323
|
collection: string;
|
|
1316
1324
|
category: string;
|
|
@@ -1425,6 +1433,7 @@ export declare class GSwapSDKError<C extends GSwapErrorCode = GSwapErrorCode> ex
|
|
|
1425
1433
|
readonly code: C;
|
|
1426
1434
|
/** The named placeholders of the error: a flat object of primitives, safe to localize with. */
|
|
1427
1435
|
readonly params: GSwapErrorParams<C>;
|
|
1436
|
+
/** The server's `Retry-After` in milliseconds (a `RATE_LIMITED` answer), when it sent one. */
|
|
1428
1437
|
readonly retryAfterMs: number | undefined;
|
|
1429
1438
|
/** The HTTP status of the response that caused this error, when there was one. */
|
|
1430
1439
|
readonly status: number | undefined;
|
|
@@ -1833,7 +1842,7 @@ export declare function createLazyPrivateKeySigner(getPrivateKey: PrivateKeyProv
|
|
|
1833
1842
|
*
|
|
1834
1843
|
* `scheme: 'personal-sign'` calls
|
|
1835
1844
|
* `gala_signChainDto([serialize({ ...dto, prefix }), walletAddress, methodName])` and REQUIRES
|
|
1836
|
-
* a wallet build that contains wallet_extension commit
|
|
1845
|
+
* a wallet build that contains wallet_extension commit 34ca4e4 (strips the embedded `prefix`
|
|
1837
1846
|
* field and hashes `prefix` + the prefix-less canonical body, the chain's scheme). Wallets
|
|
1838
1847
|
* released before that fix hash the string with the `prefix` field still inside it and the
|
|
1839
1848
|
* signature recovers to an address nobody holds, so only opt in once the fixed wallet is
|
|
@@ -1858,7 +1867,7 @@ export declare class GalaWalletSigner implements GalaChainSigner {
|
|
|
1858
1867
|
* to the same check); a GalaChain id is `client|` plus 24 hex digits, or the bare 24 hex digits
|
|
1859
1868
|
* frontend_v2 keeps for a direct `client|` login, and is passed through unchanged.
|
|
1860
1869
|
* @param options - Select native signing (default) or personal-sign explicitly.
|
|
1861
|
-
* `'personal-sign'` requires a Gala Wallet build with wallet_extension commit
|
|
1870
|
+
* `'personal-sign'` requires a Gala Wallet build with wallet_extension commit 34ca4e4.
|
|
1862
1871
|
* `selectAddress` is the identity (`client|...` / `eth|...`) Gala Wallet is switched to with
|
|
1863
1872
|
* `window.gala.setAddress` before every signature, when the wallet offers it.
|
|
1864
1873
|
*/
|
|
@@ -1917,6 +1926,7 @@ export declare class BrowserWalletSigner implements GalaChainSigner {
|
|
|
1917
1926
|
constructor(provider: BrowserWalletProvider, walletAddress: string, options?: {
|
|
1918
1927
|
scheme?: 'personal-sign' | 'eip712';
|
|
1919
1928
|
});
|
|
1929
|
+
/** The selected `0x` Ethereum account every signature is requested for. */
|
|
1920
1930
|
readonly walletAddress: string;
|
|
1921
1931
|
private readonly scheme;
|
|
1922
1932
|
/**
|
|
@@ -1939,6 +1949,7 @@ export declare class BrowserWalletSigner implements GalaChainSigner {
|
|
|
1939
1949
|
//#region src/classes/dex_fees.d.ts
|
|
1940
1950
|
/** DEX methods the backend accepts a fee quote for (its allow-list enumerates the same six). */
|
|
1941
1951
|
export declare const DEX_FEE_METHODS: readonly ['Swap', 'RequestTrade', 'AddLiquidity', 'RemoveLiquidity', 'CollectPositionFees', 'CreatePool'];
|
|
1952
|
+
/** A chain method whose network fee `DexFees.quote` can price (see `isDexFeeMethod`). */
|
|
1942
1953
|
export type DexFeeMethod = (typeof DEX_FEE_METHODS)[number];
|
|
1943
1954
|
/** Which pool contract the DTO being quoted targets: legacy (V3) or current (GalaChainDex). */
|
|
1944
1955
|
export type DexFeeContract = 'dexv3-contract' | 'dex-contract';
|
|
@@ -2055,18 +2066,19 @@ export interface ShadowSubmitResult {
|
|
|
2055
2066
|
*
|
|
2056
2067
|
* - `SHADOW_UNAVAILABLE` (503): marking failed or infra not configured; retryable. Never fall back
|
|
2057
2068
|
* silently to a public swap.
|
|
2058
|
-
* - `SHADOW_DISABLED` (400): the feature is off for this environment.
|
|
2059
2069
|
* - `SHADOW_UNSUPPORTED_TYPE` (400): shadow requested on a non-swap method.
|
|
2060
2070
|
* - `SHADOW_RELAY_REJECTED`: terminal business rejection (slippage, balance, ...), not retryable;
|
|
2061
2071
|
* `message` is the gateway's verbatim string.
|
|
2062
2072
|
*/
|
|
2063
|
-
export declare const SHADOW_SUBMIT_CODES: readonly ['SHADOW_UNAVAILABLE', '
|
|
2073
|
+
export declare const SHADOW_SUBMIT_CODES: readonly ['SHADOW_UNAVAILABLE', 'SHADOW_UNSUPPORTED_TYPE', 'SHADOW_RELAY_REJECTED'];
|
|
2064
2074
|
/** One member of {@link SHADOW_SUBMIT_CODES}. */
|
|
2065
2075
|
export type ShadowSubmitCode = (typeof SHADOW_SUBMIT_CODES)[number];
|
|
2066
2076
|
/**
|
|
2067
2077
|
* Every `kind` of a failed {@link ShadowSubmitOutcome}, for an app that maps each to its own text
|
|
2068
|
-
* (`Record<ShadowFailureKind, string>`): `unavailable` (retryable), `disabled
|
|
2069
|
-
* the
|
|
2078
|
+
* (`Record<ShadowFailureKind, string>`): `unavailable` (retryable), `disabled` (the shadow route
|
|
2079
|
+
* answered 400: the request is not a dark-swappable one, e.g. `SHADOW_UNSUPPORTED_TYPE`; Shadow
|
|
2080
|
+
* Swaps themselves are enabled in every environment), `rejected` (carries the gateway's `message`)
|
|
2081
|
+
* and `unknown`.
|
|
2070
2082
|
*/
|
|
2071
2083
|
export declare const SHADOW_FAILURE_KINDS: readonly ['unavailable', 'disabled', 'rejected', 'unknown'];
|
|
2072
2084
|
/** One member of {@link SHADOW_FAILURE_KINDS}. */
|
|
@@ -2123,7 +2135,7 @@ export declare function classifyShadowSubmitStatus(status: number): ShadowFailur
|
|
|
2123
2135
|
/**
|
|
2124
2136
|
* Prefers the body `code` (stable across status remaps) and falls back to the HTTP status.
|
|
2125
2137
|
* `SHADOW_UNAVAILABLE` is the only retryable case; `SHADOW_RELAY_REJECTED` is a terminal gateway
|
|
2126
|
-
* rejection;
|
|
2138
|
+
* rejection; `SHADOW_UNSUPPORTED_TYPE` and any other 400 map to "disabled".
|
|
2127
2139
|
*/
|
|
2128
2140
|
export declare function classifyShadowSubmitError(status: number, code?: string): ShadowFailureKind;
|
|
2129
2141
|
/**
|
|
@@ -2196,9 +2208,13 @@ export type PositionConfirmationResult = {
|
|
|
2196
2208
|
};
|
|
2197
2209
|
/** A submitted v2 transaction whose confirmation mode is explicit in the gateway response. */
|
|
2198
2210
|
export declare class SubmittedTransaction<TConfirmation = AppliedTrade | Position | null> {
|
|
2211
|
+
/** The chain method that was submitted (`RequestTrade`, `AddLiquidity`, ...). */
|
|
2199
2212
|
readonly method: string;
|
|
2213
|
+
/** The write's durable correlation key: persist it, and confirm from it alone later. */
|
|
2200
2214
|
readonly uniqueKey: string;
|
|
2215
|
+
/** The request transaction id the gateway reported, or `null` when it gave none. */
|
|
2201
2216
|
readonly transactionId: string | null;
|
|
2217
|
+
/** The block of the transaction, when the answer carried one; otherwise `null`. */
|
|
2202
2218
|
readonly blockNumber: number | null;
|
|
2203
2219
|
/** The gateway's `data.mode`: `'sync'` (executed, `result` is the chain result) or `'queued'`. */
|
|
2204
2220
|
readonly mode: 'sync' | 'queued';
|
|
@@ -2358,7 +2374,9 @@ export declare class ChainGateway {
|
|
|
2358
2374
|
private readonly chainCallTimeoutMs;
|
|
2359
2375
|
private readonly isTransportFailure;
|
|
2360
2376
|
private readonly answerOfRejectionHook;
|
|
2377
|
+
/** The request timeout in milliseconds (`Infinity` when no timer is armed). */
|
|
2361
2378
|
readonly requestTimeoutMs: number;
|
|
2379
|
+
/** The swap backend base URL every request is sent to, without a trailing slash. */
|
|
2362
2380
|
readonly dexBackendBaseUrl: string;
|
|
2363
2381
|
/** Wire format shared by the read services built on this gateway. */
|
|
2364
2382
|
readonly wire: WireOptions;
|
|
@@ -2383,7 +2401,7 @@ export declare class ChainGateway {
|
|
|
2383
2401
|
*
|
|
2384
2402
|
* Unlike `submit`, EVERY HTTP status resolves: the result is the raw `{ httpStatus, body }`,
|
|
2385
2403
|
* because shadow failures are classified from the status together with the body's `code`
|
|
2386
|
-
* (`SHADOW_UNAVAILABLE`, `
|
|
2404
|
+
* (`SHADOW_UNAVAILABLE`, `SHADOW_UNSUPPORTED_TYPE`, `SHADOW_RELAY_REJECTED`);
|
|
2387
2405
|
* see `readShadowSubmitOutcome`. Only a failure to get an answer rejects, and it rejects with
|
|
2388
2406
|
* `SUBMISSION_OUTCOME_UNKNOWN` (`params.reason` `'timeout'` or `'transport'`): the request may
|
|
2389
2407
|
* have been accepted. Every error it throws has `error.shadow === true`, and a non-SDK object
|
|
@@ -2518,7 +2536,9 @@ export interface GdexSubscription {
|
|
|
2518
2536
|
}
|
|
2519
2537
|
/** A JSON-RPC error answered by the stream. */
|
|
2520
2538
|
export declare class GdexStreamError extends Error {
|
|
2539
|
+
/** The JSON-RPC error code. */
|
|
2521
2540
|
readonly code: number;
|
|
2541
|
+
/** The error's optional `data` member, as the server sent it. */
|
|
2522
2542
|
readonly data?: unknown;
|
|
2523
2543
|
constructor(code: number, message: string, data?: unknown);
|
|
2524
2544
|
}
|
|
@@ -2556,17 +2576,26 @@ export declare class GdexStreamService {
|
|
|
2556
2576
|
connect(): Promise<void>;
|
|
2557
2577
|
/** Close the connection and stop reconnecting. */
|
|
2558
2578
|
disconnect(): void;
|
|
2579
|
+
/** `true` while the socket is open (false while connecting, reconnecting or after `disconnect()`). */
|
|
2559
2580
|
isConnected(): boolean;
|
|
2560
2581
|
/** Raw JSON-RPC escape hatch. */
|
|
2561
2582
|
request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
2562
2583
|
private send;
|
|
2584
|
+
/** `gdex_serverInfo`: the server's own description of itself, as it sends it. */
|
|
2563
2585
|
serverInfo(): Promise<Record<string, unknown>>;
|
|
2586
|
+
/** `gdex_ping`: a round trip that answers `{ pong, serverTime }`. */
|
|
2564
2587
|
ping(): Promise<{
|
|
2565
2588
|
pong: boolean;
|
|
2566
2589
|
serverTime: string;
|
|
2567
2590
|
}>;
|
|
2591
|
+
/** `gdex_getPool`: the current state of one pool, selected by its key or hash. */
|
|
2568
2592
|
getPool(selector: GdexPoolSelector): Promise<Record<string, unknown>>;
|
|
2593
|
+
/** `gdex_getBalance`: an owner's balances, or only the one of `tokenClassKey` when given. */
|
|
2569
2594
|
getBalance(owner: string, tokenClassKey?: string): Promise<Record<string, unknown>>;
|
|
2595
|
+
/**
|
|
2596
|
+
* `gdex_getPositions`: an owner's positions, optionally in one pool, a page at a time. Pass the
|
|
2597
|
+
* returned `bookmark` back in as `bookmark` for the next page.
|
|
2598
|
+
*/
|
|
2570
2599
|
getPositions(opts: {
|
|
2571
2600
|
owner: string;
|
|
2572
2601
|
pool?: GdexPoolKey;
|
|
@@ -2577,10 +2606,12 @@ export declare class GdexStreamService {
|
|
|
2577
2606
|
positions: Record<string, unknown>[];
|
|
2578
2607
|
bookmark: string;
|
|
2579
2608
|
}>;
|
|
2609
|
+
/** `gdex_getBlockHeight`: the block number the server reports, with its timestamp. */
|
|
2580
2610
|
getBlockHeight(): Promise<{
|
|
2581
2611
|
blockNumber: number;
|
|
2582
2612
|
timestamp: string;
|
|
2583
2613
|
}>;
|
|
2614
|
+
/** `gdex_quote`: a quote over the stream; give exactly one of `amountIn` or `amountOut`. */
|
|
2584
2615
|
quote(params: {
|
|
2585
2616
|
tokenIn: string;
|
|
2586
2617
|
tokenOut: string;
|
|
@@ -2588,6 +2619,7 @@ export declare class GdexStreamService {
|
|
|
2588
2619
|
amountIn?: string;
|
|
2589
2620
|
amountOut?: string;
|
|
2590
2621
|
}): Promise<Record<string, unknown>>;
|
|
2622
|
+
/** `gdex_getToken`: the server's record of one token class, as it sends it. */
|
|
2591
2623
|
getToken(tokenClassKey: string): Promise<Record<string, unknown>>;
|
|
2592
2624
|
/** One event per committed swap. Omit the pool to receive every pool's swaps. */
|
|
2593
2625
|
subscribeSwaps(cb: (event: Record<string, unknown>) => void, opts?: GdexSubscribeOptions & {
|
|
@@ -2933,10 +2965,22 @@ interface Branding<BrandT> {
|
|
|
2933
2965
|
type Brand<T, BrandT> = T & Branding<BrandT>;
|
|
2934
2966
|
//#endregion
|
|
2935
2967
|
//#region src/types/amounts.d.ts
|
|
2968
|
+
/** A decimal amount: a string or a `BigNumber`, never a JavaScript number. */
|
|
2936
2969
|
export type NumericAmount = string | BigNumber;
|
|
2970
|
+
/** A calculated square-root price (always a `BigNumber`, branded so it is never mistaken for a price). */
|
|
2937
2971
|
export type SqrtPrice = Brand<BigNumber, 'SqrtPrice'>;
|
|
2972
|
+
/**
|
|
2973
|
+
* A square-root price an API accepts: a calculated {@link SqrtPrice}, or a decimal string /
|
|
2974
|
+
* `BigNumber` the caller brands with `as SqrtPriceIn` to declare what it is.
|
|
2975
|
+
*/
|
|
2938
2976
|
export type SqrtPriceIn = Brand<NumericAmount, 'SqrtPriceIn'> | SqrtPrice;
|
|
2977
|
+
/** A calculated price (always a `BigNumber`, branded so it is never mistaken for a square-root price). */
|
|
2939
2978
|
export type Price = Brand<BigNumber, 'Price'>;
|
|
2979
|
+
/**
|
|
2980
|
+
* A price an API accepts (for example `addLiquidityByPrice`'s `minPrice` / `maxPrice`): a calculated
|
|
2981
|
+
* {@link Price}, or a decimal string / `BigNumber` the caller brands with `as PriceIn` to declare
|
|
2982
|
+
* what it is. An unbranded string does not compile.
|
|
2983
|
+
*/
|
|
2940
2984
|
export type PriceIn = Brand<NumericAmount, 'PriceIn'> | Price;
|
|
2941
2985
|
/**
|
|
2942
2986
|
* What a swap trades: exactly one of `exactIn` (sell this much of the input token) or `exactOut`
|
|
@@ -3683,10 +3727,18 @@ export declare const GSWAP_ENVIRONMENTS: Readonly<Record<GSwapEnv, GSwapEnvironm
|
|
|
3683
3727
|
//#region src/classes/gswap.d.ts
|
|
3684
3728
|
/** Options for constructing a backend-routed SDK client. */
|
|
3685
3729
|
export interface GSwapOptions {
|
|
3730
|
+
/** Signs every write. Without one, reads work and any write throws `NO_SIGNER`. */
|
|
3686
3731
|
signer?: GalaChainSigner | undefined;
|
|
3732
|
+
/**
|
|
3733
|
+
* The selected account, sent as `X-Wallet-Address` on writes (attribution only; the chain
|
|
3734
|
+
* recovers the signer from the signature). Required for shadow writes.
|
|
3735
|
+
*/
|
|
3687
3736
|
walletAddress?: string | undefined;
|
|
3737
|
+
/** `'stage'` or `'prod'` swap backend preset; defaults to `'prod'`. */
|
|
3688
3738
|
env?: GSwapEnv | undefined;
|
|
3739
|
+
/** Overrides the preset's swap backend base URL (a test or private deployment). */
|
|
3689
3740
|
dexBackendBaseUrl?: string | undefined;
|
|
3741
|
+
/** HTTP transport for every request; defaults to the global `fetch`. */
|
|
3690
3742
|
httpRequestor?: HttpRequestor | undefined;
|
|
3691
3743
|
/** Request timeout in milliseconds (default 30 000); `Infinity` arms no timer. */
|
|
3692
3744
|
chainCallTimeoutMs?: number | undefined;
|
|
@@ -3720,27 +3772,43 @@ export interface GSwapOptions {
|
|
|
3720
3772
|
*/
|
|
3721
3773
|
uniqueKeyPrefix?: string | undefined;
|
|
3722
3774
|
}
|
|
3723
|
-
/**
|
|
3775
|
+
/**
|
|
3776
|
+
* Main entry point for the current GalaChainDex SDK: one client bundling the services that read
|
|
3777
|
+
* and write through the swap backend (`quoting`, `swaps`, `pools`, `positions`, `assets`,
|
|
3778
|
+
* `symbols`, `fees`, `stream`). See {@link GSwapOptions} for configuration.
|
|
3779
|
+
*/
|
|
3724
3780
|
export declare class GSwap {
|
|
3781
|
+
/** The swap backend base URL every request goes to, without a trailing slash. */
|
|
3725
3782
|
readonly dexBackendBaseUrl: string;
|
|
3783
|
+
/** The request timeout in milliseconds (default 30 000; `Infinity` arms no timer). */
|
|
3726
3784
|
readonly chainCallTimeoutMs: number;
|
|
3785
|
+
/** The signer given at construction, if any. */
|
|
3727
3786
|
readonly signer: GalaChainSigner | undefined;
|
|
3787
|
+
/** The account given at construction, if any. */
|
|
3728
3788
|
readonly walletAddress: string | undefined;
|
|
3789
|
+
/** The chain-gateway client every other service reads and writes through. */
|
|
3729
3790
|
readonly gateway: ChainGateway;
|
|
3791
|
+
/** The trading-symbol registry. */
|
|
3730
3792
|
readonly symbols: Symbols;
|
|
3793
|
+
/** Read-only exact-input and exact-output quotes. */
|
|
3731
3794
|
readonly quoting: Quoting;
|
|
3795
|
+
/** Pool, slot0 and composite-pool reads. */
|
|
3732
3796
|
readonly pools: Pools;
|
|
3797
|
+
/** Position reads, liquidity estimates and liquidity / pool-creation writes. */
|
|
3733
3798
|
readonly positions: Positions;
|
|
3799
|
+
/** Queued swaps (`RequestTrade`), dark swaps and swap confirmation. */
|
|
3734
3800
|
readonly swaps: Swaps;
|
|
3801
|
+
/** User token balances. */
|
|
3735
3802
|
readonly assets: Assets;
|
|
3736
3803
|
/** Network-fee quotes (DryRun) signed with this client's signer. */
|
|
3737
3804
|
readonly fees: DexFees;
|
|
3805
|
+
/** The realtime stream endpoint {@link GSwap.stream} connects to. */
|
|
3738
3806
|
readonly dexBackendWsUrl: string;
|
|
3739
3807
|
private readonly webSocketImpl;
|
|
3740
3808
|
private readonly streamApiKey;
|
|
3741
3809
|
private streamClient;
|
|
3742
3810
|
/**
|
|
3743
|
-
* Create an SDK client for prod or stage.
|
|
3811
|
+
* Create an SDK client for prod (the default) or stage, or for a `dexBackendBaseUrl` of your own.
|
|
3744
3812
|
*
|
|
3745
3813
|
* @example
|
|
3746
3814
|
* ```typescript
|
|
@@ -4468,6 +4536,7 @@ export declare function tokenClassDollarKey(token: Record<string, unknown> | nul
|
|
|
4468
4536
|
export declare function canonicalDecimalString(value: string | number): string;
|
|
4469
4537
|
//#endregion
|
|
4470
4538
|
//#region src/utils/eip712.d.ts
|
|
4539
|
+
/** EIP-712 `types`: each struct name mapped to its ordered `{ name, type }` fields. */
|
|
4471
4540
|
type EIP712Types = Record<string, Array<{
|
|
4472
4541
|
name: string;
|
|
4473
4542
|
type: string;
|
|
@@ -4558,8 +4627,9 @@ type RequestTradeInput = {
|
|
|
4558
4627
|
/**
|
|
4559
4628
|
* Builds the RequestTrade DTO: `exactIn` sells that much of the input token (`sell0Qty` or
|
|
4560
4629
|
* `sell1Qty`), `exactOut` buys that much of the output token (`buy1Qty` or `buy0Qty`), plus the
|
|
4561
|
-
* side's slippage bound and an optional `priceLimit`. Key order
|
|
4562
|
-
*
|
|
4630
|
+
* side's slippage bound and an optional `priceLimit`. Key order is
|
|
4631
|
+
* `token0, token1, fee, uniqueKey`, then the one quantity, then the slippage bound, then
|
|
4632
|
+
* `priceLimit`.
|
|
4563
4633
|
*
|
|
4564
4634
|
* @example
|
|
4565
4635
|
* ```ts
|
|
@@ -4851,10 +4921,10 @@ export interface FailureClassification {
|
|
|
4851
4921
|
* object, safe to mutate or freeze.
|
|
4852
4922
|
*
|
|
4853
4923
|
* `options.retryable: false` WITHHOLDS Retry from an outcome that would otherwise allow it: the
|
|
4854
|
-
* SDK's own `not_queued` for a refusal the gateway will repeat is
|
|
4855
|
-
* { retryable: false })` (also exported, frozen, as
|
|
4856
|
-
* Retry away from an outcome but never grant it to one
|
|
4857
|
-
* accepted.
|
|
4924
|
+
* SDK's own `not_queued` for a refusal the gateway will repeat is
|
|
4925
|
+
* `classification('not_queued', { retryable: false })` (also exported, frozen, as
|
|
4926
|
+
* {@link NOT_QUEUED_FINAL}). An app may take Retry away from an outcome but never grant it to one
|
|
4927
|
+
* that cannot have it, so only `false` is accepted.
|
|
4858
4928
|
*
|
|
4859
4929
|
* @example
|
|
4860
4930
|
* ```ts
|
|
@@ -5318,12 +5388,55 @@ export declare function frameSlot0(slot0: {
|
|
|
5318
5388
|
export declare function isValidUniqueKey(uniqueKey: unknown): uniqueKey is string;
|
|
5319
5389
|
//#endregion
|
|
5320
5390
|
//#region src/utils/validation.d.ts
|
|
5391
|
+
/**
|
|
5392
|
+
* Validates a decimal amount: a string or `BigNumber`, never a JavaScript number.
|
|
5393
|
+
*
|
|
5394
|
+
* @param amount - The amount to check.
|
|
5395
|
+
* @param parameterName - The field name reported in the error's `params.field`.
|
|
5396
|
+
* @param allowZero - Accept zero (default `false`).
|
|
5397
|
+
* @throws GSwapSDKError `AMOUNT_IS_JS_NUMBER`, `AMOUNT_NOT_FINITE`, `AMOUNT_NOT_POSITIVE` (zero
|
|
5398
|
+
* when `allowZero` is false) or `AMOUNT_NEGATIVE`.
|
|
5399
|
+
*/
|
|
5321
5400
|
export declare function validateNumericAmount(amount: NumericAmount, parameterName: string, allowZero?: boolean): void;
|
|
5401
|
+
/**
|
|
5402
|
+
* Validates a spot price and a lower/upper price range: none a JavaScript number, all positive and
|
|
5403
|
+
* finite (a non-finite upper bound counts as an unbounded `1e18`), and `lowerPrice <= upperPrice`.
|
|
5404
|
+
*
|
|
5405
|
+
* @throws GSwapSDKError `PRICE_VALUES_IS_JS_NUMBER`, `INVALID_PRICE_VALUES` or `INVALID_PRICE_RANGE`.
|
|
5406
|
+
*/
|
|
5322
5407
|
export declare function validatePriceValues(spotPrice: NumericAmount, lowerPrice: NumericAmount, upperPrice: NumericAmount): void;
|
|
5408
|
+
/**
|
|
5409
|
+
* Validates a token's decimals: a non-negative integer.
|
|
5410
|
+
*
|
|
5411
|
+
* @throws GSwapSDKError `INVALID_TOKEN_DECIMALS` (`params.field` is `parameterName`).
|
|
5412
|
+
*/
|
|
5323
5413
|
export declare function validateTokenDecimals(decimals: number, parameterName: string): void;
|
|
5414
|
+
/**
|
|
5415
|
+
* Validates a position's tick range: two integers with `tickLower < tickUpper`, both within
|
|
5416
|
+
* `GC_MIN_TICK`..`GC_MAX_TICK`. It does not check alignment to a fee tier's spacing (see
|
|
5417
|
+
* `assertTickRange`).
|
|
5418
|
+
*
|
|
5419
|
+
* @throws GSwapSDKError `TICKS_NOT_INTEGERS`, `INVALID_TICK_RANGE` or `TICKS_OUT_OF_BOUNDS`.
|
|
5420
|
+
*/
|
|
5324
5421
|
export declare function validateTickRange(tickLower: number, tickUpper: number): void;
|
|
5422
|
+
/**
|
|
5423
|
+
* Asserts that `fee` is one of the fee tiers in `ALL_FEE_TIERS` (`0`, `500`, `3000`, `10000`).
|
|
5424
|
+
*
|
|
5425
|
+
* @throws GSwapSDKError `INVALID_FEE` (`params.field` `'fee'`, `params.allowed` the tiers).
|
|
5426
|
+
*/
|
|
5325
5427
|
export declare function validateFee(fee: number): asserts fee is FEE_TIER;
|
|
5428
|
+
/**
|
|
5429
|
+
* Validates a tick spacing: a positive integer.
|
|
5430
|
+
*
|
|
5431
|
+
* @throws GSwapSDKError `INVALID_TICK_SPACING`.
|
|
5432
|
+
*/
|
|
5326
5433
|
export declare function validateTickSpacing(tickSpacing: number): void;
|
|
5434
|
+
/**
|
|
5435
|
+
* Asserts that a wallet address was given and is a non-blank string. It does not check the address
|
|
5436
|
+
* format.
|
|
5437
|
+
*
|
|
5438
|
+
* @throws GSwapSDKError `MISSING_WALLET_ADDRESS` (undefined) or `INVALID_WALLET_ADDRESS` (blank).
|
|
5439
|
+
*/
|
|
5327
5440
|
export declare function validateWalletAddress(address?: string): asserts address is string;
|
|
5328
5441
|
/**
|
|
5329
5442
|
* True when `symbol` is acceptable to propose into the trading-symbol registry: ASCII letters and
|