@stablechain/sdk 1.0.7 → 1.0.9

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.cjs CHANGED
@@ -18,7 +18,8 @@
18
18
 
19
19
 
20
20
 
21
- var _chunkQQ26UI3Fcjs = require('./chunk-QQ26UI3F.cjs');
21
+
22
+ var _chunkMMZ7HVWZcjs = require('./chunk-MMZ7HVWZ.cjs');
22
23
 
23
24
  // src/stable.ts
24
25
 
@@ -122,7 +123,7 @@ var MorphoService = class {
122
123
  deposit(params) {
123
124
  this._validateAmount(params.amount, "earn deposit");
124
125
  if (params.depositBuffer !== void 0 && (params.depositBuffer <= 0 || params.depositBuffer > 1)) {
125
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
126
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
126
127
  "depositBuffer",
127
128
  params.depositBuffer,
128
129
  "earn deposit: depositBuffer must be > 0 and \u2264 1"
@@ -158,7 +159,7 @@ var MorphoService = class {
158
159
  const succeeded2 = results.filter(
159
160
  (r) => r.status === "fulfilled"
160
161
  ).length;
161
- throw new (0, _chunkQQ26UI3Fcjs.StableBulkError)({
162
+ throw new (0, _chunkMMZ7HVWZcjs.StableBulkError)({
162
163
  shortMessage: "bulkDeposit halted on first failure",
163
164
  results,
164
165
  succeeded: succeeded2,
@@ -202,7 +203,7 @@ var MorphoService = class {
202
203
  const succeeded2 = results.filter(
203
204
  (r) => r.status === "fulfilled"
204
205
  ).length;
205
- throw new (0, _chunkQQ26UI3Fcjs.StableBulkError)({
206
+ throw new (0, _chunkMMZ7HVWZcjs.StableBulkError)({
206
207
  shortMessage: "bulkWithdraw halted on first failure",
207
208
  results,
208
209
  succeeded: succeeded2,
@@ -255,7 +256,7 @@ var MorphoService = class {
255
256
  async prepareDepositCalldata(params) {
256
257
  this._validateAmount(params.amount, "prepareDepositCalldata");
257
258
  if (params.depositBuffer !== void 0 && (params.depositBuffer <= 0 || params.depositBuffer > 1)) {
258
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
259
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
259
260
  "depositBuffer",
260
261
  params.depositBuffer,
261
262
  "prepareDepositCalldata: depositBuffer must be > 0 and \u2264 1"
@@ -274,7 +275,7 @@ var MorphoService = class {
274
275
  if (assetsRaw > maxAllowed) {
275
276
  const maxFormatted = Number(_viem.formatUnits.call(void 0, maxAllowed, decimals));
276
277
  const idleFormatted = Number(_viem.formatUnits.call(void 0, vaultData.assetBalance, decimals));
277
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
278
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
278
279
  "amount",
279
280
  amount,
280
281
  `prepareDepositCalldata: amount ${amount} exceeds deposit buffer \u2014 max ${maxFormatted} (${depositBuffer * 100}% of ${idleFormatted} idle liquidity)`
@@ -332,7 +333,7 @@ var MorphoService = class {
332
333
  functionName: "decimals"
333
334
  });
334
335
  } catch (e) {
335
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
336
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
336
337
  "shareDecimals",
337
338
  void 0,
338
339
  `prepareRedeemCalldata: could not fetch share decimals for vault "${vaultAddr}" \u2014 pass shareDecimals explicitly`
@@ -378,7 +379,7 @@ var MorphoService = class {
378
379
  const idleFormatted = Number(
379
380
  _viem.formatUnits.call(void 0, vaultData.assetBalance, decimals)
380
381
  );
381
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
382
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
382
383
  "amount",
383
384
  amount,
384
385
  `earn deposit: amount ${amount} exceeds deposit buffer \u2014 max ${maxFormatted} (${depositBuffer * 100}% of ${idleFormatted} idle liquidity)`
@@ -408,7 +409,7 @@ var MorphoService = class {
408
409
  hash: approveHash
409
410
  });
410
411
  if (approveReceipt.status === "reverted") {
411
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
412
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
412
413
  phase: "approve",
413
414
  shortMessage: "earn deposit: token approval reverted on-chain",
414
415
  txHash: approveReceipt.transactionHash,
@@ -423,7 +424,7 @@ var MorphoService = class {
423
424
  const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
424
425
  const receipt = await this.pc.waitForTransactionReceipt({ hash });
425
426
  if (receipt.status === "reverted") {
426
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
427
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
427
428
  phase: "receipt",
428
429
  shortMessage: "earn deposit: vault deposit reverted on-chain",
429
430
  txHash: receipt.transactionHash,
@@ -453,7 +454,7 @@ var MorphoService = class {
453
454
  const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
454
455
  const receipt = await this.pc.waitForTransactionReceipt({ hash });
455
456
  if (receipt.status === "reverted") {
456
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
457
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
457
458
  phase: "receipt",
458
459
  shortMessage: "earn withdraw: vault withdraw reverted on-chain",
459
460
  txHash: receipt.transactionHash,
@@ -476,7 +477,7 @@ var MorphoService = class {
476
477
  functionName: "decimals"
477
478
  });
478
479
  } catch (e2) {
479
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
480
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
480
481
  "shareDecimals",
481
482
  void 0,
482
483
  `earn redeem: could not fetch share decimals for vault "${vaultAddr}" \u2014 pass shareDecimals explicitly`
@@ -499,7 +500,7 @@ var MorphoService = class {
499
500
  const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
500
501
  const receipt = await this.pc.waitForTransactionReceipt({ hash });
501
502
  if (receipt.status === "reverted") {
502
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
503
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
503
504
  phase: "receipt",
504
505
  shortMessage: "earn redeem: vault redeem reverted on-chain",
505
506
  txHash: receipt.transactionHash,
@@ -530,7 +531,7 @@ var MorphoService = class {
530
531
  const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
531
532
  const receipt = await this.pc.waitForTransactionReceipt({ hash });
532
533
  if (receipt.status === "reverted") {
533
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
534
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
534
535
  phase: "receipt",
535
536
  shortMessage: "earn forceWithdraw: vault forceWithdraw reverted on-chain",
536
537
  txHash: receipt.transactionHash,
@@ -560,7 +561,7 @@ var MorphoService = class {
560
561
  functionName: "decimals"
561
562
  });
562
563
  } catch (e3) {
563
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
564
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
564
565
  "shareDecimals",
565
566
  void 0,
566
567
  `earn forceRedeem: could not fetch share decimals for vault "${vaultAddr}" \u2014 pass shareDecimals explicitly`
@@ -583,7 +584,7 @@ var MorphoService = class {
583
584
  const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
584
585
  const receipt = await this.pc.waitForTransactionReceipt({ hash });
585
586
  if (receipt.status === "reverted") {
586
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
587
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
587
588
  phase: "receipt",
588
589
  shortMessage: "earn forceRedeem: vault forceRedeem reverted on-chain",
589
590
  txHash: receipt.transactionHash,
@@ -605,7 +606,7 @@ var MorphoService = class {
605
606
  remaining = this._pullFromAdapter(adapter, remaining, now, result);
606
607
  }
607
608
  if (remaining > 0n) {
608
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
609
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
609
610
  "amount",
610
611
  amount,
611
612
  "earn withdraw: insufficient adapter liquidity \u2014 reduce the amount or wait for market liquidity to free up"
@@ -652,7 +653,7 @@ var MorphoService = class {
652
653
  _requireFrom() {
653
654
  const from = _optionalChain([this, 'access', _4 => _4.wc, 'access', _5 => _5.account, 'optionalAccess', _6 => _6.address]);
654
655
  if (!from) {
655
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
656
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
656
657
  "signer",
657
658
  void 0,
658
659
  "earn: requires a signer \u2014 set walletClient or account in StableConfig"
@@ -665,7 +666,7 @@ var MorphoService = class {
665
666
  await this.wc.switchChain({ id: this.config.chainId });
666
667
  } catch (err) {
667
668
  if (err.code === 4001) {
668
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
669
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
669
670
  phase: "switch_chain",
670
671
  shortMessage: `earn: wallet rejected switch to chain ${this.config.chainId}`,
671
672
  chainId: this.config.chainId,
@@ -684,7 +685,7 @@ var MorphoService = class {
684
685
  chain: this.chain
685
686
  });
686
687
  } catch (err) {
687
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
688
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
688
689
  phase: "send",
689
690
  shortMessage: "earn: transaction send failed",
690
691
  chainId: this.config.chainId,
@@ -702,7 +703,7 @@ var MorphoService = class {
702
703
  })
703
704
  );
704
705
  } catch (e4) {
705
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
706
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
706
707
  "tokenDecimals",
707
708
  void 0,
708
709
  `${op}: could not fetch decimals for asset "${asset}" \u2014 pass tokenDecimals explicitly`
@@ -719,7 +720,7 @@ var MorphoService = class {
719
720
  }
720
721
  _validateAmount(amount, op) {
721
722
  if (!Number.isFinite(amount) || amount <= 0) {
722
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
723
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
723
724
  "amount",
724
725
  amount,
725
726
  `${op}: amount must be a finite positive number`
@@ -728,7 +729,7 @@ var MorphoService = class {
728
729
  }
729
730
  _validateShares(shares, op) {
730
731
  if (!Number.isFinite(shares) || shares <= 0) {
731
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
732
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
732
733
  "shares",
733
734
  shares,
734
735
  `${op}: shares must be a finite positive number`
@@ -783,21 +784,21 @@ var MORPHO_API_URL = "https://blue-api.morpho.org/graphql";
783
784
  var EarnReader = class {
784
785
  constructor(config) {
785
786
  if (!_optionalChain([config, 'access', _7 => _7.earn, 'optionalAccess', _8 => _8.vault])) {
786
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
787
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
787
788
  "earn.vault",
788
789
  void 0,
789
790
  "createStableReader: earn.vault is required"
790
791
  );
791
792
  }
792
793
  if (!_viem.isAddress.call(void 0, config.address)) {
793
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
794
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
794
795
  "address",
795
796
  config.address,
796
797
  `createStableReader: invalid user address "${config.address}"`
797
798
  );
798
799
  }
799
800
  if (!_viem.isAddress.call(void 0, config.earn.vault)) {
800
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
801
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
801
802
  "earn.vault",
802
803
  config.earn.vault,
803
804
  `createStableReader: invalid vault address "${config.earn.vault}"`
@@ -932,7 +933,7 @@ var EarnReader = class {
932
933
  );
933
934
  } catch (err) {
934
935
  if (err instanceof TypeError || err instanceof HttpError) {
935
- throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
936
+ throw new (0, _chunkMMZ7HVWZcjs.StableNetworkError)({
936
937
  shortMessage: err instanceof HttpError ? `earn: Morpho API returned ${err.status} after retries` : `earn: failed to reach Morpho API after retries \u2014 ${String(
937
938
  err
938
939
  )}`,
@@ -944,7 +945,7 @@ var EarnReader = class {
944
945
  }
945
946
  const vault = _optionalChain([body, 'optionalAccess', _9 => _9.data, 'optionalAccess', _10 => _10.vaultV2ByAddress]);
946
947
  if (!vault || typeof vault.avgNetApy !== "number") {
947
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
948
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
948
949
  "apy",
949
950
  void 0,
950
951
  "earn: vault not found in Morpho API or unexpected response shape"
@@ -996,7 +997,7 @@ var MerklService = class {
996
997
  }
997
998
  async fetchRewards(address) {
998
999
  if (!_viem.isAddress.call(void 0, address)) {
999
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1000
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1000
1001
  "address",
1001
1002
  address,
1002
1003
  `merkl: invalid address "${address}"`
@@ -1014,7 +1015,7 @@ var MerklService = class {
1014
1015
  (r) => r.rawAmount !== "0" && r.proofs.length > 0
1015
1016
  );
1016
1017
  if (claimable.length === 0) {
1017
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1018
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1018
1019
  "rewards",
1019
1020
  [],
1020
1021
  rewards.length > 0 ? "merkl: rewards are pending the next merkle tree update \u2014 try again in ~2 hours" : "merkl: no rewards to claim on this chain"
@@ -1029,7 +1030,7 @@ var MerklService = class {
1029
1030
  try {
1030
1031
  await wc.switchChain({ id: this.config.chainId });
1031
1032
  } catch (err) {
1032
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
1033
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
1033
1034
  phase: "switch_chain",
1034
1035
  shortMessage: `merkl: wallet rejected or failed to switch to chain ${this.config.chainId}`,
1035
1036
  chainId: this.config.chainId,
@@ -1053,7 +1054,7 @@ var MerklService = class {
1053
1054
  chain
1054
1055
  });
1055
1056
  } catch (err) {
1056
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
1057
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
1057
1058
  phase: "send",
1058
1059
  shortMessage: "merkl: claim transaction failed",
1059
1060
  chainId: this.config.chainId,
@@ -1066,7 +1067,7 @@ var MerklService = class {
1066
1067
  });
1067
1068
  const receipt = await pc.waitForTransactionReceipt({ hash });
1068
1069
  if (receipt.status === "reverted") {
1069
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
1070
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
1070
1071
  phase: "receipt",
1071
1072
  shortMessage: "merkl: claim transaction reverted on-chain",
1072
1073
  txHash: receipt.transactionHash,
@@ -1080,7 +1081,7 @@ var MerklService = class {
1080
1081
  }
1081
1082
  async prepareClaimCalldata(address) {
1082
1083
  if (!_viem.isAddress.call(void 0, address)) {
1083
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1084
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1084
1085
  "address",
1085
1086
  address,
1086
1087
  `merkl: invalid address "${address}"`
@@ -1091,7 +1092,7 @@ var MerklService = class {
1091
1092
  (r) => r.rawAmount !== "0" && r.proofs.length > 0
1092
1093
  );
1093
1094
  if (claimable.length === 0) {
1094
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1095
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1095
1096
  "rewards",
1096
1097
  [],
1097
1098
  rewards.length > 0 ? "merkl: rewards are pending the next merkle tree update \u2014 try again in ~2 hours" : "merkl: no rewards to claim on this chain"
@@ -1116,7 +1117,7 @@ var MerklService = class {
1116
1117
  _requireFrom() {
1117
1118
  const from = _nullishCoalesce(_optionalChain([this, 'access', _11 => _11.config, 'access', _12 => _12.walletClient, 'optionalAccess', _13 => _13.account, 'optionalAccess', _14 => _14.address]), () => ( _optionalChain([this, 'access', _15 => _15.config, 'access', _16 => _16.account, 'optionalAccess', _17 => _17.address])));
1118
1119
  if (!from) {
1119
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1120
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1120
1121
  "signer",
1121
1122
  void 0,
1122
1123
  "merkl.claim: requires a signer \u2014 set walletClient or account in StableConfig"
@@ -1158,15 +1159,15 @@ var MerklService = class {
1158
1159
  try {
1159
1160
  return await retryWithBackoff(() => this._fetchOnce(url));
1160
1161
  } catch (err) {
1161
- if (err instanceof _chunkQQ26UI3Fcjs.StableNetworkError) throw err;
1162
+ if (err instanceof _chunkMMZ7HVWZcjs.StableNetworkError) throw err;
1162
1163
  if (err instanceof HttpError) {
1163
- throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
1164
+ throw new (0, _chunkMMZ7HVWZcjs.StableNetworkError)({
1164
1165
  shortMessage: `merkl: request failed \u2014 ${err.message}`,
1165
1166
  url,
1166
1167
  cause: err
1167
1168
  });
1168
1169
  }
1169
- throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
1170
+ throw new (0, _chunkMMZ7HVWZcjs.StableNetworkError)({
1170
1171
  shortMessage: "merkl: request failed before reaching the server",
1171
1172
  url,
1172
1173
  cause: err
@@ -1183,7 +1184,7 @@ var MerklService = class {
1183
1184
  true
1184
1185
  );
1185
1186
  }
1186
- throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
1187
+ throw new (0, _chunkMMZ7HVWZcjs.StableNetworkError)({
1187
1188
  shortMessage: `merkl: API error ${res.status} ${res.statusText}`,
1188
1189
  url
1189
1190
  });
@@ -1382,13 +1383,13 @@ var LiFiService = class {
1382
1383
  const src = CHAIN_CONFIGS[fromChain];
1383
1384
  const dst = CHAIN_CONFIGS[toChain];
1384
1385
  if (!src)
1385
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1386
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1386
1387
  "fromChain",
1387
1388
  fromChain,
1388
1389
  `LI.FI bridge: unsupported source chain "${fromChain}"`
1389
1390
  );
1390
1391
  if (!dst)
1391
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1392
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1392
1393
  "toChain",
1393
1394
  toChain,
1394
1395
  `LI.FI bridge: unsupported destination chain "${toChain}"`
@@ -1420,14 +1421,14 @@ var LiFiService = class {
1420
1421
  const src = CHAIN_CONFIGS[fromChain];
1421
1422
  const dst = CHAIN_CONFIGS[toChain];
1422
1423
  if (!src) {
1423
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1424
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1424
1425
  "fromChain",
1425
1426
  fromChain,
1426
1427
  `LI.FI bridge: unsupported source chain "${fromChain}"`
1427
1428
  );
1428
1429
  }
1429
1430
  if (!dst) {
1430
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1431
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1431
1432
  "toChain",
1432
1433
  toChain,
1433
1434
  `LI.FI bridge: unsupported destination chain "${toChain}"`
@@ -1456,35 +1457,35 @@ var LiFiService = class {
1456
1457
  toAddress
1457
1458
  }) {
1458
1459
  if (!_viem.isAddress.call(void 0, fromToken)) {
1459
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1460
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1460
1461
  "fromToken",
1461
1462
  fromToken,
1462
1463
  `swap: invalid fromToken address "${fromToken}"`
1463
1464
  );
1464
1465
  }
1465
1466
  if (!_viem.isAddress.call(void 0, toToken)) {
1466
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1467
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1467
1468
  "toToken",
1468
1469
  toToken,
1469
1470
  `swap: invalid toToken address "${toToken}"`
1470
1471
  );
1471
1472
  }
1472
1473
  if (fromToken.toLowerCase() === toToken.toLowerCase()) {
1473
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1474
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1474
1475
  "toToken",
1475
1476
  toToken,
1476
1477
  "swap: fromToken and toToken must differ"
1477
1478
  );
1478
1479
  }
1479
1480
  if (!Number.isFinite(amount) || amount <= 0) {
1480
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1481
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1481
1482
  "amount",
1482
1483
  amount,
1483
1484
  "swap: amount must be a finite positive number"
1484
1485
  );
1485
1486
  }
1486
1487
  if (toAddress !== void 0 && !_viem.isAddress.call(void 0, toAddress)) {
1487
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1488
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1488
1489
  "toAddress",
1489
1490
  toAddress,
1490
1491
  `swap: invalid toAddress "${toAddress}"`
@@ -1500,35 +1501,35 @@ var LiFiService = class {
1500
1501
  recipient
1501
1502
  }) {
1502
1503
  if (!_viem.isAddress.call(void 0, fromToken)) {
1503
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1504
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1504
1505
  "fromToken",
1505
1506
  fromToken,
1506
1507
  `LI.FI bridge: invalid fromToken address "${fromToken}"`
1507
1508
  );
1508
1509
  }
1509
1510
  if (!_viem.isAddress.call(void 0, toToken)) {
1510
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1511
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1511
1512
  "toToken",
1512
1513
  toToken,
1513
1514
  `LI.FI bridge: invalid toToken address "${toToken}"`
1514
1515
  );
1515
1516
  }
1516
1517
  if (!Number.isFinite(amount) || amount <= 0) {
1517
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1518
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1518
1519
  "amount",
1519
1520
  amount,
1520
1521
  "LI.FI bridge: amount must be a finite positive number"
1521
1522
  );
1522
1523
  }
1523
1524
  if (recipient !== void 0 && !_viem.isAddress.call(void 0, recipient)) {
1524
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1525
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1525
1526
  "recipient",
1526
1527
  recipient,
1527
1528
  `LI.FI bridge: invalid recipient address "${recipient}"`
1528
1529
  );
1529
1530
  }
1530
1531
  if (fromChain === toChain) {
1531
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1532
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1532
1533
  "toChain",
1533
1534
  toChain,
1534
1535
  "LI.FI bridge: fromChain and toChain must differ"
@@ -1538,7 +1539,7 @@ var LiFiService = class {
1538
1539
  _requireFrom() {
1539
1540
  const from = _nullishCoalesce(_optionalChain([this, 'access', _29 => _29.config, 'access', _30 => _30.walletClient, 'optionalAccess', _31 => _31.account, 'optionalAccess', _32 => _32.address]), () => ( _optionalChain([this, 'access', _33 => _33.config, 'access', _34 => _34.account, 'optionalAccess', _35 => _35.address])));
1540
1541
  if (!from) {
1541
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
1542
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1542
1543
  "signer",
1543
1544
  void 0,
1544
1545
  "LI.FI: requires a signer \u2014 set walletClient or account in StableConfig"
@@ -1551,16 +1552,16 @@ var LiFiService = class {
1551
1552
  try {
1552
1553
  return await retryWithBackoff(() => this._fetchQuoteOnce(url));
1553
1554
  } catch (err) {
1554
- if (err instanceof _chunkQQ26UI3Fcjs.StableQuoteError) throw err;
1555
+ if (err instanceof _chunkMMZ7HVWZcjs.StableQuoteError) throw err;
1555
1556
  if (err instanceof HttpError) {
1556
- throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
1557
+ throw new (0, _chunkMMZ7HVWZcjs.StableQuoteError)({
1557
1558
  provider: "lifi",
1558
1559
  shortMessage: err.message,
1559
1560
  httpStatus: err.status,
1560
1561
  cause: err
1561
1562
  });
1562
1563
  }
1563
- throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
1564
+ throw new (0, _chunkMMZ7HVWZcjs.StableNetworkError)({
1564
1565
  shortMessage: "LI.FI: quote request failed before reaching the server",
1565
1566
  url,
1566
1567
  cause: err
@@ -1580,7 +1581,7 @@ var LiFiService = class {
1580
1581
  true
1581
1582
  );
1582
1583
  }
1583
- throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
1584
+ throw new (0, _chunkMMZ7HVWZcjs.StableQuoteError)({
1584
1585
  provider: "lifi",
1585
1586
  shortMessage: `LI.FI: ${_nullishCoalesce(providerMessage, () => ( res.statusText))}`,
1586
1587
  httpStatus: res.status,
@@ -1589,7 +1590,7 @@ var LiFiService = class {
1589
1590
  });
1590
1591
  }
1591
1592
  if (!isLiFiQuoteShape(body)) {
1592
- throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
1593
+ throw new (0, _chunkMMZ7HVWZcjs.StableQuoteError)({
1593
1594
  provider: "lifi",
1594
1595
  shortMessage: "LI.FI: unexpected quote response shape",
1595
1596
  httpStatus: res.status,
@@ -1617,7 +1618,7 @@ var LiFiService = class {
1617
1618
  const { transactionRequest } = quote;
1618
1619
  const srcChainId = transactionRequest.chainId;
1619
1620
  if (srcChainId !== expectedChainId) {
1620
- throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
1621
+ throw new (0, _chunkMMZ7HVWZcjs.StableQuoteError)({
1621
1622
  provider: "lifi",
1622
1623
  shortMessage: `LI.FI: returned tx for chain ${srcChainId} but expected ${expectedChainId}`,
1623
1624
  providerCode: "chain_mismatch",
@@ -1633,7 +1634,7 @@ var LiFiService = class {
1633
1634
  try {
1634
1635
  await wc.switchChain({ id: srcChainId });
1635
1636
  } catch (err) {
1636
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
1637
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
1637
1638
  phase: "switch_chain",
1638
1639
  shortMessage: `LI.FI: wallet rejected or failed to switch to chain ${srcChainId}`,
1639
1640
  chainId: srcChainId,
@@ -1659,7 +1660,7 @@ var LiFiService = class {
1659
1660
  chain: srcChain
1660
1661
  });
1661
1662
  } catch (err) {
1662
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
1663
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
1663
1664
  phase: "send",
1664
1665
  shortMessage: "LI.FI: swap/bridge transaction failed",
1665
1666
  chainId: srcChainId,
@@ -1694,7 +1695,7 @@ var LiFiService = class {
1694
1695
  chain: srcChain
1695
1696
  });
1696
1697
  } catch (err) {
1697
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
1698
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
1698
1699
  phase: "approve",
1699
1700
  shortMessage: "LI.FI: token approve failed",
1700
1701
  chainId: srcChainId,
@@ -1705,7 +1706,7 @@ var LiFiService = class {
1705
1706
  hash: approveHash
1706
1707
  });
1707
1708
  if (approveReceipt.status === "reverted") {
1708
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
1709
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
1709
1710
  phase: "approve",
1710
1711
  shortMessage: "LI.FI: token approve reverted on-chain",
1711
1712
  txHash: approveReceipt.transactionHash,
@@ -1750,8 +1751,14 @@ var XAUT0_DEPLOYMENTS = {
1750
1751
  ["plasma" /* Plasma */]: { address: "0x1B64B9025EEbb9A6239575dF9Ea4b9Ac46D4d193", decimals: 6, oftAdapter: "0x63aB93cBC9d4ecD9c4947b1A38F458147C08E6F7", approvalRequired: false },
1751
1752
  ["bsc" /* BSC */]: { address: "0x21cAef8A43163Eea865baeE23b9C2E327696A3bf", decimals: 6, oftAdapter: "0x53C3A64c8942288e12813C1F8457Db45980BcfC2", approvalRequired: false }
1752
1753
  };
1754
+ var PYUSD_DEPLOYMENTS = {
1755
+ // No floor: unlike USDT0's, this pathway's DVNs don't hold for finality. 15
1756
+ // confirmations compute to ~184s; LayerZero Scan observed ~202s (2026-10-27).
1757
+ ["ethereum" /* Ethereum */]: { address: "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8", decimals: 6, oftAdapter: "0xa2C323fE5A74aDffAd2bf3E007E36bb029606444", approvalRequired: false, minDeliverySec: 0 },
1758
+ ["stable" /* Stable */]: { address: _chunkMMZ7HVWZcjs.STABLE_PYUSD_ADDRESS, decimals: 6, oftAdapter: "0x2eb79387Fa1a6EF6DC8E25401C8fdc291Cc542C7", approvalRequired: false }
1759
+ };
1753
1760
  var USDT0_LOCKBOX_CHAINS = /* @__PURE__ */ new Set(["ethereum" /* Ethereum */, "sepolia" /* Sepolia */]);
1754
- function bridgeChain(chain, lzEid, blockTimeSec, usdt0Adapter) {
1761
+ function bridgeChain(chain, lzEid, blockTimeSec, usdt0Adapter, minDeliverySec) {
1755
1762
  const base = C[chain];
1756
1763
  const tokens = {};
1757
1764
  if (usdt0Adapter) {
@@ -1764,7 +1771,9 @@ function bridgeChain(chain, lzEid, blockTimeSec, usdt0Adapter) {
1764
1771
  }
1765
1772
  const xaut0 = XAUT0_DEPLOYMENTS[chain];
1766
1773
  if (xaut0) tokens.xaut0 = xaut0;
1767
- return { ...base, lzEid, blockTimeSec, tokens, oftAdapter: usdt0Adapter };
1774
+ const pyusd = PYUSD_DEPLOYMENTS[chain];
1775
+ if (pyusd) tokens.pyusd = pyusd;
1776
+ return { ...base, lzEid, blockTimeSec, minDeliverySec, tokens, oftAdapter: usdt0Adapter };
1768
1777
  }
1769
1778
  var BRIDGE_CHAIN_CONFIGS = {
1770
1779
  // ─── Testnet ───────────────────────────────────────────────────────────────
@@ -1772,18 +1781,18 @@ var BRIDGE_CHAIN_CONFIGS = {
1772
1781
  ["stable-testnet" /* StableTestnet */]: bridgeChain("stable-testnet" /* StableTestnet */, 40374, 0.7, "0x779Ded0c9e1022225f8E0630b35a9b54bE713736"),
1773
1782
  // ─── Mainnet ──────────────────────────────────────────────────────────────
1774
1783
  ["stable" /* Stable */]: bridgeChain("stable" /* Stable */, 30396, 0.7, "0xedaba024be4d87974d5aB11C6Dd586963CcCB027"),
1775
- ["ethereum" /* Ethereum */]: bridgeChain("ethereum" /* Ethereum */, 30101, 12, "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee"),
1776
- ["arbitrum" /* Arbitrum */]: bridgeChain("arbitrum" /* Arbitrum */, 30110, 0.25, "0x14E4A1B13bf7F943c8ff7C51fb60FA964A298D92"),
1784
+ ["ethereum" /* Ethereum */]: bridgeChain("ethereum" /* Ethereum */, 30101, 12, "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee", 1170),
1785
+ ["arbitrum" /* Arbitrum */]: bridgeChain("arbitrum" /* Arbitrum */, 30110, 0.25, "0x14E4A1B13bf7F943c8ff7C51fb60FA964A298D92", 1350),
1777
1786
  ["ink" /* Ink */]: bridgeChain("ink" /* Ink */, 30339, 1, "0x1cB6De532588fCA4a21B7209DE7C456AF8434A65"),
1778
- ["bera" /* Bera */]: bridgeChain("bera" /* Bera */, 30362, 2, "0x3Dc96399109df5ceb2C226664A086140bD0379cB"),
1787
+ ["bera" /* Bera */]: bridgeChain("bera" /* Bera */, 30362, 2, "0x3Dc96399109df5ceb2C226664A086140bD0379cB", 135),
1779
1788
  ["megaeth" /* MegaETH */]: bridgeChain("megaeth" /* MegaETH */, 30398, 1, "0x9151434b16b9763660705744891fa906f660ecc5"),
1780
1789
  ["hyperevm" /* HyperEVM */]: bridgeChain("hyperevm" /* HyperEVM */, 30367, 1, "0x904861a24F30EC96ea7CFC3bE9EA4B476d237e98"),
1781
- ["polygon" /* Polygon */]: bridgeChain("polygon" /* Polygon */, 30109, 1.5, "0x6BA10300f0DC58B7a1e4c0e41f5daBb7D7829e13"),
1790
+ ["polygon" /* Polygon */]: bridgeChain("polygon" /* Polygon */, 30109, 1.5, "0x6BA10300f0DC58B7a1e4c0e41f5daBb7D7829e13", 70),
1782
1791
  ["plasma" /* Plasma */]: bridgeChain("plasma" /* Plasma */, 30383, 1, "0x02ca37966753bDdDf11216B73B16C1dE756A7CF9"),
1783
1792
  ["optimism" /* Optimism */]: bridgeChain("optimism" /* Optimism */, 30111, 2, "0xF03b4d9AC1D5d1E7c4cEf54C2A313b9fe051A0aD"),
1784
1793
  ["unichain" /* Unichain */]: bridgeChain("unichain" /* Unichain */, 30320, 1, "0xc07bE8994D035631c36fb4a89C918CeFB2f03EC3"),
1785
1794
  ["sei" /* Sei */]: bridgeChain("sei" /* Sei */, 30280, 0.5, "0x56Fe74A2e3b484b921c447357203431a3485CC60"),
1786
- ["flare" /* Flare */]: bridgeChain("flare" /* Flare */, 30295, 1.1, "0x567287d2A9829215a37e3B88843d32f9221E7588"),
1795
+ ["flare" /* Flare */]: bridgeChain("flare" /* Flare */, 30295, 1.1, "0x567287d2A9829215a37e3B88843d32f9221E7588", 600),
1787
1796
  ["xlayer" /* XLayer */]: bridgeChain("xlayer" /* XLayer */, 30274, 1, "0x94BCCa6bdfd6A61817Ab0E960bFedE4984505554"),
1788
1797
  ["rootstock" /* Rootstock */]: bridgeChain("rootstock" /* Rootstock */, 30333, 31, "0x1a594d5d5d1c426281C1064B07f23F57B2716B61"),
1789
1798
  // XAUt0 only — BSC has no USDT0 deployment. Block time measured 2026-08-20.
@@ -1964,6 +1973,14 @@ function median(values) {
1964
1973
  const mid = Math.floor(sorted.length / 2);
1965
1974
  return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
1966
1975
  }
1976
+ function resolveDeliverySeconds(formulaSeconds, observedSeconds, minDeliverySec) {
1977
+ const base = _nullishCoalesce(formulaSeconds, () => ( observedSeconds));
1978
+ if (base === void 0) return void 0;
1979
+ if (minDeliverySec !== void 0 && minDeliverySec > base) {
1980
+ return { seconds: minDeliverySec, source: "floor" };
1981
+ }
1982
+ return { seconds: base, source: formulaSeconds !== void 0 ? "formula" : "observed" };
1983
+ }
1967
1984
  var WORKER_EXECUTOR = 1;
1968
1985
  var OPTION_LZRECEIVE = 1;
1969
1986
  var OPTION_NATIVE_DROP = 2;
@@ -1982,7 +1999,7 @@ function buildLzOptions(gasLimit = 0n, nativeDrop = 0n, dropReceiver) {
1982
1999
  ];
1983
2000
  if (nativeDrop > 0n) {
1984
2001
  if (!dropReceiver) {
1985
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2002
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
1986
2003
  "recipient",
1987
2004
  dropReceiver,
1988
2005
  "buildLzOptions: a native drop needs a receiver address"
@@ -2013,7 +2030,7 @@ function padFee(nativeFee, bufferBps) {
2013
2030
  function resolveFeeBuffer(feeBufferBps, method) {
2014
2031
  if (feeBufferBps === void 0) return DEFAULT_FEE_BUFFER_BPS;
2015
2032
  if (!Number.isInteger(feeBufferBps) || feeBufferBps < 0 || feeBufferBps > MAX_FEE_BUFFER_BPS) {
2016
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2033
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2017
2034
  "feeBufferBps",
2018
2035
  feeBufferBps,
2019
2036
  `${method}: feeBufferBps must be an integer between 0 and ${MAX_FEE_BUFFER_BPS}`
@@ -2095,7 +2112,7 @@ var LayerZeroService = class {
2095
2112
  functionName: "quoteSend",
2096
2113
  args: [sendParam, false]
2097
2114
  }).catch((err) => {
2098
- throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
2115
+ throw new (0, _chunkMMZ7HVWZcjs.StableQuoteError)({
2099
2116
  provider: "layerzero",
2100
2117
  shortMessage: plan.nativeDrop > 0n ? `${method}: quoteSend call failed \u2014 a dstNativeDrop over the pathway's executor nativeCap is the usual cause` : `${method}: quoteSend call failed`,
2101
2118
  cause: err
@@ -2103,7 +2120,7 @@ var LayerZeroService = class {
2103
2120
  }),
2104
2121
  this.readOftQuote(plan, sendParam).catch((err) => {
2105
2122
  if (!requireOft) return void 0;
2106
- throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
2123
+ throw new (0, _chunkMMZ7HVWZcjs.StableQuoteError)({
2107
2124
  provider: "layerzero",
2108
2125
  shortMessage: `${method}: quoteOFT call failed \u2014 the adapter's receipt is what floors the send at what it would actually deliver, and there is no safe default for it`,
2109
2126
  cause: err
@@ -2232,7 +2249,7 @@ var LayerZeroService = class {
2232
2249
  chain: srcChain
2233
2250
  });
2234
2251
  } catch (err) {
2235
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
2252
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
2236
2253
  phase: "approve",
2237
2254
  shortMessage: `bridge: ${asset} ${what} failed`,
2238
2255
  chainId: src.id,
@@ -2241,7 +2258,7 @@ var LayerZeroService = class {
2241
2258
  }
2242
2259
  const approveReceipt = await pc.waitForTransactionReceipt({ hash: approveHash });
2243
2260
  if (approveReceipt.status === "reverted") {
2244
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
2261
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
2245
2262
  phase: "approve",
2246
2263
  shortMessage: `bridge: ${asset} ${what} reverted on-chain`,
2247
2264
  txHash: approveReceipt.transactionHash,
@@ -2252,7 +2269,7 @@ var LayerZeroService = class {
2252
2269
  async bridge(params) {
2253
2270
  const from = this.signerAddress();
2254
2271
  if (!from) {
2255
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2272
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2256
2273
  "signer",
2257
2274
  void 0,
2258
2275
  "bridge: requires a signer \u2014 set walletClient or account in StableConfig"
@@ -2275,7 +2292,7 @@ var LayerZeroService = class {
2275
2292
  try {
2276
2293
  await wc.switchChain({ id: src.id });
2277
2294
  } catch (err) {
2278
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
2295
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
2279
2296
  phase: "switch_chain",
2280
2297
  shortMessage: `bridge: wallet rejected or failed to switch to chain ${src.id}`,
2281
2298
  chainId: src.id,
@@ -2301,7 +2318,7 @@ var LayerZeroService = class {
2301
2318
  });
2302
2319
  return { txHash: hash, toAmount: _nullishCoalesce(_optionalChain([oft, 'optionalAccess', _49 => _49.amountReceived]), () => ( params.amount)) };
2303
2320
  } catch (err) {
2304
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
2321
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
2305
2322
  phase: "send",
2306
2323
  shortMessage: "bridge: OFT send failed",
2307
2324
  chainId: src.id,
@@ -2328,7 +2345,7 @@ var LayerZeroService = class {
2328
2345
  const method = "prepareBridgeCalldata";
2329
2346
  const from = params.from;
2330
2347
  if (!_viem.isAddress.call(void 0, from)) {
2331
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2348
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2332
2349
  "from",
2333
2350
  params.from,
2334
2351
  `${method}: invalid from address "${params.from}" \u2014 the address that will sign these transactions`
@@ -2383,16 +2400,22 @@ var LayerZeroService = class {
2383
2400
  /**
2384
2401
  * Estimate how long a USDT0 bridge will take, end to end.
2385
2402
  *
2386
- * Two independent inputs, both cheap:
2387
- * - **observed** — median delivery time of recent messages LayerZero Scan has
2388
- * already settled on this exact pathway.
2389
- * - **formula** — LayerZero's documented estimate from the on-chain ULN config:
2390
- * `srcBlockTime × confirmations + dstBlockTime × (2 + dvnCount)`.
2403
+ * The number comes from the pathway's live ULN config:
2404
+ * `srcBlockTime × confirmations + dstBlockTime × (2 + dvnCount)`, floored at the
2405
+ * source chain's {@link BridgeChainConfig.minDeliverySec} where the confirmation
2406
+ * count is not the whole wait (unless the asset sets its own floor). This is what the DVNs are actually bound by, so it
2407
+ * tracks a config change the moment it lands — and on every pathway that is purely
2408
+ * confirmation-bound it agrees with both usdt0.to's own estimate and the delivery
2409
+ * times Scan reports to well under a percent.
2391
2410
  *
2392
- * `observed` wins when available. The formula assumes `confirmations` is the whole
2393
- * wait, which holds for L1 sources but badly understates rollups: Arbitrum→Stable
2394
- * computes to ~15s (60 blocks × 0.25s) while real deliveries take ~18min, because
2395
- * the DVNs wait for the L2 batch to finalize on L1.
2411
+ * The observed median of recent deliveries on this exact pathway is fetched too
2412
+ * and reported as {@link BridgeTimeEstimate.observedSeconds}, but it no longer
2413
+ * drives `seconds`. History lags the config: after Optimism→Stable was raised to
2414
+ * 1000 confirmations, a 50-message window still reaching back 261 days put the
2415
+ * median at ~15min against a real ~33min, and pathways quiet for months (Unichain,
2416
+ * XAUt0 from Arbitrum) were answering from configs that no longer exist. It stays
2417
+ * the fallback for the case the formula cannot be computed at all — an RPC that
2418
+ * will not serve the ULN read.
2396
2419
  */
2397
2420
  async estimateBridgeTime({
2398
2421
  fromChain,
@@ -2405,10 +2428,10 @@ var LayerZeroService = class {
2405
2428
  const from = _nullishCoalesce(fromToken, () => ( _optionalChain([src, 'optionalAccess', _51 => _51.tokens, 'access', _52 => _52.usdt0, 'optionalAccess', _53 => _53.address])));
2406
2429
  const to = _nullishCoalesce(toToken, () => ( _optionalChain([dst, 'optionalAccess', _54 => _54.tokens, 'access', _55 => _55.usdt0, 'optionalAccess', _56 => _56.address])));
2407
2430
  if (!(src && from)) {
2408
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("fromChain", fromChain, `estimateBridgeTime: no OFT adapter for "${fromChain}"`);
2431
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)("fromChain", fromChain, `estimateBridgeTime: no OFT adapter for "${fromChain}"`);
2409
2432
  }
2410
2433
  if (!(dst && to)) {
2411
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("toChain", toChain, `estimateBridgeTime: no OFT adapter for "${toChain}"`);
2434
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)("toChain", toChain, `estimateBridgeTime: no OFT adapter for "${toChain}"`);
2412
2435
  }
2413
2436
  const { srcToken, dstToken } = this.resolveRoute(fromChain, toChain, from, to);
2414
2437
  const [uln, observedSeconds] = await Promise.all([
@@ -2423,16 +2446,16 @@ var LayerZeroService = class {
2423
2446
  );
2424
2447
  formulaSeconds = Number.isFinite(computed) ? computed : void 0;
2425
2448
  }
2426
- const seconds = _nullishCoalesce(observedSeconds, () => ( formulaSeconds));
2427
- if (seconds === void 0) {
2428
- throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
2449
+ const floor = _nullishCoalesce(srcToken.minDeliverySec, () => ( src.minDeliverySec));
2450
+ const resolved = resolveDeliverySeconds(formulaSeconds, observedSeconds, floor);
2451
+ if (!resolved) {
2452
+ throw new (0, _chunkMMZ7HVWZcjs.StableQuoteError)({
2429
2453
  provider: "layerzero",
2430
2454
  shortMessage: `estimateBridgeTime: no pathway data for ${fromChain}\u2192${toChain}`
2431
2455
  });
2432
2456
  }
2433
2457
  return {
2434
- seconds,
2435
- source: observedSeconds !== void 0 ? "observed" : "formula",
2458
+ ...resolved,
2436
2459
  observedSeconds,
2437
2460
  formulaSeconds,
2438
2461
  confirmations: Number.isFinite(_optionalChain([uln, 'optionalAccess', _57 => _57.confirmations])) ? _optionalChain([uln, 'optionalAccess', _58 => _58.confirmations]) : void 0,
@@ -2453,7 +2476,7 @@ var LayerZeroService = class {
2453
2476
  if (err instanceof ScanHttpError && err.status === 404) {
2454
2477
  return { state: "pending", srcTxHash, scanUrl };
2455
2478
  }
2456
- throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
2479
+ throw new (0, _chunkMMZ7HVWZcjs.StableQuoteError)({
2457
2480
  provider: "layerzero",
2458
2481
  shortMessage: `trackBridge: LayerZero Scan lookup failed for ${srcTxHash}`,
2459
2482
  cause: err
@@ -2509,21 +2532,21 @@ var LayerZeroService = class {
2509
2532
  }
2510
2533
  validateBridgeParams(params, method) {
2511
2534
  if (!_viem.isAddress.call(void 0, params.recipient)) {
2512
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2535
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2513
2536
  "recipient",
2514
2537
  params.recipient,
2515
2538
  `${method}: invalid recipient address "${params.recipient}"`
2516
2539
  );
2517
2540
  }
2518
2541
  if (!Number.isFinite(params.amount) || params.amount <= 0) {
2519
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2542
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2520
2543
  "amount",
2521
2544
  params.amount,
2522
2545
  `${method}: amount must be a finite positive number`
2523
2546
  );
2524
2547
  }
2525
2548
  if (params.fromChain === params.toChain) {
2526
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2549
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2527
2550
  "toChain",
2528
2551
  params.toChain,
2529
2552
  `${method}: fromChain and toChain must differ`
@@ -2540,11 +2563,11 @@ var LayerZeroService = class {
2540
2563
  resolveRoute(fromChain, toChain, fromToken, toToken) {
2541
2564
  const src = BRIDGE_CHAIN_CONFIGS[fromChain];
2542
2565
  const dst = BRIDGE_CHAIN_CONFIGS[toChain];
2543
- if (!src) throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("fromChain", fromChain, `Unsupported source chain: "${fromChain}"`);
2544
- if (!dst) throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("toChain", toChain, `Unsupported destination chain: "${toChain}"`);
2566
+ if (!src) throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)("fromChain", fromChain, `Unsupported source chain: "${fromChain}"`);
2567
+ if (!dst) throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)("toChain", toChain, `Unsupported destination chain: "${toChain}"`);
2545
2568
  const asset = bridgeAssetFor(src, fromToken);
2546
2569
  if (!asset) {
2547
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2570
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2548
2571
  "fromToken",
2549
2572
  fromToken,
2550
2573
  `Native OFT bridge does not recognize "${fromToken}" on "${fromChain}" \u2014 it moves ${describeAssets(src)}. Use route "lifi" to bridge other tokens.`
@@ -2553,14 +2576,14 @@ var LayerZeroService = class {
2553
2576
  const srcToken = src.tokens[asset];
2554
2577
  const dstToken = dst.tokens[asset];
2555
2578
  if (!dstToken) {
2556
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2579
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2557
2580
  "toChain",
2558
2581
  toChain,
2559
2582
  `Native OFT bridge cannot deliver ${asset} to "${toChain}" \u2014 no ${asset} deployment there. Use route "lifi" instead.`
2560
2583
  );
2561
2584
  }
2562
2585
  if (dstToken.address.toLowerCase() !== toToken.toLowerCase()) {
2563
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2586
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2564
2587
  "toToken",
2565
2588
  toToken,
2566
2589
  `Native OFT bridge moves ${asset} to itself \u2014 toToken must be ${dstToken.address} on "${toChain}", got "${toToken}". Use route "lifi" to bridge between different tokens.`
@@ -2577,7 +2600,7 @@ var LayerZeroService = class {
2577
2600
  const recipientAddr = _nullishCoalesce(recipient, () => ( ZERO_ADDRESS));
2578
2601
  this.validateBridgeParams({ fromChain, toChain, amount, recipient: recipientAddr }, method);
2579
2602
  if (dstNativeDrop !== void 0 && dstNativeDrop < 0n) {
2580
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2603
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2581
2604
  "dstNativeDrop",
2582
2605
  dstNativeDrop,
2583
2606
  `${method}: dstNativeDrop must not be negative`
@@ -2591,7 +2614,7 @@ var LayerZeroService = class {
2591
2614
  toToken
2592
2615
  );
2593
2616
  if (params.fromDecimals !== void 0 && params.fromDecimals !== srcToken.decimals) {
2594
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2617
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2595
2618
  "fromDecimals",
2596
2619
  params.fromDecimals,
2597
2620
  `${method}: ${asset} has ${srcToken.decimals} decimals on "${fromChain}", not ${params.fromDecimals}. The native OFT route parses the amount with the token's own decimals; fromDecimals applies to LI.FI routes only.`
@@ -2623,7 +2646,7 @@ var LayerZeroService = class {
2623
2646
  resolveRefundAddress(refundAddress, sender, method) {
2624
2647
  if (refundAddress === void 0) return sender;
2625
2648
  if (!_viem.isAddress.call(void 0, refundAddress)) {
2626
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2649
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2627
2650
  "refundAddress",
2628
2651
  refundAddress,
2629
2652
  `${method}: invalid refundAddress "${refundAddress}"`
@@ -2666,7 +2689,7 @@ function isNativeOftRoute(fromChain, toChain, fromToken, toToken) {
2666
2689
  function selectBridge(params) {
2667
2690
  const selected = resolveBridge(params);
2668
2691
  if (selected === "lifi" && (_nullishCoalesce(params.dstNativeDrop, () => ( 0n))) > 0n) {
2669
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2692
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2670
2693
  "dstNativeDrop",
2671
2694
  params.dstNativeDrop,
2672
2695
  `bridge: dstNativeDrop is only supported on the native OFT route, and ${params.fromChain}\u2192${params.toChain} resolved to LI.FI`
@@ -2692,28 +2715,28 @@ function validateTransferParams({
2692
2715
  tokenDecimals
2693
2716
  }) {
2694
2717
  if (!_viem.isAddress.call(void 0, to)) {
2695
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2718
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2696
2719
  "to",
2697
2720
  to,
2698
2721
  `transfer: invalid recipient address "${to}"`
2699
2722
  );
2700
2723
  }
2701
2724
  if (!Number.isFinite(amount) || amount <= 0) {
2702
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2725
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2703
2726
  "amount",
2704
2727
  amount,
2705
2728
  "transfer: amount must be a finite positive number"
2706
2729
  );
2707
2730
  }
2708
2731
  if (token !== void 0 && !_viem.isAddress.call(void 0, token)) {
2709
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2732
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2710
2733
  "token",
2711
2734
  token,
2712
2735
  `transfer: invalid token address "${token}"`
2713
2736
  );
2714
2737
  }
2715
2738
  if (tokenDecimals !== void 0 && (!Number.isInteger(tokenDecimals) || tokenDecimals < 0 || tokenDecimals > 77)) {
2716
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2739
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2717
2740
  "tokenDecimals",
2718
2741
  tokenDecimals,
2719
2742
  "transfer: tokenDecimals must be an integer between 0 and 77"
@@ -2729,7 +2752,7 @@ async function resolveTokenDecimals(publicClient, token, tokenDecimals) {
2729
2752
  functionName: "decimals"
2730
2753
  });
2731
2754
  } catch (e8) {
2732
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2755
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2733
2756
  "tokenDecimals",
2734
2757
  void 0,
2735
2758
  `transfer: could not fetch decimals for token "${token}" \u2014 pass tokenDecimals explicitly`
@@ -2739,7 +2762,7 @@ async function resolveTokenDecimals(publicClient, token, tokenDecimals) {
2739
2762
  async function executeTokenTransfer(wc, publicClient, token, to, amount, tokenDecimals, acc, chain) {
2740
2763
  const code = await publicClient.getCode({ address: token });
2741
2764
  if (!code || code === "0x") {
2742
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2765
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2743
2766
  "token",
2744
2767
  token,
2745
2768
  `transfer: no contract found at "${token}" on chain ${chain.id} \u2014 check the address and network`
@@ -2789,10 +2812,10 @@ function createStable({
2789
2812
  chain,
2790
2813
  transport: _nullishCoalesce(transport, () => ( _viem.http.call(void 0, rpc)))
2791
2814
  }) : _viem.createPublicClient.call(void 0, { chain, transport: _viem.http.call(void 0, rpc) });
2792
- const authorization = _chunkQQ26UI3Fcjs.erc3009Actions.call(void 0, erc3009Client);
2815
+ const authorization = _chunkMMZ7HVWZcjs.erc3009Actions.call(void 0, erc3009Client);
2793
2816
  function requireEarn() {
2794
2817
  if (!morpho) {
2795
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2818
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2796
2819
  "earn",
2797
2820
  void 0,
2798
2821
  "stable.earn.*: pass earn: { vault: '0x...' } to createStable() to enable earn operations"
@@ -2803,7 +2826,7 @@ function createStable({
2803
2826
  function requireSignerAddress() {
2804
2827
  const from = _nullishCoalesce(_optionalChain([walletClient, 'optionalAccess', _84 => _84.account, 'optionalAccess', _85 => _85.address]), () => ( _optionalChain([account, 'optionalAccess', _86 => _86.address])));
2805
2828
  if (!from) {
2806
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2829
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2807
2830
  "signer",
2808
2831
  void 0,
2809
2832
  "stable.rewards.*: requires a signer \u2014 set walletClient or account in StableConfig"
@@ -2823,7 +2846,7 @@ function createStable({
2823
2846
  try {
2824
2847
  await wc.switchChain({ id: chain.id });
2825
2848
  } catch (err) {
2826
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
2849
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
2827
2850
  phase: "switch_chain",
2828
2851
  shortMessage: `transfer: wallet rejected or failed to switch to chain ${chain.id}`,
2829
2852
  chainId: chain.id,
@@ -2855,7 +2878,7 @@ function createStable({
2855
2878
  );
2856
2879
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
2857
2880
  if (receipt.status === "reverted") {
2858
- throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
2881
+ throw new (0, _chunkMMZ7HVWZcjs.StableTransactionError)({
2859
2882
  phase: "receipt",
2860
2883
  shortMessage: "transfer: transaction reverted on-chain",
2861
2884
  txHash: receipt.transactionHash,
@@ -2872,7 +2895,7 @@ function createStable({
2872
2895
  bridge: async (params) => selectBridge(params) === "oft" ? lz.bridge(params) : lifi.bridge(params),
2873
2896
  prepareBridgeCalldata: async (params) => {
2874
2897
  if (selectBridge(params) !== "oft") {
2875
- throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
2898
+ throw new (0, _chunkMMZ7HVWZcjs.StableValidationError)(
2876
2899
  "route",
2877
2900
  _nullishCoalesce(params.route, () => ( "auto")),
2878
2901
  `prepareBridgeCalldata: only the native OFT route can be built unsigned, and ${params.fromChain}\u2192${params.toChain} resolved to LI.FI`
@@ -2950,4 +2973,5 @@ function createStableReader(config) {
2950
2973
 
2951
2974
 
2952
2975
 
2953
- exports.BRIDGE_CHAIN_CONFIGS = BRIDGE_CHAIN_CONFIGS; exports.CHAIN_CONFIGS = CHAIN_CONFIGS; exports.Chain = Chain; exports.ERC3009_ABI = _chunkQQ26UI3Fcjs.ERC3009_ABI; exports.Network = Network; exports.OFT_ADAPTER_ABI = OFT_ADAPTER_ABI; exports.STABLE_USDT_ADDRESS = _chunkQQ26UI3Fcjs.STABLE_USDT_ADDRESS; exports.STABLE_VAULT_ADDRESS = _chunkQQ26UI3Fcjs.STABLE_VAULT_ADDRESS; exports.StableBulkError = _chunkQQ26UI3Fcjs.StableBulkError; exports.StableError = _chunkQQ26UI3Fcjs.StableError; exports.StableNetworkError = _chunkQQ26UI3Fcjs.StableNetworkError; exports.StableQuoteError = _chunkQQ26UI3Fcjs.StableQuoteError; exports.StableTransactionError = _chunkQQ26UI3Fcjs.StableTransactionError; exports.StableValidationError = _chunkQQ26UI3Fcjs.StableValidationError; exports.bridgeAssetFor = bridgeAssetFor; exports.buildLzOptions = buildLzOptions; exports.cancelAuthorization = _chunkQQ26UI3Fcjs.cancelAuthorization; exports.clearBridgeEstimateCache = clearBridgeEstimateCache; exports.createStable = createStable; exports.createStableReader = createStableReader; exports.erc3009Actions = _chunkQQ26UI3Fcjs.erc3009Actions; exports.getAuthorizationState = _chunkQQ26UI3Fcjs.getAuthorizationState; exports.getAuthorizationUsage = _chunkQQ26UI3Fcjs.getAuthorizationUsage; exports.prepareTransferWithAuthorization = _chunkQQ26UI3Fcjs.prepareTransferWithAuthorization; exports.receiveWithAuthorization = _chunkQQ26UI3Fcjs.receiveWithAuthorization; exports.signReceiveAuthorization = _chunkQQ26UI3Fcjs.signReceiveAuthorization; exports.signTransferAuthorization = _chunkQQ26UI3Fcjs.signTransferAuthorization; exports.transferWithAuthorization = _chunkQQ26UI3Fcjs.transferWithAuthorization; exports.verifyAuthorization = _chunkQQ26UI3Fcjs.verifyAuthorization;
2976
+
2977
+ exports.BRIDGE_CHAIN_CONFIGS = BRIDGE_CHAIN_CONFIGS; exports.CHAIN_CONFIGS = CHAIN_CONFIGS; exports.Chain = Chain; exports.ERC3009_ABI = _chunkMMZ7HVWZcjs.ERC3009_ABI; exports.Network = Network; exports.OFT_ADAPTER_ABI = OFT_ADAPTER_ABI; exports.STABLE_PYUSD_ADDRESS = _chunkMMZ7HVWZcjs.STABLE_PYUSD_ADDRESS; exports.STABLE_USDT_ADDRESS = _chunkMMZ7HVWZcjs.STABLE_USDT_ADDRESS; exports.STABLE_VAULT_ADDRESS = _chunkMMZ7HVWZcjs.STABLE_VAULT_ADDRESS; exports.StableBulkError = _chunkMMZ7HVWZcjs.StableBulkError; exports.StableError = _chunkMMZ7HVWZcjs.StableError; exports.StableNetworkError = _chunkMMZ7HVWZcjs.StableNetworkError; exports.StableQuoteError = _chunkMMZ7HVWZcjs.StableQuoteError; exports.StableTransactionError = _chunkMMZ7HVWZcjs.StableTransactionError; exports.StableValidationError = _chunkMMZ7HVWZcjs.StableValidationError; exports.bridgeAssetFor = bridgeAssetFor; exports.buildLzOptions = buildLzOptions; exports.cancelAuthorization = _chunkMMZ7HVWZcjs.cancelAuthorization; exports.clearBridgeEstimateCache = clearBridgeEstimateCache; exports.createStable = createStable; exports.createStableReader = createStableReader; exports.erc3009Actions = _chunkMMZ7HVWZcjs.erc3009Actions; exports.getAuthorizationState = _chunkMMZ7HVWZcjs.getAuthorizationState; exports.getAuthorizationUsage = _chunkMMZ7HVWZcjs.getAuthorizationUsage; exports.prepareTransferWithAuthorization = _chunkMMZ7HVWZcjs.prepareTransferWithAuthorization; exports.receiveWithAuthorization = _chunkMMZ7HVWZcjs.receiveWithAuthorization; exports.signReceiveAuthorization = _chunkMMZ7HVWZcjs.signReceiveAuthorization; exports.signTransferAuthorization = _chunkMMZ7HVWZcjs.signTransferAuthorization; exports.transferWithAuthorization = _chunkMMZ7HVWZcjs.transferWithAuthorization; exports.verifyAuthorization = _chunkMMZ7HVWZcjs.verifyAuthorization;