@sodax/types 2.0.0 → 2.1.0-rc.2

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.
@@ -519,11 +519,13 @@ export interface SubmitTxStatusResponseV2 {
519
519
  * client sees it: all methods are async and all field types are the
520
520
  * post-serialization wire shapes above (bigint/Date → decimal/ISO `string`).
521
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.
522
+ * The backend `SwapsController` `implements` this, which is what keeps the two surfaces from
523
+ * drifting. Two things make that work: handlers are DECLARED with the wire-shaped response DTOs
524
+ * (what they hand back at runtime may still be pre-serialization domain values — `bigint`, `Date`,
525
+ * branded `Hex`/`Address`/`SpokeChainKey` — for the response interceptor to convert), and every
526
+ * handler is `async`. A handler needing a server-only trailing parameter (`@Req`, `@Ip`, …) takes
527
+ * the variadic-generic route of `IStellarSponsoringApi` in `sponsoringApi.ts` rather than dropping
528
+ * the `implements` clause.
527
529
  */
528
530
  export interface ISwapsApiV2 {
529
531
  /** GET /swaps/tokens */
@@ -640,9 +642,8 @@ export type GetRelayChainIdMapResponseV2 = Record<string, string>;
640
642
  * client sees it: all methods are async and all field types are the
641
643
  * post-serialization wire shapes above (bigint → decimal `string`).
642
644
  *
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.
645
+ * As with {@link ISwapsApiV2}, a NestJS controller may `implements` this once its handlers are
646
+ * declared `async` and typed with the wire-shaped DTOs.
646
647
  */
647
648
  export interface IConfigApiV2 {
648
649
  /** GET /config/all */
@@ -0,0 +1,268 @@
1
+ import type { RawTxReturnType } from '../common/index.js';
2
+ import type { BitcoinBoundExtrasV2, PacketDataV2, PartnerFeeV2, RelayExtraDataResponseV2 } from './backendApiV2.js';
3
+ /** A supported bridge token descriptor (`XToken` projected to JSON primitives). */
4
+ export interface BridgeTokenV2 {
5
+ /** Token symbol (e.g. `USDC`). */
6
+ symbol: string;
7
+ /** Token name (e.g. `USD Coin`). */
8
+ name: string;
9
+ /** Token decimals. */
10
+ decimals: number;
11
+ /** Token address on its spoke chain (or hub address for hub tokens). */
12
+ address: string;
13
+ /** SODAX SpokeChainKey identifier (e.g. `0xa4b1.arbitrum`, `solana`). */
14
+ chainKey: string;
15
+ /** Corresponding hub-side asset address on Sonic. */
16
+ hubAsset: string;
17
+ /** Hub vault address that custodies bridged liquidity for this token. */
18
+ vault: string;
19
+ }
20
+ /** GET /bridge/tokens — map of SpokeChainKey → supported bridge tokens. */
21
+ export type GetBridgeTokensResponseV2 = Record<string, readonly BridgeTokenV2[]>;
22
+ /**
23
+ * GET /bridge/tokens/:chainKey — supported bridge tokens for a single chain.
24
+ *
25
+ * The trailing `& _AssertJsonSafe<…>` wires the compile-time JSON-safety guard into
26
+ * the bridge wire surface: if a `bigint` ever leaks into `BridgeTokenV2`, the
27
+ * constraint fails and `pnpm checkTs` / `pnpm build` go red. It is `& unknown` in the
28
+ * happy path, so it does not change the type.
29
+ */
30
+ export type GetBridgeTokensByChainResponseV2 = readonly BridgeTokenV2[] & _AssertJsonSafe<[_ContainsBigint<BridgeTokenV2>] extends [false] ? true : false>;
31
+ /**
32
+ * Shared request body for `/bridge/allowance/check`, `/bridge/approve`, and
33
+ * `/bridge/intents`. Uses the swaps param naming: the SDK maps its domain
34
+ * `CreateBridgeIntentParams` (`srcToken`/`dstToken`/`amount`/`recipient`) onto these
35
+ * wire names before the POST.
36
+ *
37
+ * Carries an optional `partnerFee` per-request override (defaults to the backend's configured
38
+ * `bridgePartnerFee`), mirroring `SwapExtrasV2.partnerFee`. The Bitcoin Bound token is carried as
39
+ * `bound.accessToken`, mirroring the SDK's grouped `extras.bound`.
40
+ */
41
+ export interface CreateBridgeIntentParamsV2 {
42
+ /** Source spoke chain key (SODAX SpokeChainKey). */
43
+ srcChainKey: string;
44
+ /** Destination spoke chain key (SODAX SpokeChainKey). */
45
+ dstChainKey: string;
46
+ /** Input token address on the source spoke chain (SDK domain `srcToken`). */
47
+ inputToken: string;
48
+ /** Output token address on the destination spoke chain (SDK domain `dstToken`). */
49
+ outputToken: string;
50
+ /** Input amount in smallest unit of the input token (SDK domain `amount`; bigint → decimal string). */
51
+ inputAmount: string;
52
+ /** User address on the source spoke chain (chain-specific format). */
53
+ srcAddress: string;
54
+ /** Recipient address on the destination spoke chain (SDK domain `recipient`). */
55
+ dstAddress: string;
56
+ /**
57
+ * Source-chain signer public key (compressed hex), for chains whose address can't
58
+ * yield it (e.g. Stacks). Only used when building a raw intent.
59
+ */
60
+ srcPublicKey?: string;
61
+ /**
62
+ * Bitcoin Bound (Radfi) inputs, grouped so future Bound fields extend one slot.
63
+ * Only used for raw Bitcoin TRADING-mode intents.
64
+ */
65
+ bound?: BitcoinBoundExtrasV2;
66
+ /**
67
+ * Per-request partner-fee override (address + amount|percentage). Defaults to the backend's
68
+ * configured `bridgePartnerFee` when omitted, so an integrator can charge its own fee per request
69
+ * (e.g. route the fee to its own wallet). Mirrors `SwapExtrasV2.partnerFee`.
70
+ */
71
+ partnerFee?: PartnerFeeV2;
72
+ }
73
+ /** POST /bridge/allowance/check — response body. */
74
+ export interface BridgeAllowanceCheckResponseV2 {
75
+ /** True when the source token allowance is already sufficient for the bridge. */
76
+ valid: boolean;
77
+ }
78
+ /** POST /bridge/approve — response body. */
79
+ export interface BridgeApproveResponseV2 {
80
+ /** Unsigned approval transaction — the `RawTxReturnType` variant for the request's `srcChainKey`. */
81
+ tx: RawTxReturnType;
82
+ }
83
+ /**
84
+ * POST /bridge/intents — response body. No `intent` struct (bridge is vault-backed,
85
+ * not solver-based); `createBridgeIntent` returns the unsigned spoke-deposit tx plus
86
+ * the relay envelope.
87
+ */
88
+ export interface CreateBridgeIntentResponseV2 {
89
+ /** Unsigned spoke-deposit transaction — the `RawTxReturnType` variant for the request's `srcChainKey`. */
90
+ tx: RawTxReturnType;
91
+ /** Relay envelope `{ address, payload }` submitted to the intent relay. */
92
+ relayData: RelayExtraDataResponseV2;
93
+ }
94
+ /**
95
+ * POST /bridge/submit-tx — request body. Idempotent on `(txHash, srcChainKey)`.
96
+ *
97
+ * Carries the FULL `relayData { address, payload }` envelope: bridge has no
98
+ * `intent.creator` for the backend to rebuild the relay address, so the client sends it —
99
+ * dropping the address would break split-tx-chain relay (Stellar/Solana/Sui/Stacks…).
100
+ */
101
+ export interface BridgeSubmitTxRequestV2 {
102
+ /** Transaction hash of the spoke-deposit tx that was broadcast (1–127 chars). */
103
+ txHash: string;
104
+ /** Source chain key (spoke chain the tx was submitted from). */
105
+ srcChainKey: string;
106
+ /** Address of the wallet that submitted the tx (1–127 chars). */
107
+ walletAddress: string;
108
+ /** Relay envelope received from createBridgeIntent, submitted to the intent relay. */
109
+ relayData: RelayExtraDataResponseV2;
110
+ }
111
+ /** POST /bridge/submit-tx — response `data` payload. */
112
+ export interface BridgeSubmitTxResponseDataV2 {
113
+ /** Whether the row was newly inserted or matched an existing record. */
114
+ status: 'inserted' | 'duplicate';
115
+ /** Message indicating the result of the submission. */
116
+ message: string;
117
+ }
118
+ /** POST /bridge/submit-tx — response body. */
119
+ export interface BridgeSubmitTxResponseV2 {
120
+ /** True when the submission was accepted (or was a duplicate). */
121
+ success: boolean;
122
+ /** Submission result payload. */
123
+ data: BridgeSubmitTxResponseDataV2;
124
+ }
125
+ /** GET /bridge/submit-tx/status — query params. */
126
+ export interface BridgeSubmitTxStatusQueryV2 {
127
+ /** Transaction hash of the submitted bridge tx (1–127 chars). */
128
+ txHash: string;
129
+ /** Source chain key. */
130
+ srcChainKey: string;
131
+ }
132
+ /**
133
+ * Lifecycle status of a submitted bridge tx. 5-state: drops the swaps-only
134
+ * `'posting_execution'` (bridge has no solver post-execution). The SDK schema stays
135
+ * tolerant of unknown states so a future backend extension never breaks parse.
136
+ */
137
+ export type SubmitBridgeTxStatusV2 = 'pending' | 'relaying' | 'relayed' | 'executed' | 'failed';
138
+ /** Processing result for a submitted bridge tx (present when executed). No `intent_hash` (no solver). */
139
+ export interface BridgeSubmitTxStatusResultV2 {
140
+ /** Destination intent tx hash. */
141
+ dstIntentTxHash: string;
142
+ /** Packet data from the relay. */
143
+ packetData?: PacketDataV2;
144
+ }
145
+ /** Processing state of a submitted bridge tx. */
146
+ export interface BridgeSubmitTxStatusDataV2 {
147
+ /** Transaction hash. */
148
+ txHash: string;
149
+ /** Source chain key. */
150
+ srcChainKey: string;
151
+ /**
152
+ * Current processing status. Typed as `string` (not the {@link SubmitBridgeTxStatusV2} union)
153
+ * because the SDK response schema is deliberately tolerant of unknown states, so a future
154
+ * backend lifecycle addition never breaks response parsing. Compare against the
155
+ * {@link SubmitBridgeTxStatusV2} literals for the known terminal states (`'executed'`/`'failed'`).
156
+ */
157
+ status: string;
158
+ /** Step where processing failed (one of {@link SubmitBridgeTxStatusV2}; tolerant `string`). */
159
+ failedAtStep?: string;
160
+ /** Failure reason. */
161
+ failureReason?: string;
162
+ /** Number of processing attempts (claim-time counter). */
163
+ processingAttempts: number;
164
+ /** ISO 8601 timestamp set when the bridge exhausted its processing budget and was abandoned. */
165
+ abandonedAt?: string;
166
+ /** Processing result (present when executed). */
167
+ result?: BridgeSubmitTxStatusResultV2;
168
+ /** User-facing hint when status is failed or the bridge was abandoned. */
169
+ userMessage?: string;
170
+ }
171
+ /** GET /bridge/submit-tx/status — response body. */
172
+ export interface BridgeSubmitTxStatusResponseV2 {
173
+ /** True when a record was found. */
174
+ success: boolean;
175
+ /** The submit-tx processing state. */
176
+ data: BridgeSubmitTxStatusDataV2;
177
+ }
178
+ /** POST /bridge/fee — request body. */
179
+ export interface BridgeFeeRequestV2 {
180
+ /** Input amount in smallest unit of the input token (bigint → decimal string). */
181
+ inputAmount: string;
182
+ /** Per-request partner-fee override; defaults to the backend's configured `bridgePartnerFee`. */
183
+ partnerFee?: PartnerFeeV2;
184
+ }
185
+ /** POST /bridge/fee — response body. The partner fee is a fixed %/amount of the input (token-independent); it uses the per-request `partnerFee` when supplied, else the configured `bridgePartnerFee`. */
186
+ export interface BridgeFeeResponseV2 {
187
+ /** Partner fee in smallest unit (decimal string; `'0'` when no partner fee is configured). */
188
+ fee: string;
189
+ }
190
+ /**
191
+ * Shared request body for `/bridge/bridgeable-amount` and `/bridge/bridgeable/check` — the (from, to)
192
+ * token pair by `(chainKey, tokenAddress)`. The backend resolves each pair to an XToken from chain config.
193
+ */
194
+ export interface BridgeQuoteRequestV2 {
195
+ /** Source spoke chain key. */
196
+ srcChainKey: string;
197
+ /** Destination spoke chain key. */
198
+ dstChainKey: string;
199
+ /** Input token address on the source spoke chain. */
200
+ inputToken: string;
201
+ /** Output token address on the destination spoke chain. */
202
+ outputToken: string;
203
+ }
204
+ /** A bridge limit (`BridgeLimit` projected to JSON: bigint `amount` → decimal string). */
205
+ export interface BridgeLimitV2 {
206
+ /** Limit amount in smallest unit (bigint → decimal string). */
207
+ amount: string;
208
+ /** Token decimals. */
209
+ decimals: number;
210
+ /** Whether the limit is the deposit capacity or the withdrawal liquidity. */
211
+ type: 'DEPOSIT_LIMIT' | 'WITHDRAWAL_LIMIT';
212
+ }
213
+ /** POST /bridge/bridgeable-amount — response body. */
214
+ export interface BridgeableAmountResponseV2 {
215
+ /** Deposit capacity / withdrawal liquidity limit for the pair. */
216
+ limit: BridgeLimitV2;
217
+ }
218
+ /** POST /bridge/bridgeable/check — response body. */
219
+ export interface BridgeableCheckResponseV2 {
220
+ /** True when the (from, to) token pair is bridgeable. */
221
+ bridgeable: boolean;
222
+ }
223
+ /**
224
+ * Client-side surface for the backend Bridge API v2 — for typed HTTP clients
225
+ * (fetch wrappers / SDK adapters). Each method describes one endpoint as the client
226
+ * sees it: all methods are async and all field types are the post-serialization wire
227
+ * shapes above (bigint/Date → decimal/ISO `string`).
228
+ *
229
+ * As with {@link import('./backendApiV2.js').ISwapsApiV2}, the backend `BridgeController`
230
+ * `implements` this — declaring its handlers `async` and typed with the wire-shaped DTOs — so a
231
+ * request or response shape cannot drift from this contract without failing the build.
232
+ *
233
+ * `getFee`/`getBridgeableAmount`/`isBridgeable` are read-only quotes computable client-side (config +
234
+ * vault math); an SDK consumer should prefer the local `sodax.bridge.*` equivalents (no round-trip).
235
+ * They also have backend endpoints (for non-SDK HTTP clients), mirrored here for client parity.
236
+ */
237
+ export interface IBridgeApiV2 {
238
+ /** POST /bridge/allowance/check */
239
+ checkAllowance(body: CreateBridgeIntentParamsV2): Promise<BridgeAllowanceCheckResponseV2>;
240
+ /** POST /bridge/approve */
241
+ approve(body: CreateBridgeIntentParamsV2): Promise<BridgeApproveResponseV2>;
242
+ /** POST /bridge/intents */
243
+ createBridgeIntent(body: CreateBridgeIntentParamsV2): Promise<CreateBridgeIntentResponseV2>;
244
+ /** POST /bridge/submit-tx */
245
+ submitTx(body: BridgeSubmitTxRequestV2): Promise<BridgeSubmitTxResponseV2>;
246
+ /** GET /bridge/submit-tx/status */
247
+ getSubmitTxStatus(query: BridgeSubmitTxStatusQueryV2): Promise<BridgeSubmitTxStatusResponseV2>;
248
+ /** GET /bridge/tokens */
249
+ getTokens(): Promise<GetBridgeTokensResponseV2>;
250
+ /** GET /bridge/tokens/:chainKey */
251
+ getTokensByChain(chainKey: string): Promise<GetBridgeTokensByChainResponseV2>;
252
+ /** POST /bridge/fee — partner fee for an amount (per-request `body.partnerFee` override or the configured default; computable client-side, here for HTTP parity). */
253
+ getFee(body: BridgeFeeRequestV2): Promise<BridgeFeeResponseV2>;
254
+ /** POST /bridge/bridgeable-amount — deposit capacity / withdrawal liquidity for a pair. */
255
+ getBridgeableAmount(body: BridgeQuoteRequestV2): Promise<BridgeableAmountResponseV2>;
256
+ /** POST /bridge/bridgeable/check — whether a (from, to) pair is bridgeable. */
257
+ isBridgeable(body: BridgeQuoteRequestV2): Promise<BridgeableCheckResponseV2>;
258
+ }
259
+ /** True if `T` contains a `bigint` anywhere in its data shape. Recurses arrays/records/objects. */
260
+ 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 {
261
+ [K in keyof T]-?: _ContainsBigint<T[K]>;
262
+ }[keyof T] ? true : false : false;
263
+ /**
264
+ * Resolves to `unknown` (an identity in an intersection) when `Ok` proves JSON-safety;
265
+ * otherwise the `Ok extends true` constraint is violated and compilation fails at the use site.
266
+ */
267
+ type _AssertJsonSafe<_Ok extends true> = unknown;
268
+ export {};
@@ -0,0 +1,23 @@
1
+ // Backend Bridge API v2 — request/response contract types.
2
+ //
3
+ // Mirrors `backendApiV2.ts` (Swaps API v2). One type per request/response of every
4
+ // endpoint in the backend bridge controller (`@Controller('bridge')`, served on the
5
+ // shared swaps host). They favor plain primitives (`string`/`number`/`boolean`/plain
6
+ // objects) over SDK branded types.
7
+ //
8
+ // Same JSON-safety rule as the swaps section: outbound (response) values are pure
9
+ // JSON — every bigint-derived value is a decimal `string`, every `Date` an ISO 8601
10
+ // `string`. A response NEVER contains `bigint` on the wire (the one typed exception
11
+ // is the unsigned `tx`, the SDK domain union `RawTxReturnType`, which the SDK
12
+ // client's response schema rebuilds into `bigint`/`Uint8Array` on parse).
13
+ //
14
+ // Bridge deltas vs swaps:
15
+ // - NO `intent` struct — `createBridgeIntent` returns `{ tx, relayData }`.
16
+ // - NO solver / `intent_hash` / `posting_execution` — terminal success is
17
+ // `status === 'executed' && result.dstIntentTxHash`.
18
+ // - `submit-tx` carries the FULL `relayData { address, payload }` envelope: with no
19
+ // `intent.creator` the backend cannot rebuild the relay address, so the client sends it.
20
+ // - Surface: checkAllowance, approve, createBridgeIntent, submitTx, getSubmitTxStatus,
21
+ // getTokens, getTokensByChain, getFee, getBridgeableAmount, isBridgeable (the last 3
22
+ // are read-only discovery/quote — computable client-side, mirrored here for HTTP parity).
23
+ export {};
@@ -1,2 +1,4 @@
1
1
  export * from './backendApiV1.js';
2
2
  export * from './backendApiV2.js';
3
+ export * from './sponsoringApi.js';
4
+ export * from './backendBridgeApiV2.js';
@@ -1,2 +1,4 @@
1
1
  export * from './backendApiV1.js';
2
2
  export * from './backendApiV2.js';
3
+ export * from './sponsoringApi.js';
4
+ export * from './backendBridgeApiV2.js';
@@ -0,0 +1,62 @@
1
+ /** Build parameters enforced by the Stellar sponsoring service. */
2
+ export interface StellarSponsorConfig {
3
+ /** Rotatable sponsor public key; do not hardcode it in clients. */
4
+ sponsorAccount: string;
5
+ networkPassphrase: string;
6
+ minTotalFeeStroops: string;
7
+ maxTotalFeeStroops: string;
8
+ operationCount: number;
9
+ minPerOperationFeeStroops: string;
10
+ maxPerOperationFeeStroops: string;
11
+ /** Fee per operation to pass to `TransactionBuilder`. */
12
+ recommendedPerOperationFeeStroops: string;
13
+ /** Maximum distance from now to the transaction's `maxTime`, in seconds. */
14
+ maxTimeboundSeconds: number;
15
+ /** Required `createAccount.startingBalance`; do not hardcode it. */
16
+ requiredStartingBalance: string;
17
+ }
18
+ /** Request body for a Stellar sponsored account creation. Extra fields are rejected. */
19
+ export interface StellarSponsoredAccountRequest {
20
+ /**
21
+ * Base64 transaction XDR signed by the account being created.
22
+ * Must not be a fee-bump envelope.
23
+ */
24
+ data: string;
25
+ }
26
+ /**
27
+ * Successful sponsored-account result. An already-active account is also a
28
+ * success, but has no submitted transaction hash.
29
+ */
30
+ export type StellarSponsoredAccountResponse = {
31
+ hash: string;
32
+ alreadyActive: false;
33
+ } | {
34
+ hash: null;
35
+ alreadyActive: true;
36
+ };
37
+ export type SponsoringApiErrorCode = 'INVALID_SPONSOR_XDR' | 'INVALID_RESERVE_DATA' | 'SPONSOR_SEQUENCE_CONFLICT' | 'SPONSOR_TRANSACTION_REJECTED' | 'HORIZON_UNAVAILABLE' | 'SPONSOR_RATE_LIMITED' | 'SPONSOR_BUDGET_EXHAUSTED';
38
+ /** Runtime values used to distinguish domain codes from framework error labels. */
39
+ export declare const SPONSORING_API_ERROR_CODES: readonly ["INVALID_SPONSOR_XDR", "INVALID_RESERVE_DATA", "SPONSOR_SEQUENCE_CONFLICT", "SPONSOR_TRANSACTION_REJECTED", "HORIZON_UNAVAILABLE", "SPONSOR_RATE_LIMITED", "SPONSOR_BUDGET_EXHAUSTED"];
40
+ /**
41
+ * `error` may be a domain code, a framework label, or absent. Check it
42
+ * against {@link SPONSORING_API_ERROR_CODES} before treating it as a code.
43
+ */
44
+ export interface SponsoringApiErrorResponse {
45
+ statusCode: number;
46
+ /** Human-readable only; do not use for control flow. */
47
+ message: string;
48
+ error?: SponsoringApiErrorCode | string;
49
+ /** Per-key rate-limit backoff in seconds. */
50
+ retryAfterSeconds?: number;
51
+ /**
52
+ * Current sponsor sequence on a sequence conflict. Advisory because another
53
+ * submission can immediately make it stale.
54
+ */
55
+ sponsorSequence?: string;
56
+ }
57
+ export interface IStellarSponsoringApi<GetConfigArgs extends unknown[] = [], CreateAccountArgs extends unknown[] = []> {
58
+ /** GET /sponsorships/stellar/config */
59
+ getStellarSponsorConfig(...extraArgs: GetConfigArgs): Promise<StellarSponsorConfig>;
60
+ /** POST /sponsorships/stellar/accounts */
61
+ createStellarSponsoredAccount(body: StellarSponsoredAccountRequest, ...extraArgs: CreateAccountArgs): Promise<StellarSponsoredAccountResponse>;
62
+ }
@@ -0,0 +1,12 @@
1
+ /** Runtime values used to distinguish domain codes from framework error labels. */
2
+ export const SPONSORING_API_ERROR_CODES = [
3
+ 'INVALID_SPONSOR_XDR',
4
+ 'INVALID_RESERVE_DATA',
5
+ 'SPONSOR_SEQUENCE_CONFLICT',
6
+ 'SPONSOR_TRANSACTION_REJECTED',
7
+ 'HORIZON_UNAVAILABLE',
8
+ 'SPONSOR_RATE_LIMITED',
9
+ 'SPONSOR_BUDGET_EXHAUSTED',
10
+ ];
11
+ // Keep the runtime list exhaustive.
12
+ true;
@@ -1,4 +1,24 @@
1
1
  import type { ICoreWallet } from '../wallet/wallet.js';
2
+ import type { XToken } from '../chains/tokens.js';
3
+ /**
4
+ * Bitcoin protocol dust limit, in satoshis. Any native-BTC output below this is "dust" — economically
5
+ * unspendable, and nodes/relays reject transactions that create it. Native-BTC deposits (Bitcoin as the
6
+ * source) and deliveries (Bitcoin as the destination) must clear this threshold. Single source of truth
7
+ * for the value; number-based UTXO math converts it with `Number(...)`.
8
+ */
9
+ export declare const BITCOIN_DUST_SATS = 546n;
10
+ /**
11
+ * True when `token` (an address or symbol) is native BTC for the given Bitcoin chain config, matched
12
+ * against the config's own native identifiers — the literal 'btc', its `nativeToken` symbol, and the
13
+ * BTC token address (e.g. '0:0') — all case-insensitively. Single source of truth for native-BTC
14
+ * identity so the deposit-PSBT builder and the swap/bridge dust-limit guard never drift. Note: the
15
+ * generic `isNativeToken` cannot be used here because Bitcoin's `nativeToken` is a symbol, not an
16
+ * on-chain address.
17
+ */
18
+ export declare function isNativeBitcoinToken(chainConfig: {
19
+ nativeToken: string;
20
+ supportedTokens: Partial<Record<string, XToken>>;
21
+ }, token: string): boolean;
2
22
  /** Check whether an AddressType is supported for signing/spending. */
3
23
  export declare function isSupportedBitcoinAddressType(addressType: string): addressType is BtcAddressType;
4
24
  /**
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Bitcoin protocol dust limit, in satoshis. Any native-BTC output below this is "dust" — economically
3
+ * unspendable, and nodes/relays reject transactions that create it. Native-BTC deposits (Bitcoin as the
4
+ * source) and deliveries (Bitcoin as the destination) must clear this threshold. Single source of truth
5
+ * for the value; number-based UTXO math converts it with `Number(...)`.
6
+ */
7
+ export const BITCOIN_DUST_SATS = 546n;
8
+ /**
9
+ * True when `token` (an address or symbol) is native BTC for the given Bitcoin chain config, matched
10
+ * against the config's own native identifiers — the literal 'btc', its `nativeToken` symbol, and the
11
+ * BTC token address (e.g. '0:0') — all case-insensitively. Single source of truth for native-BTC
12
+ * identity so the deposit-PSBT builder and the swap/bridge dust-limit guard never drift. Note: the
13
+ * generic `isNativeToken` cannot be used here because Bitcoin's `nativeToken` is a symbol, not an
14
+ * on-chain address.
15
+ */
16
+ export function isNativeBitcoinToken(chainConfig, token) {
17
+ const nativeBtcTokens = new Set(['btc', chainConfig.nativeToken, chainConfig.supportedTokens.BTC?.address]
18
+ .filter((value) => !!value)
19
+ .map(value => value.toLowerCase()));
20
+ return nativeBtcTokens.has(token.toLowerCase());
21
+ }
1
22
  /** Check whether an AddressType is supported for signing/spending. */
2
23
  export function isSupportedBitcoinAddressType(addressType) {
3
24
  return BTC_ADDRESS_TYPES.includes(addressType);
@@ -755,7 +755,7 @@ export declare const spokeChainConfig: {
755
755
  readonly name: "Soda RBNT";
756
756
  readonly decimals: 18;
757
757
  readonly address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
758
- readonly chainKey: "redbelly";
758
+ readonly chainKey: "sonic";
759
759
  readonly hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
760
760
  readonly vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
761
761
  };
@@ -3762,7 +3762,7 @@ export declare const hubConfig: {
3762
3762
  readonly name: "Soda RBNT";
3763
3763
  readonly decimals: 18;
3764
3764
  readonly address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
3765
- readonly chainKey: "redbelly";
3765
+ readonly chainKey: "sonic";
3766
3766
  readonly hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
3767
3767
  readonly vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
3768
3768
  };
@@ -205,7 +205,7 @@ export declare const SodaTokens: {
205
205
  readonly name: "Soda RBNT";
206
206
  readonly decimals: 18;
207
207
  readonly address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
208
- readonly chainKey: "redbelly";
208
+ readonly chainKey: "sonic";
209
209
  readonly hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
210
210
  readonly vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
211
211
  };
@@ -535,7 +535,7 @@ export declare const sonicSupportedTokens: {
535
535
  readonly name: "Soda RBNT";
536
536
  readonly decimals: 18;
537
537
  readonly address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
538
- readonly chainKey: "redbelly";
538
+ readonly chainKey: "sonic";
539
539
  readonly hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
540
540
  readonly vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
541
541
  };
@@ -2886,7 +2886,7 @@ export declare const supportedTokensByChain: {
2886
2886
  readonly name: "Soda RBNT";
2887
2887
  readonly decimals: 18;
2888
2888
  readonly address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
2889
- readonly chainKey: "redbelly";
2889
+ readonly chainKey: "sonic";
2890
2890
  readonly hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
2891
2891
  readonly vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
2892
2892
  };
@@ -214,7 +214,7 @@ export const SodaTokens = {
214
214
  name: 'Soda RBNT',
215
215
  decimals: 18,
216
216
  address: '0x4B207114F9118dEAC56436e1aE3c45648783c7Ac',
217
- chainKey: ChainKeys.REDBELLY_MAINNET,
217
+ chainKey: ChainKeys.SONIC_MAINNET,
218
218
  hubAsset: '0x4B207114F9118dEAC56436e1aE3c45648783c7Ac',
219
219
  vault: '0x4B207114F9118dEAC56436e1aE3c45648783c7Ac',
220
220
  },
@@ -3,7 +3,7 @@ import type { ChainKey, ChainKeys, ChainType } from '../chains/chain-keys.js';
3
3
  import type { GetChainType, SpokeChainConfig, spokeChainConfig, SpokeChainKey, IconAddress } from '../chains/chains.js';
4
4
  import type { XToken } from '../chains/tokens.js';
5
5
  import type { EvmRawTransaction, EvmReturnType } from '../evm/evm.js';
6
- import type { BitcoinReturnType } from '../bitcoin/bitcoin.js';
6
+ import type { BitcoinRawTransaction, BitcoinReturnType } from '../bitcoin/bitcoin.js';
7
7
  import type { IconRawTransaction, IconReturnType } from '../icon/icon.js';
8
8
  import type { InjectiveRawTransaction, InjectiveReturnType } from '../injective/injective.js';
9
9
  import type { NearRawTransaction, NearReturnType } from '../near/near.js';
@@ -138,7 +138,18 @@ export declare enum SolverIntentErrorCode {
138
138
  UNKNOWN = -999
139
139
  }
140
140
  export type HashTxReturnType = EvmReturnType<false> | SolanaReturnType<false> | IconReturnType<false> | SuiReturnType<false> | InjectiveReturnType<false> | StellarReturnType<false> | StacksReturnType<false> | NearReturnType<false>;
141
- export type RawTxReturnType = EvmRawTransaction | SolanaRawTransaction | InjectiveRawTransaction | IconRawTransaction | SuiRawTransaction | StellarRawTransaction | StacksRawTransaction | NearRawTransaction;
141
+ /**
142
+ * Fallback raw-tx union for {@link TxReturnType} (which prefers a chain-keyed branch), and the declared
143
+ * shape of the backend APIs' unsigned `tx` response field, where the chain is only known from the
144
+ * request's `srcChainKey` at runtime.
145
+ *
146
+ * `BitcoinRawTransaction` is listed even though it is currently structurally identical to
147
+ * `SolanaRawTransaction` (both `{ from: string; to: string; value: bigint; data: string }`) and so would
148
+ * be absorbed by it: Bitcoin is a supported raw-tx source, and naming it keeps that a stated part of the
149
+ * contract rather than a coincidence that would silently lapse if the Solana member's string aliases were
150
+ * ever branded.
151
+ */
152
+ export type RawTxReturnType = EvmRawTransaction | SolanaRawTransaction | InjectiveRawTransaction | IconRawTransaction | SuiRawTransaction | StellarRawTransaction | StacksRawTransaction | NearRawTransaction | BitcoinRawTransaction;
142
153
  export type GetDefaultTxReturnType<Raw extends boolean> = Raw extends true ? RawTxReturnType : HashTxReturnType;
143
154
  /**
144
155
  * Return type for a transaction based on the given ChainId or ChainType.
@@ -15,6 +15,12 @@ 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
+ /**
19
+ * Gateway base URL, including its deployment-owned version prefix.
20
+ */
21
+ export declare const DEFAULT_SPONSORING_API_ENDPOINT = "https://api.sodax.com/v1";
22
+ /** Stellar sponsorship route relative to the configured base URL. */
23
+ export declare const SPONSORING_API_STELLAR_BASE_PATH = "/sponsorships/stellar";
18
24
  export type BaseApiConfig = {
19
25
  baseURL: HttpUrl;
20
26
  timeout: number;
@@ -23,18 +29,28 @@ export type BaseApiConfig = {
23
29
  /** Per-endpoint config for the swaps API. Structurally identical to {@link BaseApiConfig}. */
24
30
  export type SwapsApiConfig = BaseApiConfig;
25
31
  /**
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.
32
+ * Independently routed sponsoring config. `baseURL` includes any deployment
33
+ * prefix; `apiKey` becomes `x-api-key`. Browser-bundled keys are public.
34
+ */
35
+ export type SponsoringApiConfig = BaseApiConfig & {
36
+ apiKey?: string;
37
+ };
38
+ /**
39
+ * Independent service configs. At least one slice is required to keep this
40
+ * union distinct from flat {@link BaseApiConfig}.
31
41
  */
32
42
  export type CustomApiConfig = {
33
43
  baseApiConfig: BaseApiConfig;
34
44
  swapsApiConfig?: SwapsApiConfig;
45
+ sponsoringApiConfig?: SponsoringApiConfig;
35
46
  } | {
36
47
  baseApiConfig?: BaseApiConfig;
37
48
  swapsApiConfig: SwapsApiConfig;
49
+ sponsoringApiConfig?: SponsoringApiConfig;
50
+ } | {
51
+ baseApiConfig?: BaseApiConfig;
52
+ swapsApiConfig?: SwapsApiConfig;
53
+ sponsoringApiConfig: SponsoringApiConfig;
38
54
  };
39
55
  export type ApiConfig = BaseApiConfig | CustomApiConfig;
40
56
  export declare const apiConfig: {
@@ -14,6 +14,12 @@ export const DEFAULT_BACKEND_API_HEADERS = {
14
14
  };
15
15
  export const DEFAULT_RELAYER_API_ENDPOINT = 'https://xcall-relay.nw.iconblockchain.xyz';
16
16
  export const VAULT_TOKEN_DECIMALS = 18;
17
+ /**
18
+ * Gateway base URL, including its deployment-owned version prefix.
19
+ */
20
+ export const DEFAULT_SPONSORING_API_ENDPOINT = 'https://api.sodax.com/v1';
21
+ /** Stellar sponsorship route relative to the configured base URL. */
22
+ export const SPONSORING_API_STELLAR_BASE_PATH = '/sponsorships/stellar';
17
23
  export const apiConfig = {
18
24
  baseURL: DEFAULT_BACKEND_API_ENDPOINT,
19
25
  timeout: DEFAULT_BACKEND_API_TIMEOUT,
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 = 220;
22
+ export declare const CONFIG_VERSION = 222;
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 = 220; // this value should be incremented (inside release/sdk branch) each time @sodax/types package is updated
22
+ export const CONFIG_VERSION = 222; // this value should be incremented (inside release/sdk branch) each time @sodax/types package is updated
@@ -948,7 +948,7 @@ export declare const moneyMarketSupportedTokens: {
948
948
  readonly name: "Soda RBNT";
949
949
  readonly decimals: 18;
950
950
  readonly address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
951
- readonly chainKey: "redbelly";
951
+ readonly chainKey: "sonic";
952
952
  readonly hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
953
953
  readonly vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
954
954
  } | {
@@ -2352,7 +2352,7 @@ export declare const moneyMarketConfig: {
2352
2352
  readonly name: "Soda RBNT";
2353
2353
  readonly decimals: 18;
2354
2354
  readonly address: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
2355
- readonly chainKey: "redbelly";
2355
+ readonly chainKey: "sonic";
2356
2356
  readonly hubAsset: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
2357
2357
  readonly vault: "0x4B207114F9118dEAC56436e1aE3c45648783c7Ac";
2358
2358
  } | {