@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 +21 -0
- package/README.md +65 -0
- package/dist/index.d.mts +323 -0
- package/dist/index.d.ts +323 -0
- package/dist/index.js +6346 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6321 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
|
@@ -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 };
|