@stablechain/sdk 1.0.4 → 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",
@@ -99,6 +109,53 @@ interface BridgeQuote {
99
109
  nativeFee?: bigint;
100
110
  /** LayerZero fee paid in LZ token (wei) — only present for USDT0→USDT0 (OFT) routes */
101
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;
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;
102
159
  }
103
160
  /**
104
161
  * Bridge route selection:
@@ -358,8 +415,22 @@ interface StableClient {
358
415
  transfer(params: TransferParams): Promise<OperationResult>;
359
416
  quoteBridge(params: BridgeParams): Promise<BridgeQuote>;
360
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>;
361
425
  quoteSwap(params: SwapParams): Promise<SwapQuote>;
362
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>;
363
434
  earn: {
364
435
  deposit(params: EarnDepositParams): Promise<EarnResult>;
365
436
  bulkDeposit(items: EarnDepositParams[], options?: BulkDepositOptions): Promise<BulkEarnResult>;
@@ -419,8 +490,15 @@ interface BridgeChainConfig extends ChainConfig {
419
490
  oftAdapter?: Address;
420
491
  /** False when the OFT adapter exists but has no outbound send pathways configured */
421
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;
422
498
  }
423
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;
424
502
 
425
503
  declare const STABLE_USDT_ADDRESS: Address;
426
504
  declare const STABLE_VAULT_ADDRESS: Address;
@@ -449,12 +527,12 @@ declare class StableQuoteError extends StableError {
449
527
  });
450
528
  }
451
529
  declare class StableTransactionError extends StableError {
452
- phase: "approve" | "send" | "receipt" | "switch_chain";
530
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
453
531
  txHash?: `0x${string}`;
454
532
  chainId?: number;
455
533
  revertReason?: string;
456
534
  constructor(args: {
457
- phase: "approve" | "send" | "receipt" | "switch_chain";
535
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
458
536
  shortMessage: string;
459
537
  txHash?: `0x${string}`;
460
538
  chainId?: number;
@@ -482,4 +560,4 @@ declare class StableBulkError extends StableError {
482
560
  });
483
561
  }
484
562
 
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 };
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",
@@ -99,6 +109,53 @@ interface BridgeQuote {
99
109
  nativeFee?: bigint;
100
110
  /** LayerZero fee paid in LZ token (wei) — only present for USDT0→USDT0 (OFT) routes */
101
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;
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;
102
159
  }
103
160
  /**
104
161
  * Bridge route selection:
@@ -358,8 +415,22 @@ interface StableClient {
358
415
  transfer(params: TransferParams): Promise<OperationResult>;
359
416
  quoteBridge(params: BridgeParams): Promise<BridgeQuote>;
360
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>;
361
425
  quoteSwap(params: SwapParams): Promise<SwapQuote>;
362
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>;
363
434
  earn: {
364
435
  deposit(params: EarnDepositParams): Promise<EarnResult>;
365
436
  bulkDeposit(items: EarnDepositParams[], options?: BulkDepositOptions): Promise<BulkEarnResult>;
@@ -419,8 +490,15 @@ interface BridgeChainConfig extends ChainConfig {
419
490
  oftAdapter?: Address;
420
491
  /** False when the OFT adapter exists but has no outbound send pathways configured */
421
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;
422
498
  }
423
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;
424
502
 
425
503
  declare const STABLE_USDT_ADDRESS: Address;
426
504
  declare const STABLE_VAULT_ADDRESS: Address;
@@ -449,12 +527,12 @@ declare class StableQuoteError extends StableError {
449
527
  });
450
528
  }
451
529
  declare class StableTransactionError extends StableError {
452
- phase: "approve" | "send" | "receipt" | "switch_chain";
530
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
453
531
  txHash?: `0x${string}`;
454
532
  chainId?: number;
455
533
  revertReason?: string;
456
534
  constructor(args: {
457
- phase: "approve" | "send" | "receipt" | "switch_chain";
535
+ phase: "approve" | "send" | "receipt" | "switch_chain" | "sign";
458
536
  shortMessage: string;
459
537
  txHash?: `0x${string}`;
460
538
  chainId?: number;
@@ -482,4 +560,4 @@ declare class StableBulkError extends StableError {
482
560
  });
483
561
  }
484
562
 
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 };
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 };