@stablechain/sdk 1.0.4 → 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/dist/index.d.cts CHANGED
@@ -1,3 +1,5 @@
1
+ import { erc3009Actions } from './erc3009.cjs';
2
+ export { Authorization, AuthorizationUsage, CancelAuthorizationParameters, ERC3009_ABI, Erc3009DomainOverrides, GetAuthorizationStateParameters, GetAuthorizationUsageParameters, PreparedAuthorizationCall, ReceiveWithAuthorizationParameters, SignReceiveAuthorizationParameters, SignTransferAuthorizationParameters, SignedAuthorization, TransferWithAuthorizationParameters, VerifyAuthorizationParameters, VerifyAuthorizationResult, VerifyFailureReason, cancelAuthorization, getAuthorizationState, getAuthorizationUsage, prepareTransferWithAuthorization, receiveWithAuthorization, signReceiveAuthorization, signTransferAuthorization, transferWithAuthorization, verifyAuthorization } from './erc3009.cjs';
1
3
  import { Account, Transport, WalletClient, Address, BaseError } from 'viem';
2
4
 
3
5
  interface EarnConfig {
@@ -86,29 +88,164 @@ declare enum Chain {
86
88
  MegaETH = "megaeth",
87
89
  Base = "base",
88
90
  BSC = "bsc",
89
- HyperEVM = "hyperevm"
91
+ HyperEVM = "hyperevm",
92
+ Polygon = "polygon",
93
+ Plasma = "plasma",
94
+ Optimism = "optimism",
95
+ Unichain = "unichain",
96
+ Sei = "sei",
97
+ Flare = "flare",
98
+ XLayer = "xlayer",
99
+ Rootstock = "rootstock"
90
100
  }
91
101
  declare enum Network {
92
102
  Mainnet = "mainnet",
93
103
  Testnet = "testnet"
94
104
  }
95
105
  interface BridgeQuote {
96
- /** Estimated output amount on the destination chain */
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
+ */
97
113
  toAmount?: number;
98
- /** LayerZero native messaging fee (wei) — only present for USDT0→USDT0 (OFT) routes */
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
+ */
99
120
  nativeFee?: bigint;
100
- /** LayerZero fee paid in LZ token (wei) — only present for USDT0→USDT0 (OFT) routes */
121
+ /** LayerZero fee paid in LZ token (wei) — only present for native OFT routes */
101
122
  lzTokenFee?: bigint;
123
+ /**
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,
142
+ * and omitted if the estimate could not be resolved — never treat it as required.
143
+ */
144
+ estimate?: BridgeTimeEstimate;
145
+ }
146
+ /**
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.
196
+ *
197
+ * Almost all of the wait is source-chain finality: the DVNs securing the pathway
198
+ * refuse to attest until the send transaction is buried under `confirmations`
199
+ * source blocks. Destination execution is a few blocks on top of that.
200
+ */
201
+ interface BridgeTimeEstimate {
202
+ /** Best available estimate, in seconds — prefer this for display */
203
+ seconds: number;
204
+ /** Which input produced `seconds` — see {@link BridgeTimeEstimate.observedSeconds} */
205
+ source: "observed" | "formula";
206
+ /**
207
+ * Median delivery time of recent delivered messages on this exact pathway,
208
+ * from LayerZero Scan. More trustworthy than `formulaSeconds` — notably on
209
+ * rollup sources, where DVNs wait for L1 finality rather than raw block count.
210
+ */
211
+ observedSeconds?: number;
212
+ /**
213
+ * LayerZero's documented estimate:
214
+ * `srcBlockTime × confirmations + dstBlockTime × (2 + dvnCount)`.
215
+ */
216
+ formulaSeconds?: number;
217
+ /** Source-chain block confirmations the DVNs wait for before attesting */
218
+ confirmations?: number;
219
+ /** Number of DVNs (required + optional) verifying this pathway */
220
+ dvnCount?: number;
221
+ }
222
+ /** Delivery state of an in-flight USDT0 bridge, normalized from LayerZero Scan. */
223
+ type BridgeDeliveryState = "pending" | "inflight" | "delivered" | "failed";
224
+ interface BridgeStatus {
225
+ state: BridgeDeliveryState;
226
+ /** Raw LayerZero Scan status, e.g. "INFLIGHT" | "DELIVERED" | "FAILED" | "BLOCKED" */
227
+ raw?: string;
228
+ srcTxHash: string;
229
+ /** Destination transaction hash — present once delivered */
230
+ dstTxHash?: string;
231
+ /** Seconds since the source transaction was mined */
232
+ elapsedSeconds?: number;
233
+ /** Human-facing tracking page */
234
+ scanUrl: string;
102
235
  }
103
236
  /**
104
237
  * Bridge route selection:
105
- * - `"usdt0"` — force the USDT0 LayerZero OFT path (no protocol fee, just gas + LZ
106
- * messaging fee; slower). Throws if the chain pair has no USDT0 adapter.
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.
107
243
  * - `"lifi"` — force the LI.FI aggregator path (fast, charges a fee).
108
- * - `"auto"` — use USDT0 when both chains support it and tokens match, else LI.FI.
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.
109
246
  * This is the default.
110
247
  */
111
- type BridgeRoute = "auto" | "usdt0" | "lifi";
248
+ type BridgeRoute = "auto" | "oft" | "usdt0" | "lifi";
112
249
  interface BridgeParams {
113
250
  fromChain: Chain;
114
251
  toChain: Chain;
@@ -122,11 +259,26 @@ interface BridgeParams {
122
259
  /** Recipient address — defaults to the signer */
123
260
  recipient?: string;
124
261
  /**
125
- * Which bridge to use. Defaults to "auto" (USDT0 OFT when available, else LI.FI).
262
+ * Which bridge to use. Defaults to "auto" (native OFT when available, else LI.FI).
126
263
  * See {@link BridgeRoute}.
127
264
  */
128
265
  route?: BridgeRoute;
129
- /** Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to bridge() */
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
+ */
130
282
  quote?: BridgeQuote;
131
283
  }
132
284
  interface EarnDepositParams {
@@ -358,8 +510,25 @@ interface StableClient {
358
510
  transfer(params: TransferParams): Promise<OperationResult>;
359
511
  quoteBridge(params: BridgeParams): Promise<BridgeQuote>;
360
512
  bridge(params: BridgeParams): Promise<OperationResult>;
513
+ /**
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.
519
+ */
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. */
522
+ trackBridge(srcTxHash: string): Promise<BridgeStatus>;
361
523
  quoteSwap(params: SwapParams): Promise<SwapQuote>;
362
524
  swap(params: SwapParams): Promise<OperationResult>;
525
+ /**
526
+ * ERC-3009 gasless transfers ("Transfer With Authorization"). Sign a portable
527
+ * authorization the payer can hand off, then have anyone (a relayer, the
528
+ * recipient, or the enterprise gas-waiver rail) settle it on-chain. See
529
+ * {@link erc3009Actions} for the individual viem-style actions.
530
+ */
531
+ authorization: ReturnType<typeof erc3009Actions>;
363
532
  earn: {
364
533
  deposit(params: EarnDepositParams): Promise<EarnResult>;
365
534
  bulkDeposit(items: EarnDepositParams[], options?: BulkDepositOptions): Promise<BulkEarnResult>;
@@ -413,14 +582,54 @@ interface ChainConfig {
413
582
  }
414
583
  declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
415
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
+ }
416
604
  interface BridgeChainConfig extends ChainConfig {
417
605
  lzEid: number;
418
- /** Only set on source chains that have an OFT Adapter deployed */
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
+ */
419
616
  oftAdapter?: Address;
420
617
  /** False when the OFT adapter exists but has no outbound send pathways configured */
421
618
  lzOutbound?: boolean;
619
+ /**
620
+ * Average seconds per block, used to turn LayerZero's block-confirmation
621
+ * requirement into a wall-clock estimate. Measured from mainnet, 2026-07-30.
622
+ */
623
+ blockTimeSec?: number;
422
624
  }
423
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;
631
+ /** Drop cached pathway configs and observed timings — forces the next estimate to refetch. */
632
+ declare function clearBridgeEstimateCache(): void;
424
633
 
425
634
  declare const STABLE_USDT_ADDRESS: Address;
426
635
  declare const STABLE_VAULT_ADDRESS: Address;
@@ -449,12 +658,12 @@ declare class StableQuoteError extends StableError {
449
658
  });
450
659
  }
451
660
  declare class StableTransactionError extends StableError {
452
- phase: "approve" | "send" | "receipt" | "switch_chain";
661
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
453
662
  txHash?: `0x${string}`;
454
663
  chainId?: number;
455
664
  revertReason?: string;
456
665
  constructor(args: {
457
- phase: "approve" | "send" | "receipt" | "switch_chain";
666
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
458
667
  shortMessage: string;
459
668
  txHash?: `0x${string}`;
460
669
  chainId?: number;
@@ -482,4 +691,4 @@ declare class StableBulkError extends StableError {
482
691
  });
483
692
  }
484
693
 
485
- export { BRIDGE_CHAIN_CONFIGS, type BridgeChainConfig, type BridgeParams, type BridgeQuote, type BridgeRoute, 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, createStable, createStableReader };
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
@@ -1,3 +1,5 @@
1
+ import { erc3009Actions } from './erc3009.js';
2
+ export { Authorization, AuthorizationUsage, CancelAuthorizationParameters, ERC3009_ABI, Erc3009DomainOverrides, GetAuthorizationStateParameters, GetAuthorizationUsageParameters, PreparedAuthorizationCall, ReceiveWithAuthorizationParameters, SignReceiveAuthorizationParameters, SignTransferAuthorizationParameters, SignedAuthorization, TransferWithAuthorizationParameters, VerifyAuthorizationParameters, VerifyAuthorizationResult, VerifyFailureReason, cancelAuthorization, getAuthorizationState, getAuthorizationUsage, prepareTransferWithAuthorization, receiveWithAuthorization, signReceiveAuthorization, signTransferAuthorization, transferWithAuthorization, verifyAuthorization } from './erc3009.js';
1
3
  import { Account, Transport, WalletClient, Address, BaseError } from 'viem';
2
4
 
3
5
  interface EarnConfig {
@@ -86,29 +88,164 @@ declare enum Chain {
86
88
  MegaETH = "megaeth",
87
89
  Base = "base",
88
90
  BSC = "bsc",
89
- HyperEVM = "hyperevm"
91
+ HyperEVM = "hyperevm",
92
+ Polygon = "polygon",
93
+ Plasma = "plasma",
94
+ Optimism = "optimism",
95
+ Unichain = "unichain",
96
+ Sei = "sei",
97
+ Flare = "flare",
98
+ XLayer = "xlayer",
99
+ Rootstock = "rootstock"
90
100
  }
91
101
  declare enum Network {
92
102
  Mainnet = "mainnet",
93
103
  Testnet = "testnet"
94
104
  }
95
105
  interface BridgeQuote {
96
- /** Estimated output amount on the destination chain */
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
+ */
97
113
  toAmount?: number;
98
- /** LayerZero native messaging fee (wei) — only present for USDT0→USDT0 (OFT) routes */
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
+ */
99
120
  nativeFee?: bigint;
100
- /** LayerZero fee paid in LZ token (wei) — only present for USDT0→USDT0 (OFT) routes */
121
+ /** LayerZero fee paid in LZ token (wei) — only present for native OFT routes */
101
122
  lzTokenFee?: bigint;
123
+ /**
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,
142
+ * and omitted if the estimate could not be resolved — never treat it as required.
143
+ */
144
+ estimate?: BridgeTimeEstimate;
145
+ }
146
+ /**
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.
196
+ *
197
+ * Almost all of the wait is source-chain finality: the DVNs securing the pathway
198
+ * refuse to attest until the send transaction is buried under `confirmations`
199
+ * source blocks. Destination execution is a few blocks on top of that.
200
+ */
201
+ interface BridgeTimeEstimate {
202
+ /** Best available estimate, in seconds — prefer this for display */
203
+ seconds: number;
204
+ /** Which input produced `seconds` — see {@link BridgeTimeEstimate.observedSeconds} */
205
+ source: "observed" | "formula";
206
+ /**
207
+ * Median delivery time of recent delivered messages on this exact pathway,
208
+ * from LayerZero Scan. More trustworthy than `formulaSeconds` — notably on
209
+ * rollup sources, where DVNs wait for L1 finality rather than raw block count.
210
+ */
211
+ observedSeconds?: number;
212
+ /**
213
+ * LayerZero's documented estimate:
214
+ * `srcBlockTime × confirmations + dstBlockTime × (2 + dvnCount)`.
215
+ */
216
+ formulaSeconds?: number;
217
+ /** Source-chain block confirmations the DVNs wait for before attesting */
218
+ confirmations?: number;
219
+ /** Number of DVNs (required + optional) verifying this pathway */
220
+ dvnCount?: number;
221
+ }
222
+ /** Delivery state of an in-flight USDT0 bridge, normalized from LayerZero Scan. */
223
+ type BridgeDeliveryState = "pending" | "inflight" | "delivered" | "failed";
224
+ interface BridgeStatus {
225
+ state: BridgeDeliveryState;
226
+ /** Raw LayerZero Scan status, e.g. "INFLIGHT" | "DELIVERED" | "FAILED" | "BLOCKED" */
227
+ raw?: string;
228
+ srcTxHash: string;
229
+ /** Destination transaction hash — present once delivered */
230
+ dstTxHash?: string;
231
+ /** Seconds since the source transaction was mined */
232
+ elapsedSeconds?: number;
233
+ /** Human-facing tracking page */
234
+ scanUrl: string;
102
235
  }
103
236
  /**
104
237
  * Bridge route selection:
105
- * - `"usdt0"` — force the USDT0 LayerZero OFT path (no protocol fee, just gas + LZ
106
- * messaging fee; slower). Throws if the chain pair has no USDT0 adapter.
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.
107
243
  * - `"lifi"` — force the LI.FI aggregator path (fast, charges a fee).
108
- * - `"auto"` — use USDT0 when both chains support it and tokens match, else LI.FI.
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.
109
246
  * This is the default.
110
247
  */
111
- type BridgeRoute = "auto" | "usdt0" | "lifi";
248
+ type BridgeRoute = "auto" | "oft" | "usdt0" | "lifi";
112
249
  interface BridgeParams {
113
250
  fromChain: Chain;
114
251
  toChain: Chain;
@@ -122,11 +259,26 @@ interface BridgeParams {
122
259
  /** Recipient address — defaults to the signer */
123
260
  recipient?: string;
124
261
  /**
125
- * Which bridge to use. Defaults to "auto" (USDT0 OFT when available, else LI.FI).
262
+ * Which bridge to use. Defaults to "auto" (native OFT when available, else LI.FI).
126
263
  * See {@link BridgeRoute}.
127
264
  */
128
265
  route?: BridgeRoute;
129
- /** Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to bridge() */
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
+ */
130
282
  quote?: BridgeQuote;
131
283
  }
132
284
  interface EarnDepositParams {
@@ -358,8 +510,25 @@ interface StableClient {
358
510
  transfer(params: TransferParams): Promise<OperationResult>;
359
511
  quoteBridge(params: BridgeParams): Promise<BridgeQuote>;
360
512
  bridge(params: BridgeParams): Promise<OperationResult>;
513
+ /**
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.
519
+ */
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. */
522
+ trackBridge(srcTxHash: string): Promise<BridgeStatus>;
361
523
  quoteSwap(params: SwapParams): Promise<SwapQuote>;
362
524
  swap(params: SwapParams): Promise<OperationResult>;
525
+ /**
526
+ * ERC-3009 gasless transfers ("Transfer With Authorization"). Sign a portable
527
+ * authorization the payer can hand off, then have anyone (a relayer, the
528
+ * recipient, or the enterprise gas-waiver rail) settle it on-chain. See
529
+ * {@link erc3009Actions} for the individual viem-style actions.
530
+ */
531
+ authorization: ReturnType<typeof erc3009Actions>;
363
532
  earn: {
364
533
  deposit(params: EarnDepositParams): Promise<EarnResult>;
365
534
  bulkDeposit(items: EarnDepositParams[], options?: BulkDepositOptions): Promise<BulkEarnResult>;
@@ -413,14 +582,54 @@ interface ChainConfig {
413
582
  }
414
583
  declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
415
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
+ }
416
604
  interface BridgeChainConfig extends ChainConfig {
417
605
  lzEid: number;
418
- /** Only set on source chains that have an OFT Adapter deployed */
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
+ */
419
616
  oftAdapter?: Address;
420
617
  /** False when the OFT adapter exists but has no outbound send pathways configured */
421
618
  lzOutbound?: boolean;
619
+ /**
620
+ * Average seconds per block, used to turn LayerZero's block-confirmation
621
+ * requirement into a wall-clock estimate. Measured from mainnet, 2026-07-30.
622
+ */
623
+ blockTimeSec?: number;
422
624
  }
423
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;
631
+ /** Drop cached pathway configs and observed timings — forces the next estimate to refetch. */
632
+ declare function clearBridgeEstimateCache(): void;
424
633
 
425
634
  declare const STABLE_USDT_ADDRESS: Address;
426
635
  declare const STABLE_VAULT_ADDRESS: Address;
@@ -449,12 +658,12 @@ declare class StableQuoteError extends StableError {
449
658
  });
450
659
  }
451
660
  declare class StableTransactionError extends StableError {
452
- phase: "approve" | "send" | "receipt" | "switch_chain";
661
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
453
662
  txHash?: `0x${string}`;
454
663
  chainId?: number;
455
664
  revertReason?: string;
456
665
  constructor(args: {
457
- phase: "approve" | "send" | "receipt" | "switch_chain";
666
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
458
667
  shortMessage: string;
459
668
  txHash?: `0x${string}`;
460
669
  chainId?: number;
@@ -482,4 +691,4 @@ declare class StableBulkError extends StableError {
482
691
  });
483
692
  }
484
693
 
485
- export { BRIDGE_CHAIN_CONFIGS, type BridgeChainConfig, type BridgeParams, type BridgeQuote, type BridgeRoute, 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, createStable, createStableReader };
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 };