@stablechain/sdk 1.0.5 → 1.0.6
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 +129 -8
- package/dist/index.cjs +426 -158
- package/dist/index.d.cts +148 -17
- package/dist/index.d.ts +148 -17
- package/dist/index.js +416 -148
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -103,20 +103,96 @@ declare enum Network {
|
|
|
103
103
|
Testnet = "testnet"
|
|
104
104
|
}
|
|
105
105
|
interface BridgeQuote {
|
|
106
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Amount the recipient is expected to receive on the destination chain.
|
|
108
|
+
*
|
|
109
|
+
* On native OFT routes this is `oft.amountReceivedLD` — the input minus any
|
|
110
|
+
* OFT-level fee and minus dust removed by decimal conversion — and falls back
|
|
111
|
+
* to the input amount when `quoteOFT` could not be read.
|
|
112
|
+
*/
|
|
107
113
|
toAmount?: number;
|
|
108
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* LayerZero messaging fee (wei of the source chain's native token) — only
|
|
116
|
+
* present for native OFT routes. This is the whole `MessagingFee.nativeFee`
|
|
117
|
+
* that `send` must be called with: DVN fees, executor fee and any requested
|
|
118
|
+
* destination native drop, bundled. `quoteSend` returns no breakdown of it.
|
|
119
|
+
*/
|
|
109
120
|
nativeFee?: bigint;
|
|
110
|
-
/** LayerZero fee paid in LZ token (wei) — only present for
|
|
121
|
+
/** LayerZero fee paid in LZ token (wei) — only present for native OFT routes */
|
|
111
122
|
lzTokenFee?: bigint;
|
|
112
123
|
/**
|
|
113
|
-
*
|
|
124
|
+
* OFT-level accounting for the send: what the adapter itself debits, credits
|
|
125
|
+
* and charges, independent of the LayerZero messaging fee. Only present for
|
|
126
|
+
* native OFT routes, and omitted when the `quoteOFT` read failed.
|
|
127
|
+
*/
|
|
128
|
+
oft?: BridgeOftQuote;
|
|
129
|
+
/**
|
|
130
|
+
* Source-chain execution cost of the `send` transaction. Only present for
|
|
131
|
+
* native OFT routes, and omitted when neither simulation nor fallback could
|
|
132
|
+
* produce a number. Excludes {@link BridgeQuote.nativeFee}.
|
|
133
|
+
*/
|
|
134
|
+
srcGas?: BridgeGasEstimate;
|
|
135
|
+
/**
|
|
136
|
+
* Everything the sender pays out of their native balance, in wei:
|
|
137
|
+
* `srcGas.costWei + nativeFee`. Present only when both parts are known.
|
|
138
|
+
*/
|
|
139
|
+
totalCostWei?: bigint;
|
|
140
|
+
/**
|
|
141
|
+
* How long the bridge is expected to take. Only present for native OFT routes,
|
|
114
142
|
* and omitted if the estimate could not be resolved — never treat it as required.
|
|
115
143
|
*/
|
|
116
144
|
estimate?: BridgeTimeEstimate;
|
|
117
145
|
}
|
|
118
146
|
/**
|
|
119
|
-
*
|
|
147
|
+
* One fee the OFT itself reports for a send, from `quoteOFT`'s `oftFeeDetails`.
|
|
148
|
+
*
|
|
149
|
+
* Every pathway in BRIDGE_CHAIN_CONFIGS reported none when checked on 2026-08-20
|
|
150
|
+
* (Ethereum, Stable, Arbitrum and Plasma adapters), so an empty `fees` array is the
|
|
151
|
+
* normal case rather than a failed read. A deployment that does charge at the OFT
|
|
152
|
+
* level — the kind of thing a bridge UI shows as its own fee row — reports it here
|
|
153
|
+
* rather than inside the LayerZero messaging fee.
|
|
154
|
+
*/
|
|
155
|
+
interface BridgeOftFee {
|
|
156
|
+
/** Fee in the source token's smallest unit. Negative means a credit, not a charge. */
|
|
157
|
+
amountLD: bigint;
|
|
158
|
+
/** Human-readable amount, same sign convention as {@link BridgeOftFee.amountLD} */
|
|
159
|
+
amount: number;
|
|
160
|
+
/** Whatever the adapter calls this fee — its own string, shown as-is */
|
|
161
|
+
description: string;
|
|
162
|
+
}
|
|
163
|
+
/** What the OFT adapter reports for a send, read from `quoteOFT`. */
|
|
164
|
+
interface BridgeOftQuote {
|
|
165
|
+
/** Amount debited on the source chain, in the source token's smallest unit */
|
|
166
|
+
amountSentLD: bigint;
|
|
167
|
+
/** Amount credited on the destination chain, in the source token's smallest unit */
|
|
168
|
+
amountReceivedLD: bigint;
|
|
169
|
+
/** Human-readable {@link BridgeOftQuote.amountReceivedLD} */
|
|
170
|
+
amountReceived: number;
|
|
171
|
+
/** Fees the adapter charges. Empty on pathways that charge none. */
|
|
172
|
+
fees: BridgeOftFee[];
|
|
173
|
+
/** Smallest amount this pathway accepts, in the source token's smallest unit */
|
|
174
|
+
minAmountLD: bigint;
|
|
175
|
+
/** Largest amount this pathway accepts, in the source token's smallest unit */
|
|
176
|
+
maxAmountLD: bigint;
|
|
177
|
+
}
|
|
178
|
+
/** Source-chain gas for the OFT `send` transaction. */
|
|
179
|
+
interface BridgeGasEstimate {
|
|
180
|
+
/** Gas units */
|
|
181
|
+
gas: bigint;
|
|
182
|
+
/** Price per gas unit (wei) — `maxFeePerGas` where the chain is EIP-1559 */
|
|
183
|
+
gasPriceWei: bigint;
|
|
184
|
+
/** `gas × gasPriceWei` */
|
|
185
|
+
costWei: bigint;
|
|
186
|
+
/**
|
|
187
|
+
* `"simulated"` means `gas` came from simulating the real `send` — trust it.
|
|
188
|
+
* `"fallback"` means the simulation failed (no allowance or no balance yet is
|
|
189
|
+
* the usual reason when quoting before approving) and `gas` is a typical-send
|
|
190
|
+
* constant, so treat the cost as indicative only.
|
|
191
|
+
*/
|
|
192
|
+
source: "simulated" | "fallback";
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Expected end-to-end delivery time for a native (LayerZero OFT) bridge.
|
|
120
196
|
*
|
|
121
197
|
* Almost all of the wait is source-chain finality: the DVNs securing the pathway
|
|
122
198
|
* refuse to attest until the send transaction is buried under `confirmations`
|
|
@@ -159,13 +235,17 @@ interface BridgeStatus {
|
|
|
159
235
|
}
|
|
160
236
|
/**
|
|
161
237
|
* Bridge route selection:
|
|
162
|
-
* - `"
|
|
163
|
-
*
|
|
238
|
+
* - `"oft"` — force the native LayerZero OFT path for whichever asset the token
|
|
239
|
+
* addresses name, USDT0 or XAUt0 (no protocol fee, just gas + LZ messaging fee;
|
|
240
|
+
* slower). Throws if the chain pair has no adapter for that asset.
|
|
241
|
+
* - `"usdt0"` — deprecated alias for `"oft"`, kept for compatibility. It does not
|
|
242
|
+
* restrict the route to USDT0; the token addresses decide the asset.
|
|
164
243
|
* - `"lifi"` — force the LI.FI aggregator path (fast, charges a fee).
|
|
165
|
-
* - `"auto"` — use
|
|
244
|
+
* - `"auto"` — use the native OFT mesh (USDT0 or XAUt0) when both chains deploy
|
|
245
|
+
* the requested asset and the token addresses match, else LI.FI.
|
|
166
246
|
* This is the default.
|
|
167
247
|
*/
|
|
168
|
-
type BridgeRoute = "auto" | "usdt0" | "lifi";
|
|
248
|
+
type BridgeRoute = "auto" | "oft" | "usdt0" | "lifi";
|
|
169
249
|
interface BridgeParams {
|
|
170
250
|
fromChain: Chain;
|
|
171
251
|
toChain: Chain;
|
|
@@ -179,11 +259,26 @@ interface BridgeParams {
|
|
|
179
259
|
/** Recipient address — defaults to the signer */
|
|
180
260
|
recipient?: string;
|
|
181
261
|
/**
|
|
182
|
-
* Which bridge to use. Defaults to "auto" (
|
|
262
|
+
* Which bridge to use. Defaults to "auto" (native OFT when available, else LI.FI).
|
|
183
263
|
* See {@link BridgeRoute}.
|
|
184
264
|
*/
|
|
185
265
|
route?: BridgeRoute;
|
|
186
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* Destination native token (wei) to airdrop to the recipient alongside the
|
|
268
|
+
* tokens — LayerZero's executor native-drop option, what bridge UIs call
|
|
269
|
+
* "gas on destination". Paid for by the sender through a larger
|
|
270
|
+
* {@link BridgeQuote.nativeFee}.
|
|
271
|
+
*
|
|
272
|
+
* Only supported on native OFT routes, and capped per pathway by the
|
|
273
|
+
* executor's configured `nativeCap`: asking for more makes `quoteSend`
|
|
274
|
+
* revert rather than silently clamping.
|
|
275
|
+
*/
|
|
276
|
+
dstNativeDrop?: bigint;
|
|
277
|
+
/**
|
|
278
|
+
* Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to
|
|
279
|
+
* bridge(). Must have been quoted with the same `dstNativeDrop`, since the
|
|
280
|
+
* drop is part of what `nativeFee` pays for.
|
|
281
|
+
*/
|
|
187
282
|
quote?: BridgeQuote;
|
|
188
283
|
}
|
|
189
284
|
interface EarnDepositParams {
|
|
@@ -416,11 +511,14 @@ interface StableClient {
|
|
|
416
511
|
quoteBridge(params: BridgeParams): Promise<BridgeQuote>;
|
|
417
512
|
bridge(params: BridgeParams): Promise<OperationResult>;
|
|
418
513
|
/**
|
|
419
|
-
* Expected delivery time for a
|
|
420
|
-
* Throws for chain pairs with no
|
|
514
|
+
* Expected delivery time for a native OFT (LayerZero) bridge, before sending.
|
|
515
|
+
* Throws for chain pairs with no OFT adapter — LI.FI carries its own ETA.
|
|
516
|
+
*
|
|
517
|
+
* Pass `fromToken`/`toToken` to estimate a specific asset; omitting them
|
|
518
|
+
* estimates the USDT0 pathway.
|
|
421
519
|
*/
|
|
422
|
-
estimateBridgeTime(params: Pick<BridgeParams, "fromChain" | "toChain">): Promise<BridgeTimeEstimate>;
|
|
423
|
-
/** Delivery status of an in-flight
|
|
520
|
+
estimateBridgeTime(params: Pick<BridgeParams, "fromChain" | "toChain"> & Partial<Pick<BridgeParams, "fromToken" | "toToken">>): Promise<BridgeTimeEstimate>;
|
|
521
|
+
/** Delivery status of an in-flight OFT bridge, by source transaction hash. */
|
|
424
522
|
trackBridge(srcTxHash: string): Promise<BridgeStatus>;
|
|
425
523
|
quoteSwap(params: SwapParams): Promise<SwapQuote>;
|
|
426
524
|
swap(params: SwapParams): Promise<OperationResult>;
|
|
@@ -484,9 +582,37 @@ interface ChainConfig {
|
|
|
484
582
|
}
|
|
485
583
|
declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
|
|
486
584
|
|
|
585
|
+
/** An asset with its own LayerZero OFT mesh. Each has separate adapters per chain. */
|
|
586
|
+
type BridgeAsset = "usdt0" | "xaut0";
|
|
587
|
+
/** One asset's deployment on one chain. */
|
|
588
|
+
interface BridgeTokenConfig {
|
|
589
|
+
/** The ERC-20 a holder owns — what gets debited, and approved when required */
|
|
590
|
+
address: Address;
|
|
591
|
+
/** Decimals of that ERC-20 on this chain */
|
|
592
|
+
decimals: number;
|
|
593
|
+
/** The OFT (or OFT Adapter) that escrows-or-burns on send */
|
|
594
|
+
oftAdapter: Address;
|
|
595
|
+
/**
|
|
596
|
+
* Whether `send` pulls the token via `transferFrom` and so needs an allowance.
|
|
597
|
+
* Only the lockbox chain does; remote deployments burn from the caller directly.
|
|
598
|
+
* Undefined means "approve when the allowance is short" — the safe default.
|
|
599
|
+
*/
|
|
600
|
+
approvalRequired?: boolean;
|
|
601
|
+
/** False when the adapter exists but has no outbound send pathways configured */
|
|
602
|
+
lzOutbound?: boolean;
|
|
603
|
+
}
|
|
487
604
|
interface BridgeChainConfig extends ChainConfig {
|
|
488
605
|
lzEid: number;
|
|
489
|
-
/**
|
|
606
|
+
/**
|
|
607
|
+
* Which OFT assets this chain can bridge. A chain may carry one and not the
|
|
608
|
+
* other — BSC has XAUt0 but no USDT0 deployment.
|
|
609
|
+
*/
|
|
610
|
+
tokens: Partial<Record<BridgeAsset, BridgeTokenConfig>>;
|
|
611
|
+
/**
|
|
612
|
+
* The USDT0 adapter. Predates XAUt0 and is part of the exported
|
|
613
|
+
* BRIDGE_CHAIN_CONFIGS surface, so it still means USDT0 specifically —
|
|
614
|
+
* prefer `tokens[asset].oftAdapter`.
|
|
615
|
+
*/
|
|
490
616
|
oftAdapter?: Address;
|
|
491
617
|
/** False when the OFT adapter exists but has no outbound send pathways configured */
|
|
492
618
|
lzOutbound?: boolean;
|
|
@@ -497,6 +623,11 @@ interface BridgeChainConfig extends ChainConfig {
|
|
|
497
623
|
blockTimeSec?: number;
|
|
498
624
|
}
|
|
499
625
|
declare const BRIDGE_CHAIN_CONFIGS: Partial<Record<Chain, BridgeChainConfig>>;
|
|
626
|
+
/**
|
|
627
|
+
* Which OFT asset a token address refers to on a chain, or undefined when the
|
|
628
|
+
* chain has no OFT deployment matching it.
|
|
629
|
+
*/
|
|
630
|
+
declare function bridgeAssetFor(cfg: BridgeChainConfig, token: string): BridgeAsset | undefined;
|
|
500
631
|
/** Drop cached pathway configs and observed timings — forces the next estimate to refetch. */
|
|
501
632
|
declare function clearBridgeEstimateCache(): void;
|
|
502
633
|
|
|
@@ -560,4 +691,4 @@ declare class StableBulkError extends StableError {
|
|
|
560
691
|
});
|
|
561
692
|
}
|
|
562
693
|
|
|
563
|
-
export { BRIDGE_CHAIN_CONFIGS, type BridgeChainConfig, type BridgeDeliveryState, type BridgeParams, type BridgeQuote, type BridgeRoute, type BridgeStatus, type BridgeTimeEstimate, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, type BulkWithdrawOptions, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositCalldata, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawCalldata, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, type MerklClaimCalldata, type MerklClaimResult, type MerklReward, type MerklRewardToken, type MerklRewardsResult, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type VaultYield, type VaultYieldReward, type WithdrawStatus, type YieldPreview, clearBridgeEstimateCache, createStable, createStableReader, erc3009Actions };
|
|
694
|
+
export { BRIDGE_CHAIN_CONFIGS, type BridgeAsset, type BridgeChainConfig, type BridgeDeliveryState, type BridgeGasEstimate, type BridgeOftFee, type BridgeOftQuote, type BridgeParams, type BridgeQuote, type BridgeRoute, type BridgeStatus, type BridgeTimeEstimate, type BridgeTokenConfig, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, type BulkWithdrawOptions, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositCalldata, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawCalldata, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, type MerklClaimCalldata, type MerklClaimResult, type MerklReward, type MerklRewardToken, type MerklRewardsResult, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type VaultYield, type VaultYieldReward, type WithdrawStatus, type YieldPreview, bridgeAssetFor, clearBridgeEstimateCache, createStable, createStableReader, erc3009Actions };
|
package/dist/index.d.ts
CHANGED
|
@@ -103,20 +103,96 @@ declare enum Network {
|
|
|
103
103
|
Testnet = "testnet"
|
|
104
104
|
}
|
|
105
105
|
interface BridgeQuote {
|
|
106
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Amount the recipient is expected to receive on the destination chain.
|
|
108
|
+
*
|
|
109
|
+
* On native OFT routes this is `oft.amountReceivedLD` — the input minus any
|
|
110
|
+
* OFT-level fee and minus dust removed by decimal conversion — and falls back
|
|
111
|
+
* to the input amount when `quoteOFT` could not be read.
|
|
112
|
+
*/
|
|
107
113
|
toAmount?: number;
|
|
108
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* LayerZero messaging fee (wei of the source chain's native token) — only
|
|
116
|
+
* present for native OFT routes. This is the whole `MessagingFee.nativeFee`
|
|
117
|
+
* that `send` must be called with: DVN fees, executor fee and any requested
|
|
118
|
+
* destination native drop, bundled. `quoteSend` returns no breakdown of it.
|
|
119
|
+
*/
|
|
109
120
|
nativeFee?: bigint;
|
|
110
|
-
/** LayerZero fee paid in LZ token (wei) — only present for
|
|
121
|
+
/** LayerZero fee paid in LZ token (wei) — only present for native OFT routes */
|
|
111
122
|
lzTokenFee?: bigint;
|
|
112
123
|
/**
|
|
113
|
-
*
|
|
124
|
+
* OFT-level accounting for the send: what the adapter itself debits, credits
|
|
125
|
+
* and charges, independent of the LayerZero messaging fee. Only present for
|
|
126
|
+
* native OFT routes, and omitted when the `quoteOFT` read failed.
|
|
127
|
+
*/
|
|
128
|
+
oft?: BridgeOftQuote;
|
|
129
|
+
/**
|
|
130
|
+
* Source-chain execution cost of the `send` transaction. Only present for
|
|
131
|
+
* native OFT routes, and omitted when neither simulation nor fallback could
|
|
132
|
+
* produce a number. Excludes {@link BridgeQuote.nativeFee}.
|
|
133
|
+
*/
|
|
134
|
+
srcGas?: BridgeGasEstimate;
|
|
135
|
+
/**
|
|
136
|
+
* Everything the sender pays out of their native balance, in wei:
|
|
137
|
+
* `srcGas.costWei + nativeFee`. Present only when both parts are known.
|
|
138
|
+
*/
|
|
139
|
+
totalCostWei?: bigint;
|
|
140
|
+
/**
|
|
141
|
+
* How long the bridge is expected to take. Only present for native OFT routes,
|
|
114
142
|
* and omitted if the estimate could not be resolved — never treat it as required.
|
|
115
143
|
*/
|
|
116
144
|
estimate?: BridgeTimeEstimate;
|
|
117
145
|
}
|
|
118
146
|
/**
|
|
119
|
-
*
|
|
147
|
+
* One fee the OFT itself reports for a send, from `quoteOFT`'s `oftFeeDetails`.
|
|
148
|
+
*
|
|
149
|
+
* Every pathway in BRIDGE_CHAIN_CONFIGS reported none when checked on 2026-08-20
|
|
150
|
+
* (Ethereum, Stable, Arbitrum and Plasma adapters), so an empty `fees` array is the
|
|
151
|
+
* normal case rather than a failed read. A deployment that does charge at the OFT
|
|
152
|
+
* level — the kind of thing a bridge UI shows as its own fee row — reports it here
|
|
153
|
+
* rather than inside the LayerZero messaging fee.
|
|
154
|
+
*/
|
|
155
|
+
interface BridgeOftFee {
|
|
156
|
+
/** Fee in the source token's smallest unit. Negative means a credit, not a charge. */
|
|
157
|
+
amountLD: bigint;
|
|
158
|
+
/** Human-readable amount, same sign convention as {@link BridgeOftFee.amountLD} */
|
|
159
|
+
amount: number;
|
|
160
|
+
/** Whatever the adapter calls this fee — its own string, shown as-is */
|
|
161
|
+
description: string;
|
|
162
|
+
}
|
|
163
|
+
/** What the OFT adapter reports for a send, read from `quoteOFT`. */
|
|
164
|
+
interface BridgeOftQuote {
|
|
165
|
+
/** Amount debited on the source chain, in the source token's smallest unit */
|
|
166
|
+
amountSentLD: bigint;
|
|
167
|
+
/** Amount credited on the destination chain, in the source token's smallest unit */
|
|
168
|
+
amountReceivedLD: bigint;
|
|
169
|
+
/** Human-readable {@link BridgeOftQuote.amountReceivedLD} */
|
|
170
|
+
amountReceived: number;
|
|
171
|
+
/** Fees the adapter charges. Empty on pathways that charge none. */
|
|
172
|
+
fees: BridgeOftFee[];
|
|
173
|
+
/** Smallest amount this pathway accepts, in the source token's smallest unit */
|
|
174
|
+
minAmountLD: bigint;
|
|
175
|
+
/** Largest amount this pathway accepts, in the source token's smallest unit */
|
|
176
|
+
maxAmountLD: bigint;
|
|
177
|
+
}
|
|
178
|
+
/** Source-chain gas for the OFT `send` transaction. */
|
|
179
|
+
interface BridgeGasEstimate {
|
|
180
|
+
/** Gas units */
|
|
181
|
+
gas: bigint;
|
|
182
|
+
/** Price per gas unit (wei) — `maxFeePerGas` where the chain is EIP-1559 */
|
|
183
|
+
gasPriceWei: bigint;
|
|
184
|
+
/** `gas × gasPriceWei` */
|
|
185
|
+
costWei: bigint;
|
|
186
|
+
/**
|
|
187
|
+
* `"simulated"` means `gas` came from simulating the real `send` — trust it.
|
|
188
|
+
* `"fallback"` means the simulation failed (no allowance or no balance yet is
|
|
189
|
+
* the usual reason when quoting before approving) and `gas` is a typical-send
|
|
190
|
+
* constant, so treat the cost as indicative only.
|
|
191
|
+
*/
|
|
192
|
+
source: "simulated" | "fallback";
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Expected end-to-end delivery time for a native (LayerZero OFT) bridge.
|
|
120
196
|
*
|
|
121
197
|
* Almost all of the wait is source-chain finality: the DVNs securing the pathway
|
|
122
198
|
* refuse to attest until the send transaction is buried under `confirmations`
|
|
@@ -159,13 +235,17 @@ interface BridgeStatus {
|
|
|
159
235
|
}
|
|
160
236
|
/**
|
|
161
237
|
* Bridge route selection:
|
|
162
|
-
* - `"
|
|
163
|
-
*
|
|
238
|
+
* - `"oft"` — force the native LayerZero OFT path for whichever asset the token
|
|
239
|
+
* addresses name, USDT0 or XAUt0 (no protocol fee, just gas + LZ messaging fee;
|
|
240
|
+
* slower). Throws if the chain pair has no adapter for that asset.
|
|
241
|
+
* - `"usdt0"` — deprecated alias for `"oft"`, kept for compatibility. It does not
|
|
242
|
+
* restrict the route to USDT0; the token addresses decide the asset.
|
|
164
243
|
* - `"lifi"` — force the LI.FI aggregator path (fast, charges a fee).
|
|
165
|
-
* - `"auto"` — use
|
|
244
|
+
* - `"auto"` — use the native OFT mesh (USDT0 or XAUt0) when both chains deploy
|
|
245
|
+
* the requested asset and the token addresses match, else LI.FI.
|
|
166
246
|
* This is the default.
|
|
167
247
|
*/
|
|
168
|
-
type BridgeRoute = "auto" | "usdt0" | "lifi";
|
|
248
|
+
type BridgeRoute = "auto" | "oft" | "usdt0" | "lifi";
|
|
169
249
|
interface BridgeParams {
|
|
170
250
|
fromChain: Chain;
|
|
171
251
|
toChain: Chain;
|
|
@@ -179,11 +259,26 @@ interface BridgeParams {
|
|
|
179
259
|
/** Recipient address — defaults to the signer */
|
|
180
260
|
recipient?: string;
|
|
181
261
|
/**
|
|
182
|
-
* Which bridge to use. Defaults to "auto" (
|
|
262
|
+
* Which bridge to use. Defaults to "auto" (native OFT when available, else LI.FI).
|
|
183
263
|
* See {@link BridgeRoute}.
|
|
184
264
|
*/
|
|
185
265
|
route?: BridgeRoute;
|
|
186
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* Destination native token (wei) to airdrop to the recipient alongside the
|
|
268
|
+
* tokens — LayerZero's executor native-drop option, what bridge UIs call
|
|
269
|
+
* "gas on destination". Paid for by the sender through a larger
|
|
270
|
+
* {@link BridgeQuote.nativeFee}.
|
|
271
|
+
*
|
|
272
|
+
* Only supported on native OFT routes, and capped per pathway by the
|
|
273
|
+
* executor's configured `nativeCap`: asking for more makes `quoteSend`
|
|
274
|
+
* revert rather than silently clamping.
|
|
275
|
+
*/
|
|
276
|
+
dstNativeDrop?: bigint;
|
|
277
|
+
/**
|
|
278
|
+
* Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to
|
|
279
|
+
* bridge(). Must have been quoted with the same `dstNativeDrop`, since the
|
|
280
|
+
* drop is part of what `nativeFee` pays for.
|
|
281
|
+
*/
|
|
187
282
|
quote?: BridgeQuote;
|
|
188
283
|
}
|
|
189
284
|
interface EarnDepositParams {
|
|
@@ -416,11 +511,14 @@ interface StableClient {
|
|
|
416
511
|
quoteBridge(params: BridgeParams): Promise<BridgeQuote>;
|
|
417
512
|
bridge(params: BridgeParams): Promise<OperationResult>;
|
|
418
513
|
/**
|
|
419
|
-
* Expected delivery time for a
|
|
420
|
-
* Throws for chain pairs with no
|
|
514
|
+
* Expected delivery time for a native OFT (LayerZero) bridge, before sending.
|
|
515
|
+
* Throws for chain pairs with no OFT adapter — LI.FI carries its own ETA.
|
|
516
|
+
*
|
|
517
|
+
* Pass `fromToken`/`toToken` to estimate a specific asset; omitting them
|
|
518
|
+
* estimates the USDT0 pathway.
|
|
421
519
|
*/
|
|
422
|
-
estimateBridgeTime(params: Pick<BridgeParams, "fromChain" | "toChain">): Promise<BridgeTimeEstimate>;
|
|
423
|
-
/** Delivery status of an in-flight
|
|
520
|
+
estimateBridgeTime(params: Pick<BridgeParams, "fromChain" | "toChain"> & Partial<Pick<BridgeParams, "fromToken" | "toToken">>): Promise<BridgeTimeEstimate>;
|
|
521
|
+
/** Delivery status of an in-flight OFT bridge, by source transaction hash. */
|
|
424
522
|
trackBridge(srcTxHash: string): Promise<BridgeStatus>;
|
|
425
523
|
quoteSwap(params: SwapParams): Promise<SwapQuote>;
|
|
426
524
|
swap(params: SwapParams): Promise<OperationResult>;
|
|
@@ -484,9 +582,37 @@ interface ChainConfig {
|
|
|
484
582
|
}
|
|
485
583
|
declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
|
|
486
584
|
|
|
585
|
+
/** An asset with its own LayerZero OFT mesh. Each has separate adapters per chain. */
|
|
586
|
+
type BridgeAsset = "usdt0" | "xaut0";
|
|
587
|
+
/** One asset's deployment on one chain. */
|
|
588
|
+
interface BridgeTokenConfig {
|
|
589
|
+
/** The ERC-20 a holder owns — what gets debited, and approved when required */
|
|
590
|
+
address: Address;
|
|
591
|
+
/** Decimals of that ERC-20 on this chain */
|
|
592
|
+
decimals: number;
|
|
593
|
+
/** The OFT (or OFT Adapter) that escrows-or-burns on send */
|
|
594
|
+
oftAdapter: Address;
|
|
595
|
+
/**
|
|
596
|
+
* Whether `send` pulls the token via `transferFrom` and so needs an allowance.
|
|
597
|
+
* Only the lockbox chain does; remote deployments burn from the caller directly.
|
|
598
|
+
* Undefined means "approve when the allowance is short" — the safe default.
|
|
599
|
+
*/
|
|
600
|
+
approvalRequired?: boolean;
|
|
601
|
+
/** False when the adapter exists but has no outbound send pathways configured */
|
|
602
|
+
lzOutbound?: boolean;
|
|
603
|
+
}
|
|
487
604
|
interface BridgeChainConfig extends ChainConfig {
|
|
488
605
|
lzEid: number;
|
|
489
|
-
/**
|
|
606
|
+
/**
|
|
607
|
+
* Which OFT assets this chain can bridge. A chain may carry one and not the
|
|
608
|
+
* other — BSC has XAUt0 but no USDT0 deployment.
|
|
609
|
+
*/
|
|
610
|
+
tokens: Partial<Record<BridgeAsset, BridgeTokenConfig>>;
|
|
611
|
+
/**
|
|
612
|
+
* The USDT0 adapter. Predates XAUt0 and is part of the exported
|
|
613
|
+
* BRIDGE_CHAIN_CONFIGS surface, so it still means USDT0 specifically —
|
|
614
|
+
* prefer `tokens[asset].oftAdapter`.
|
|
615
|
+
*/
|
|
490
616
|
oftAdapter?: Address;
|
|
491
617
|
/** False when the OFT adapter exists but has no outbound send pathways configured */
|
|
492
618
|
lzOutbound?: boolean;
|
|
@@ -497,6 +623,11 @@ interface BridgeChainConfig extends ChainConfig {
|
|
|
497
623
|
blockTimeSec?: number;
|
|
498
624
|
}
|
|
499
625
|
declare const BRIDGE_CHAIN_CONFIGS: Partial<Record<Chain, BridgeChainConfig>>;
|
|
626
|
+
/**
|
|
627
|
+
* Which OFT asset a token address refers to on a chain, or undefined when the
|
|
628
|
+
* chain has no OFT deployment matching it.
|
|
629
|
+
*/
|
|
630
|
+
declare function bridgeAssetFor(cfg: BridgeChainConfig, token: string): BridgeAsset | undefined;
|
|
500
631
|
/** Drop cached pathway configs and observed timings — forces the next estimate to refetch. */
|
|
501
632
|
declare function clearBridgeEstimateCache(): void;
|
|
502
633
|
|
|
@@ -560,4 +691,4 @@ declare class StableBulkError extends StableError {
|
|
|
560
691
|
});
|
|
561
692
|
}
|
|
562
693
|
|
|
563
|
-
export { BRIDGE_CHAIN_CONFIGS, type BridgeChainConfig, type BridgeDeliveryState, type BridgeParams, type BridgeQuote, type BridgeRoute, type BridgeStatus, type BridgeTimeEstimate, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, type BulkWithdrawOptions, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositCalldata, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawCalldata, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, type MerklClaimCalldata, type MerklClaimResult, type MerklReward, type MerklRewardToken, type MerklRewardsResult, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type VaultYield, type VaultYieldReward, type WithdrawStatus, type YieldPreview, clearBridgeEstimateCache, createStable, createStableReader, erc3009Actions };
|
|
694
|
+
export { BRIDGE_CHAIN_CONFIGS, type BridgeAsset, type BridgeChainConfig, type BridgeDeliveryState, type BridgeGasEstimate, type BridgeOftFee, type BridgeOftQuote, type BridgeParams, type BridgeQuote, type BridgeRoute, type BridgeStatus, type BridgeTimeEstimate, type BridgeTokenConfig, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, type BulkWithdrawOptions, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositCalldata, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawCalldata, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, type MerklClaimCalldata, type MerklClaimResult, type MerklReward, type MerklRewardToken, type MerklRewardsResult, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type VaultYield, type VaultYieldReward, type WithdrawStatus, type YieldPreview, bridgeAssetFor, clearBridgeEstimateCache, createStable, createStableReader, erc3009Actions };
|