@sodax/types 2.0.0-rc.2 → 2.0.0-rc.21
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 +4 -2
- package/dist/backend/backendApiV1.d.ts +28 -0
- package/dist/backend/backendApiV1.js +1 -0
- package/dist/backend/backendApiV2.d.ts +678 -0
- package/dist/backend/backendApiV2.js +38 -0
- package/dist/backend/index.d.ts +2 -2
- package/dist/backend/index.js +2 -2
- package/dist/bitcoin/bitcoin.d.ts +18 -1
- package/dist/bitcoin/bitcoin.js +13 -1
- package/dist/bitcoin/index.d.ts +0 -1
- package/dist/bitcoin/index.js +0 -1
- package/dist/chains/chain-keys.d.ts +3 -3
- package/dist/chains/chain-keys.js +1 -1
- package/dist/chains/chains.d.ts +390 -13
- package/dist/chains/chains.js +76 -5
- package/dist/chains/index.d.ts +0 -1
- package/dist/chains/index.js +0 -1
- package/dist/chains/tokens.d.ts +530 -7
- package/dist/chains/tokens.js +241 -3
- package/dist/common/common.d.ts +15 -8
- package/dist/common/common.js +0 -1
- package/dist/common/constants.d.ts +19 -2
- package/dist/common/constants.js +0 -1
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.js +0 -1
- package/dist/dex/dex.d.ts +4 -2
- package/dist/dex/dex.js +0 -1
- package/dist/dex/index.d.ts +0 -1
- package/dist/dex/index.js +0 -1
- package/dist/dex/pancakeswap-infinity.d.ts +0 -1
- package/dist/dex/pancakeswap-infinity.js +0 -1
- package/dist/evm/evm.d.ts +0 -1
- package/dist/evm/evm.js +0 -1
- package/dist/evm/index.d.ts +0 -1
- package/dist/evm/index.js +0 -1
- package/dist/hooks/hooks.d.ts +42 -0
- package/dist/hooks/hooks.js +44 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/icon/icon.d.ts +0 -1
- package/dist/icon/icon.js +0 -1
- package/dist/icon/index.d.ts +0 -1
- package/dist/icon/index.js +0 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/injective/index.d.ts +0 -1
- package/dist/injective/index.js +0 -1
- package/dist/injective/injective.d.ts +4 -1
- package/dist/injective/injective.js +0 -1
- package/dist/leverageYield/index.d.ts +1 -0
- package/dist/leverageYield/index.js +1 -0
- package/dist/leverageYield/leverageYield.d.ts +152 -0
- package/dist/leverageYield/leverageYield.js +51 -0
- package/dist/moneyMarket/index.d.ts +0 -1
- package/dist/moneyMarket/index.js +0 -1
- package/dist/moneyMarket/moneyMarket.d.ts +270 -5
- package/dist/moneyMarket/moneyMarket.js +15 -1
- package/dist/near/index.d.ts +0 -1
- package/dist/near/index.js +0 -1
- package/dist/near/near-api-js.d.ts +0 -1
- package/dist/near/near-api-js.js +0 -1
- package/dist/near/near.d.ts +5 -2
- package/dist/near/near.js +0 -1
- package/dist/shared/analytics.d.ts +119 -0
- package/dist/shared/analytics.js +1 -0
- package/dist/shared/features.d.ts +9 -0
- package/dist/shared/features.js +1 -0
- package/dist/shared/index.d.ts +3 -1
- package/dist/shared/index.js +3 -1
- package/dist/shared/logger.d.ts +27 -0
- package/dist/shared/logger.js +1 -0
- package/dist/shared/shared.d.ts +21 -1
- package/dist/shared/shared.js +0 -1
- package/dist/sodax-config/index.d.ts +0 -1
- package/dist/sodax-config/index.js +0 -1
- package/dist/sodax-config/sodax-config.d.ts +729 -77
- package/dist/sodax-config/sodax-config.js +3 -5
- package/dist/solana/index.d.ts +0 -1
- package/dist/solana/index.js +0 -1
- package/dist/solana/solana-web3.d.ts +0 -1
- package/dist/solana/solana-web3.js +0 -1
- package/dist/solana/solana.d.ts +2 -1
- package/dist/solana/solana.js +0 -1
- package/dist/stacks/index.d.ts +0 -1
- package/dist/stacks/index.js +0 -1
- package/dist/stacks/stacks.d.ts +2 -1
- package/dist/stacks/stacks.js +0 -1
- package/dist/stellar/index.d.ts +0 -1
- package/dist/stellar/index.js +0 -1
- package/dist/stellar/stellar.d.ts +4 -1
- package/dist/stellar/stellar.js +0 -1
- package/dist/sui/index.d.ts +0 -1
- package/dist/sui/index.js +0 -1
- package/dist/sui/sui.d.ts +3 -3
- package/dist/sui/sui.js +0 -1
- package/dist/swap/index.d.ts +0 -1
- package/dist/swap/index.js +0 -1
- package/dist/swap/swap.d.ts +466 -107
- package/dist/swap/swap.js +75 -14
- package/dist/utils/deep-partial.d.ts +0 -1
- package/dist/utils/deep-partial.js +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/utils.d.ts +0 -1
- package/dist/utils/utils.js +0 -1
- package/dist/wallet/index.d.ts +0 -1
- package/dist/wallet/index.js +0 -1
- package/dist/wallet/providers.d.ts +0 -1
- package/dist/wallet/providers.js +0 -1
- package/dist/wallet/wallet.d.ts +0 -1
- package/dist/wallet/wallet.js +0 -1
- package/package.json +28 -11
- package/dist/backend/backendApi.d.ts +0 -75
- package/dist/backend/backendApi.d.ts.map +0 -1
- package/dist/backend/backendApi.js +0 -2
- package/dist/backend/backendApi.js.map +0 -1
- package/dist/backend/index.d.ts.map +0 -1
- package/dist/backend/index.js.map +0 -1
- package/dist/bitcoin/bitcoin.d.ts.map +0 -1
- package/dist/bitcoin/bitcoin.js.map +0 -1
- package/dist/bitcoin/index.d.ts.map +0 -1
- package/dist/bitcoin/index.js.map +0 -1
- package/dist/chains/chain-keys.d.ts.map +0 -1
- package/dist/chains/chain-keys.js.map +0 -1
- package/dist/chains/chains.d.ts.map +0 -1
- package/dist/chains/chains.js.map +0 -1
- package/dist/chains/index.d.ts.map +0 -1
- package/dist/chains/index.js.map +0 -1
- package/dist/chains/tokens.d.ts.map +0 -1
- package/dist/chains/tokens.js.map +0 -1
- package/dist/common/common.d.ts.map +0 -1
- package/dist/common/common.js.map +0 -1
- package/dist/common/constants.d.ts.map +0 -1
- package/dist/common/constants.js.map +0 -1
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js.map +0 -1
- package/dist/dex/dex.d.ts.map +0 -1
- package/dist/dex/dex.js.map +0 -1
- package/dist/dex/index.d.ts.map +0 -1
- package/dist/dex/index.js.map +0 -1
- package/dist/dex/pancakeswap-infinity.d.ts.map +0 -1
- package/dist/dex/pancakeswap-infinity.js.map +0 -1
- package/dist/evm/evm.d.ts.map +0 -1
- package/dist/evm/evm.js.map +0 -1
- package/dist/evm/index.d.ts.map +0 -1
- package/dist/evm/index.js.map +0 -1
- package/dist/icon/icon.d.ts.map +0 -1
- package/dist/icon/icon.js.map +0 -1
- package/dist/icon/index.d.ts.map +0 -1
- package/dist/icon/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/injective/index.d.ts.map +0 -1
- package/dist/injective/index.js.map +0 -1
- package/dist/injective/injective.d.ts.map +0 -1
- package/dist/injective/injective.js.map +0 -1
- package/dist/moneyMarket/index.d.ts.map +0 -1
- package/dist/moneyMarket/index.js.map +0 -1
- package/dist/moneyMarket/moneyMarket.d.ts.map +0 -1
- package/dist/moneyMarket/moneyMarket.js.map +0 -1
- package/dist/near/index.d.ts.map +0 -1
- package/dist/near/index.js.map +0 -1
- package/dist/near/near-api-js.d.ts.map +0 -1
- package/dist/near/near-api-js.js.map +0 -1
- package/dist/near/near.d.ts.map +0 -1
- package/dist/near/near.js.map +0 -1
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/index.js.map +0 -1
- package/dist/shared/shared.d.ts.map +0 -1
- package/dist/shared/shared.js.map +0 -1
- package/dist/sodax-config/index.d.ts.map +0 -1
- package/dist/sodax-config/index.js.map +0 -1
- package/dist/sodax-config/sodax-config.d.ts.map +0 -1
- package/dist/sodax-config/sodax-config.js.map +0 -1
- package/dist/solana/index.d.ts.map +0 -1
- package/dist/solana/index.js.map +0 -1
- package/dist/solana/solana-web3.d.ts.map +0 -1
- package/dist/solana/solana-web3.js.map +0 -1
- package/dist/solana/solana.d.ts.map +0 -1
- package/dist/solana/solana.js.map +0 -1
- package/dist/stacks/index.d.ts.map +0 -1
- package/dist/stacks/index.js.map +0 -1
- package/dist/stacks/stacks.d.ts.map +0 -1
- package/dist/stacks/stacks.js.map +0 -1
- package/dist/stellar/index.d.ts.map +0 -1
- package/dist/stellar/index.js.map +0 -1
- package/dist/stellar/stellar.d.ts.map +0 -1
- package/dist/stellar/stellar.js.map +0 -1
- package/dist/sui/index.d.ts.map +0 -1
- package/dist/sui/index.js.map +0 -1
- package/dist/sui/sui.d.ts.map +0 -1
- package/dist/sui/sui.js.map +0 -1
- package/dist/swap/index.d.ts.map +0 -1
- package/dist/swap/index.js.map +0 -1
- package/dist/swap/swap.d.ts.map +0 -1
- package/dist/swap/swap.js.map +0 -1
- package/dist/utils/deep-partial.d.ts.map +0 -1
- package/dist/utils/deep-partial.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/dist/wallet/index.d.ts.map +0 -1
- package/dist/wallet/index.js.map +0 -1
- package/dist/wallet/providers.d.ts.map +0 -1
- package/dist/wallet/providers.js.map +0 -1
- package/dist/wallet/wallet.d.ts.map +0 -1
- package/dist/wallet/wallet.js.map +0 -1
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import type { SpokeChainConfig } from '../chains/chains.js';
|
|
2
|
+
import type { XToken } from '../chains/tokens.js';
|
|
3
|
+
import type { RelayConfig } from '../common/constants.js';
|
|
4
|
+
import type { ConcentratedLiquidityConfig, DexDefaultConfig } from '../dex/dex.js';
|
|
5
|
+
import type { SodaxDefaultConfig } from '../sodax-config/sodax-config.js';
|
|
6
|
+
import type { RawTxReturnType } from '../common/index.js';
|
|
7
|
+
/** Quote direction. Only exact-input quoting is supported. */
|
|
8
|
+
export type QuoteTypeV2 = 'exact_input';
|
|
9
|
+
/**
|
|
10
|
+
* JSON-safe partner fee for swap requests. Wire mirror of the SDK `PartnerFee` union, with the
|
|
11
|
+
* bigint `amount` projected to a decimal `string`. `address` is the EVM hub fee receiver; provide
|
|
12
|
+
* either a fixed `amount` (input token's smallest unit, decimal string) or a `percentage` (basis
|
|
13
|
+
* points, e.g. 100 = 1%). If both are present the backend uses `amount`, matching the SDK.
|
|
14
|
+
*/
|
|
15
|
+
export type PartnerFeeV2 = {
|
|
16
|
+
address: string;
|
|
17
|
+
amount: string;
|
|
18
|
+
} | {
|
|
19
|
+
address: string;
|
|
20
|
+
percentage: number;
|
|
21
|
+
};
|
|
22
|
+
/** JSON-safe mirror of the SDK `BitcoinBoundExtras` — Bound Exchange (Radfi) inputs for raw Bitcoin TRADING-mode intents. */
|
|
23
|
+
export interface BitcoinBoundExtrasV2 {
|
|
24
|
+
/**
|
|
25
|
+
* Bound Exchange (Radfi) access token; threads through the typed DTO instead of an
|
|
26
|
+
* `x-bound-access-token` header. Only consumed for raw Bitcoin TRADING-mode intents.
|
|
27
|
+
*/
|
|
28
|
+
accessToken?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* JSON-safe mirror of the SDK `SwapExtras<K>` — per-request swap extras flattened onto a request body.
|
|
32
|
+
* All fields are optional; chain applicability is documented per field (the wire DTO can't `K`-gate the
|
|
33
|
+
* way the SDK type does). Shared by {@link CreateIntentParamsV2} and {@link QuoteRequestV2}.
|
|
34
|
+
*/
|
|
35
|
+
export interface SwapExtrasV2 {
|
|
36
|
+
/**
|
|
37
|
+
* Per-request partner-fee override; defaults to the backend's configured fee. Keeps the fee-adjusted
|
|
38
|
+
* quote and the built intent consistent with `createIntent`.
|
|
39
|
+
*/
|
|
40
|
+
partnerFee?: PartnerFeeV2;
|
|
41
|
+
/**
|
|
42
|
+
* Source-chain signer public key (compressed hex), for chains whose address can't yield it (e.g.
|
|
43
|
+
* Stacks). Only used when building a raw intent.
|
|
44
|
+
*/
|
|
45
|
+
srcPublicKey?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Bitcoin Bound (Radfi) inputs, grouped so future Bound fields extend one slot instead of adding a
|
|
48
|
+
* top-level field per item. Only used for raw Bitcoin TRADING-mode intents.
|
|
49
|
+
*/
|
|
50
|
+
bound?: BitcoinBoundExtrasV2;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Solver intent status code:
|
|
54
|
+
* -1 NOT_FOUND, 1 NOT_STARTED_YET, 2 STARTED_NOT_FINISHED, 3 SOLVED (terminal), 4 FAILED (terminal).
|
|
55
|
+
*/
|
|
56
|
+
export type SwapIntentStatusCodeV2 = -1 | 1 | 2 | 3 | 4;
|
|
57
|
+
/** A supported swap token descriptor (`XToken` projected to JSON primitives). */
|
|
58
|
+
export interface SwapTokenV2 {
|
|
59
|
+
/** Token symbol (e.g. `USDC`). */
|
|
60
|
+
symbol: string;
|
|
61
|
+
/** Token name (e.g. `USD Coin`). */
|
|
62
|
+
name: string;
|
|
63
|
+
/** Token decimals. */
|
|
64
|
+
decimals: number;
|
|
65
|
+
/** Token address on its spoke chain (or hub address for hub tokens). */
|
|
66
|
+
address: string;
|
|
67
|
+
/** SODAX SpokeChainKey identifier (e.g. `0xa4b1.arbitrum`, `solana`). */
|
|
68
|
+
chainKey: string;
|
|
69
|
+
/** Corresponding hub-side asset address on Sonic. */
|
|
70
|
+
hubAsset: string;
|
|
71
|
+
/** Hub vault address that custodies bridged liquidity for this token. */
|
|
72
|
+
vault: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Intent struct (hub representation) the client SENDS in request bodies
|
|
76
|
+
* (`/swaps/intents/cancel`, `/swaps/intents/hash`, `/swaps/intents/extra-data`,
|
|
77
|
+
* `/swaps/submit-tx`). Mirrors the backend `IntentDto`: the numeric fields are
|
|
78
|
+
* `bigint`; the transport serializes them to decimal strings on the wire.
|
|
79
|
+
*
|
|
80
|
+
* Differs from {@link IntentResponseV2} (the server-returned variant), whose
|
|
81
|
+
* numeric fields are decimal `string` because outbound JSON cannot carry bigint.
|
|
82
|
+
*/
|
|
83
|
+
export interface IntentRequestV2 {
|
|
84
|
+
/** Intent ID. */
|
|
85
|
+
intentId: bigint;
|
|
86
|
+
/** Creator address. */
|
|
87
|
+
creator: string;
|
|
88
|
+
/** Input token address (hub asset). */
|
|
89
|
+
inputToken: string;
|
|
90
|
+
/** Output token address (hub asset). */
|
|
91
|
+
outputToken: string;
|
|
92
|
+
/** Input amount in smallest unit. */
|
|
93
|
+
inputAmount: bigint;
|
|
94
|
+
/** Minimum acceptable output amount in smallest unit. */
|
|
95
|
+
minOutputAmount: bigint;
|
|
96
|
+
/** Unix timestamp (seconds) when the intent expires; `0n` for no expiry. */
|
|
97
|
+
deadline: bigint;
|
|
98
|
+
/** Whether partial fills are allowed. */
|
|
99
|
+
allowPartialFill: boolean;
|
|
100
|
+
/** Source intent-relay chain id (e.g. `146n` for Sonic). */
|
|
101
|
+
srcChain: bigint;
|
|
102
|
+
/** Destination intent-relay chain id. */
|
|
103
|
+
dstChain: bigint;
|
|
104
|
+
/** Source address (hex). */
|
|
105
|
+
srcAddress: string;
|
|
106
|
+
/** Destination address (hex). */
|
|
107
|
+
dstAddress: string;
|
|
108
|
+
/** Solver address; the zero address means "any solver". */
|
|
109
|
+
solver: string;
|
|
110
|
+
/** Arbitrary intent calldata (hex). */
|
|
111
|
+
data: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Intent struct (hub representation) the server RETURNS in responses
|
|
115
|
+
* (`POST /swaps/intents`, `GET /swaps/intents/:txHash`). Pure JSON: all
|
|
116
|
+
* bigint-derived fields are decimal strings (outbound JSON cannot carry bigint).
|
|
117
|
+
*
|
|
118
|
+
* Differs from {@link IntentRequestV2} (the client-sent variant), whose numeric
|
|
119
|
+
* fields are `bigint`.
|
|
120
|
+
*/
|
|
121
|
+
export interface IntentResponseV2 {
|
|
122
|
+
/** Intent ID (decimal string). */
|
|
123
|
+
intentId: string;
|
|
124
|
+
/** Creator address. */
|
|
125
|
+
creator: string;
|
|
126
|
+
/** Input token address (hub asset). */
|
|
127
|
+
inputToken: string;
|
|
128
|
+
/** Output token address (hub asset). */
|
|
129
|
+
outputToken: string;
|
|
130
|
+
/** Input amount in smallest unit (decimal string). */
|
|
131
|
+
inputAmount: string;
|
|
132
|
+
/** Minimum acceptable output amount in smallest unit (decimal string). */
|
|
133
|
+
minOutputAmount: string;
|
|
134
|
+
/** Unix timestamp (seconds) when the intent expires; `"0"` for no expiry (decimal string). */
|
|
135
|
+
deadline: string;
|
|
136
|
+
/** Whether partial fills are allowed. */
|
|
137
|
+
allowPartialFill: boolean;
|
|
138
|
+
/** Source intent-relay chain id (decimal string, e.g. `"146"`). */
|
|
139
|
+
srcChain: string;
|
|
140
|
+
/** Destination intent-relay chain id (decimal string). */
|
|
141
|
+
dstChain: string;
|
|
142
|
+
/** Source address (hex). */
|
|
143
|
+
srcAddress: string;
|
|
144
|
+
/** Destination address (hex). */
|
|
145
|
+
dstAddress: string;
|
|
146
|
+
/** Solver address; the zero address means "any solver". */
|
|
147
|
+
solver: string;
|
|
148
|
+
/** Arbitrary intent calldata (hex). */
|
|
149
|
+
data: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Relay payload the client SENDS to `POST /swaps/intents/submit` (required for
|
|
153
|
+
* Solana / Bitcoin sources). Identical wire shape to {@link RelayExtraDataResponseV2}.
|
|
154
|
+
*/
|
|
155
|
+
export interface RelayExtraDataRequestV2 {
|
|
156
|
+
/** Relay payload address (hex). */
|
|
157
|
+
address: string;
|
|
158
|
+
/** Relay payload (hex). */
|
|
159
|
+
payload: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Relay payload the server RETURNS from `POST /swaps/intents` (`relayData`) and
|
|
163
|
+
* `POST /swaps/intents/extra-data`. Identical wire shape to {@link RelayExtraDataRequestV2}.
|
|
164
|
+
*/
|
|
165
|
+
export interface RelayExtraDataResponseV2 {
|
|
166
|
+
/** Relay payload address (hex). */
|
|
167
|
+
address: string;
|
|
168
|
+
/** Relay payload (hex). */
|
|
169
|
+
payload: string;
|
|
170
|
+
}
|
|
171
|
+
/** GET /swaps/tokens — map of SpokeChainKey → supported swap tokens. */
|
|
172
|
+
export type GetSwapTokensResponseV2 = Record<string, readonly SwapTokenV2[]>;
|
|
173
|
+
/** GET /swaps/tokens/:chainKey — supported swap tokens for a single chain. */
|
|
174
|
+
export type GetSwapTokensByChainResponseV2 = readonly SwapTokenV2[];
|
|
175
|
+
/**
|
|
176
|
+
* POST /swaps/quote — request body. Inherits the swap extras (`partnerFee`, `srcPublicKey`, `bound`) from
|
|
177
|
+
* {@link SwapExtrasV2}; the inherited `srcPublicKey`/`bound` are consumed only by the `includeTxData=true`
|
|
178
|
+
* intent-building path (Stacks/Bitcoin sources), mirroring `srcAddress`/`dstAddress` below.
|
|
179
|
+
*/
|
|
180
|
+
export interface QuoteRequestV2 extends SwapExtrasV2 {
|
|
181
|
+
/** Source token address on the source spoke chain. */
|
|
182
|
+
tokenSrc: string;
|
|
183
|
+
/** Source spoke chain key (SODAX SpokeChainKey). */
|
|
184
|
+
tokenSrcChainKey: string;
|
|
185
|
+
/** Destination token address on the destination spoke chain. */
|
|
186
|
+
tokenDst: string;
|
|
187
|
+
/** Destination spoke chain key (SODAX SpokeChainKey). */
|
|
188
|
+
tokenDstChainKey: string;
|
|
189
|
+
/** Input amount in smallest unit of the source token (decimal string). */
|
|
190
|
+
amount: string;
|
|
191
|
+
/** Quote type (only `exact_input` is supported). */
|
|
192
|
+
quoteType: QuoteTypeV2;
|
|
193
|
+
/** Source address — required only when `includeTxData=true` (with the inherited `srcPublicKey`/`bound` for Stacks/Bitcoin sources); ignored otherwise. */
|
|
194
|
+
srcAddress?: string;
|
|
195
|
+
/** Destination address — required only when `includeTxData=true`; ignored otherwise. */
|
|
196
|
+
dstAddress?: string;
|
|
197
|
+
}
|
|
198
|
+
/** POST /swaps/quote — query params. */
|
|
199
|
+
export interface QuoteQueryV2 {
|
|
200
|
+
/** When true, also build and return `{ tx, intent, relayData }` using the quoted amount as `minOutputAmount`. */
|
|
201
|
+
includeTxData?: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** POST /swaps/quote — response body. */
|
|
204
|
+
export interface QuoteResponseV2 {
|
|
205
|
+
/** Quoted output amount in smallest unit of the destination token (decimal string). */
|
|
206
|
+
quotedAmount: string;
|
|
207
|
+
/** Unsigned create-intent transaction; present only when `includeTxData=true`. */
|
|
208
|
+
txData?: CreateIntentResponseV2;
|
|
209
|
+
}
|
|
210
|
+
/** GET /swaps/deadline — query params. */
|
|
211
|
+
export interface DeadlineQueryV2 {
|
|
212
|
+
/** Offset in seconds added to the hub timestamp. Defaults to 300 (5 minutes); minimum 1. */
|
|
213
|
+
offsetSeconds?: number;
|
|
214
|
+
}
|
|
215
|
+
/** GET /swaps/deadline — response body. */
|
|
216
|
+
export interface DeadlineResponseV2 {
|
|
217
|
+
/** Unix timestamp (seconds) at which the swap intent will expire (decimal string). */
|
|
218
|
+
deadline: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Shared request body for `/swaps/allowance/check`, `/swaps/approve`, and `/swaps/intents`. Inherits the
|
|
222
|
+
* swap extras (`partnerFee`, `srcPublicKey`, `bound`) from {@link SwapExtrasV2}; the Bitcoin Bound token
|
|
223
|
+
* is carried as `bound.accessToken` (not a flat `accessToken`), mirroring the SDK's grouped `extras.bound`.
|
|
224
|
+
*/
|
|
225
|
+
export interface CreateIntentParamsV2 extends SwapExtrasV2 {
|
|
226
|
+
/** Source spoke chain key (SODAX SpokeChainKey). */
|
|
227
|
+
srcChainKey: string;
|
|
228
|
+
/** Destination spoke chain key (SODAX SpokeChainKey). */
|
|
229
|
+
dstChainKey: string;
|
|
230
|
+
/** Input token address on the source spoke chain. */
|
|
231
|
+
inputToken: string;
|
|
232
|
+
/** Output token address on the destination spoke chain. */
|
|
233
|
+
outputToken: string;
|
|
234
|
+
/** Input amount in smallest unit of the input token (decimal string). */
|
|
235
|
+
inputAmount: string;
|
|
236
|
+
/** Minimum acceptable output in smallest unit of the output token (decimal string). */
|
|
237
|
+
minOutputAmount: string;
|
|
238
|
+
/** Unix timestamp (seconds) at which the intent expires; `"0"` for limit-order semantics (decimal string). */
|
|
239
|
+
deadline: string;
|
|
240
|
+
/** Whether partial fills are allowed for this intent. */
|
|
241
|
+
allowPartialFill: boolean;
|
|
242
|
+
/** User address on the source spoke chain (chain-specific format). */
|
|
243
|
+
srcAddress: string;
|
|
244
|
+
/** Recipient address on the destination spoke chain (chain-specific format). */
|
|
245
|
+
dstAddress: string;
|
|
246
|
+
/** Solver address (EVM hub address). Defaults to the zero address for "any solver". */
|
|
247
|
+
solver?: string;
|
|
248
|
+
/** Arbitrary calldata hex string. Defaults to `0x`. */
|
|
249
|
+
data?: string;
|
|
250
|
+
}
|
|
251
|
+
/** POST /swaps/allowance/check — response body. */
|
|
252
|
+
export interface AllowanceCheckResponseV2 {
|
|
253
|
+
/** True when the source token allowance is already sufficient for the intent. */
|
|
254
|
+
valid: boolean;
|
|
255
|
+
}
|
|
256
|
+
/** POST /swaps/approve — response body. */
|
|
257
|
+
export interface ApproveResponseV2 {
|
|
258
|
+
/** Unsigned approval transaction — the `RawTxReturnType` variant for the request's `srcChainKey`. */
|
|
259
|
+
tx: RawTxReturnType;
|
|
260
|
+
}
|
|
261
|
+
/** POST /swaps/intents — response body. */
|
|
262
|
+
export interface CreateIntentResponseV2 {
|
|
263
|
+
/** Unsigned create-intent transaction — the `RawTxReturnType` variant for the request's `srcChainKey`. */
|
|
264
|
+
tx: RawTxReturnType;
|
|
265
|
+
/** Built intent struct (hub representation). */
|
|
266
|
+
intent: IntentResponseV2;
|
|
267
|
+
/** Extra data required when calling `POST /swaps/intents/submit`. */
|
|
268
|
+
relayData: RelayExtraDataResponseV2;
|
|
269
|
+
}
|
|
270
|
+
/** POST /swaps/intents/submit — request body. */
|
|
271
|
+
export interface SubmitIntentRequestV2 {
|
|
272
|
+
/** Intent-relay chain id of the source chain (decimal string). NOT the SpokeChainKey. */
|
|
273
|
+
chainId: string;
|
|
274
|
+
/** Transaction hash on the source spoke chain after the caller broadcast the intent tx. */
|
|
275
|
+
txHash: string;
|
|
276
|
+
/** Required for Solana / Bitcoin sources — pass the `relayData` returned by `/swaps/intents` verbatim. */
|
|
277
|
+
data?: RelayExtraDataRequestV2;
|
|
278
|
+
}
|
|
279
|
+
/** POST /swaps/intents/submit — response body. */
|
|
280
|
+
export interface SubmitIntentResponseV2 {
|
|
281
|
+
/** Raw response from the intent relay. Shape varies; treat as opaque. */
|
|
282
|
+
result: unknown;
|
|
283
|
+
}
|
|
284
|
+
/** POST /swaps/intents/status — request body. */
|
|
285
|
+
export interface StatusRequestV2 {
|
|
286
|
+
/** Hub-side intent transaction hash (32-byte hex). */
|
|
287
|
+
intentTxHash: string;
|
|
288
|
+
}
|
|
289
|
+
/** POST /swaps/intents/status — response body. */
|
|
290
|
+
export interface StatusResponseV2 {
|
|
291
|
+
/** Solver intent status code. */
|
|
292
|
+
status: SwapIntentStatusCodeV2;
|
|
293
|
+
/** Fill transaction hash on the destination chain. Present only when `status === 3` (SOLVED). */
|
|
294
|
+
fillTxHash?: string;
|
|
295
|
+
}
|
|
296
|
+
/** POST /swaps/intents/cancel — request body. */
|
|
297
|
+
export interface CancelIntentRequestV2 {
|
|
298
|
+
/** Source spoke chain key on which the intent was created. */
|
|
299
|
+
srcChainKey: string;
|
|
300
|
+
/** Intent struct (as returned by `/swaps/intents`). */
|
|
301
|
+
intent: IntentRequestV2;
|
|
302
|
+
}
|
|
303
|
+
/** POST /swaps/intents/cancel — response body. */
|
|
304
|
+
export interface CancelIntentResponseV2 {
|
|
305
|
+
/** Unsigned cancel-intent transaction — the `RawTxReturnType` variant for the request's `srcChainKey`. */
|
|
306
|
+
tx: RawTxReturnType;
|
|
307
|
+
}
|
|
308
|
+
/** POST /swaps/intents/hash — request body. */
|
|
309
|
+
export interface IntentHashRequestV2 {
|
|
310
|
+
/** Intent struct to hash. */
|
|
311
|
+
intent: IntentRequestV2;
|
|
312
|
+
}
|
|
313
|
+
/** POST /swaps/intents/hash — response body. */
|
|
314
|
+
export interface IntentHashResponseV2 {
|
|
315
|
+
/** keccak256 hash of the intent struct (32-byte hex). */
|
|
316
|
+
hash: string;
|
|
317
|
+
}
|
|
318
|
+
/** POST /swaps/intents/packet — request body. */
|
|
319
|
+
export interface IntentPacketRequestV2 {
|
|
320
|
+
/** Destination spoke chain key on which the intent was filled. */
|
|
321
|
+
chainId: string;
|
|
322
|
+
/** Fill transaction hash on the destination chain (returned by `/swaps/intents/status`). */
|
|
323
|
+
fillTxHash: string;
|
|
324
|
+
/** Polling timeout in milliseconds. Defaults to the SDK default (~60s); minimum 1. */
|
|
325
|
+
timeout?: number;
|
|
326
|
+
}
|
|
327
|
+
/** POST /swaps/intents/packet — response body. */
|
|
328
|
+
export interface IntentPacketResponseV2 {
|
|
329
|
+
/** Source intent-relay chain id (numeric). */
|
|
330
|
+
srcChainId: number;
|
|
331
|
+
/** Source-chain transaction hash that originated the packet. */
|
|
332
|
+
srcTxHash: string;
|
|
333
|
+
/** Encoded source address. */
|
|
334
|
+
srcAddress: string;
|
|
335
|
+
/** Relay status (e.g. `executed`). */
|
|
336
|
+
status: string;
|
|
337
|
+
/** Destination intent-relay chain id (numeric). */
|
|
338
|
+
dstChainId: number;
|
|
339
|
+
/** Connection sequence number assigned by the relay. */
|
|
340
|
+
connSn: number;
|
|
341
|
+
/** Encoded destination address. */
|
|
342
|
+
dstAddress: string;
|
|
343
|
+
/** Destination-chain transaction hash where the fill landed. */
|
|
344
|
+
dstTxHash: string;
|
|
345
|
+
/** Relay signatures collected for this packet. */
|
|
346
|
+
signatures: string[];
|
|
347
|
+
/** Packet payload (hex). */
|
|
348
|
+
payload: string;
|
|
349
|
+
}
|
|
350
|
+
/** POST /swaps/intents/extra-data — request body. Provide EITHER `txHash` OR `intent`, not both. */
|
|
351
|
+
export interface IntentExtraDataRequestV2 {
|
|
352
|
+
/** Source-chain tx hash. Provide either this OR `intent`. */
|
|
353
|
+
txHash?: string;
|
|
354
|
+
/** Intent struct. Provide either this OR `txHash`. */
|
|
355
|
+
intent?: IntentRequestV2;
|
|
356
|
+
}
|
|
357
|
+
/** POST /swaps/intents/extra-data — response body (same shape as relay extra data). */
|
|
358
|
+
export type IntentExtraDataResponseV2 = RelayExtraDataResponseV2;
|
|
359
|
+
/** GET /swaps/intents/:txHash/fill — on-chain fill state for an intent. */
|
|
360
|
+
export interface IntentStateV2 {
|
|
361
|
+
/** Whether the intent exists on the hub chain. */
|
|
362
|
+
exists: boolean;
|
|
363
|
+
/** Remaining input amount left to fill (decimal string). */
|
|
364
|
+
remainingInput: string;
|
|
365
|
+
/** Received output amount so far (decimal string). */
|
|
366
|
+
receivedOutput: string;
|
|
367
|
+
/** Whether a payment is pending. */
|
|
368
|
+
pendingPayment: boolean;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* GET /swaps/intents/:txHash — decoded Intent struct from the hub's IntentCreated
|
|
372
|
+
* event. Bigint fields are serialized as decimal strings.
|
|
373
|
+
*/
|
|
374
|
+
export type GetIntentResponseV2 = IntentResponseV2;
|
|
375
|
+
/**
|
|
376
|
+
* POST /swaps/limit-orders — request body. Same as create-intent but `deadline` is optional.
|
|
377
|
+
*
|
|
378
|
+
* The trailing `& _AssertJsonSafe<…>` wires the compile-time JSON-safety guard (see the Config API v2
|
|
379
|
+
* section) into the swap request surface: if a `bigint` ever leaks into `SwapExtrasV2` — or the
|
|
380
|
+
* `PartnerFeeV2` / `BitcoinBoundExtrasV2` it composes — the constraint fails and `pnpm checkTs` /
|
|
381
|
+
* `pnpm build` go red. It is `& unknown` in the happy path, so it does not change the type. This is the
|
|
382
|
+
* swaps-section analog of the guard on `GetAllConfigResponseV2`; `CreateLimitOrderParamsV2` is the one
|
|
383
|
+
* exported swaps request `type` (the others are interfaces, which cannot carry an intersection).
|
|
384
|
+
*/
|
|
385
|
+
export type CreateLimitOrderParamsV2 = Omit<CreateIntentParamsV2, 'deadline'> & {
|
|
386
|
+
/** Unix timestamp (seconds) at which the limit order expires. Omit (or pass `"0"`) for no expiry. */
|
|
387
|
+
deadline?: string;
|
|
388
|
+
} & _AssertJsonSafe<[_ContainsBigint<SwapExtrasV2>] extends [false] ? true : false>;
|
|
389
|
+
/** POST /swaps/limit-orders — response body (same shape as create-intent). */
|
|
390
|
+
export type CreateLimitOrderResponseV2 = CreateIntentResponseV2;
|
|
391
|
+
/** POST /swaps/gas/estimate — request body. */
|
|
392
|
+
export interface GasEstimateRequestV2 {
|
|
393
|
+
/** Spoke chain key the transaction targets. */
|
|
394
|
+
chainKey: string;
|
|
395
|
+
/** Raw transaction object (chain-specific shape). For EVM: `{ from, to, value, data }` with `value` as decimal string. */
|
|
396
|
+
tx: Record<string, unknown>;
|
|
397
|
+
}
|
|
398
|
+
/** POST /swaps/gas/estimate — response body. */
|
|
399
|
+
export interface GasEstimateResponseV2 {
|
|
400
|
+
/**
|
|
401
|
+
* Gas estimate. Shape varies by chain family: EVM/Bitcoin/Near/Solana →
|
|
402
|
+
* decimal string (bigint); Sui/Stellar/Stacks/Icon/Injective → structured object.
|
|
403
|
+
*/
|
|
404
|
+
gas: unknown;
|
|
405
|
+
}
|
|
406
|
+
/** GET /swaps/fees/partner and GET /swaps/fees/solver — query params. */
|
|
407
|
+
export interface FeeQueryV2 {
|
|
408
|
+
/** Input amount in smallest unit (decimal string). */
|
|
409
|
+
amount: string;
|
|
410
|
+
}
|
|
411
|
+
/** GET /swaps/fees/partner and GET /swaps/fees/solver — response body. */
|
|
412
|
+
export interface FeeResponseV2 {
|
|
413
|
+
/** Fee amount in smallest unit of the input token (decimal string). */
|
|
414
|
+
fee: string;
|
|
415
|
+
}
|
|
416
|
+
/** POST /swaps/submit-tx — request body. */
|
|
417
|
+
export interface SubmitTxRequestV2 {
|
|
418
|
+
/** Transaction hash of the tx that will be submitted (1–127 chars). */
|
|
419
|
+
txHash: string;
|
|
420
|
+
/** Source chain key (spoke chain the tx will be submitted from). */
|
|
421
|
+
srcChainKey: string;
|
|
422
|
+
/** Address of the wallet that will submit the tx (1–127 chars). */
|
|
423
|
+
walletAddress: string;
|
|
424
|
+
/** Intent object received from createIntent. */
|
|
425
|
+
intent: IntentRequestV2;
|
|
426
|
+
/** Relay data received from createIntent, submitted to the intent relay (hex). */
|
|
427
|
+
relayData: string;
|
|
428
|
+
}
|
|
429
|
+
/** POST /swaps/submit-tx — response `data` payload. */
|
|
430
|
+
export interface SubmitTxResponseDataV2 {
|
|
431
|
+
/** Whether the row was newly inserted or matched an existing record. */
|
|
432
|
+
status: 'inserted' | 'duplicate';
|
|
433
|
+
/** Message indicating the result of the submission. */
|
|
434
|
+
message: string;
|
|
435
|
+
}
|
|
436
|
+
/** POST /swaps/submit-tx — response body. */
|
|
437
|
+
export interface SubmitTxResponseV2 {
|
|
438
|
+
/** True when the submission was accepted (or was a duplicate). */
|
|
439
|
+
success: boolean;
|
|
440
|
+
/** Submission result payload. */
|
|
441
|
+
data: SubmitTxResponseDataV2;
|
|
442
|
+
}
|
|
443
|
+
/** GET /swaps/submit-tx/status — query params. */
|
|
444
|
+
export interface SubmitTxStatusQueryV2 {
|
|
445
|
+
/** Transaction hash of the submitted swap tx (1–127 chars). */
|
|
446
|
+
txHash: string;
|
|
447
|
+
/** Source chain key. */
|
|
448
|
+
srcChainKey: string;
|
|
449
|
+
}
|
|
450
|
+
/** Lifecycle status of a submitted swap tx. */
|
|
451
|
+
export type SubmitSwapTxStatusV2 = 'pending' | 'relaying' | 'relayed' | 'posting_execution' | 'posted_execution' | 'solved' | 'failed';
|
|
452
|
+
/** Lifecycle status of a cross-chain relay packet. */
|
|
453
|
+
export type PacketDataStatusV2 = 'pending' | 'validating' | 'executing' | 'executed';
|
|
454
|
+
/** Relay packet data attached to a submit-tx processing result (snake_case as stored). */
|
|
455
|
+
export interface PacketDataV2 {
|
|
456
|
+
/** Source intent-relay chain id (numeric). */
|
|
457
|
+
src_chain_id: number;
|
|
458
|
+
/** Source-chain transaction hash. */
|
|
459
|
+
src_tx_hash: string;
|
|
460
|
+
/** Encoded source address. */
|
|
461
|
+
src_address: string;
|
|
462
|
+
/** Packet lifecycle status. */
|
|
463
|
+
status: PacketDataStatusV2;
|
|
464
|
+
/** Destination intent-relay chain id (numeric). */
|
|
465
|
+
dst_chain_id: number;
|
|
466
|
+
/** Connection sequence number assigned by the relay. */
|
|
467
|
+
conn_sn: number;
|
|
468
|
+
/** Encoded destination address. */
|
|
469
|
+
dst_address: string;
|
|
470
|
+
/** Destination-chain transaction hash. */
|
|
471
|
+
dst_tx_hash: string;
|
|
472
|
+
/** Relay signatures collected for this packet. */
|
|
473
|
+
signatures: string[];
|
|
474
|
+
/** Packet payload (hex). */
|
|
475
|
+
payload: string;
|
|
476
|
+
}
|
|
477
|
+
/** Processing result for a submitted swap tx (present when solved). */
|
|
478
|
+
export interface SubmitTxStatusResultV2 {
|
|
479
|
+
/** Destination intent tx hash. */
|
|
480
|
+
dstIntentTxHash: string;
|
|
481
|
+
/** Packet data from the relay. */
|
|
482
|
+
packetData?: PacketDataV2;
|
|
483
|
+
/** Intent hash from the solver API (populated after post-execution). */
|
|
484
|
+
intent_hash?: string;
|
|
485
|
+
}
|
|
486
|
+
/** Processing state of a submitted swap tx. */
|
|
487
|
+
export interface SubmitTxStatusDataV2 {
|
|
488
|
+
/** Transaction hash. */
|
|
489
|
+
txHash: string;
|
|
490
|
+
/** Source chain key. */
|
|
491
|
+
srcChainKey: string;
|
|
492
|
+
/** Current processing status. */
|
|
493
|
+
status: SubmitSwapTxStatusV2;
|
|
494
|
+
/** Step where processing failed. */
|
|
495
|
+
failedAtStep?: SubmitSwapTxStatusV2;
|
|
496
|
+
/** Failure reason. */
|
|
497
|
+
failureReason?: string;
|
|
498
|
+
/** Number of processing attempts (claim-time counter). */
|
|
499
|
+
processingAttempts: number;
|
|
500
|
+
/** ISO 8601 timestamp set when the swap exhausted its processing budget and was abandoned. */
|
|
501
|
+
abandonedAt?: string;
|
|
502
|
+
/** Processing result (present when solved). */
|
|
503
|
+
result?: SubmitTxStatusResultV2;
|
|
504
|
+
/** User-facing hint when status is failed or the swap was abandoned. */
|
|
505
|
+
userMessage?: string;
|
|
506
|
+
/** True when an on-chain INTENT_CANCELLED event exists for this swap's intent (failed swaps only). */
|
|
507
|
+
intentCancelled?: boolean;
|
|
508
|
+
}
|
|
509
|
+
/** GET /swaps/submit-tx/status — response body. */
|
|
510
|
+
export interface SubmitTxStatusResponseV2 {
|
|
511
|
+
/** True when a record was found. */
|
|
512
|
+
success: boolean;
|
|
513
|
+
/** The submit-tx processing state. */
|
|
514
|
+
data: SubmitTxStatusDataV2;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Client-side surface for the backend Swaps API v2 — for typed HTTP clients
|
|
518
|
+
* (fetch wrappers / SDK adapters). Each method describes one endpoint as the
|
|
519
|
+
* client sees it: all methods are async and all field types are the
|
|
520
|
+
* post-serialization wire shapes above (bigint/Date → decimal/ISO `string`).
|
|
521
|
+
*
|
|
522
|
+
* Do NOT `implements` this on the NestJS `SwapsController`. Handlers return
|
|
523
|
+
* pre-serialization domain types (`bigint`, `Date`, branded `Hex`/`Address`/
|
|
524
|
+
* `SpokeChainKey`) and may be synchronous; the response interceptor serializes
|
|
525
|
+
* them into these wire shapes afterwards. A single class cannot be both the
|
|
526
|
+
* pre-serialization producer and the post-serialization contract.
|
|
527
|
+
*/
|
|
528
|
+
export interface ISwapsApiV2 {
|
|
529
|
+
/** GET /swaps/tokens */
|
|
530
|
+
getTokens(): Promise<GetSwapTokensResponseV2>;
|
|
531
|
+
/** GET /swaps/tokens/:chainKey */
|
|
532
|
+
getTokensByChain(chainKey: string): Promise<GetSwapTokensByChainResponseV2>;
|
|
533
|
+
/** POST /swaps/quote */
|
|
534
|
+
getQuote(body: QuoteRequestV2, query?: QuoteQueryV2): Promise<QuoteResponseV2>;
|
|
535
|
+
/** GET /swaps/deadline */
|
|
536
|
+
getDeadline(query?: DeadlineQueryV2): Promise<DeadlineResponseV2>;
|
|
537
|
+
/** POST /swaps/allowance/check */
|
|
538
|
+
checkAllowance(body: CreateIntentParamsV2): Promise<AllowanceCheckResponseV2>;
|
|
539
|
+
/** POST /swaps/approve */
|
|
540
|
+
approve(body: CreateIntentParamsV2): Promise<ApproveResponseV2>;
|
|
541
|
+
/** POST /swaps/intents */
|
|
542
|
+
createIntent(body: CreateIntentParamsV2): Promise<CreateIntentResponseV2>;
|
|
543
|
+
/** POST /swaps/intents/submit */
|
|
544
|
+
submitIntent(body: SubmitIntentRequestV2): Promise<SubmitIntentResponseV2>;
|
|
545
|
+
/** POST /swaps/intents/status */
|
|
546
|
+
getStatus(body: StatusRequestV2): Promise<StatusResponseV2>;
|
|
547
|
+
/** POST /swaps/intents/cancel */
|
|
548
|
+
cancelIntent(body: CancelIntentRequestV2): Promise<CancelIntentResponseV2>;
|
|
549
|
+
/** POST /swaps/intents/hash */
|
|
550
|
+
getIntentHash(body: IntentHashRequestV2): Promise<IntentHashResponseV2>;
|
|
551
|
+
/** POST /swaps/intents/packet */
|
|
552
|
+
getSolvedIntentPacket(body: IntentPacketRequestV2): Promise<IntentPacketResponseV2>;
|
|
553
|
+
/** POST /swaps/intents/extra-data */
|
|
554
|
+
getIntentSubmitTxExtraData(body: IntentExtraDataRequestV2): Promise<IntentExtraDataResponseV2>;
|
|
555
|
+
/** GET /swaps/intents/:txHash/fill */
|
|
556
|
+
getFilledIntent(txHash: string): Promise<IntentStateV2>;
|
|
557
|
+
/** GET /swaps/intents/:txHash */
|
|
558
|
+
getIntent(txHash: string): Promise<GetIntentResponseV2>;
|
|
559
|
+
/** POST /swaps/limit-orders */
|
|
560
|
+
createLimitOrderIntent(body: CreateLimitOrderParamsV2): Promise<CreateLimitOrderResponseV2>;
|
|
561
|
+
/** POST /swaps/gas/estimate */
|
|
562
|
+
estimateGas(body: GasEstimateRequestV2): Promise<GasEstimateResponseV2>;
|
|
563
|
+
/** GET /swaps/fees/partner */
|
|
564
|
+
getPartnerFee(query: FeeQueryV2): Promise<FeeResponseV2>;
|
|
565
|
+
/** GET /swaps/fees/solver */
|
|
566
|
+
getSolverFee(query: FeeQueryV2): Promise<FeeResponseV2>;
|
|
567
|
+
/** POST /swaps/submit-tx */
|
|
568
|
+
submitTx(body: SubmitTxRequestV2): Promise<SubmitTxResponseV2>;
|
|
569
|
+
/** GET /swaps/submit-tx/status */
|
|
570
|
+
getSubmitTxStatus(query: SubmitTxStatusQueryV2): Promise<SubmitTxStatusResponseV2>;
|
|
571
|
+
}
|
|
572
|
+
/** JSON-safe {@link RelayConfig}: relay chain ids are decimal strings on the wire. */
|
|
573
|
+
export type RelayConfigV2 = Omit<RelayConfig, 'relayChainIdMap'> & {
|
|
574
|
+
/** SpokeChainKey → intent-relay chain id as a decimal string (e.g. `"146"`). */
|
|
575
|
+
relayChainIdMap: Record<string, string>;
|
|
576
|
+
};
|
|
577
|
+
/** JSON-safe {@link ConcentratedLiquidityConfig}: `defaultBitmap` is a decimal string. */
|
|
578
|
+
export type ConcentratedLiquidityConfigV2 = Omit<ConcentratedLiquidityConfig, 'defaultBitmap'> & {
|
|
579
|
+
/** Default tick bitmap; bigint projected to a decimal string. */
|
|
580
|
+
defaultBitmap: string;
|
|
581
|
+
};
|
|
582
|
+
/** JSON-safe {@link DexDefaultConfig}. Only the concentrated-liquidity config carries bigint. */
|
|
583
|
+
export type DexConfigV2 = Omit<DexDefaultConfig, 'concentratedLiquidityConfig'> & {
|
|
584
|
+
concentratedLiquidityConfig: ConcentratedLiquidityConfigV2;
|
|
585
|
+
};
|
|
586
|
+
/**
|
|
587
|
+
* JSON-safe projection of {@link SodaxDefaultConfig} — the STATIC config the backend serves,
|
|
588
|
+
* never the merged `SodaxConfig`. `SodaxDefaultConfig` already exposes only static per-feature
|
|
589
|
+
* configs (`SwapsDefaultConfig`, `MoneyMarketDefaultConfig`, `BridgeDefaultConfig`,
|
|
590
|
+
* `LeverageYieldDefaultConfig`, `DexDefaultConfig`), so every field is reused untouched —
|
|
591
|
+
* `chains`, `swaps`, `moneyMarket`, `bridge`, `leverageYield`, `hub`, `api`, `solver` are all
|
|
592
|
+
* JSON-safe as-is. Only `dex` and `relay` are projected to their `*V2` variants because they
|
|
593
|
+
* carry a `bigint` field.
|
|
594
|
+
*
|
|
595
|
+
* No options ever reach the wire: the global `fee`, the `logger`, and every per-feature
|
|
596
|
+
* `partnerFee` live on `SodaxOptions` (resolved client-side), which is not part of `SodaxDefaultConfig`.
|
|
597
|
+
*/
|
|
598
|
+
export type SodaxConfigV2 = Omit<SodaxDefaultConfig, 'dex' | 'relay'> & {
|
|
599
|
+
dex: DexConfigV2;
|
|
600
|
+
relay: RelayConfigV2;
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* GET /config/all — full config plus its schema version for drift detection.
|
|
604
|
+
*
|
|
605
|
+
* `version` is REQUIRED here (the v1 `GetAllConfigApiResponse.version` is optional):
|
|
606
|
+
* `ConfigService` already treats a missing/older version as "reject and keep the
|
|
607
|
+
* packaged defaults", so a required field is a strictly cleaner v2 contract.
|
|
608
|
+
*/
|
|
609
|
+
export type GetAllConfigResponseV2 = {
|
|
610
|
+
/** Config schema version; compared against the SDK's `CONFIG_VERSION`. */
|
|
611
|
+
version: number;
|
|
612
|
+
/** Full JSON-safe SODAX config. */
|
|
613
|
+
config: SodaxConfigV2;
|
|
614
|
+
} & _AssertJsonSafe<[_ContainsBigint<SodaxConfigV2>] extends [false] ? true : false>;
|
|
615
|
+
/** GET /config/spoke/chains — supported spoke chain keys. */
|
|
616
|
+
export type GetChainsResponseV2 = readonly string[];
|
|
617
|
+
/** GET /config/spoke/all-chains-configs — full per-chain config (no bigint → `SpokeChainConfig` reused). */
|
|
618
|
+
export type GetSpokeChainConfigsResponseV2 = Record<string, SpokeChainConfig>;
|
|
619
|
+
/**
|
|
620
|
+
* GET /config/swap/tokens — supported swap tokens per chain.
|
|
621
|
+
*
|
|
622
|
+
* Returns the canonical {@link XToken} (incl. its optional `access`), NOT the
|
|
623
|
+
* swaps-domain `SwapTokenV2`: this is config data, so it mirrors the source token
|
|
624
|
+
* exactly. (`GetSwapTokensResponseV2` above is the unrelated `/swaps/tokens` shape.)
|
|
625
|
+
*/
|
|
626
|
+
export type GetSwapTokensConfigResponseV2 = Record<string, readonly XToken[]>;
|
|
627
|
+
/** GET /config/swap/:chainKey/tokens — supported swap tokens for one chain. */
|
|
628
|
+
export type GetSwapTokensConfigByChainResponseV2 = readonly XToken[];
|
|
629
|
+
/** GET /config/money-market/tokens — supported money-market tokens per chain. */
|
|
630
|
+
export type GetMoneyMarketTokensConfigResponseV2 = Record<string, readonly XToken[]>;
|
|
631
|
+
/** GET /config/money-market/:chainKey/tokens — supported money-market tokens for one chain. */
|
|
632
|
+
export type GetMoneyMarketTokensConfigByChainResponseV2 = readonly XToken[];
|
|
633
|
+
/** GET /config/money-market/reserve-assets — hub reserve asset addresses. */
|
|
634
|
+
export type GetMoneyMarketReserveAssetsResponseV2 = readonly string[];
|
|
635
|
+
/** GET /config/relay/chain-id-map — SpokeChainKey → intent-relay chain id (decimal string). */
|
|
636
|
+
export type GetRelayChainIdMapResponseV2 = Record<string, string>;
|
|
637
|
+
/**
|
|
638
|
+
* Client-side surface for the backend Config API v2 — for typed HTTP clients
|
|
639
|
+
* (fetch wrappers / SDK adapters). Each method describes one endpoint as the
|
|
640
|
+
* client sees it: all methods are async and all field types are the
|
|
641
|
+
* post-serialization wire shapes above (bigint → decimal `string`).
|
|
642
|
+
*
|
|
643
|
+
* As with {@link ISwapsApiV2}, do NOT `implements` this on the NestJS controller:
|
|
644
|
+
* handlers return pre-serialization domain types (`bigint`, branded values) and the
|
|
645
|
+
* response interceptor serializes them into these wire shapes afterwards.
|
|
646
|
+
*/
|
|
647
|
+
export interface IConfigApiV2 {
|
|
648
|
+
/** GET /config/all */
|
|
649
|
+
getAllConfig(): Promise<GetAllConfigResponseV2>;
|
|
650
|
+
/** GET /config/spoke/chains */
|
|
651
|
+
getChains(): Promise<GetChainsResponseV2>;
|
|
652
|
+
/** GET /config/spoke/all-chains-configs */
|
|
653
|
+
getSpokeChainConfigs(): Promise<GetSpokeChainConfigsResponseV2>;
|
|
654
|
+
/** GET /config/swap/tokens */
|
|
655
|
+
getSwapTokens(): Promise<GetSwapTokensConfigResponseV2>;
|
|
656
|
+
/** GET /config/swap/:chainKey/tokens */
|
|
657
|
+
getSwapTokensByChain(chainKey: string): Promise<GetSwapTokensConfigByChainResponseV2>;
|
|
658
|
+
/** GET /config/money-market/tokens */
|
|
659
|
+
getMoneyMarketTokens(): Promise<GetMoneyMarketTokensConfigResponseV2>;
|
|
660
|
+
/** GET /config/money-market/:chainKey/tokens */
|
|
661
|
+
getMoneyMarketTokensByChain(chainKey: string): Promise<GetMoneyMarketTokensConfigByChainResponseV2>;
|
|
662
|
+
/** GET /config/money-market/reserve-assets */
|
|
663
|
+
getMoneyMarketReserveAssets(): Promise<GetMoneyMarketReserveAssetsResponseV2>;
|
|
664
|
+
/** GET /config/relay/chain-id-map */
|
|
665
|
+
getRelayChainIdMap(): Promise<GetRelayChainIdMapResponseV2>;
|
|
666
|
+
}
|
|
667
|
+
/** True if `T` contains a `bigint` anywhere in its data shape. Recurses arrays/records/objects. */
|
|
668
|
+
type _ContainsBigint<T> = T extends bigint ? true : T extends string | number | boolean | symbol | null | undefined ? false : T extends readonly (infer U)[] ? _ContainsBigint<U> : T extends object ? true extends {
|
|
669
|
+
[K in keyof T]-?: _ContainsBigint<T[K]>;
|
|
670
|
+
}[keyof T] ? true : false : false;
|
|
671
|
+
/**
|
|
672
|
+
* Resolves to `unknown` (an identity in an intersection) when `Ok` proves JSON-safety;
|
|
673
|
+
* otherwise the `Ok extends true` constraint is violated and compilation fails at the use site.
|
|
674
|
+
* The caller passes `[_ContainsBigint<T>] extends [false] ? true : false` — the `[…] extends […]`
|
|
675
|
+
* wrap is union-safe (a `true | false` result from union distribution still resolves to `false`).
|
|
676
|
+
*/
|
|
677
|
+
type _AssertJsonSafe<_Ok extends true> = unknown;
|
|
678
|
+
export {};
|