@stableflow/bridges 0.0.0-experimental-5a8afd7389-20260703

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 StableFlow AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @stableflow/bridges
2
+
3
+ StableFlow bridge services: OneClick, CCTP, USDT0, FraxZero, Native, and composite routes.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @stableflow/bridges @stableflow/core
9
+ ```
10
+
11
+ Also install the wallet adapter(s) for the chains you support (e.g. `@stableflow/wallet-evm`).
12
+
13
+ ## When to use
14
+
15
+ Use this package when you need:
16
+
17
+ - **Multi-route quotes** across all supported bridge services (`BridgeSFA.getAllQuote`)
18
+ - **Unified send and status** for a selected route (`BridgeSFA.send`, `BridgeSFA.getStatus`)
19
+ - Low-level access to individual bridge implementations via `ServiceMap`
20
+
21
+ For HTTP-only quote/status without wallet orchestration, [`@stableflow/core`](../core/README.md) `SFA` may be enough.
22
+
23
+ ## Main exports
24
+
25
+ | Export | Description |
26
+ |--------|-------------|
27
+ | `BridgeSFA` | Multi-route quote, send, and status |
28
+ | `GetAllQuoteParams` | Parameters for `getAllQuote` |
29
+ | `ServiceMap` | Per-service `quote` / `send` / `getStatus` implementations |
30
+ | `getQuoteModes` | Helpers to interpret quote shape (OneClick, exact output, etc.) |
31
+ | Utilities | `formatQuoteError`, `addressToBytes32`, `quoteSignature`, `formatNumber` |
32
+ | USDT0 / FraxZero | `USDT0_CONFIG`, `OFT_ABI`, `getHopMsgFee`, `FRAXZERO_MIDDLE_TOKEN_*`, … |
33
+
34
+ Supported `Service` values (from `@stableflow/core`): `oneclick`, `usdt0`, `cctp`, `fraxzero`, composite routes (`usdt0-oneclick`, `oneclick-usdt0`, `fraxzero-oneclick`, `oneclick-fraxzero`), and `native`.
35
+
36
+ See `dist/index.d.ts` after `pnpm build`.
37
+
38
+ ## Quick example
39
+
40
+ ```ts
41
+ import { BridgeSFA } from '@stableflow/bridges';
42
+ import { EVMWallet } from '@stableflow/wallet-evm';
43
+
44
+ const wallet = new EVMWallet(/* provider */);
45
+
46
+ const results = await BridgeSFA.getAllQuote({
47
+ dry: true, // fast comparison; use dry: false before send
48
+ prices: { ETH: '3000', BNB: '900' },
49
+ fromToken,
50
+ toToken,
51
+ wallet: wallet.wallet,
52
+ recipient: '0x...',
53
+ refundTo: '0x...',
54
+ amountWei: '1000000',
55
+ slippageTolerance: 0.5,
56
+ });
57
+
58
+ const txHash = await BridgeSFA.send(serviceType, { wallet: wallet.wallet, quote });
59
+ const status = await BridgeSFA.getStatus(serviceType, { quote, hash: txHash });
60
+ ```
61
+
62
+ ## See also
63
+
64
+ - [Developer Guide](../../DEVELOPER_GUIDE.md) — `dry` flag, wallet integration, Hyperliquid
65
+ - [@stableflow/core](../core/README.md)
@@ -0,0 +1,323 @@
1
+ import * as _stableflow_core from '@stableflow/core';
2
+ import { Service, TokenConfig, WalletConfig, CancelablePromise, SubmitDepositTxResponse, TransactionStatus } from '@stableflow/core';
3
+ import Big from 'big.js';
4
+
5
+ declare const ServiceMap: Record<Service, any>;
6
+
7
+ /**
8
+ * Serializable, unsigned EVM transaction data.
9
+ *
10
+ * This is what an API-driven custody integrator (e.g. an MPC wallet such as
11
+ * Fireblocks) receives. Stableflow builds the calldata; the integrator signs
12
+ * and broadcasts it through their own infrastructure, then reports the
13
+ * resulting hash back via `BridgeSFA.report`.
14
+ */
15
+ interface EvmTxData {
16
+ chainId: number;
17
+ from: string;
18
+ to: string;
19
+ /** Hex-encoded calldata. `0x` for a plain native-token transfer. */
20
+ data: string;
21
+ /** Native token amount in wei, as a decimal string. */
22
+ value: string;
23
+ /** Optional gas limit as a decimal string. */
24
+ gasLimit?: string;
25
+ }
26
+ /**
27
+ * EIP-712 typed data for an ERC20 `Permit`, returned unsigned so an external
28
+ * signer (MPC/Fireblocks) can produce the signature. Nothing is signed or
29
+ * verified inside the SDK for this payload.
30
+ */
31
+ interface PermitTypedData {
32
+ domain: {
33
+ name: string;
34
+ version: string;
35
+ chainId: number;
36
+ verifyingContract: string;
37
+ };
38
+ types: Record<string, Array<{
39
+ name: string;
40
+ type: string;
41
+ }>>;
42
+ values: {
43
+ owner: string;
44
+ spender: string;
45
+ value: string;
46
+ nonce: string;
47
+ deadline: number;
48
+ };
49
+ deadline: number;
50
+ nonce: number;
51
+ token: string;
52
+ spender: string;
53
+ owner: string;
54
+ }
55
+ /**
56
+ * Result of `BridgeSFA.buildTransaction`.
57
+ *
58
+ * Depending on the route, the integrator may need to: broadcast `approveTx`
59
+ * (optionally `approveResetTx` first on Ethereum), sign `permitTypedData`,
60
+ * and always broadcast the main `tx`. See `BridgeSFA.buildTransaction`.
61
+ */
62
+ interface BuildTransactionResult {
63
+ chainId: number;
64
+ from: string;
65
+ /** Present when `quote.needApprove === true`. */
66
+ approveTx?: EvmTxData;
67
+ /**
68
+ * Present when `quote.needApprove === true` and the source chain is Ethereum.
69
+ * Some Ethereum tokens (e.g. USDT) require resetting the allowance to 0
70
+ * before setting a new non-zero allowance.
71
+ */
72
+ approveResetTx?: EvmTxData;
73
+ /** Present when `quote.needPermit === true`. Must be signed off-chain. */
74
+ permitTypedData?: PermitTypedData;
75
+ /** The main source-chain transaction to sign and broadcast. */
76
+ tx: EvmTxData;
77
+ }
78
+ /**
79
+ * Build the main unsigned source-chain transaction from a quote, mirroring the
80
+ * branching in `BridgeSFA.send` but producing serializable calldata instead of
81
+ * signing/broadcasting.
82
+ */
83
+ declare const buildSendTx: (serviceType: Service, quote: any) => EvmTxData;
84
+ /**
85
+ * Build the ERC20 approve transaction(s) for a quote that requires approval.
86
+ * On Ethereum an additional `approveResetTx` (approve 0) is returned so the
87
+ * integrator can reset a stale allowance before setting a new one.
88
+ */
89
+ declare const buildApproveTx: (serviceType: Service, quote: any) => {
90
+ approveTx?: EvmTxData;
91
+ approveResetTx?: EvmTxData;
92
+ };
93
+ /**
94
+ * Build the EIP-712 `Permit` typed data for a permit-required route, returned
95
+ * unsigned. The integrator signs it with their MPC/Fireblocks signer, splits
96
+ * the signature into `v/r/s`, and passes the assembled `permitSignature` to
97
+ * `BridgeSFA.report`.
98
+ */
99
+ declare const buildPermitTypedData: (params: {
100
+ permitToken: TokenConfig;
101
+ permitAmountWei: string;
102
+ permitSpender: string;
103
+ owner: string;
104
+ }) => Promise<PermitTypedData>;
105
+
106
+ /**
107
+ * Normalized ERC20 permit signature passed to `BridgeSFA.send` / `BridgeSFA.report`
108
+ * when a route requires a permit (`quote.needPermit === true`).
109
+ */
110
+ interface PermitSignature {
111
+ amount: string;
112
+ deadline: number;
113
+ nonce: string;
114
+ owner: string;
115
+ r: string;
116
+ s: string;
117
+ v: 27 | 28;
118
+ }
119
+ interface GetAllQuoteParams {
120
+ singleService?: Service;
121
+ disabledServices?: Service[];
122
+ dry?: boolean;
123
+ prices: Record<string, string>;
124
+ fromToken: TokenConfig;
125
+ toToken: TokenConfig;
126
+ wallet: WalletConfig;
127
+ evmWallet?: WalletConfig | null;
128
+ evmAddress?: string | null;
129
+ recipient: string;
130
+ refundTo: string;
131
+ amountWei: string;
132
+ slippageTolerance: number;
133
+ minInputAmount?: string;
134
+ /** @deprecated Please migrate to oneclickParams */
135
+ appFees?: {
136
+ recipient: string;
137
+ fee: number;
138
+ }[];
139
+ oneclickParams?: {
140
+ appFees?: {
141
+ recipient: string;
142
+ fee: number;
143
+ }[];
144
+ swapType?: "EXACT_INPUT" | "EXACT_OUTPUT" | "FLEX_INPUT";
145
+ isProxy?: boolean;
146
+ };
147
+ }
148
+ /**
149
+ * Full cross-chain bridge API (multi-route quote, send, status).
150
+ * Install `@stableflow/bridges` alongside `@stableflow/core`.
151
+ */
152
+ declare class BridgeSFA {
153
+ static getAllQuote(params: GetAllQuoteParams): Promise<Array<{
154
+ serviceType: Service;
155
+ quote?: any;
156
+ error?: string;
157
+ }>>;
158
+ static send(serviceType: Service, params: {
159
+ wallet: any;
160
+ quote: any;
161
+ permitSignature?: PermitSignature;
162
+ }): Promise<string>;
163
+ /**
164
+ * Build the backend report payload for a submitted source-chain transaction.
165
+ * Shared by `send` (fire-and-forget) and `report` (awaited).
166
+ */
167
+ private static buildReportData;
168
+ /**
169
+ * API-driven custody: build the serializable, unsigned transaction data for a
170
+ * route WITHOUT a signer. Intended for MPC wallets (e.g. Fireblocks) that sign
171
+ * and broadcast through their own infrastructure.
172
+ *
173
+ * Returns any required `approveTx` (and `approveResetTx` on Ethereum), the
174
+ * `permitTypedData` to sign off-chain when `quote.needPermit`, and the main
175
+ * `tx`. After the integrator broadcasts `tx`, call `BridgeSFA.report` with the
176
+ * resulting hash (and the permit signature, if any) so StableFlow can execute
177
+ * the destination leg.
178
+ *
179
+ * EVM only for now; non-EVM source chains throw.
180
+ */
181
+ static buildTransaction(serviceType: Service, params: {
182
+ quote: any;
183
+ }): Promise<BuildTransactionResult>;
184
+ /**
185
+ * API-driven custody: report an externally signed & broadcast source-chain
186
+ * transaction back to StableFlow so it can track and execute the destination
187
+ * leg. Pair with `BridgeSFA.buildTransaction`.
188
+ *
189
+ * When `quote.needPermit === true`, `permitSignature` is required.
190
+ */
191
+ static report(serviceType: Service, params: {
192
+ quote: any;
193
+ hash: string;
194
+ permitSignature?: PermitSignature;
195
+ }): CancelablePromise<SubmitDepositTxResponse>;
196
+ static getStatus(serviceType: Service, params: {
197
+ quote: any;
198
+ hash: string;
199
+ }): Promise<{
200
+ status: TransactionStatus;
201
+ toChainTxHash?: string;
202
+ }>;
203
+ }
204
+
205
+ interface LayerZeroChainConfig {
206
+ eid: number;
207
+ chainKey: string;
208
+ blockTime: number;
209
+ }
210
+
211
+ declare const getQuoteModes: (params: {
212
+ quoteData?: any;
213
+ bridgeStore?: {
214
+ quoteDataService: Service;
215
+ };
216
+ }) => {
217
+ isExactOutput: boolean;
218
+ isOneClickService: boolean;
219
+ isQuoteParamDepositAddress: boolean;
220
+ isPermitWithNonce: boolean;
221
+ };
222
+
223
+ declare function addressToBytes32(chainType: string, address: string): string;
224
+
225
+ declare const formatQuoteError: (error: any, options: {
226
+ service: Service;
227
+ fromToken: TokenConfig;
228
+ }) => {
229
+ serviceType: "oneclick";
230
+ error: string;
231
+ } | {
232
+ serviceType: "usdt0" | "cctp" | "fraxzero" | "fraxzero-oneclick" | "oneclick-fraxzero" | "usdt0-oneclick" | "oneclick-usdt0" | "native";
233
+ error: any;
234
+ };
235
+
236
+ declare function quoteSignature(params: any): Promise<any>;
237
+
238
+ declare const formatNumber: (value: string | number | Big.Big | undefined, precision: number, isSimple?: boolean, options?: {
239
+ prefix?: string;
240
+ isLTIntegerZero?: boolean;
241
+ isZeroPrecision?: boolean;
242
+ isShort?: boolean;
243
+ isShortUppercase?: boolean;
244
+ round?: Big.RoundingMode;
245
+ isLessPrecision?: boolean;
246
+ }) => any;
247
+
248
+ declare const getHopMsgFee: (params: any) => Promise<bigint>;
249
+
250
+ interface Usdt0Config extends LayerZeroChainConfig {
251
+ contractAddress: string;
252
+ oft?: string;
253
+ oftLegacy?: string;
254
+ oftMultiHopComposer?: string;
255
+ oftTetherTokenOFTExtension?: string;
256
+ confirmations: number;
257
+ lzReceiveOptionGas: number;
258
+ lzReceiveOptionGasLegacy: number;
259
+ composeOptionGas?: number;
260
+ oftApprovalRequired?: boolean;
261
+ oftLegacyApprovalRequired?: boolean;
262
+ }
263
+ declare const USDT0_CONFIG: Record<string, Usdt0Config>;
264
+ declare const LZ_RECEIVE_VALUE: Record<string, any>;
265
+ declare const USDT0_LEGACY_MESH_TRANSFTER_FEE = 0.0003;
266
+ declare const DATA_HEX_PROTOBUF_EXTRA = 3;
267
+ declare const SIGNATURE_SIZE = 67;
268
+
269
+ declare const OFT_ABI: ({
270
+ inputs: never[];
271
+ name: string;
272
+ outputs: {
273
+ internalType: string;
274
+ name: string;
275
+ type: string;
276
+ }[];
277
+ stateMutability: string;
278
+ type: string;
279
+ } | {
280
+ inputs: ({
281
+ components: {
282
+ internalType: string;
283
+ name: string;
284
+ type: string;
285
+ }[];
286
+ internalType: string;
287
+ name: string;
288
+ type: string;
289
+ } | {
290
+ internalType: string;
291
+ name: string;
292
+ type: string;
293
+ components?: undefined;
294
+ })[];
295
+ name: string;
296
+ outputs: {
297
+ components: ({
298
+ internalType: string;
299
+ name: string;
300
+ type: string;
301
+ components?: undefined;
302
+ } | {
303
+ components: {
304
+ internalType: string;
305
+ name: string;
306
+ type: string;
307
+ }[];
308
+ internalType: string;
309
+ name: string;
310
+ type: string;
311
+ })[];
312
+ internalType: string;
313
+ name: string;
314
+ type: string;
315
+ }[];
316
+ stateMutability: string;
317
+ type: string;
318
+ })[];
319
+
320
+ declare const FRAXZERO_MIDDLE_TOKEN_USDC: _stableflow_core.TokenConfig;
321
+ declare const FRAXZERO_MIDDLE_TOKEN_FRXUSD: _stableflow_core.TokenConfig;
322
+
323
+ export { BridgeSFA, type BuildTransactionResult, DATA_HEX_PROTOBUF_EXTRA, type EvmTxData, FRAXZERO_MIDDLE_TOKEN_FRXUSD, FRAXZERO_MIDDLE_TOKEN_USDC, type GetAllQuoteParams, LZ_RECEIVE_VALUE, OFT_ABI, type PermitSignature, type PermitTypedData, SIGNATURE_SIZE, ServiceMap, USDT0_CONFIG, USDT0_LEGACY_MESH_TRANSFTER_FEE, addressToBytes32, buildApproveTx, buildPermitTypedData, buildSendTx, formatNumber, formatQuoteError, getHopMsgFee, getQuoteModes, quoteSignature };