@sodax/types 2.0.0-rc.17 → 2.0.0-rc.19

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.
@@ -0,0 +1,28 @@
1
+ import type { SpokeChainKey, IntentRelayChainIdMap } from '../chains/chains.js';
2
+ import type { XToken } from '../chains/tokens.js';
3
+ import type { Result, SpokeChainConfigMap } from '../common/common.js';
4
+ import type { Address } from '../shared/shared.js';
5
+ export type GetChainsApiResponse = readonly SpokeChainKey[];
6
+ export type GetSwapTokensApiResponse = Record<SpokeChainKey, readonly XToken[]>;
7
+ export type GetSwapTokensByChainIdApiResponse = readonly XToken[];
8
+ export type GetMoneyMarketTokensApiResponse = Record<SpokeChainKey, readonly XToken[]>;
9
+ export type GetMoneyMarketTokensByChainIdApiResponse = readonly XToken[];
10
+ export type GetRelayChainIdMapApiResponse = IntentRelayChainIdMap;
11
+ export type GetSpokeChainConfigApiResponse = SpokeChainConfigMap;
12
+ export type GetMoneyMarketReserveAssetsApiResponse = readonly Address[];
13
+ export type GetAllConfigApiResponse = {
14
+ version?: number;
15
+ supportedChains: GetChainsApiResponse;
16
+ supportedSwapTokens: GetSwapTokensApiResponse;
17
+ supportedMoneyMarketTokens: GetMoneyMarketTokensApiResponse;
18
+ supportedMoneyMarketReserveAssets: GetMoneyMarketReserveAssetsApiResponse;
19
+ relayChainIdMap: GetRelayChainIdMapApiResponse;
20
+ spokeChainConfig: GetSpokeChainConfigApiResponse;
21
+ };
22
+ export interface IConfigApiV1 {
23
+ getChains(): Promise<Result<GetChainsApiResponse>>;
24
+ getSwapTokens(): Promise<Result<GetSwapTokensApiResponse>>;
25
+ getSwapTokensByChainId(chainId: SpokeChainKey): Promise<Result<GetSwapTokensByChainIdApiResponse>>;
26
+ getMoneyMarketTokens(): Promise<Result<GetMoneyMarketTokensApiResponse>>;
27
+ getMoneyMarketTokensByChainId(chainId: SpokeChainKey): Promise<Result<GetMoneyMarketTokensByChainIdApiResponse>>;
28
+ }
@@ -3,6 +3,7 @@ import type { XToken } from '../chains/tokens.js';
3
3
  import type { RelayConfig } from '../common/constants.js';
4
4
  import type { ConcentratedLiquidityConfig, DexDefaultConfig } from '../dex/dex.js';
5
5
  import type { SodaxDefaultConfig } from '../sodax-config/sodax-config.js';
6
+ import type { RawTxReturnType } from '../common/index.js';
6
7
  /** Quote direction. Only exact-input quoting is supported. */
7
8
  export type QuoteTypeV2 = 'exact_input';
8
9
  /**
@@ -254,13 +255,13 @@ export interface AllowanceCheckResponseV2 {
254
255
  }
255
256
  /** POST /swaps/approve — response body. */
256
257
  export interface ApproveResponseV2 {
257
- /** Unsigned approval transaction (chain-specific shape). For EVM: `{ from, to, value, data }`. */
258
- tx: unknown;
258
+ /** Unsigned approval transaction the `RawTxReturnType` variant for the request's `srcChainKey`. */
259
+ tx: RawTxReturnType;
259
260
  }
260
261
  /** POST /swaps/intents — response body. */
