@stablechain/sdk 1.0.3 → 1.0.5

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,7 +88,15 @@ 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",
@@ -95,7 +105,67 @@ declare enum Network {
95
105
  interface BridgeQuote {
96
106
  /** Estimated output amount on the destination chain */
97
107
  toAmount?: number;
108
+ /** LayerZero native messaging fee (wei) — only present for USDT0→USDT0 (OFT) routes */
109
+ nativeFee?: bigint;
110
+ /** LayerZero fee paid in LZ token (wei) — only present for USDT0→USDT0 (OFT) routes */
111
+ lzTokenFee?: bigint;
112
+ /**
113
+ * How long the bridge is expected to take. Only present for USDT0 (OFT) routes,
114
+ * and omitted if the estimate could not be resolved — never treat it as required.
115
+ */
116
+ estimate?: BridgeTimeEstimate;
98
117
  }
118
+ /**
119
+ * Expected end-to-end delivery time for a USDT0 (LayerZero OFT) bridge.
120
+ *
121
+ * Almost all of the wait is source-chain finality: the DVNs securing the pathway
122
+ * refuse to attest until the send transaction is buried under `confirmations`
123
+ * source blocks. Destination execution is a few blocks on top of that.
124
+ */
125
+ interface BridgeTimeEstimate {
126
+ /** Best available estimate, in seconds — prefer this for display */
127
+ seconds: number;
128
+ /** Which input produced `seconds` — see {@link BridgeTimeEstimate.observedSeconds} */
129
+ source: "observed" | "formula";
130
+ /**
131
+ * Median delivery time of recent delivered messages on this exact pathway,
132
+ * from LayerZero Scan. More trustworthy than `formulaSeconds` — notably on
133
+ * rollup sources, where DVNs wait for L1 finality rather than raw block count.
134
+ */
135
+ observedSeconds?: number;
136
+ /**
137
+ * LayerZero's documented estimate:
138
+ * `srcBlockTime × confirmations + dstBlockTime × (2 + dvnCount)`.
139
+ */
140
+ formulaSeconds?: number;
141
+ /** Source-chain block confirmations the DVNs wait for before attesting */
142
+ confirmations?: number;
143
+ /** Number of DVNs (required + optional) verifying this pathway */
144
+ dvnCount?: number;
145
+ }
146
+ /** Delivery state of an in-flight USDT0 bridge, normalized from LayerZero Scan. */
147
+ type BridgeDeliveryState = "pending" | "inflight" | "delivered" | "failed";
148
+ interface BridgeStatus {
149
+ state: BridgeDeliveryState;
150
+ /** Raw LayerZero Scan status, e.g. "INFLIGHT" | "DELIVERED" | "FAILED" | "BLOCKED" */
151
+ raw?: string;
152
+ srcTxHash: string;
153
+ /** Destination transaction hash — present once delivered */
154
+ dstTxHash?: string;
155
+ /** Seconds since the source transaction was mined */
156
+ elapsedSeconds?: number;
157
+ /** Human-facing tracking page */
158
+ scanUrl: string;
159
+ }
160
+ /**
161
+ * Bridge route selection:
162
+ * - `"usdt0"` — force the USDT0 LayerZero OFT path (no protocol fee, just gas + LZ
163
+ * messaging fee; slower). Throws if the chain pair has no USDT0 adapter.
164
+ * - `"lifi"` — force the LI.FI aggregator path (fast, charges a fee).
165
+ * - `"auto"` — use USDT0 when both chains support it and tokens match, else LI.FI.
166
+ * This is the default.
167
+ */
168
+ type BridgeRoute = "auto" | "usdt0" | "lifi";
99
169
  interface BridgeParams {
100
170
  fromChain: Chain;
101
171
  toChain: Chain;
@@ -108,6 +178,11 @@ interface BridgeParams {
108
178
  fromDecimals?: number;
109
179
  /** Recipient address — defaults to the signer */
110
180
  recipient?: string;
181
+ /**
182
+ * Which bridge to use. Defaults to "auto" (USDT0 OFT when available, else LI.FI).
183
+ * See {@link BridgeRoute}.
184
+ */
185
+ route?: BridgeRoute;
111
186
  /** Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to bridge() */
112
187
  quote?: BridgeQuote;
113
188
  }
@@ -340,8 +415,22 @@ interface StableClient {
340
415
  transfer(params: TransferParams): Promise<OperationResult>;
341
416
  quoteBridge(params: BridgeParams): Promise<BridgeQuote>;
342
417
  bridge(params: BridgeParams): Promise<OperationResult>;
418
+ /**
419
+ * Expected delivery time for a USDT0 (LayerZero OFT) bridge, before sending.
420
+ * Throws for chain pairs with no USDT0 adapter — LI.FI carries its own ETA.
421
+ */
422
+ estimateBridgeTime(params: Pick<BridgeParams, "fromChain" | "toChain">): Promise<BridgeTimeEstimate>;
423
+ /** Delivery status of an in-flight USDT0 bridge, by source transaction hash. */
424
+ trackBridge(srcTxHash: string): Promise<BridgeStatus>;
343
425
  quoteSwap(params: SwapParams): Promise<SwapQuote>;
344
426
  swap(params: SwapParams): Promise<OperationResult>;
427
+ /**
428
+ * ERC-3009 gasless transfers ("Transfer With Authorization"). Sign a portable
429
+ * authorization the payer can hand off, then have anyone (a relayer, the
430
+ * recipient, or the enterprise gas-waiver rail) settle it on-chain. See
431
+ * {@link erc3009Actions} for the individual viem-style actions.
432
+ */
433
+ authorization: ReturnType<typeof erc3009Actions>;
345
434
  earn: {
346
435
  deposit(params: EarnDepositParams): Promise<EarnResult>;
347
436
  bulkDeposit(items: EarnDepositParams[], options?: BulkDepositOptions): Promise<BulkEarnResult>;
@@ -395,6 +484,22 @@ interface ChainConfig {
395
484
  }
396
485
  declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
397
486
 
487
+ interface BridgeChainConfig extends ChainConfig {
488
+ lzEid: number;
489
+ /** Only set on source chains that have an OFT Adapter deployed */
490
+ oftAdapter?: Address;
491
+ /** False when the OFT adapter exists but has no outbound send pathways configured */
492
+ lzOutbound?: boolean;
493
+ /**
494
+ * Average seconds per block, used to turn LayerZero's block-confirmation
495
+ * requirement into a wall-clock estimate. Measured from mainnet, 2026-07-30.
496
+ */
497
+ blockTimeSec?: number;
498
+ }
499
+ declare const BRIDGE_CHAIN_CONFIGS: Partial<Record<Chain, BridgeChainConfig>>;
500
+ /** Drop cached pathway configs and observed timings — forces the next estimate to refetch. */
501
+ declare function clearBridgeEstimateCache(): void;
502
+
398
503
  declare const STABLE_USDT_ADDRESS: Address;
399
504
  declare const STABLE_VAULT_ADDRESS: Address;
400
505
 
@@ -422,12 +527,12 @@ declare class StableQuoteError extends StableError {
422
527
  });
423
528
  }
424
529
  declare class StableTransactionError extends StableError {
425
- phase: "approve" | "send" | "receipt" | "switch_chain";
530
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
426
531
  txHash?: `0x${string}`;
427
532
  chainId?: number;
428
533
  revertReason?: string;
429
534
  constructor(args: {
430
- phase: "approve" | "send" | "receipt" | "switch_chain";
535
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
431
536
  shortMessage: string;
432
537
  txHash?: `0x${string}`;
433
538
  chainId?: number;
@@ -455,4 +560,4 @@ declare class StableBulkError extends StableError {
455
560
  });
456
561
  }
457
562
 
458
- export { type BridgeParams, type BridgeQuote, 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 };
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 };
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,7 +88,15 @@ 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",
@@ -95,7 +105,67 @@ declare enum Network {
95
105
  interface BridgeQuote {
96
106
  /** Estimated output amount on the destination chain */
97
107
  toAmount?: number;
108
+ /** LayerZero native messaging fee (wei) — only present for USDT0→USDT0 (OFT) routes */
109
+ nativeFee?: bigint;
110
+ /** LayerZero fee paid in LZ token (wei) — only present for USDT0→USDT0 (OFT) routes */
111
+ lzTokenFee?: bigint;
112
+ /**
113
+ * How long the bridge is expected to take. Only present for USDT0 (OFT) routes,
114
+ * and omitted if the estimate could not be resolved — never treat it as required.
115
+ */
116
+ estimate?: BridgeTimeEstimate;
98
117
  }
118
+ /**
119
+ * Expected end-to-end delivery time for a USDT0 (LayerZero OFT) bridge.
120
+ *
121
+ * Almost all of the wait is source-chain finality: the DVNs securing the pathway
122
+ * refuse to attest until the send transaction is buried under `confirmations`
123
+ * source blocks. Destination execution is a few blocks on top of that.
124
+ */
125
+ interface BridgeTimeEstimate {
126
+ /** Best available estimate, in seconds — prefer this for display */
127
+ seconds: number;
128
+ /** Which input produced `seconds` — see {@link BridgeTimeEstimate.observedSeconds} */
129
+ source: "observed" | "formula";
130
+ /**
131
+ * Median delivery time of recent delivered messages on this exact pathway,
132
+ * from LayerZero Scan. More trustworthy than `formulaSeconds` — notably on
133
+ * rollup sources, where DVNs wait for L1 finality rather than raw block count.
134
+ */
135
+ observedSeconds?: number;
136
+ /**
137
+ * LayerZero's documented estimate:
138
+ * `srcBlockTime × confirmations + dstBlockTime × (2 + dvnCount)`.
139
+ */
140
+ formulaSeconds?: number;
141
+ /** Source-chain block confirmations the DVNs wait for before attesting */
142
+ confirmations?: number;
143
+ /** Number of DVNs (required + optional) verifying this pathway */
144
+ dvnCount?: number;
145
+ }
146
+ /** Delivery state of an in-flight USDT0 bridge, normalized from LayerZero Scan. */
147
+ type BridgeDeliveryState = "pending" | "inflight" | "delivered" | "failed";
148
+ interface BridgeStatus {
149
+ state: BridgeDeliveryState;
150
+ /** Raw LayerZero Scan status, e.g. "INFLIGHT" | "DELIVERED" | "FAILED" | "BLOCKED" */
151
+ raw?: string;
152
+ srcTxHash: string;
153
+ /** Destination transaction hash — present once delivered */
154
+ dstTxHash?: string;
155
+ /** Seconds since the source transaction was mined */
156
+ elapsedSeconds?: number;
157
+ /** Human-facing tracking page */
158
+ scanUrl: string;
159
+ }
160
+ /**
161
+ * Bridge route selection:
162
+ * - `"usdt0"` — force the USDT0 LayerZero OFT path (no protocol fee, just gas + LZ
163
+ * messaging fee; slower). Throws if the chain pair has no USDT0 adapter.
164
+ * - `"lifi"` — force the LI.FI aggregator path (fast, charges a fee).
165
+ * - `"auto"` — use USDT0 when both chains support it and tokens match, else LI.FI.
166
+ * This is the default.
167
+ */
168
+ type BridgeRoute = "auto" | "usdt0" | "lifi";
99
169
  interface BridgeParams {
100
170
  fromChain: Chain;
101
171
  toChain: Chain;
@@ -108,6 +178,11 @@ interface BridgeParams {
108
178
  fromDecimals?: number;
109
179
  /** Recipient address — defaults to the signer */
110
180
  recipient?: string;
181
+ /**
182
+ * Which bridge to use. Defaults to "auto" (USDT0 OFT when available, else LI.FI).
183
+ * See {@link BridgeRoute}.
184
+ */
185
+ route?: BridgeRoute;
111
186
  /** Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to bridge() */
112
187
  quote?: BridgeQuote;
113
188
  }
@@ -340,8 +415,22 @@ interface StableClient {
340
415
  transfer(params: TransferParams): Promise<OperationResult>;
341
416
  quoteBridge(params: BridgeParams): Promise<BridgeQuote>;
342
417
  bridge(params: BridgeParams): Promise<OperationResult>;
418
+ /**
419
+ * Expected delivery time for a USDT0 (LayerZero OFT) bridge, before sending.
420
+ * Throws for chain pairs with no USDT0 adapter — LI.FI carries its own ETA.
421
+ */
422
+ estimateBridgeTime(params: Pick<BridgeParams, "fromChain" | "toChain">): Promise<BridgeTimeEstimate>;
423
+ /** Delivery status of an in-flight USDT0 bridge, by source transaction hash. */
424
+ trackBridge(srcTxHash: string): Promise<BridgeStatus>;
343
425
  quoteSwap(params: SwapParams): Promise<SwapQuote>;
344
426
  swap(params: SwapParams): Promise<OperationResult>;
427
+ /**
428
+ * ERC-3009 gasless transfers ("Transfer With Authorization"). Sign a portable
429
+ * authorization the payer can hand off, then have anyone (a relayer, the
430
+ * recipient, or the enterprise gas-waiver rail) settle it on-chain. See
431
+ * {@link erc3009Actions} for the individual viem-style actions.
432
+ */
433
+ authorization: ReturnType<typeof erc3009Actions>;
345
434
  earn: {
346
435
  deposit(params: EarnDepositParams): Promise<EarnResult>;
347
436
  bulkDeposit(items: EarnDepositParams[], options?: BulkDepositOptions): Promise<BulkEarnResult>;
@@ -395,6 +484,22 @@ interface ChainConfig {
395
484
  }
396
485
  declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
397
486
 
487
+ interface BridgeChainConfig extends ChainConfig {
488
+ lzEid: number;
489
+ /** Only set on source chains that have an OFT Adapter deployed */
490
+ oftAdapter?: Address;
491
+ /** False when the OFT adapter exists but has no outbound send pathways configured */
492
+ lzOutbound?: boolean;
493
+ /**
494
+ * Average seconds per block, used to turn LayerZero's block-confirmation
495
+ * requirement into a wall-clock estimate. Measured from mainnet, 2026-07-30.
496
+ */
497
+ blockTimeSec?: number;
498
+ }
499
+ declare const BRIDGE_CHAIN_CONFIGS: Partial<Record<Chain, BridgeChainConfig>>;
500
+ /** Drop cached pathway configs and observed timings — forces the next estimate to refetch. */
501
+ declare function clearBridgeEstimateCache(): void;
502
+
398
503
  declare const STABLE_USDT_ADDRESS: Address;
399
504
  declare const STABLE_VAULT_ADDRESS: Address;
400
505
 
@@ -422,12 +527,12 @@ declare class StableQuoteError extends StableError {
422
527
  });
423
528
  }
424
529
  declare class StableTransactionError extends StableError {
425
- phase: "approve" | "send" | "receipt" | "switch_chain";
530
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
426
531
  txHash?: `0x${string}`;
427
532
  chainId?: number;
428
533
  revertReason?: string;
429
534
  constructor(args: {
430
- phase: "approve" | "send" | "receipt" | "switch_chain";
535
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
431
536
  shortMessage: string;
432
537
  txHash?: `0x${string}`;
433
538
  chainId?: number;
@@ -455,4 +560,4 @@ declare class StableBulkError extends StableError {
455
560
  });
456
561
  }
457
562
 
458
- export { type BridgeParams, type BridgeQuote, 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 };
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 };