261
262
  export interface CreateIntentResponseV2 {
262
- /** Unsigned create-intent transaction (chain-specific shape). For EVM: `{ from, to, value, data }`. */
263
- tx: unknown;
263
+ /** Unsigned create-intent transaction the `RawTxReturnType` variant for the request's `srcChainKey`. */
264
+ tx: RawTxReturnType;
264
265
  /** Built intent struct (hub representation). */
265
266
  intent: IntentResponseV2;
266
267
  /** Extra data required when calling `POST /swaps/intents/submit`. */
@@ -301,8 +302,8 @@ export interface CancelIntentRequestV2 {
301
302
  }
302
303
  /** POST /swaps/intents/cancel — response body. */
303
304
  export interface CancelIntentResponseV2 {
304
- /** Unsigned cancel transaction (chain-specific shape). For EVM: `{ from, to, value, data }`. */
305
- tx: unknown;
305
+ /** Unsigned cancel-intent transaction the `RawTxReturnType` variant for the request's `srcChainKey`. */
306
+ tx: RawTxReturnType;
306
307
  }
307
308
  /** POST /swaps/intents/hash — request body. */
308
309
  export interface IntentHashRequestV2 {
@@ -10,15 +10,21 @@
10
10
  // - Outbound (response) types are pure JSON: every bigint-derived value (intent
11
11
  // ids, amounts, deadlines, fees, relay chain ids) is a decimal `string`, and
12
12
  // every `Date` is an ISO 8601 `string` (e.g. `abandonedAt`). A response NEVER
13
- // contains `bigint` — JSON cannot represent it.
13
+ // contains `bigint` on the wire — JSON cannot represent it (the one typed
14
+ // exception is the unsigned `tx`; see below).
14
15
  // - Inbound (request) types mirror the server's parsed request DTOs: the Intent
15
16
  // struct (`IntentRequestV2`) carries `bigint` for its numeric fields, matching
16
17
  // the backend `IntentDto`. Other request fields (amounts/deadlines on
17
18
  // `CreateIntentParamsV2`/`QuoteRequestV2`, fees, relay chain ids, etc.) are
18
19
  // decimal `string`, matching their `@IsNumberString` DTO fields.
19
20
  // - `Hex` / `Address` / `Hash` / `SpokeChainKey` are plain `string` everywhere.
20
- // - Chain-specific opaque payloads (unsigned `tx`, gas estimate, raw relay
21
- // `result`) are `unknown` because their shape varies by chain family.
21
+ // - The unsigned `tx` is typed as the SDK domain union `RawTxReturnType`. It
22
+ // travels as pure JSON (bigints stringified; Injective byte arrays as
23
+ // `{ "0": N, … }` index objects), and the SDK client's response schema
24
+ // (`@sodax/sdk` `rawTxSchemas`) rebuilds the domain shape (`bigint`,
25
+ // `Uint8Array`) on parse — the inverse of the backend's `stringifyBigInts`.
26
+ // - The remaining chain-specific opaque payloads (gas estimate, raw relay
27
+ // `result`) stay `unknown` because their shape varies by chain family.
22
28
  //
23
29
  // Shapes used in both directions are split into a `*RequestV2` (client → server)
24
30
  // and a `*ResponseV2` (server → client) interface. `IntentRequestV2` (bigint
@@ -1,2 +1,2 @@
1
- export * from './backendApi.js';
1
+ export * from './backendApiV1.js';
2
2
  export * from './backendApiV2.js';
@@ -1,2 +1,2 @@
1
- export * from './backendApi.js';
1
+ export * from './backendApiV1.js';
2
2
  export * from './backendApiV2.js';
@@ -29,7 +29,7 @@ export const RelayChainIdMap = {
29
29
  [ChainKeys.STACKS_MAINNET]: 60n,
30
30
  };
31
31
  export const INTENT_CHAIN_IDS = Object.values(RelayChainIdMap);
32
- export const IntentRelayChainIdToChainKey = Object.fromEntries(Object.entries(RelayChainIdMap).map(([chainKey, chainId]) => [chainId, chainKey]));
32
+ export const IntentRelayChainIdToChainKey = new Map(Object.entries(RelayChainIdMap).map(([chainKey, chainId]) => [chainId, chainKey]));
33
33
  /**
34
34
  * Base URL for default chain logos hosted in the `@sodax/assets` package.
35
35
  * Each logo is served from `main` via raw.githubusercontent and named by its
@@ -15,11 +15,28 @@ export declare const DEFAULT_BACKEND_API_HEADERS: {
15
15
  };
16
16
  export declare const DEFAULT_RELAYER_API_ENDPOINT = "https://xcall-relay.nw.iconblockchain.xyz";
17
17
  export declare const VAULT_TOKEN_DECIMALS = 18;
18
- export type ApiConfig = {
18
+ export type BaseApiConfig = {
19
19
  baseURL: HttpUrl;
20
20
  timeout: number;
21
21
  headers: Record<string, string>;
22
22
  };
23
+ /** Per-endpoint config for the swaps API. Structurally identical to {@link BaseApiConfig}. */
24
+ export type SwapsApiConfig = BaseApiConfig;
25
+ /**
26
+ * Nested config that points the base (backend) API and the swaps API at independent endpoints.
27
+ * At least one slice must be provided — an empty custom config is meaningless (pass a flat
28
+ * {@link BaseApiConfig} instead). Requiring a slice keeps the two members disjoint from
29
+ * `BaseApiConfig` (which carries `baseURL`), so {@link ApiConfig} can be discriminated by the
30
+ * presence of a `baseApiConfig` / `swapsApiConfig` slice.
31
+ */
32
+ export type CustomApiConfig = {
33
+ baseApiConfig: BaseApiConfig;
34
+ swapsApiConfig?: SwapsApiConfig;
35
+ } | {
36
+ baseApiConfig?: BaseApiConfig;
37
+ swapsApiConfig: SwapsApiConfig;
38
+ };
39
+ export type ApiConfig = BaseApiConfig | CustomApiConfig;
23
40
  export declare const apiConfig: {
24
41
  baseURL: "https://api.sodax.com/v1/be";
25
42
  timeout: number;
package/dist/index.d.ts CHANGED
@@ -19,4 +19,4 @@ export * from './sui/index.js';
19
19
  export * from './swap/index.js';
20
20
  export * from './utils/index.js';
21
21
  export * from './wallet/index.js';
22
- export declare const CONFIG_VERSION = 215;
22
+ export declare const CONFIG_VERSION = 217;
package/dist/index.js CHANGED
@@ -19,4 +19,4 @@ export * from './sui/index.js';
19
19
  export * from './swap/index.js';
20
20
  export * from './utils/index.js';
21
21
  export * from './wallet/index.js';
22
- export const CONFIG_VERSION = 215; // this value should be incremented (inside release/sdk branch) each time @sodax/types package is updated
22
+ export const CONFIG_VERSION = 217; // this value should be incremented (inside release/sdk branch) each time @sodax/types package is updated
@@ -0,0 +1,119 @@
1
+ import type { SodaxFeature } from './features.js';
2
+ /**
3
+ * Analytics for the SDK — structured, opt-in tracking of user-action flows.
4
+ *
5
+ * This is deliberately separate from {@link SodaxLogger}. The logger is a developer-facing
6
+ * diagnostics sink that is **on by default** (`console`) and takes free-form messages. Analytics
7
+ * is a product-facing event stream that is **off by default**: the SDK emits nothing — and never
8
+ * even builds an event payload — unless a consumer explicitly enables it via
9
+ * `new Sodax({ analytics })`. This keeps feature code paths free of analytics overhead when it is
10
+ * not in use.
11
+ *
12
+ * Enable and shape it through {@link AnalyticsOption} on the `Sodax` constructor:
13
+ * - omitted / `false` — disabled (default).
14
+ * - an {@link AnalyticsConfig} — forward events to your own product-analytics backend, optionally
15
+ * scoped by feature and detail level.
16
+ */
17
+ /**
18
+ * Lifecycle phase of a tracked feature action flow. Every event marks where in a feature's action
19
+ * flow it was emitted, so a sink can pair a `start` with its terminal `success` / `failure`
20
+ * (e.g. to measure duration or drop-off).
21
+ */
22
+ export type AnalyticsEventPhase = 'start' | 'success' | 'failure';
23
+ /**
24
+ * Detail level an event belongs to. Consumers choose how much the SDK tracks:
25
+ * - `basic` — coarse action flow (feature, action, phase) only.
26
+ * - `detailed` — adds richer `data` payloads (amounts, tokens, chain keys, …).
27
+ *
28
+ * The SDK only builds and emits a `detailed` event when the configured level is `detailed`, so
29
+ * heavier payloads are never constructed when a consumer stays on `basic`.
30
+ */
31
+ export type AnalyticsDetailLevel = 'basic' | 'detailed';
32
+ /**
33
+ * A single user-action analytics event emitted by the SDK at a feature action-flow boundary.
34
+ *
35
+ * `feature` + `action` + `phase` form the stable identity of an event — the same `(feature,
36
+ * action)` tagging the error layer already standardizes — so events line up with errors in a
37
+ * downstream sink. `data` is an optional structured payload whose richness depends on the
38
+ * configured {@link AnalyticsDetailLevel}.
39
+ */
40
+ export interface AnalyticsEvent {
41
+ /** The high-level feature the action belongs to. */
42
+ feature: SodaxFeature;
43
+ /** The feature-level operation in flight, e.g. `'supply'`, `'createIntent'`, `'stake'`. */
44
+ action: string;
45
+ /** Where in the action flow this event was emitted. */
46
+ phase: AnalyticsEventPhase;
47
+ /** The detail level this event belongs to; gated against the configured level. */
48
+ level: AnalyticsDetailLevel;
49
+ /** Optional structured payload. Present mainly on `detailed` events. */
50
+ data?: Record<string, unknown>;
51
+ }
52
+ /**
53
+ * Consumer-supplied tracker: the SDK calls it once per emitted event, and the consumer forwards the
54
+ * event to their product-analytics backend (Segment, Amplitude, PostHog, a custom collector, …),
55
+ * e.g. `tracker: (event) => amplitude.track(event.action, event.data)`.
56
+ *
57
+ * It must be cheap and non-throwing — the SDK treats it as fire-and-forget, does not await it, and
58
+ * swallows any error it throws so analytics can never break a feature flow.
59
+ */
60
+ export type AnalyticsTracker = (event: AnalyticsEvent) => void;
61
+ /**
62
+ * How much of one feature to track, in the {@link AnalyticsConfig.features} allowlist:
63
+ * - `true` — every action of the feature.
64
+ * - `{ actions }` — only the named actions (e.g. `{ actions: ['supply', 'borrow'] }`).
65
+ */
66
+ export type AnalyticsFeatureScope = true | {
67
+ actions: readonly string[];
68
+ };
69
+ /**
70
+ * The set of features (and actions) to track — an **allowlist**. Two equivalent forms:
71
+ * - Object: per-feature {@link AnalyticsFeatureScope}. A feature **omitted from the object is OFF**.
72
+ * `{ swap: true, moneyMarket: { actions: ['supply'] } }`.
73
+ * - Array shorthand: a list of features, each fully tracked. `['swap', 'moneyMarket']`.
74
+ *
75
+ * Omitting {@link AnalyticsConfig.features} entirely tracks **everything** (all features, all
76
+ * actions) — scoping is opt-in.
77
+ */
78
+ export type AnalyticsFeatures = Partial<Record<SodaxFeature, AnalyticsFeatureScope>> | readonly SodaxFeature[];
79
+ /**
80
+ * Analytics configuration passed to `new Sodax({ analytics })`.
81
+ *
82
+ * Providing this object is what turns analytics on; the {@link AnalyticsTracker} `tracker` is the
83
+ * only required field. `level` and `features` narrow what gets emitted so consumers track only what
84
+ * they care about — by detail level and by feature/action.
85
+ *
86
+ * @example
87
+ * new Sodax({
88
+ * analytics: {
89
+ * tracker: (event) => amplitude.track(event.action, event.data),
90
+ * features: {
91
+ * swap: true, // all swap actions
92
+ * moneyMarket: { actions: ['supply', 'borrow'] }, // only these
93
+ * // staking omitted → OFF
94
+ * }, // or simple form: features: ['swap', 'moneyMarket']
95
+ * },
96
+ * });
97
+ */
98
+ export interface AnalyticsConfig {
99
+ /** Where events are delivered. Required — enabling analytics means supplying a tracker. */
100
+ tracker: AnalyticsTracker;
101
+ /**
102
+ * Highest detail level to emit. Defaults to `'basic'`. Events tagged `'detailed'` are only built
103
+ * and delivered when this is `'detailed'`.
104
+ */
105
+ level?: AnalyticsDetailLevel;
106
+ /**
107
+ * Allowlist of features/actions to track. Omit to track everything; otherwise only the listed
108
+ * features (and, with `{ actions }`, only the listed actions) emit. See {@link AnalyticsFeatures}.
109
+ */
110
+ features?: AnalyticsFeatures;
111
+ }
112
+ /**
113
+ * The `analytics` option accepted by `new Sodax(...)`. Either a full {@link AnalyticsConfig} or
114
+ * `false` (the default — analytics disabled).
115
+ *
116
+ * Like `logger`, this is a client-side runtime option resolved once by the SDK; it is never
117
+ * fetched from or overwritten by the backend config.
118
+ */
119
+ export type AnalyticsOption = AnalyticsConfig | false;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The set of high-level SODAX SDK features.
3
+ *
4
+ * Used as a first-class tag across cross-cutting concerns — error reporting
5
+ * (`SodaxError.feature` in `@sodax/sdk`) and analytics ({@link AnalyticsEvent.feature} and
6
+ * per-feature analytics toggles). It lives in `@sodax/types`, the lowest layer, so every package
7
+ * shares one source of truth instead of redefining the list; `@sodax/sdk` re-exports it.
8
+ */
9
+ export type SodaxFeature = 'swap' | 'moneyMarket' | 'bridge' | 'staking' | 'migration' | 'dex' | 'partner' | 'recovery' | 'backend' | 'leverageYield';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,4 @@
1
1
  export * from './shared.js';
2
2
  export * from './logger.js';
3
+ export * from './features.js';
4
+ export * from './analytics.js';
@@ -1,2 +1,4 @@
1
1
  export * from './shared.js';
2
2
  export * from './logger.js';
3
+ export * from './features.js';
4
+ export * from './analytics.js';
@@ -1,5 +1,6 @@
1
1
  import type { TxPollingConfig } from '../shared/shared.js';
2
2
  import type { SodaxLoggerOption } from '../shared/logger.js';
3
+ import type { AnalyticsOption } from '../shared/analytics.js';
3
4
  import type { DeepPartial } from '../utils/deep-partial.js';
4
5
  import { type ApiConfig, type SolverConfig, type RelayConfig } from '../common/constants.js';
5
6
  import type { MoneyMarketDefaultConfig, MoneyMarketOptions, PartnerFee, Prettify } from '../common/common.js';
@@ -35,11 +36,13 @@ export type BridgeDefaultConfig = {};
35
36
  export declare const bridgeConfig: {};
36
37
  export type SodaxOptionalConfig = {
37
38
  logger?: SodaxLoggerOption;
39
+ analytics?: AnalyticsOption;
38
40
  fee?: PartnerFee;
39
41
  swaps?: SwapsOptions;
40
42
  moneyMarket?: MoneyMarketOptions;
41
43
  bridge?: BridgeOptions;
42
44
  leverageYield?: LeverageYieldOptions;
45
+ swapsOptions?: SwapsClientOptions;
43
46
  };
44
47
  /**
45
48
  * Options (always optional) accepted by `new Sodax(...)`. A deep-partial override of the {@link SodaxDefaultConfig} data
@@ -68,8 +71,17 @@ export type SodaxDefaultConfig = {
68
71
  relay: RelayConfig;
69
72
  };
70
73
  /**
71
- * Sodax default static data object which can always be overriden through Sodax instance (i.e. new Sodax(...config))
74
+ * Client-side swap behavior options. Like {@link SodaxOptionalConfig.logger}, these are runtime toggles
75
+ * resolved once at construction — NOT part of the backend-fetched {@link SodaxDefaultConfig} data.
72
76
  */
77
+ export type SwapsClientOptions = {
78
+ /**
79
+ * Opt-in: route `swap()` through the backend submit-tx 2-step flow (the backend relays +
80
+ * post-executes server-side). On ANY non-success the SDK falls back to the client-side relay so
81
+ * the swap still completes. Default `false` (the current fully client-side flow).
82
+ */
83
+ useBackendSubmitTx?: boolean;
84
+ };
73
85
  export declare const sodaxConfig: {
74
86
  chains: {
75
87
  readonly sonic: {
@@ -5,9 +5,7 @@ import { swapsConfig } from '../swap/swap.js';
5
5
  import { leverageYieldConfig, } from '../leverageYield/leverageYield.js';
6
6
  import { spokeChainConfig, hubConfig, } from '../chains/chains.js';
7
7
  export const bridgeConfig = {};
8
- /**
9
- * Sodax default static data object which can always be overriden through Sodax instance (i.e. new Sodax(...config))
10
- */
8
+ // default sodax config object which can always be overriden through Sodax instance (i.e. new Sodax(...config))
11
9
  export const sodaxConfig = {
12
10
  chains: spokeChainConfig,
13
11
  swaps: swapsConfig,
@@ -100,6 +100,8 @@ export interface ISolanaWalletProvider extends ICoreWallet {
100
100
  readonly chainType: 'SOLANA';
101
101
  getWalletAddress: () => Promise<string>;
102
102
  sendTransaction: (rawTransaction: Uint8Array | Array<number>) => Promise<TransactionSignature>;
103
+ /** Deserialize, sign, and broadcast an unsigned `SolanaRawTransaction` (e.g. from the Swaps API). */
104
+ signAndSendTransaction?: (params: SolanaRawTransaction) => Promise<TransactionSignature>;
103
105
  waitForConfirmation: (signature: TransactionSignature, commitment: Commitment) => Promise<SolanaRpcResponseAndContext<SolanaSignatureResult>>;
104
106
  buildV0Txn: (instructions: SolanaRawTransactionInstruction[]) => Promise<SolanaSerializedTransaction>;
105
107
  getWalletBase58PublicKey: () => SolanaBase58PublicKey;
@@ -207,4 +207,6 @@ export interface IStacksWalletProvider extends ICoreWallet {
207
207
  getPublicKey: () => Promise<string>;
208
208
  getBalance: (address: string) => Promise<bigint>;
209
209
  sendTransaction: (txParams: StacksTransactionParams) => Promise<string>;
210
+ /** Sign and broadcast an unsigned `StacksRawTransaction` (e.g. from the Swaps API). Returns the tx id. */
211
+ signAndSendTransaction?: (params: StacksRawTransaction) => Promise<string>;
210
212
  }
@@ -92,5 +92,9 @@ export interface IStellarWalletProvider extends ICoreWallet {
92
92
  readonly chainType: 'STELLAR';
93
93
  signTransaction: (tx: XDR) => Promise<XDR>;
94
94
  waitForTransactionReceipt: (txHash: string) => Promise<StellarRawTransactionReceipt>;
95
+ /** Broadcast an already-signed XDR transaction via the Soroban RPC server. Returns the tx hash. */
96
+ sendTransaction?: (signedTx: XDR) => Promise<string>;
97
+ /** Sign and broadcast an unsigned `StellarRawTransaction` (e.g. from the Swaps API). Returns the tx hash. */
98
+ signAndSendTransaction?: (params: StellarRawTransaction) => Promise<string>;
95
99
  }
96
100
  export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "2.0.0-rc.17",
7
+ "version": "2.0.0-rc.19",
8
8
  "description": "Sodax Common Types",
9
9
  "main": "dist/index.js",
10
10
  "homepage": "https://github.com/icon-project/sodax-sdks/tree/main/packages/types",
@@ -1,74 +0,0 @@
1
- import type { SpokeChainKey, IntentRelayChainIdMap } from '../chains/chains.js';
2
- import type { XToken } from '../chains/tokens.js';
3
- import type { Result, SpokeChainConfigMap } from '../common/common.js';
4
- import type { Address } from '../shared/shared.js';
5
- import type { SodaxConfig } from '../sodax-config/sodax-config.js';
6
- export type GetChainsApiResponse = readonly SpokeChainKey[];
7
- export type GetSwapTokensApiResponse = Record<SpokeChainKey, readonly XToken[]>;
8
- export type GetSwapTokensByChainIdApiResponse = readonly XToken[];
9
- export type GetMoneyMarketTokensApiResponse = Record<SpokeChainKey, readonly XToken[]>;
10
- export type GetMoneyMarketTokensByChainIdApiResponse = readonly XToken[];
11
- export type GetRelayChainIdMapApiResponse = IntentRelayChainIdMap;
12
- export type GetSpokeChainConfigApiResponse = SpokeChainConfigMap;
13
- export type GetMoneyMarketReserveAssetsApiResponse = readonly Address[];
14
- export type GetAllConfigApiResponse = {
15
- version?: number;
16
- config: SodaxConfig;
17
- };
18
- export interface IConfigApi {
19
- getChains(): Promise<Result<GetChainsApiResponse>>;
20
- getSwapTokens(): Promise<Result<GetSwapTokensApiResponse>>;
21
- getSwapTokensByChainId(chainId: SpokeChainKey): Promise<Result<GetSwapTokensByChainIdApiResponse>>;
22
- getMoneyMarketTokens(): Promise<Result<GetMoneyMarketTokensApiResponse>>;
23
- getMoneyMarketTokensByChainId(chainId: SpokeChainKey): Promise<Result<GetMoneyMarketTokensByChainIdApiResponse>>;
24
- }
25
- export interface SwapIntentData {
26
- intentId: string;
27
- creator: string;
28
- inputToken: string;
29
- outputToken: string;
30
- inputAmount: string;
31
- minOutputAmount: string;
32
- deadline: string;
33
- allowPartialFill: boolean;
34
- srcChain: number;
35
- dstChain: number;
36
- srcAddress: string;
37
- dstAddress: string;
38
- solver: string;
39
- data: string;
40
- }
41
- export interface SubmitSwapTxRequest {
42
- txHash: string;
43
- srcChainKey: string;
44
- walletAddress: string;
45
- intent: SwapIntentData;
46
- relayData: string;
47
- }
48
- export interface SubmitSwapTxResponse {
49
- success: boolean;
50
- message: string;
51
- }
52
- export interface GetSubmitSwapTxStatusParams {
53
- txHash: string;
54
- srcChainKey?: string;
55
- }
56
- export interface SubmitSwapTxStatusResult {
57
- dstIntentTxHash: string;
58
- packetData?: Record<string, unknown>;
59
- intent_hash?: string;
60
- }
61
- export type SubmitSwapTxStatus = 'pending' | 'verifying' | 'verified' | 'relaying' | 'relayed' | 'posting_execution' | 'executed' | 'failed';
62
- export interface SubmitSwapTxStatusData {
63
- txHash: string;
64
- srcChainKey: string;
65
- status: SubmitSwapTxStatus;
66
- failedAtStep?: string;
67
- failureReason?: string;
68
- failedAttempts: number;
69
- result?: SubmitSwapTxStatusResult;
70
- }
71
- export interface SubmitSwapTxStatusResponse {
72
- success: boolean;
73
- data: SubmitSwapTxStatusData;
74
- }
File without changes