@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/README.md +757 -0
- package/dist/chunk-QQ26UI3F.cjs +665 -0
- package/dist/chunk-VS6GBRDF.js +665 -0
- package/dist/erc3009.cjs +26 -0
- package/dist/erc3009.d.cts +429 -0
- package/dist/erc3009.d.ts +429 -0
- package/dist/erc3009.js +26 -0
- package/dist/index.cjs +451 -221
- package/dist/index.d.cts +82 -4
- package/dist/index.d.ts +82 -4
- package/dist/index.js +346 -116
- package/package.json +6 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkQQ26UI3Fcjs = require('./chunk-QQ26UI3F.cjs');
|
|
22
|
+
|
|
23
|
+
// src/stable.ts
|
|
2
24
|
|
|
3
25
|
|
|
4
26
|
|
|
@@ -25,85 +47,6 @@ var _morphosdk = require('@morpho-org/morpho-sdk');
|
|
|
25
47
|
|
|
26
48
|
|
|
27
49
|
|
|
28
|
-
// src/errors.ts
|
|
29
|
-
|
|
30
|
-
var StableError = class extends _viem.BaseError {
|
|
31
|
-
};
|
|
32
|
-
var StableValidationError = class extends StableError {
|
|
33
|
-
constructor(field, value, reason, opts) {
|
|
34
|
-
super(reason, {
|
|
35
|
-
name: "StableValidationError",
|
|
36
|
-
cause: _optionalChain([opts, 'optionalAccess', _ => _.cause]),
|
|
37
|
-
metaMessages: [`Field: ${field}`, `Value: ${formatValue(value)}`]
|
|
38
|
-
});
|
|
39
|
-
this.field = field;
|
|
40
|
-
this.value = value;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var StableQuoteError = class extends StableError {
|
|
44
|
-
constructor(args) {
|
|
45
|
-
const meta = [`Provider: ${args.provider}`];
|
|
46
|
-
if (args.httpStatus !== void 0)
|
|
47
|
-
meta.push(`HTTP status: ${args.httpStatus}`);
|
|
48
|
-
if (args.providerCode) meta.push(`Provider code: ${args.providerCode}`);
|
|
49
|
-
super(args.shortMessage, {
|
|
50
|
-
name: "StableQuoteError",
|
|
51
|
-
cause: args.cause,
|
|
52
|
-
metaMessages: meta
|
|
53
|
-
});
|
|
54
|
-
this.provider = args.provider;
|
|
55
|
-
this.httpStatus = args.httpStatus;
|
|
56
|
-
this.providerCode = args.providerCode;
|
|
57
|
-
this.body = args.body;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var StableTransactionError = class extends StableError {
|
|
61
|
-
constructor(args) {
|
|
62
|
-
const meta = [`Phase: ${args.phase}`];
|
|
63
|
-
if (args.chainId !== void 0) meta.push(`Chain ID: ${args.chainId}`);
|
|
64
|
-
if (args.txHash) meta.push(`Tx hash: ${args.txHash}`);
|
|
65
|
-
if (args.revertReason) meta.push(`Revert reason: ${args.revertReason}`);
|
|
66
|
-
super(args.shortMessage, {
|
|
67
|
-
name: "StableTransactionError",
|
|
68
|
-
cause: args.cause,
|
|
69
|
-
metaMessages: meta
|
|
70
|
-
});
|
|
71
|
-
this.phase = args.phase;
|
|
72
|
-
this.txHash = args.txHash;
|
|
73
|
-
this.chainId = args.chainId;
|
|
74
|
-
this.revertReason = args.revertReason;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var StableNetworkError = class extends StableError {
|
|
78
|
-
constructor(args) {
|
|
79
|
-
super(args.shortMessage, {
|
|
80
|
-
name: "StableNetworkError",
|
|
81
|
-
cause: args.cause,
|
|
82
|
-
metaMessages: args.url ? [`URL: ${args.url}`] : void 0
|
|
83
|
-
});
|
|
84
|
-
this.url = args.url;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
var StableBulkError = class extends StableError {
|
|
88
|
-
constructor(args) {
|
|
89
|
-
super(args.shortMessage, { name: "StableBulkError" });
|
|
90
|
-
this.results = args.results;
|
|
91
|
-
this.succeeded = args.succeeded;
|
|
92
|
-
this.failed = args.failed;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
function formatValue(v) {
|
|
96
|
-
if (typeof v === "bigint") return `${v}n`;
|
|
97
|
-
if (typeof v === "string") return JSON.stringify(v);
|
|
98
|
-
if (v === null) return "null";
|
|
99
|
-
if (v === void 0) return "undefined";
|
|
100
|
-
try {
|
|
101
|
-
return JSON.stringify(v);
|
|
102
|
-
} catch (e) {
|
|
103
|
-
return String(v);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
50
|
// src/helpers/chain.ts
|
|
108
51
|
|
|
109
52
|
function makeChain(id, rpc) {
|
|
@@ -162,7 +105,7 @@ var MorphoService = class {
|
|
|
162
105
|
chain: this.chain,
|
|
163
106
|
transport: _nullishCoalesce(config.transport, () => ( _viem.http.call(void 0, config.rpc)))
|
|
164
107
|
})));
|
|
165
|
-
const morphoWc = _optionalChain([this, 'access',
|
|
108
|
+
const morphoWc = _optionalChain([this, 'access', _ => _.wc, 'access', _2 => _2.chain, 'optionalAccess', _3 => _3.id]) === config.chainId ? this.wc : _viem.createWalletClient.call(void 0, {
|
|
166
109
|
account: this.wc.account,
|
|
167
110
|
chain: this.chain,
|
|
168
111
|
transport: _viem.custom.call(void 0, {
|
|
@@ -179,7 +122,7 @@ var MorphoService = class {
|
|
|
179
122
|
deposit(params) {
|
|
180
123
|
this._validateAmount(params.amount, "earn deposit");
|
|
181
124
|
if (params.depositBuffer !== void 0 && (params.depositBuffer <= 0 || params.depositBuffer > 1)) {
|
|
182
|
-
throw new StableValidationError(
|
|
125
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
183
126
|
"depositBuffer",
|
|
184
127
|
params.depositBuffer,
|
|
185
128
|
"earn deposit: depositBuffer must be > 0 and \u2264 1"
|
|
@@ -215,7 +158,7 @@ var MorphoService = class {
|
|
|
215
158
|
const succeeded2 = results.filter(
|
|
216
159
|
(r) => r.status === "fulfilled"
|
|
217
160
|
).length;
|
|
218
|
-
throw new StableBulkError({
|
|
161
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableBulkError)({
|
|
219
162
|
shortMessage: "bulkDeposit halted on first failure",
|
|
220
163
|
results,
|
|
221
164
|
succeeded: succeeded2,
|
|
@@ -259,7 +202,7 @@ var MorphoService = class {
|
|
|
259
202
|
const succeeded2 = results.filter(
|
|
260
203
|
(r) => r.status === "fulfilled"
|
|
261
204
|
).length;
|
|
262
|
-
throw new StableBulkError({
|
|
205
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableBulkError)({
|
|
263
206
|
shortMessage: "bulkWithdraw halted on first failure",
|
|
264
207
|
results,
|
|
265
208
|
succeeded: succeeded2,
|
|
@@ -312,7 +255,7 @@ var MorphoService = class {
|
|
|
312
255
|
async prepareDepositCalldata(params) {
|
|
313
256
|
this._validateAmount(params.amount, "prepareDepositCalldata");
|
|
314
257
|
if (params.depositBuffer !== void 0 && (params.depositBuffer <= 0 || params.depositBuffer > 1)) {
|
|
315
|
-
throw new StableValidationError(
|
|
258
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
316
259
|
"depositBuffer",
|
|
317
260
|
params.depositBuffer,
|
|
318
261
|
"prepareDepositCalldata: depositBuffer must be > 0 and \u2264 1"
|
|
@@ -331,7 +274,7 @@ var MorphoService = class {
|
|
|
331
274
|
if (assetsRaw > maxAllowed) {
|
|
332
275
|
const maxFormatted = Number(_viem.formatUnits.call(void 0, maxAllowed, decimals));
|
|
333
276
|
const idleFormatted = Number(_viem.formatUnits.call(void 0, vaultData.assetBalance, decimals));
|
|
334
|
-
throw new StableValidationError(
|
|
277
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
335
278
|
"amount",
|
|
336
279
|
amount,
|
|
337
280
|
`prepareDepositCalldata: amount ${amount} exceeds deposit buffer \u2014 max ${maxFormatted} (${depositBuffer * 100}% of ${idleFormatted} idle liquidity)`
|
|
@@ -388,8 +331,8 @@ var MorphoService = class {
|
|
|
388
331
|
abi: _viem.erc20Abi,
|
|
389
332
|
functionName: "decimals"
|
|
390
333
|
});
|
|
391
|
-
} catch (
|
|
392
|
-
throw new StableValidationError(
|
|
334
|
+
} catch (e) {
|
|
335
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
393
336
|
"shareDecimals",
|
|
394
337
|
void 0,
|
|
395
338
|
`prepareRedeemCalldata: could not fetch share decimals for vault "${vaultAddr}" \u2014 pass shareDecimals explicitly`
|
|
@@ -435,7 +378,7 @@ var MorphoService = class {
|
|
|
435
378
|
const idleFormatted = Number(
|
|
436
379
|
_viem.formatUnits.call(void 0, vaultData.assetBalance, decimals)
|
|
437
380
|
);
|
|
438
|
-
throw new StableValidationError(
|
|
381
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
439
382
|
"amount",
|
|
440
383
|
amount,
|
|
441
384
|
`earn deposit: amount ${amount} exceeds deposit buffer \u2014 max ${maxFormatted} (${depositBuffer * 100}% of ${idleFormatted} idle liquidity)`
|
|
@@ -465,7 +408,7 @@ var MorphoService = class {
|
|
|
465
408
|
hash: approveHash
|
|
466
409
|
});
|
|
467
410
|
if (approveReceipt.status === "reverted") {
|
|
468
|
-
throw new StableTransactionError({
|
|
411
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
469
412
|
phase: "approve",
|
|
470
413
|
shortMessage: "earn deposit: token approval reverted on-chain",
|
|
471
414
|
txHash: approveReceipt.transactionHash,
|
|
@@ -480,7 +423,7 @@ var MorphoService = class {
|
|
|
480
423
|
const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
|
|
481
424
|
const receipt = await this.pc.waitForTransactionReceipt({ hash });
|
|
482
425
|
if (receipt.status === "reverted") {
|
|
483
|
-
throw new StableTransactionError({
|
|
426
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
484
427
|
phase: "receipt",
|
|
485
428
|
shortMessage: "earn deposit: vault deposit reverted on-chain",
|
|
486
429
|
txHash: receipt.transactionHash,
|
|
@@ -510,7 +453,7 @@ var MorphoService = class {
|
|
|
510
453
|
const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
|
|
511
454
|
const receipt = await this.pc.waitForTransactionReceipt({ hash });
|
|
512
455
|
if (receipt.status === "reverted") {
|
|
513
|
-
throw new StableTransactionError({
|
|
456
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
514
457
|
phase: "receipt",
|
|
515
458
|
shortMessage: "earn withdraw: vault withdraw reverted on-chain",
|
|
516
459
|
txHash: receipt.transactionHash,
|
|
@@ -532,8 +475,8 @@ var MorphoService = class {
|
|
|
532
475
|
abi: _viem.erc20Abi,
|
|
533
476
|
functionName: "decimals"
|
|
534
477
|
});
|
|
535
|
-
} catch (
|
|
536
|
-
throw new StableValidationError(
|
|
478
|
+
} catch (e2) {
|
|
479
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
537
480
|
"shareDecimals",
|
|
538
481
|
void 0,
|
|
539
482
|
`earn redeem: could not fetch share decimals for vault "${vaultAddr}" \u2014 pass shareDecimals explicitly`
|
|
@@ -556,7 +499,7 @@ var MorphoService = class {
|
|
|
556
499
|
const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
|
|
557
500
|
const receipt = await this.pc.waitForTransactionReceipt({ hash });
|
|
558
501
|
if (receipt.status === "reverted") {
|
|
559
|
-
throw new StableTransactionError({
|
|
502
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
560
503
|
phase: "receipt",
|
|
561
504
|
shortMessage: "earn redeem: vault redeem reverted on-chain",
|
|
562
505
|
txHash: receipt.transactionHash,
|
|
@@ -587,7 +530,7 @@ var MorphoService = class {
|
|
|
587
530
|
const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
|
|
588
531
|
const receipt = await this.pc.waitForTransactionReceipt({ hash });
|
|
589
532
|
if (receipt.status === "reverted") {
|
|
590
|
-
throw new StableTransactionError({
|
|
533
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
591
534
|
phase: "receipt",
|
|
592
535
|
shortMessage: "earn forceWithdraw: vault forceWithdraw reverted on-chain",
|
|
593
536
|
txHash: receipt.transactionHash,
|
|
@@ -616,8 +559,8 @@ var MorphoService = class {
|
|
|
616
559
|
abi: _viem.erc20Abi,
|
|
617
560
|
functionName: "decimals"
|
|
618
561
|
});
|
|
619
|
-
} catch (
|
|
620
|
-
throw new StableValidationError(
|
|
562
|
+
} catch (e3) {
|
|
563
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
621
564
|
"shareDecimals",
|
|
622
565
|
void 0,
|
|
623
566
|
`earn forceRedeem: could not fetch share decimals for vault "${vaultAddr}" \u2014 pass shareDecimals explicitly`
|
|
@@ -640,7 +583,7 @@ var MorphoService = class {
|
|
|
640
583
|
const hash = await this._sendTx(tx.to, tx.data, tx.value, from);
|
|
641
584
|
const receipt = await this.pc.waitForTransactionReceipt({ hash });
|
|
642
585
|
if (receipt.status === "reverted") {
|
|
643
|
-
throw new StableTransactionError({
|
|
586
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
644
587
|
phase: "receipt",
|
|
645
588
|
shortMessage: "earn forceRedeem: vault forceRedeem reverted on-chain",
|
|
646
589
|
txHash: receipt.transactionHash,
|
|
@@ -662,7 +605,7 @@ var MorphoService = class {
|
|
|
662
605
|
remaining = this._pullFromAdapter(adapter, remaining, now, result);
|
|
663
606
|
}
|
|
664
607
|
if (remaining > 0n) {
|
|
665
|
-
throw new StableValidationError(
|
|
608
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
666
609
|
"amount",
|
|
667
610
|
amount,
|
|
668
611
|
"earn withdraw: insufficient adapter liquidity \u2014 reduce the amount or wait for market liquidity to free up"
|
|
@@ -707,9 +650,9 @@ var MorphoService = class {
|
|
|
707
650
|
}
|
|
708
651
|
// ─── Helpers ─────────────────────────────────────────────────────────────
|
|
709
652
|
_requireFrom() {
|
|
710
|
-
const from = _optionalChain([this, 'access',
|
|
653
|
+
const from = _optionalChain([this, 'access', _4 => _4.wc, 'access', _5 => _5.account, 'optionalAccess', _6 => _6.address]);
|
|
711
654
|
if (!from) {
|
|
712
|
-
throw new StableValidationError(
|
|
655
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
713
656
|
"signer",
|
|
714
657
|
void 0,
|
|
715
658
|
"earn: requires a signer \u2014 set walletClient or account in StableConfig"
|
|
@@ -722,7 +665,7 @@ var MorphoService = class {
|
|
|
722
665
|
await this.wc.switchChain({ id: this.config.chainId });
|
|
723
666
|
} catch (err) {
|
|
724
667
|
if (err.code === 4001) {
|
|
725
|
-
throw new StableTransactionError({
|
|
668
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
726
669
|
phase: "switch_chain",
|
|
727
670
|
shortMessage: `earn: wallet rejected switch to chain ${this.config.chainId}`,
|
|
728
671
|
chainId: this.config.chainId,
|
|
@@ -741,7 +684,7 @@ var MorphoService = class {
|
|
|
741
684
|
chain: this.chain
|
|
742
685
|
});
|
|
743
686
|
} catch (err) {
|
|
744
|
-
throw new StableTransactionError({
|
|
687
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
745
688
|
phase: "send",
|
|
746
689
|
shortMessage: "earn: transaction send failed",
|
|
747
690
|
chainId: this.config.chainId,
|
|
@@ -758,8 +701,8 @@ var MorphoService = class {
|
|
|
758
701
|
functionName: "decimals"
|
|
759
702
|
})
|
|
760
703
|
);
|
|
761
|
-
} catch (
|
|
762
|
-
throw new StableValidationError(
|
|
704
|
+
} catch (e4) {
|
|
705
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
763
706
|
"tokenDecimals",
|
|
764
707
|
void 0,
|
|
765
708
|
`${op}: could not fetch decimals for asset "${asset}" \u2014 pass tokenDecimals explicitly`
|
|
@@ -776,7 +719,7 @@ var MorphoService = class {
|
|
|
776
719
|
}
|
|
777
720
|
_validateAmount(amount, op) {
|
|
778
721
|
if (!Number.isFinite(amount) || amount <= 0) {
|
|
779
|
-
throw new StableValidationError(
|
|
722
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
780
723
|
"amount",
|
|
781
724
|
amount,
|
|
782
725
|
`${op}: amount must be a finite positive number`
|
|
@@ -785,7 +728,7 @@ var MorphoService = class {
|
|
|
785
728
|
}
|
|
786
729
|
_validateShares(shares, op) {
|
|
787
730
|
if (!Number.isFinite(shares) || shares <= 0) {
|
|
788
|
-
throw new StableValidationError(
|
|
731
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
789
732
|
"shares",
|
|
790
733
|
shares,
|
|
791
734
|
`${op}: shares must be a finite positive number`
|
|
@@ -807,19 +750,27 @@ var MorphoService = class {
|
|
|
807
750
|
|
|
808
751
|
|
|
809
752
|
// src/types.ts
|
|
810
|
-
var Chain = /* @__PURE__ */ ((
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
753
|
+
var Chain = /* @__PURE__ */ ((Chain2) => {
|
|
754
|
+
Chain2["Sepolia"] = "sepolia";
|
|
755
|
+
Chain2["StableTestnet"] = "stable-testnet";
|
|
756
|
+
Chain2["Stable"] = "stable";
|
|
757
|
+
Chain2["Ethereum"] = "ethereum";
|
|
758
|
+
Chain2["Arbitrum"] = "arbitrum";
|
|
759
|
+
Chain2["Ink"] = "ink";
|
|
760
|
+
Chain2["Bera"] = "bera";
|
|
761
|
+
Chain2["MegaETH"] = "megaeth";
|
|
762
|
+
Chain2["Base"] = "base";
|
|
763
|
+
Chain2["BSC"] = "bsc";
|
|
764
|
+
Chain2["HyperEVM"] = "hyperevm";
|
|
765
|
+
Chain2["Polygon"] = "polygon";
|
|
766
|
+
Chain2["Plasma"] = "plasma";
|
|
767
|
+
Chain2["Optimism"] = "optimism";
|
|
768
|
+
Chain2["Unichain"] = "unichain";
|
|
769
|
+
Chain2["Sei"] = "sei";
|
|
770
|
+
Chain2["Flare"] = "flare";
|
|
771
|
+
Chain2["XLayer"] = "xlayer";
|
|
772
|
+
Chain2["Rootstock"] = "rootstock";
|
|
773
|
+
return Chain2;
|
|
823
774
|
})(Chain || {});
|
|
824
775
|
var Network = /* @__PURE__ */ ((Network2) => {
|
|
825
776
|
Network2["Mainnet"] = "mainnet";
|
|
@@ -831,22 +782,22 @@ var Network = /* @__PURE__ */ ((Network2) => {
|
|
|
831
782
|
var MORPHO_API_URL = "https://blue-api.morpho.org/graphql";
|
|
832
783
|
var EarnReader = class {
|
|
833
784
|
constructor(config) {
|
|
834
|
-
if (!_optionalChain([config, 'access',
|
|
835
|
-
throw new StableValidationError(
|
|
785
|
+
if (!_optionalChain([config, 'access', _7 => _7.earn, 'optionalAccess', _8 => _8.vault])) {
|
|
786
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
836
787
|
"earn.vault",
|
|
837
788
|
void 0,
|
|
838
789
|
"createStableReader: earn.vault is required"
|
|
839
790
|
);
|
|
840
791
|
}
|
|
841
792
|
if (!_viem.isAddress.call(void 0, config.address)) {
|
|
842
|
-
throw new StableValidationError(
|
|
793
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
843
794
|
"address",
|
|
844
795
|
config.address,
|
|
845
796
|
`createStableReader: invalid user address "${config.address}"`
|
|
846
797
|
);
|
|
847
798
|
}
|
|
848
799
|
if (!_viem.isAddress.call(void 0, config.earn.vault)) {
|
|
849
|
-
throw new StableValidationError(
|
|
800
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
850
801
|
"earn.vault",
|
|
851
802
|
config.earn.vault,
|
|
852
803
|
`createStableReader: invalid vault address "${config.earn.vault}"`
|
|
@@ -981,7 +932,7 @@ var EarnReader = class {
|
|
|
981
932
|
);
|
|
982
933
|
} catch (err) {
|
|
983
934
|
if (err instanceof TypeError || err instanceof HttpError) {
|
|
984
|
-
throw new StableNetworkError({
|
|
935
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
|
|
985
936
|
shortMessage: err instanceof HttpError ? `earn: Morpho API returned ${err.status} after retries` : `earn: failed to reach Morpho API after retries \u2014 ${String(
|
|
986
937
|
err
|
|
987
938
|
)}`,
|
|
@@ -991,9 +942,9 @@ var EarnReader = class {
|
|
|
991
942
|
}
|
|
992
943
|
throw err;
|
|
993
944
|
}
|
|
994
|
-
const vault = _optionalChain([body, 'optionalAccess',
|
|
945
|
+
const vault = _optionalChain([body, 'optionalAccess', _9 => _9.data, 'optionalAccess', _10 => _10.vaultV2ByAddress]);
|
|
995
946
|
if (!vault || typeof vault.avgNetApy !== "number") {
|
|
996
|
-
throw new StableValidationError(
|
|
947
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
997
948
|
"apy",
|
|
998
949
|
void 0,
|
|
999
950
|
"earn: vault not found in Morpho API or unexpected response shape"
|
|
@@ -1045,7 +996,7 @@ var MerklService = class {
|
|
|
1045
996
|
}
|
|
1046
997
|
async fetchRewards(address) {
|
|
1047
998
|
if (!_viem.isAddress.call(void 0, address)) {
|
|
1048
|
-
throw new StableValidationError(
|
|
999
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1049
1000
|
"address",
|
|
1050
1001
|
address,
|
|
1051
1002
|
`merkl: invalid address "${address}"`
|
|
@@ -1063,7 +1014,7 @@ var MerklService = class {
|
|
|
1063
1014
|
(r) => r.rawAmount !== "0" && r.proofs.length > 0
|
|
1064
1015
|
);
|
|
1065
1016
|
if (claimable.length === 0) {
|
|
1066
|
-
throw new StableValidationError(
|
|
1017
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1067
1018
|
"rewards",
|
|
1068
1019
|
[],
|
|
1069
1020
|
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"
|
|
@@ -1078,7 +1029,7 @@ var MerklService = class {
|
|
|
1078
1029
|
try {
|
|
1079
1030
|
await wc.switchChain({ id: this.config.chainId });
|
|
1080
1031
|
} catch (err) {
|
|
1081
|
-
throw new StableTransactionError({
|
|
1032
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1082
1033
|
phase: "switch_chain",
|
|
1083
1034
|
shortMessage: `merkl: wallet rejected or failed to switch to chain ${this.config.chainId}`,
|
|
1084
1035
|
chainId: this.config.chainId,
|
|
@@ -1102,7 +1053,7 @@ var MerklService = class {
|
|
|
1102
1053
|
chain
|
|
1103
1054
|
});
|
|
1104
1055
|
} catch (err) {
|
|
1105
|
-
throw new StableTransactionError({
|
|
1056
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1106
1057
|
phase: "send",
|
|
1107
1058
|
shortMessage: "merkl: claim transaction failed",
|
|
1108
1059
|
chainId: this.config.chainId,
|
|
@@ -1115,7 +1066,7 @@ var MerklService = class {
|
|
|
1115
1066
|
});
|
|
1116
1067
|
const receipt = await pc.waitForTransactionReceipt({ hash });
|
|
1117
1068
|
if (receipt.status === "reverted") {
|
|
1118
|
-
throw new StableTransactionError({
|
|
1069
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1119
1070
|
phase: "receipt",
|
|
1120
1071
|
shortMessage: "merkl: claim transaction reverted on-chain",
|
|
1121
1072
|
txHash: receipt.transactionHash,
|
|
@@ -1129,7 +1080,7 @@ var MerklService = class {
|
|
|
1129
1080
|
}
|
|
1130
1081
|
async prepareClaimCalldata(address) {
|
|
1131
1082
|
if (!_viem.isAddress.call(void 0, address)) {
|
|
1132
|
-
throw new StableValidationError(
|
|
1083
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1133
1084
|
"address",
|
|
1134
1085
|
address,
|
|
1135
1086
|
`merkl: invalid address "${address}"`
|
|
@@ -1140,7 +1091,7 @@ var MerklService = class {
|
|
|
1140
1091
|
(r) => r.rawAmount !== "0" && r.proofs.length > 0
|
|
1141
1092
|
);
|
|
1142
1093
|
if (claimable.length === 0) {
|
|
1143
|
-
throw new StableValidationError(
|
|
1094
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1144
1095
|
"rewards",
|
|
1145
1096
|
[],
|
|
1146
1097
|
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"
|
|
@@ -1163,9 +1114,9 @@ var MerklService = class {
|
|
|
1163
1114
|
};
|
|
1164
1115
|
}
|
|
1165
1116
|
_requireFrom() {
|
|
1166
|
-
const from = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1117
|
+
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])));
|
|
1167
1118
|
if (!from) {
|
|
1168
|
-
throw new StableValidationError(
|
|
1119
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1169
1120
|
"signer",
|
|
1170
1121
|
void 0,
|
|
1171
1122
|
"merkl.claim: requires a signer \u2014 set walletClient or account in StableConfig"
|
|
@@ -1178,7 +1129,7 @@ var MerklService = class {
|
|
|
1178
1129
|
const rewards = [];
|
|
1179
1130
|
const entries = Array.isArray(data) ? data : [data];
|
|
1180
1131
|
for (const entry of entries) {
|
|
1181
|
-
if (_optionalChain([entry, 'optionalAccess',
|
|
1132
|
+
if (_optionalChain([entry, 'optionalAccess', _18 => _18.chain, 'optionalAccess', _19 => _19.id]) !== chainId) continue;
|
|
1182
1133
|
for (const reward of _nullishCoalesce(entry.rewards, () => ( []))) {
|
|
1183
1134
|
const parsed = this._parseReward(reward);
|
|
1184
1135
|
if (parsed) rewards.push(parsed);
|
|
@@ -1187,7 +1138,7 @@ var MerklService = class {
|
|
|
1187
1138
|
return { chainId, rewards };
|
|
1188
1139
|
}
|
|
1189
1140
|
_parseReward(reward) {
|
|
1190
|
-
if (!_optionalChain([reward, 'optionalAccess',
|
|
1141
|
+
if (!_optionalChain([reward, 'optionalAccess', _20 => _20.token, 'optionalAccess', _21 => _21.address])) return null;
|
|
1191
1142
|
const net = BigInt(_nullishCoalesce(reward.amount, () => ( "0"))) - BigInt(_nullishCoalesce(reward.claimed, () => ( "0")));
|
|
1192
1143
|
if (net <= 0n) return null;
|
|
1193
1144
|
const rawAmount = net.toString();
|
|
@@ -1207,15 +1158,15 @@ var MerklService = class {
|
|
|
1207
1158
|
try {
|
|
1208
1159
|
return await retryWithBackoff(() => this._fetchOnce(url));
|
|
1209
1160
|
} catch (err) {
|
|
1210
|
-
if (err instanceof StableNetworkError) throw err;
|
|
1161
|
+
if (err instanceof _chunkQQ26UI3Fcjs.StableNetworkError) throw err;
|
|
1211
1162
|
if (err instanceof HttpError) {
|
|
1212
|
-
throw new StableNetworkError({
|
|
1163
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
|
|
1213
1164
|
shortMessage: `merkl: request failed \u2014 ${err.message}`,
|
|
1214
1165
|
url,
|
|
1215
1166
|
cause: err
|
|
1216
1167
|
});
|
|
1217
1168
|
}
|
|
1218
|
-
throw new StableNetworkError({
|
|
1169
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
|
|
1219
1170
|
shortMessage: "merkl: request failed before reaching the server",
|
|
1220
1171
|
url,
|
|
1221
1172
|
cause: err
|
|
@@ -1232,7 +1183,7 @@ var MerklService = class {
|
|
|
1232
1183
|
true
|
|
1233
1184
|
);
|
|
1234
1185
|
}
|
|
1235
|
-
throw new StableNetworkError({
|
|
1186
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
|
|
1236
1187
|
shortMessage: `merkl: API error ${res.status} ${res.statusText}`,
|
|
1237
1188
|
url
|
|
1238
1189
|
});
|
|
@@ -1259,7 +1210,7 @@ var CHAIN_CONFIGS = {
|
|
|
1259
1210
|
id: 11155111,
|
|
1260
1211
|
rpc: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
1261
1212
|
usdt: "0xc4DCC311c028e341fd8602D8eB89c5de94625927",
|
|
1262
|
-
decimals:
|
|
1213
|
+
decimals: 6
|
|
1263
1214
|
},
|
|
1264
1215
|
["stable-testnet" /* StableTestnet */]: {
|
|
1265
1216
|
id: 2201,
|
|
@@ -1277,13 +1228,15 @@ var CHAIN_CONFIGS = {
|
|
|
1277
1228
|
["ethereum" /* Ethereum */]: {
|
|
1278
1229
|
id: 1,
|
|
1279
1230
|
rpc: "https://ethereum-rpc.publicnode.com",
|
|
1280
|
-
|
|
1231
|
+
// Canonical USDT. Not the OFT adapter — this field is used as an ERC-20
|
|
1232
|
+
// (allowance/approve/balanceOf) and as the token address for LI.FI.
|
|
1233
|
+
usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
1281
1234
|
decimals: 6
|
|
1282
1235
|
},
|
|
1283
1236
|
["arbitrum" /* Arbitrum */]: {
|
|
1284
1237
|
id: 42161,
|
|
1285
1238
|
rpc: "https://arbitrum-one-rpc.publicnode.com",
|
|
1286
|
-
usdt: "
|
|
1239
|
+
usdt: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
1287
1240
|
decimals: 6
|
|
1288
1241
|
},
|
|
1289
1242
|
["ink" /* Ink */]: {
|
|
@@ -1300,7 +1253,7 @@ var CHAIN_CONFIGS = {
|
|
|
1300
1253
|
},
|
|
1301
1254
|
["megaeth" /* MegaETH */]: {
|
|
1302
1255
|
id: 4326,
|
|
1303
|
-
rpc: "https://
|
|
1256
|
+
rpc: "https://mainnet.megaeth.com/rpc",
|
|
1304
1257
|
usdt: "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
|
|
1305
1258
|
decimals: 6
|
|
1306
1259
|
},
|
|
@@ -1321,6 +1274,55 @@ var CHAIN_CONFIGS = {
|
|
|
1321
1274
|
rpc: "https://rpc.hyperliquid.xyz/evm",
|
|
1322
1275
|
usdt: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
|
|
1323
1276
|
decimals: 6
|
|
1277
|
+
},
|
|
1278
|
+
["polygon" /* Polygon */]: {
|
|
1279
|
+
id: 137,
|
|
1280
|
+
rpc: "https://polygon-bor-rpc.publicnode.com",
|
|
1281
|
+
// Polygon's canonical USDT, migrated to USDT0
|
|
1282
|
+
usdt: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
|
|
1283
|
+
decimals: 6
|
|
1284
|
+
},
|
|
1285
|
+
["plasma" /* Plasma */]: {
|
|
1286
|
+
id: 9745,
|
|
1287
|
+
rpc: "https://rpc.plasma.to",
|
|
1288
|
+
usdt: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
|
|
1289
|
+
decimals: 6
|
|
1290
|
+
},
|
|
1291
|
+
["optimism" /* Optimism */]: {
|
|
1292
|
+
id: 10,
|
|
1293
|
+
rpc: "https://optimism-rpc.publicnode.com",
|
|
1294
|
+
usdt: "0x01bFF41798a0BcF287b996046Ca68b395DbC1071",
|
|
1295
|
+
decimals: 6
|
|
1296
|
+
},
|
|
1297
|
+
["unichain" /* Unichain */]: {
|
|
1298
|
+
id: 130,
|
|
1299
|
+
rpc: "https://unichain-rpc.publicnode.com",
|
|
1300
|
+
usdt: "0x9151434b16b9763660705744891fA906F660EcC5",
|
|
1301
|
+
decimals: 6
|
|
1302
|
+
},
|
|
1303
|
+
["sei" /* Sei */]: {
|
|
1304
|
+
id: 1329,
|
|
1305
|
+
rpc: "https://sei-evm-rpc.publicnode.com",
|
|
1306
|
+
usdt: "0x9151434b16b9763660705744891fA906F660EcC5",
|
|
1307
|
+
decimals: 6
|
|
1308
|
+
},
|
|
1309
|
+
["flare" /* Flare */]: {
|
|
1310
|
+
id: 14,
|
|
1311
|
+
rpc: "https://flare-api.flare.network/ext/C/rpc",
|
|
1312
|
+
usdt: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
|
|
1313
|
+
decimals: 6
|
|
1314
|
+
},
|
|
1315
|
+
["xlayer" /* XLayer */]: {
|
|
1316
|
+
id: 196,
|
|
1317
|
+
rpc: "https://rpc.xlayer.tech",
|
|
1318
|
+
usdt: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
|
|
1319
|
+
decimals: 6
|
|
1320
|
+
},
|
|
1321
|
+
["rootstock" /* Rootstock */]: {
|
|
1322
|
+
id: 30,
|
|
1323
|
+
rpc: "https://public-node.rsk.co",
|
|
1324
|
+
usdt: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
|
|
1325
|
+
decimals: 6
|
|
1324
1326
|
}
|
|
1325
1327
|
};
|
|
1326
1328
|
|
|
@@ -1376,17 +1378,17 @@ var LiFiService = class {
|
|
|
1376
1378
|
fromDecimals = 6,
|
|
1377
1379
|
recipient
|
|
1378
1380
|
} = params;
|
|
1379
|
-
const from = _nullishCoalesce(_nullishCoalesce(_optionalChain([this, 'access',
|
|
1381
|
+
const from = _nullishCoalesce(_nullishCoalesce(_optionalChain([this, 'access', _22 => _22.config, 'access', _23 => _23.walletClient, 'optionalAccess', _24 => _24.account, 'optionalAccess', _25 => _25.address]), () => ( _optionalChain([this, 'access', _26 => _26.config, 'access', _27 => _27.account, 'optionalAccess', _28 => _28.address]))), () => ( "0x0000000000000000000000000000000000000000"));
|
|
1380
1382
|
const src = CHAIN_CONFIGS[fromChain];
|
|
1381
1383
|
const dst = CHAIN_CONFIGS[toChain];
|
|
1382
1384
|
if (!src)
|
|
1383
|
-
throw new StableValidationError(
|
|
1385
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1384
1386
|
"fromChain",
|
|
1385
1387
|
fromChain,
|
|
1386
1388
|
`LI.FI bridge: unsupported source chain "${fromChain}"`
|
|
1387
1389
|
);
|
|
1388
1390
|
if (!dst)
|
|
1389
|
-
throw new StableValidationError(
|
|
1391
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1390
1392
|
"toChain",
|
|
1391
1393
|
toChain,
|
|
1392
1394
|
`LI.FI bridge: unsupported destination chain "${toChain}"`
|
|
@@ -1418,14 +1420,14 @@ var LiFiService = class {
|
|
|
1418
1420
|
const src = CHAIN_CONFIGS[fromChain];
|
|
1419
1421
|
const dst = CHAIN_CONFIGS[toChain];
|
|
1420
1422
|
if (!src) {
|
|
1421
|
-
throw new StableValidationError(
|
|
1423
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1422
1424
|
"fromChain",
|
|
1423
1425
|
fromChain,
|
|
1424
1426
|
`LI.FI bridge: unsupported source chain "${fromChain}"`
|
|
1425
1427
|
);
|
|
1426
1428
|
}
|
|
1427
1429
|
if (!dst) {
|
|
1428
|
-
throw new StableValidationError(
|
|
1430
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1429
1431
|
"toChain",
|
|
1430
1432
|
toChain,
|
|
1431
1433
|
`LI.FI bridge: unsupported destination chain "${toChain}"`
|
|
@@ -1454,35 +1456,35 @@ var LiFiService = class {
|
|
|
1454
1456
|
toAddress
|
|
1455
1457
|
}) {
|
|
1456
1458
|
if (!_viem.isAddress.call(void 0, fromToken)) {
|
|
1457
|
-
throw new StableValidationError(
|
|
1459
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1458
1460
|
"fromToken",
|
|
1459
1461
|
fromToken,
|
|
1460
1462
|
`swap: invalid fromToken address "${fromToken}"`
|
|
1461
1463
|
);
|
|
1462
1464
|
}
|
|
1463
1465
|
if (!_viem.isAddress.call(void 0, toToken)) {
|
|
1464
|
-
throw new StableValidationError(
|
|
1466
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1465
1467
|
"toToken",
|
|
1466
1468
|
toToken,
|
|
1467
1469
|
`swap: invalid toToken address "${toToken}"`
|
|
1468
1470
|
);
|
|
1469
1471
|
}
|
|
1470
1472
|
if (fromToken.toLowerCase() === toToken.toLowerCase()) {
|
|
1471
|
-
throw new StableValidationError(
|
|
1473
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1472
1474
|
"toToken",
|
|
1473
1475
|
toToken,
|
|
1474
1476
|
"swap: fromToken and toToken must differ"
|
|
1475
1477
|
);
|
|
1476
1478
|
}
|
|
1477
1479
|
if (!Number.isFinite(amount) || amount <= 0) {
|
|
1478
|
-
throw new StableValidationError(
|
|
1480
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1479
1481
|
"amount",
|
|
1480
1482
|
amount,
|
|
1481
1483
|
"swap: amount must be a finite positive number"
|
|
1482
1484
|
);
|
|
1483
1485
|
}
|
|
1484
1486
|
if (toAddress !== void 0 && !_viem.isAddress.call(void 0, toAddress)) {
|
|
1485
|
-
throw new StableValidationError(
|
|
1487
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1486
1488
|
"toAddress",
|
|
1487
1489
|
toAddress,
|
|
1488
1490
|
`swap: invalid toAddress "${toAddress}"`
|
|
@@ -1498,35 +1500,35 @@ var LiFiService = class {
|
|
|
1498
1500
|
recipient
|
|
1499
1501
|
}) {
|
|
1500
1502
|
if (!_viem.isAddress.call(void 0, fromToken)) {
|
|
1501
|
-
throw new StableValidationError(
|
|
1503
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1502
1504
|
"fromToken",
|
|
1503
1505
|
fromToken,
|
|
1504
1506
|
`LI.FI bridge: invalid fromToken address "${fromToken}"`
|
|
1505
1507
|
);
|
|
1506
1508
|
}
|
|
1507
1509
|
if (!_viem.isAddress.call(void 0, toToken)) {
|
|
1508
|
-
throw new StableValidationError(
|
|
1510
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1509
1511
|
"toToken",
|
|
1510
1512
|
toToken,
|
|
1511
1513
|
`LI.FI bridge: invalid toToken address "${toToken}"`
|
|
1512
1514
|
);
|
|
1513
1515
|
}
|
|
1514
1516
|
if (!Number.isFinite(amount) || amount <= 0) {
|
|
1515
|
-
throw new StableValidationError(
|
|
1517
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1516
1518
|
"amount",
|
|
1517
1519
|
amount,
|
|
1518
1520
|
"LI.FI bridge: amount must be a finite positive number"
|
|
1519
1521
|
);
|
|
1520
1522
|
}
|
|
1521
1523
|
if (recipient !== void 0 && !_viem.isAddress.call(void 0, recipient)) {
|
|
1522
|
-
throw new StableValidationError(
|
|
1524
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1523
1525
|
"recipient",
|
|
1524
1526
|
recipient,
|
|
1525
1527
|
`LI.FI bridge: invalid recipient address "${recipient}"`
|
|
1526
1528
|
);
|
|
1527
1529
|
}
|
|
1528
1530
|
if (fromChain === toChain) {
|
|
1529
|
-
throw new StableValidationError(
|
|
1531
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1530
1532
|
"toChain",
|
|
1531
1533
|
toChain,
|
|
1532
1534
|
"LI.FI bridge: fromChain and toChain must differ"
|
|
@@ -1534,9 +1536,9 @@ var LiFiService = class {
|
|
|
1534
1536
|
}
|
|
1535
1537
|
}
|
|
1536
1538
|
_requireFrom() {
|
|
1537
|
-
const from = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1539
|
+
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])));
|
|
1538
1540
|
if (!from) {
|
|
1539
|
-
throw new StableValidationError(
|
|
1541
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1540
1542
|
"signer",
|
|
1541
1543
|
void 0,
|
|
1542
1544
|
"LI.FI: requires a signer \u2014 set walletClient or account in StableConfig"
|
|
@@ -1549,16 +1551,16 @@ var LiFiService = class {
|
|
|
1549
1551
|
try {
|
|
1550
1552
|
return await retryWithBackoff(() => this._fetchQuoteOnce(url));
|
|
1551
1553
|
} catch (err) {
|
|
1552
|
-
if (err instanceof StableQuoteError) throw err;
|
|
1554
|
+
if (err instanceof _chunkQQ26UI3Fcjs.StableQuoteError) throw err;
|
|
1553
1555
|
if (err instanceof HttpError) {
|
|
1554
|
-
throw new StableQuoteError({
|
|
1556
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
|
|
1555
1557
|
provider: "lifi",
|
|
1556
1558
|
shortMessage: err.message,
|
|
1557
1559
|
httpStatus: err.status,
|
|
1558
1560
|
cause: err
|
|
1559
1561
|
});
|
|
1560
1562
|
}
|
|
1561
|
-
throw new StableNetworkError({
|
|
1563
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableNetworkError)({
|
|
1562
1564
|
shortMessage: "LI.FI: quote request failed before reaching the server",
|
|
1563
1565
|
url,
|
|
1564
1566
|
cause: err
|
|
@@ -1578,7 +1580,7 @@ var LiFiService = class {
|
|
|
1578
1580
|
true
|
|
1579
1581
|
);
|
|
1580
1582
|
}
|
|
1581
|
-
throw new StableQuoteError({
|
|
1583
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
|
|
1582
1584
|
provider: "lifi",
|
|
1583
1585
|
shortMessage: `LI.FI: ${_nullishCoalesce(providerMessage, () => ( res.statusText))}`,
|
|
1584
1586
|
httpStatus: res.status,
|
|
@@ -1587,7 +1589,7 @@ var LiFiService = class {
|
|
|
1587
1589
|
});
|
|
1588
1590
|
}
|
|
1589
1591
|
if (!isLiFiQuoteShape(body)) {
|
|
1590
|
-
throw new StableQuoteError({
|
|
1592
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
|
|
1591
1593
|
provider: "lifi",
|
|
1592
1594
|
shortMessage: "LI.FI: unexpected quote response shape",
|
|
1593
1595
|
httpStatus: res.status,
|
|
@@ -1615,7 +1617,7 @@ var LiFiService = class {
|
|
|
1615
1617
|
const { transactionRequest } = quote;
|
|
1616
1618
|
const srcChainId = transactionRequest.chainId;
|
|
1617
1619
|
if (srcChainId !== expectedChainId) {
|
|
1618
|
-
throw new StableQuoteError({
|
|
1620
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
|
|
1619
1621
|
provider: "lifi",
|
|
1620
1622
|
shortMessage: `LI.FI: returned tx for chain ${srcChainId} but expected ${expectedChainId}`,
|
|
1621
1623
|
providerCode: "chain_mismatch",
|
|
@@ -1631,7 +1633,7 @@ var LiFiService = class {
|
|
|
1631
1633
|
try {
|
|
1632
1634
|
await wc.switchChain({ id: srcChainId });
|
|
1633
1635
|
} catch (err) {
|
|
1634
|
-
throw new StableTransactionError({
|
|
1636
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1635
1637
|
phase: "switch_chain",
|
|
1636
1638
|
shortMessage: `LI.FI: wallet rejected or failed to switch to chain ${srcChainId}`,
|
|
1637
1639
|
chainId: srcChainId,
|
|
@@ -1657,7 +1659,7 @@ var LiFiService = class {
|
|
|
1657
1659
|
chain: srcChain
|
|
1658
1660
|
});
|
|
1659
1661
|
} catch (err) {
|
|
1660
|
-
throw new StableTransactionError({
|
|
1662
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1661
1663
|
phase: "send",
|
|
1662
1664
|
shortMessage: "LI.FI: swap/bridge transaction failed",
|
|
1663
1665
|
chainId: srcChainId,
|
|
@@ -1692,7 +1694,7 @@ var LiFiService = class {
|
|
|
1692
1694
|
chain: srcChain
|
|
1693
1695
|
});
|
|
1694
1696
|
} catch (err) {
|
|
1695
|
-
throw new StableTransactionError({
|
|
1697
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1696
1698
|
phase: "approve",
|
|
1697
1699
|
shortMessage: "LI.FI: token approve failed",
|
|
1698
1700
|
chainId: srcChainId,
|
|
@@ -1703,7 +1705,7 @@ var LiFiService = class {
|
|
|
1703
1705
|
hash: approveHash
|
|
1704
1706
|
});
|
|
1705
1707
|
if (approveReceipt.status === "reverted") {
|
|
1706
|
-
throw new StableTransactionError({
|
|
1708
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1707
1709
|
phase: "approve",
|
|
1708
1710
|
shortMessage: "LI.FI: token approve reverted on-chain",
|
|
1709
1711
|
txHash: approveReceipt.transactionHash,
|
|
@@ -1738,16 +1740,24 @@ function isLiFiQuoteShape(v) {
|
|
|
1738
1740
|
var C = CHAIN_CONFIGS;
|
|
1739
1741
|
var BRIDGE_CHAIN_CONFIGS = {
|
|
1740
1742
|
// ─── Testnet ───────────────────────────────────────────────────────────────
|
|
1741
|
-
["sepolia" /* Sepolia */]: { ...C["sepolia" /* Sepolia */], lzEid: 40161, oftAdapter: "0xc099cD946d5efCC35A99D64E808c1430cEf08126" },
|
|
1742
|
-
["stable-testnet" /* StableTestnet */]: { ...C["stable-testnet" /* StableTestnet */], lzEid: 40374, oftAdapter: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736" },
|
|
1743
|
+
["sepolia" /* Sepolia */]: { ...C["sepolia" /* Sepolia */], lzEid: 40161, oftAdapter: "0xc099cD946d5efCC35A99D64E808c1430cEf08126", blockTimeSec: 12 },
|
|
1744
|
+
["stable-testnet" /* StableTestnet */]: { ...C["stable-testnet" /* StableTestnet */], lzEid: 40374, oftAdapter: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736", blockTimeSec: 0.7 },
|
|
1743
1745
|
// ─── Mainnet ──────────────────────────────────────────────────────────────
|
|
1744
|
-
["stable" /* Stable */]: { ...C["stable" /* Stable */], lzEid: 30396, oftAdapter: "0xedaba024be4d87974d5aB11C6Dd586963CcCB027" },
|
|
1745
|
-
["ethereum" /* Ethereum */]: { ...C["ethereum" /* Ethereum */], lzEid: 30101, oftAdapter: "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee" },
|
|
1746
|
-
["arbitrum" /* Arbitrum */]: { ...C["arbitrum" /* Arbitrum */], lzEid: 30110, oftAdapter: "0x14E4A1B13bf7F943c8ff7C51fb60FA964A298D92" },
|
|
1747
|
-
["ink" /* Ink */]: { ...C["ink" /* Ink */], lzEid: 30339, oftAdapter: "0x1cB6De532588fCA4a21B7209DE7C456AF8434A65" },
|
|
1748
|
-
["bera" /* Bera */]: { ...C["bera" /* Bera */], lzEid: 30362, oftAdapter: "0x3Dc96399109df5ceb2C226664A086140bD0379cB" },
|
|
1749
|
-
["megaeth" /* MegaETH */]: { ...C["megaeth" /* MegaETH */], lzEid: 30398, oftAdapter: "0x9151434b16b9763660705744891fa906f660ecc5" },
|
|
1750
|
-
["hyperevm" /* HyperEVM */]: { ...C["hyperevm" /* HyperEVM */], lzEid: 30367, oftAdapter: "0x904861a24F30EC96ea7CFC3bE9EA4B476d237e98" }
|
|
1746
|
+
["stable" /* Stable */]: { ...C["stable" /* Stable */], lzEid: 30396, oftAdapter: "0xedaba024be4d87974d5aB11C6Dd586963CcCB027", blockTimeSec: 0.7 },
|
|
1747
|
+
["ethereum" /* Ethereum */]: { ...C["ethereum" /* Ethereum */], lzEid: 30101, oftAdapter: "0x6C96dE32CEa08842dcc4058c14d3aaAD7Fa41dee", blockTimeSec: 12 },
|
|
1748
|
+
["arbitrum" /* Arbitrum */]: { ...C["arbitrum" /* Arbitrum */], lzEid: 30110, oftAdapter: "0x14E4A1B13bf7F943c8ff7C51fb60FA964A298D92", blockTimeSec: 0.25 },
|
|
1749
|
+
["ink" /* Ink */]: { ...C["ink" /* Ink */], lzEid: 30339, oftAdapter: "0x1cB6De532588fCA4a21B7209DE7C456AF8434A65", blockTimeSec: 1 },
|
|
1750
|
+
["bera" /* Bera */]: { ...C["bera" /* Bera */], lzEid: 30362, oftAdapter: "0x3Dc96399109df5ceb2C226664A086140bD0379cB", blockTimeSec: 2 },
|
|
1751
|
+
["megaeth" /* MegaETH */]: { ...C["megaeth" /* MegaETH */], lzEid: 30398, oftAdapter: "0x9151434b16b9763660705744891fa906f660ecc5", blockTimeSec: 1 },
|
|
1752
|
+
["hyperevm" /* HyperEVM */]: { ...C["hyperevm" /* HyperEVM */], lzEid: 30367, oftAdapter: "0x904861a24F30EC96ea7CFC3bE9EA4B476d237e98", blockTimeSec: 1 },
|
|
1753
|
+
["polygon" /* Polygon */]: { ...C["polygon" /* Polygon */], lzEid: 30109, oftAdapter: "0x6BA10300f0DC58B7a1e4c0e41f5daBb7D7829e13", blockTimeSec: 1.5 },
|
|
1754
|
+
["plasma" /* Plasma */]: { ...C["plasma" /* Plasma */], lzEid: 30383, oftAdapter: "0x02ca37966753bDdDf11216B73B16C1dE756A7CF9", blockTimeSec: 1 },
|
|
1755
|
+
["optimism" /* Optimism */]: { ...C["optimism" /* Optimism */], lzEid: 30111, oftAdapter: "0xF03b4d9AC1D5d1E7c4cEf54C2A313b9fe051A0aD", blockTimeSec: 2 },
|
|
1756
|
+
["unichain" /* Unichain */]: { ...C["unichain" /* Unichain */], lzEid: 30320, oftAdapter: "0xc07bE8994D035631c36fb4a89C918CeFB2f03EC3", blockTimeSec: 1 },
|
|
1757
|
+
["sei" /* Sei */]: { ...C["sei" /* Sei */], lzEid: 30280, oftAdapter: "0x56Fe74A2e3b484b921c447357203431a3485CC60", blockTimeSec: 0.5 },
|
|
1758
|
+
["flare" /* Flare */]: { ...C["flare" /* Flare */], lzEid: 30295, oftAdapter: "0x567287d2A9829215a37e3B88843d32f9221E7588", blockTimeSec: 1.1 },
|
|
1759
|
+
["xlayer" /* XLayer */]: { ...C["xlayer" /* XLayer */], lzEid: 30274, oftAdapter: "0x94BCCa6bdfd6A61817Ab0E960bFedE4984505554", blockTimeSec: 1 },
|
|
1760
|
+
["rootstock" /* Rootstock */]: { ...C["rootstock" /* Rootstock */], lzEid: 30333, oftAdapter: "0x1a594d5d5d1c426281C1064B07f23F57B2716B61", blockTimeSec: 31 }
|
|
1751
1761
|
};
|
|
1752
1762
|
var OFT_ADAPTER_ABI = [
|
|
1753
1763
|
{
|
|
@@ -1812,6 +1822,80 @@ var OFT_ADAPTER_ABI = [
|
|
|
1812
1822
|
stateMutability: "payable"
|
|
1813
1823
|
}
|
|
1814
1824
|
];
|
|
1825
|
+
var OAPP_ABI = [
|
|
1826
|
+
{ name: "endpoint", type: "function", stateMutability: "view", inputs: [], outputs: [{ type: "address" }] }
|
|
1827
|
+
];
|
|
1828
|
+
var ENDPOINT_V2_ABI = [
|
|
1829
|
+
{
|
|
1830
|
+
name: "getSendLibrary",
|
|
1831
|
+
type: "function",
|
|
1832
|
+
stateMutability: "view",
|
|
1833
|
+
inputs: [{ name: "_sender", type: "address" }, { name: "_dstEid", type: "uint32" }],
|
|
1834
|
+
outputs: [{ type: "address" }]
|
|
1835
|
+
}
|
|
1836
|
+
];
|
|
1837
|
+
var SEND_ULN_ABI = [
|
|
1838
|
+
{
|
|
1839
|
+
name: "getUlnConfig",
|
|
1840
|
+
type: "function",
|
|
1841
|
+
stateMutability: "view",
|
|
1842
|
+
inputs: [{ name: "_oapp", type: "address" }, { name: "_remoteEid", type: "uint32" }],
|
|
1843
|
+
outputs: [
|
|
1844
|
+
{
|
|
1845
|
+
name: "rtnConfig",
|
|
1846
|
+
type: "tuple",
|
|
1847
|
+
components: [
|
|
1848
|
+
{ name: "confirmations", type: "uint64" },
|
|
1849
|
+
{ name: "requiredDVNCount", type: "uint8" },
|
|
1850
|
+
{ name: "optionalDVNCount", type: "uint8" },
|
|
1851
|
+
{ name: "optionalDVNThreshold", type: "uint8" },
|
|
1852
|
+
{ name: "requiredDVNs", type: "address[]" },
|
|
1853
|
+
{ name: "optionalDVNs", type: "address[]" }
|
|
1854
|
+
]
|
|
1855
|
+
}
|
|
1856
|
+
]
|
|
1857
|
+
}
|
|
1858
|
+
];
|
|
1859
|
+
var LZ_SCAN_API = "https://scan.layerzero-api.com/v1";
|
|
1860
|
+
var LZ_SCAN_UI = "https://layerzeroscan.com";
|
|
1861
|
+
var CACHE_TTL_MS = 5 * 6e4;
|
|
1862
|
+
var cache = /* @__PURE__ */ new Map();
|
|
1863
|
+
function clearBridgeEstimateCache() {
|
|
1864
|
+
cache.clear();
|
|
1865
|
+
}
|
|
1866
|
+
async function cached(key, ttlMs, load) {
|
|
1867
|
+
const hit = cache.get(key);
|
|
1868
|
+
if (hit && Date.now() - hit.at < ttlMs) return hit.value;
|
|
1869
|
+
const value = await load();
|
|
1870
|
+
cache.set(key, { at: Date.now(), value });
|
|
1871
|
+
return value;
|
|
1872
|
+
}
|
|
1873
|
+
var ScanHttpError = class extends Error {
|
|
1874
|
+
constructor(status, path) {
|
|
1875
|
+
super(`LayerZero Scan ${status} for ${path}`);
|
|
1876
|
+
this.status = status;
|
|
1877
|
+
this.name = "ScanHttpError";
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
async function scanFetch(path, timeoutMs = 8e3) {
|
|
1881
|
+
const res = await fetch(`${LZ_SCAN_API}${path}`, { signal: AbortSignal.timeout(timeoutMs) });
|
|
1882
|
+
if (!res.ok) throw new ScanHttpError(res.status, path);
|
|
1883
|
+
return res.json();
|
|
1884
|
+
}
|
|
1885
|
+
var TERMINAL_FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
1886
|
+
"FAILED",
|
|
1887
|
+
"BLOCKED",
|
|
1888
|
+
"PAYLOAD_STORED",
|
|
1889
|
+
"APPLICATION_BURNED",
|
|
1890
|
+
"APPLICATION_SKIPPED",
|
|
1891
|
+
"UNRESOLVABLE_COMMAND",
|
|
1892
|
+
"MALFORMED_COMMAND"
|
|
1893
|
+
]);
|
|
1894
|
+
function median(values) {
|
|
1895
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
1896
|
+
const mid = Math.floor(sorted.length / 2);
|
|
1897
|
+
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
1898
|
+
}
|
|
1815
1899
|
function buildLzOptions(gasLimit = 0n) {
|
|
1816
1900
|
return _viem.concat.call(void 0, [
|
|
1817
1901
|
_viem.numberToHex.call(void 0, 3, { size: 2 }),
|
|
@@ -1830,9 +1914,20 @@ var LayerZeroService = class {
|
|
|
1830
1914
|
constructor(config) {
|
|
1831
1915
|
this.config = config;
|
|
1832
1916
|
}
|
|
1833
|
-
async quoteBridge(
|
|
1917
|
+
async quoteBridge(params) {
|
|
1918
|
+
const [fee, estimate] = await Promise.all([
|
|
1919
|
+
this.quoteFee(params, "quoteBridge"),
|
|
1920
|
+
this.estimateBridgeTime(params).catch(() => void 0)
|
|
1921
|
+
]);
|
|
1922
|
+
return { ...fee, toAmount: params.amount, estimate };
|
|
1923
|
+
}
|
|
1924
|
+
/**
|
|
1925
|
+
* LayerZero messaging fee for a send, with no delivery estimate attached — the
|
|
1926
|
+
* send path needs the fee and nothing else, and must not wait on Scan for it.
|
|
1927
|
+
*/
|
|
1928
|
+
async quoteFee({ fromChain, toChain, fromToken, toToken, amount, recipient }, method) {
|
|
1834
1929
|
const recipientAddr = _nullishCoalesce(recipient, () => ( "0x0000000000000000000000000000000000000000"));
|
|
1835
|
-
this.validateBridgeParams({ fromChain, toChain, amount, recipient: recipientAddr },
|
|
1930
|
+
this.validateBridgeParams({ fromChain, toChain, amount, recipient: recipientAddr }, method);
|
|
1836
1931
|
const { src, dst } = this.resolveChains(fromChain, toChain, fromToken, toToken);
|
|
1837
1932
|
const oftAdapter = src.oftAdapter;
|
|
1838
1933
|
const amountLD = _viem.parseUnits.call(void 0, String(amount), src.decimals);
|
|
@@ -1846,19 +1941,19 @@ var LayerZeroService = class {
|
|
|
1846
1941
|
functionName: "quoteSend",
|
|
1847
1942
|
args: [this.buildSendParams(dst, amountLD, recipientAddr), false]
|
|
1848
1943
|
});
|
|
1849
|
-
return { nativeFee, lzTokenFee
|
|
1944
|
+
return { nativeFee, lzTokenFee };
|
|
1850
1945
|
} catch (err) {
|
|
1851
|
-
throw new StableQuoteError({
|
|
1946
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
|
|
1852
1947
|
provider: "layerzero",
|
|
1853
|
-
shortMessage:
|
|
1948
|
+
shortMessage: `${method}: quoteSend call failed`,
|
|
1854
1949
|
cause: err
|
|
1855
1950
|
});
|
|
1856
1951
|
}
|
|
1857
1952
|
}
|
|
1858
1953
|
async bridge({ fromChain, toChain, fromToken, toToken, amount, recipient, quote }) {
|
|
1859
|
-
const from = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1954
|
+
const from = _nullishCoalesce(_optionalChain([this, 'access', _36 => _36.config, 'access', _37 => _37.walletClient, 'optionalAccess', _38 => _38.account, 'optionalAccess', _39 => _39.address]), () => ( _optionalChain([this, 'access', _40 => _40.config, 'access', _41 => _41.account, 'optionalAccess', _42 => _42.address])));
|
|
1860
1955
|
if (!from) {
|
|
1861
|
-
throw new StableValidationError(
|
|
1956
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1862
1957
|
"signer",
|
|
1863
1958
|
void 0,
|
|
1864
1959
|
"bridge: requires a signer \u2014 set walletClient or account in StableConfig"
|
|
@@ -1878,7 +1973,7 @@ var LayerZeroService = class {
|
|
|
1878
1973
|
try {
|
|
1879
1974
|
await wc.switchChain({ id: src.id });
|
|
1880
1975
|
} catch (err) {
|
|
1881
|
-
throw new StableTransactionError({
|
|
1976
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1882
1977
|
phase: "switch_chain",
|
|
1883
1978
|
shortMessage: `bridge: wallet rejected or failed to switch to chain ${src.id}`,
|
|
1884
1979
|
chainId: src.id,
|
|
@@ -1887,8 +1982,7 @@ var LayerZeroService = class {
|
|
|
1887
1982
|
}
|
|
1888
1983
|
const amountLD = _viem.parseUnits.call(void 0, String(amount), src.decimals);
|
|
1889
1984
|
const sendParams = this.buildSendParams(dst, amountLD, recipientAddr);
|
|
1890
|
-
const
|
|
1891
|
-
const { nativeFee = 0n, lzTokenFee = 0n } = lzFee;
|
|
1985
|
+
const { nativeFee, lzTokenFee } = _optionalChain([quote, 'optionalAccess', _43 => _43.nativeFee]) !== void 0 && _optionalChain([quote, 'optionalAccess', _44 => _44.lzTokenFee]) !== void 0 ? { nativeFee: quote.nativeFee, lzTokenFee: quote.lzTokenFee } : await this.quoteFee({ fromChain, toChain, fromToken, toToken, amount, recipient: recipientAddr }, "bridge");
|
|
1892
1986
|
const allowance = await pc.readContract({
|
|
1893
1987
|
address: src.usdt,
|
|
1894
1988
|
abi: _viem.erc20Abi,
|
|
@@ -1907,7 +2001,7 @@ var LayerZeroService = class {
|
|
|
1907
2001
|
chain: srcChain
|
|
1908
2002
|
});
|
|
1909
2003
|
} catch (err) {
|
|
1910
|
-
throw new StableTransactionError({
|
|
2004
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1911
2005
|
phase: "approve",
|
|
1912
2006
|
shortMessage: "bridge: USDT0 approve failed",
|
|
1913
2007
|
chainId: src.id,
|
|
@@ -1916,7 +2010,7 @@ var LayerZeroService = class {
|
|
|
1916
2010
|
}
|
|
1917
2011
|
const approveReceipt = await pc.waitForTransactionReceipt({ hash: approveHash });
|
|
1918
2012
|
if (approveReceipt.status === "reverted") {
|
|
1919
|
-
throw new StableTransactionError({
|
|
2013
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1920
2014
|
phase: "approve",
|
|
1921
2015
|
shortMessage: "bridge: USDT0 approve reverted on-chain",
|
|
1922
2016
|
txHash: approveReceipt.transactionHash,
|
|
@@ -1936,7 +2030,7 @@ var LayerZeroService = class {
|
|
|
1936
2030
|
});
|
|
1937
2031
|
return { txHash: hash, toAmount: amount };
|
|
1938
2032
|
} catch (err) {
|
|
1939
|
-
throw new StableTransactionError({
|
|
2033
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
1940
2034
|
phase: "send",
|
|
1941
2035
|
shortMessage: "bridge: OFT send failed",
|
|
1942
2036
|
chainId: src.id,
|
|
@@ -1944,23 +2038,142 @@ var LayerZeroService = class {
|
|
|
1944
2038
|
});
|
|
1945
2039
|
}
|
|
1946
2040
|
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Estimate how long a USDT0 bridge will take, end to end.
|
|
2043
|
+
*
|
|
2044
|
+
* Two independent inputs, both cheap:
|
|
2045
|
+
* - **observed** — median delivery time of recent messages LayerZero Scan has
|
|
2046
|
+
* already settled on this exact pathway.
|
|
2047
|
+
* - **formula** — LayerZero's documented estimate from the on-chain ULN config:
|
|
2048
|
+
* `srcBlockTime × confirmations + dstBlockTime × (2 + dvnCount)`.
|
|
2049
|
+
*
|
|
2050
|
+
* `observed` wins when available. The formula assumes `confirmations` is the whole
|
|
2051
|
+
* wait, which holds for L1 sources but badly understates rollups: Arbitrum→Stable
|
|
2052
|
+
* computes to ~15s (60 blocks × 0.25s) while real deliveries take ~18min, because
|
|
2053
|
+
* the DVNs wait for the L2 batch to finalize on L1.
|
|
2054
|
+
*/
|
|
2055
|
+
async estimateBridgeTime({ fromChain, toChain }) {
|
|
2056
|
+
const src = BRIDGE_CHAIN_CONFIGS[fromChain];
|
|
2057
|
+
const dst = BRIDGE_CHAIN_CONFIGS[toChain];
|
|
2058
|
+
if (!_optionalChain([src, 'optionalAccess', _45 => _45.oftAdapter])) {
|
|
2059
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("fromChain", fromChain, `estimateBridgeTime: no OFT adapter for "${fromChain}"`);
|
|
2060
|
+
}
|
|
2061
|
+
if (!_optionalChain([dst, 'optionalAccess', _46 => _46.oftAdapter])) {
|
|
2062
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("toChain", toChain, `estimateBridgeTime: no OFT adapter for "${toChain}"`);
|
|
2063
|
+
}
|
|
2064
|
+
const [uln, observedSeconds] = await Promise.all([
|
|
2065
|
+
this.getUlnConfig(src, dst).catch(() => void 0),
|
|
2066
|
+
this.observedBridgeSeconds(src, dst).catch(() => void 0)
|
|
2067
|
+
]);
|
|
2068
|
+
const dvnCount = uln ? uln.requiredDVNCount + uln.optionalDVNCount : void 0;
|
|
2069
|
+
let formulaSeconds;
|
|
2070
|
+
if (uln && dvnCount !== void 0 && src.blockTimeSec && dst.blockTimeSec) {
|
|
2071
|
+
const computed = Math.round(
|
|
2072
|
+
uln.confirmations * src.blockTimeSec + dst.blockTimeSec * (2 + dvnCount)
|
|
2073
|
+
);
|
|
2074
|
+
formulaSeconds = Number.isFinite(computed) ? computed : void 0;
|
|
2075
|
+
}
|
|
2076
|
+
const seconds = _nullishCoalesce(observedSeconds, () => ( formulaSeconds));
|
|
2077
|
+
if (seconds === void 0) {
|
|
2078
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
|
|
2079
|
+
provider: "layerzero",
|
|
2080
|
+
shortMessage: `estimateBridgeTime: no pathway data for ${fromChain}\u2192${toChain}`
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
return {
|
|
2084
|
+
seconds,
|
|
2085
|
+
source: observedSeconds !== void 0 ? "observed" : "formula",
|
|
2086
|
+
observedSeconds,
|
|
2087
|
+
formulaSeconds,
|
|
2088
|
+
confirmations: Number.isFinite(_optionalChain([uln, 'optionalAccess', _47 => _47.confirmations])) ? _optionalChain([uln, 'optionalAccess', _48 => _48.confirmations]) : void 0,
|
|
2089
|
+
dvnCount: Number.isFinite(dvnCount) ? dvnCount : void 0
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Follow an in-flight bridge by its source transaction hash. Poll this after
|
|
2094
|
+
* `bridge()` to drive a progress UI; a message LayerZero Scan has not indexed
|
|
2095
|
+
* yet reports `"pending"` rather than throwing.
|
|
2096
|
+
*/
|
|
2097
|
+
async trackBridge(srcTxHash) {
|
|
2098
|
+
const scanUrl = `${LZ_SCAN_UI}/tx/${srcTxHash}`;
|
|
2099
|
+
let message;
|
|
2100
|
+
try {
|
|
2101
|
+
message = await _asyncOptionalChain([(await scanFetch(`/messages/tx/${srcTxHash}`)), 'optionalAccess', async _49 => _49.data, 'optionalAccess', async _50 => _50[0]]);
|
|
2102
|
+
} catch (err) {
|
|
2103
|
+
if (err instanceof ScanHttpError && err.status === 404) {
|
|
2104
|
+
return { state: "pending", srcTxHash, scanUrl };
|
|
2105
|
+
}
|
|
2106
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableQuoteError)({
|
|
2107
|
+
provider: "layerzero",
|
|
2108
|
+
shortMessage: `trackBridge: LayerZero Scan lookup failed for ${srcTxHash}`,
|
|
2109
|
+
cause: err
|
|
2110
|
+
});
|
|
2111
|
+
}
|
|
2112
|
+
if (!message) return { state: "pending", srcTxHash, scanUrl };
|
|
2113
|
+
const raw = _nullishCoalesce(_optionalChain([message, 'access', _51 => _51.status, 'optionalAccess', _52 => _52.name]), () => ( ""));
|
|
2114
|
+
const sentAt = _optionalChain([message, 'access', _53 => _53.source, 'optionalAccess', _54 => _54.tx, 'optionalAccess', _55 => _55.blockTimestamp]);
|
|
2115
|
+
return {
|
|
2116
|
+
// Everything terminal that is not DELIVERED means the tokens will not land
|
|
2117
|
+
// on their own; `raw` carries which of those it was.
|
|
2118
|
+
state: raw === "DELIVERED" ? "delivered" : TERMINAL_FAILURE_STATUSES.has(raw) ? "failed" : "inflight",
|
|
2119
|
+
raw,
|
|
2120
|
+
srcTxHash,
|
|
2121
|
+
dstTxHash: _optionalChain([message, 'access', _56 => _56.destination, 'optionalAccess', _57 => _57.tx, 'optionalAccess', _58 => _58.txHash]),
|
|
2122
|
+
elapsedSeconds: sentAt ? Math.max(0, Math.floor(Date.now() / 1e3) - sentAt) : void 0,
|
|
2123
|
+
scanUrl
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
/** Effective ULN config the DVNs enforce for this pathway, read from the source chain. */
|
|
2127
|
+
async getUlnConfig(src, dst) {
|
|
2128
|
+
return cached(`uln:${src.lzEid}-${dst.lzEid}`, CACHE_TTL_MS, async () => {
|
|
2129
|
+
const pc = _viem.createPublicClient.call(void 0, { chain: makeChain(src.id, src.rpc), transport: _viem.http.call(void 0, src.rpc) });
|
|
2130
|
+
const oapp = src.oftAdapter;
|
|
2131
|
+
const endpoint = await pc.readContract({ address: oapp, abi: OAPP_ABI, functionName: "endpoint" });
|
|
2132
|
+
const sendLib = await pc.readContract({
|
|
2133
|
+
address: endpoint,
|
|
2134
|
+
abi: ENDPOINT_V2_ABI,
|
|
2135
|
+
functionName: "getSendLibrary",
|
|
2136
|
+
args: [oapp, dst.lzEid]
|
|
2137
|
+
});
|
|
2138
|
+
const cfg = await pc.readContract({
|
|
2139
|
+
address: sendLib,
|
|
2140
|
+
abi: SEND_ULN_ABI,
|
|
2141
|
+
functionName: "getUlnConfig",
|
|
2142
|
+
args: [oapp, dst.lzEid]
|
|
2143
|
+
});
|
|
2144
|
+
return {
|
|
2145
|
+
confirmations: Number(cfg.confirmations),
|
|
2146
|
+
requiredDVNCount: Number(cfg.requiredDVNCount),
|
|
2147
|
+
optionalDVNCount: Number(cfg.optionalDVNCount)
|
|
2148
|
+
};
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
/** Median delivery time of recently delivered messages on this pathway, in seconds. */
|
|
2152
|
+
async observedBridgeSeconds(src, dst) {
|
|
2153
|
+
const pathwayId = `${src.lzEid}-${dst.lzEid}-${src.oftAdapter.toLowerCase()}-${dst.oftAdapter.toLowerCase()}`;
|
|
2154
|
+
return cached(`observed:${pathwayId}`, CACHE_TTL_MS, async () => {
|
|
2155
|
+
const { data } = await scanFetch(`/messages/pathway/${pathwayId}?limit=50`);
|
|
2156
|
+
const durations = (_nullishCoalesce(data, () => ( []))).filter((m) => _optionalChain([m, 'access', _59 => _59.status, 'optionalAccess', _60 => _60.name]) === "DELIVERED").map((m) => (_nullishCoalesce(_optionalChain([m, 'access', _61 => _61.destination, 'optionalAccess', _62 => _62.tx, 'optionalAccess', _63 => _63.blockTimestamp]), () => ( 0))) - (_nullishCoalesce(_optionalChain([m, 'access', _64 => _64.source, 'optionalAccess', _65 => _65.tx, 'optionalAccess', _66 => _66.blockTimestamp]), () => ( 0)))).filter((d) => d > 0);
|
|
2157
|
+
return durations.length >= 3 ? Math.round(median(durations)) : void 0;
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
1947
2160
|
validateBridgeParams(params, method) {
|
|
1948
2161
|
if (!_viem.isAddress.call(void 0, params.recipient)) {
|
|
1949
|
-
throw new StableValidationError(
|
|
2162
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1950
2163
|
"recipient",
|
|
1951
2164
|
params.recipient,
|
|
1952
2165
|
`${method}: invalid recipient address "${params.recipient}"`
|
|
1953
2166
|
);
|
|
1954
2167
|
}
|
|
1955
2168
|
if (!Number.isFinite(params.amount) || params.amount <= 0) {
|
|
1956
|
-
throw new StableValidationError(
|
|
2169
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1957
2170
|
"amount",
|
|
1958
2171
|
params.amount,
|
|
1959
2172
|
`${method}: amount must be a finite positive number`
|
|
1960
2173
|
);
|
|
1961
2174
|
}
|
|
1962
2175
|
if (params.fromChain === params.toChain) {
|
|
1963
|
-
throw new StableValidationError(
|
|
2176
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1964
2177
|
"toChain",
|
|
1965
2178
|
params.toChain,
|
|
1966
2179
|
`${method}: fromChain and toChain must differ`
|
|
@@ -1970,20 +2183,20 @@ var LayerZeroService = class {
|
|
|
1970
2183
|
resolveChains(fromChain, toChain, fromToken, toToken) {
|
|
1971
2184
|
const src = BRIDGE_CHAIN_CONFIGS[fromChain];
|
|
1972
2185
|
const dst = BRIDGE_CHAIN_CONFIGS[toChain];
|
|
1973
|
-
if (!src) throw new StableValidationError("fromChain", fromChain, `Unsupported source chain: "${fromChain}"`);
|
|
1974
|
-
if (!dst) throw new StableValidationError("toChain", toChain, `Unsupported destination chain: "${toChain}"`);
|
|
2186
|
+
if (!src) throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("fromChain", fromChain, `Unsupported source chain: "${fromChain}"`);
|
|
2187
|
+
if (!dst) throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("toChain", toChain, `Unsupported destination chain: "${toChain}"`);
|
|
1975
2188
|
if (!src.oftAdapter) {
|
|
1976
|
-
throw new StableValidationError("fromChain", fromChain, `No OFT adapter configured for "${fromChain}"`);
|
|
2189
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)("fromChain", fromChain, `No OFT adapter configured for "${fromChain}"`);
|
|
1977
2190
|
}
|
|
1978
2191
|
if (fromToken.toLowerCase() !== src.usdt.toLowerCase()) {
|
|
1979
|
-
throw new StableValidationError(
|
|
2192
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1980
2193
|
"fromToken",
|
|
1981
2194
|
fromToken,
|
|
1982
2195
|
`USDT0 bridge only moves USDT0 \u2014 fromToken must be ${src.usdt} on "${fromChain}", got "${fromToken}". Use route "lifi" to bridge other tokens.`
|
|
1983
2196
|
);
|
|
1984
2197
|
}
|
|
1985
2198
|
if (toToken.toLowerCase() !== dst.usdt.toLowerCase()) {
|
|
1986
|
-
throw new StableValidationError(
|
|
2199
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
1987
2200
|
"toToken",
|
|
1988
2201
|
toToken,
|
|
1989
2202
|
`USDT0 bridge only moves USDT0 \u2014 toToken must be ${dst.usdt} on "${toChain}", got "${toToken}". Use route "lifi" to bridge other tokens.`
|
|
@@ -2028,28 +2241,28 @@ function validateTransferParams({
|
|
|
2028
2241
|
tokenDecimals
|
|
2029
2242
|
}) {
|
|
2030
2243
|
if (!_viem.isAddress.call(void 0, to)) {
|
|
2031
|
-
throw new StableValidationError(
|
|
2244
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
2032
2245
|
"to",
|
|
2033
2246
|
to,
|
|
2034
2247
|
`transfer: invalid recipient address "${to}"`
|
|
2035
2248
|
);
|
|
2036
2249
|
}
|
|
2037
2250
|
if (!Number.isFinite(amount) || amount <= 0) {
|
|
2038
|
-
throw new StableValidationError(
|
|
2251
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
2039
2252
|
"amount",
|
|
2040
2253
|
amount,
|
|
2041
2254
|
"transfer: amount must be a finite positive number"
|
|
2042
2255
|
);
|
|
2043
2256
|
}
|
|
2044
2257
|
if (token !== void 0 && !_viem.isAddress.call(void 0, token)) {
|
|
2045
|
-
throw new StableValidationError(
|
|
2258
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
2046
2259
|
"token",
|
|
2047
2260
|
token,
|
|
2048
2261
|
`transfer: invalid token address "${token}"`
|
|
2049
2262
|
);
|
|
2050
2263
|
}
|
|
2051
2264
|
if (tokenDecimals !== void 0 && (!Number.isInteger(tokenDecimals) || tokenDecimals < 0 || tokenDecimals > 77)) {
|
|
2052
|
-
throw new StableValidationError(
|
|
2265
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
2053
2266
|
"tokenDecimals",
|
|
2054
2267
|
tokenDecimals,
|
|
2055
2268
|
"transfer: tokenDecimals must be an integer between 0 and 77"
|
|
@@ -2064,8 +2277,8 @@ async function resolveTokenDecimals(publicClient, token, tokenDecimals) {
|
|
|
2064
2277
|
abi: _viem.erc20Abi,
|
|
2065
2278
|
functionName: "decimals"
|
|
2066
2279
|
});
|
|
2067
|
-
} catch (
|
|
2068
|
-
throw new StableValidationError(
|
|
2280
|
+
} catch (e5) {
|
|
2281
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
2069
2282
|
"tokenDecimals",
|
|
2070
2283
|
void 0,
|
|
2071
2284
|
`transfer: could not fetch decimals for token "${token}" \u2014 pass tokenDecimals explicitly`
|
|
@@ -2075,7 +2288,7 @@ async function resolveTokenDecimals(publicClient, token, tokenDecimals) {
|
|
|
2075
2288
|
async function executeTokenTransfer(wc, publicClient, token, to, amount, tokenDecimals, acc, chain) {
|
|
2076
2289
|
const code = await publicClient.getCode({ address: token });
|
|
2077
2290
|
if (!code || code === "0x") {
|
|
2078
|
-
throw new StableValidationError(
|
|
2291
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
2079
2292
|
"token",
|
|
2080
2293
|
token,
|
|
2081
2294
|
`transfer: no contract found at "${token}" on chain ${chain.id} \u2014 check the address and network`
|
|
@@ -2119,9 +2332,15 @@ function createStable({
|
|
|
2119
2332
|
chainId: chain.id,
|
|
2120
2333
|
vault: earnConfig.vault
|
|
2121
2334
|
}) : null;
|
|
2335
|
+
const erc3009Client = walletClient ? walletClient : account ? _viem.createWalletClient.call(void 0, {
|
|
2336
|
+
account,
|
|
2337
|
+
chain,
|
|
2338
|
+
transport: _nullishCoalesce(transport, () => ( _viem.http.call(void 0, rpc)))
|
|
2339
|
+
}) : _viem.createPublicClient.call(void 0, { chain, transport: _viem.http.call(void 0, rpc) });
|
|
2340
|
+
const authorization = _chunkQQ26UI3Fcjs.erc3009Actions.call(void 0, erc3009Client);
|
|
2122
2341
|
function requireEarn() {
|
|
2123
2342
|
if (!morpho) {
|
|
2124
|
-
throw new StableValidationError(
|
|
2343
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
2125
2344
|
"earn",
|
|
2126
2345
|
void 0,
|
|
2127
2346
|
"stable.earn.*: pass earn: { vault: '0x...' } to createStable() to enable earn operations"
|
|
@@ -2130,9 +2349,9 @@ function createStable({
|
|
|
2130
2349
|
return morpho;
|
|
2131
2350
|
}
|
|
2132
2351
|
function requireSignerAddress() {
|
|
2133
|
-
const from = _nullishCoalesce(_optionalChain([walletClient, 'optionalAccess',
|
|
2352
|
+
const from = _nullishCoalesce(_optionalChain([walletClient, 'optionalAccess', _67 => _67.account, 'optionalAccess', _68 => _68.address]), () => ( _optionalChain([account, 'optionalAccess', _69 => _69.address])));
|
|
2134
2353
|
if (!from) {
|
|
2135
|
-
throw new StableValidationError(
|
|
2354
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableValidationError)(
|
|
2136
2355
|
"signer",
|
|
2137
2356
|
void 0,
|
|
2138
2357
|
"stable.rewards.*: requires a signer \u2014 set walletClient or account in StableConfig"
|
|
@@ -2143,7 +2362,7 @@ function createStable({
|
|
|
2143
2362
|
async function transfer(params) {
|
|
2144
2363
|
validateTransferParams(params);
|
|
2145
2364
|
const { from, to, amount, token, tokenDecimals } = params;
|
|
2146
|
-
const acc = _nullishCoalesce(_nullishCoalesce(_optionalChain([walletClient, 'optionalAccess',
|
|
2365
|
+
const acc = _nullishCoalesce(_nullishCoalesce(_optionalChain([walletClient, 'optionalAccess', _70 => _70.account]), () => ( account)), () => ( from));
|
|
2147
2366
|
const wc = _nullishCoalesce(walletClient, () => ( _viem.createWalletClient.call(void 0, {
|
|
2148
2367
|
account: acc,
|
|
2149
2368
|
chain,
|
|
@@ -2152,7 +2371,7 @@ function createStable({
|
|
|
2152
2371
|
try {
|
|
2153
2372
|
await wc.switchChain({ id: chain.id });
|
|
2154
2373
|
} catch (err) {
|
|
2155
|
-
throw new StableTransactionError({
|
|
2374
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
2156
2375
|
phase: "switch_chain",
|
|
2157
2376
|
shortMessage: `transfer: wallet rejected or failed to switch to chain ${chain.id}`,
|
|
2158
2377
|
chainId: chain.id,
|
|
@@ -2184,7 +2403,7 @@ function createStable({
|
|
|
2184
2403
|
);
|
|
2185
2404
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
2186
2405
|
if (receipt.status === "reverted") {
|
|
2187
|
-
throw new StableTransactionError({
|
|
2406
|
+
throw new (0, _chunkQQ26UI3Fcjs.StableTransactionError)({
|
|
2188
2407
|
phase: "receipt",
|
|
2189
2408
|
shortMessage: "transfer: transaction reverted on-chain",
|
|
2190
2409
|
txHash: receipt.transactionHash,
|
|
@@ -2197,8 +2416,11 @@ function createStable({
|
|
|
2197
2416
|
transfer,
|
|
2198
2417
|
quoteBridge: (params) => selectBridge(params) === "usdt0" ? lz.quoteBridge(params) : lifi.quoteBridge(params),
|
|
2199
2418
|
bridge: (params) => selectBridge(params) === "usdt0" ? lz.bridge(params) : lifi.bridge(params),
|
|
2419
|
+
estimateBridgeTime: (params) => lz.estimateBridgeTime(params),
|
|
2420
|
+
trackBridge: (srcTxHash) => lz.trackBridge(srcTxHash),
|
|
2200
2421
|
quoteSwap: (params) => lifi.quoteSwap(params),
|
|
2201
2422
|
swap: (params) => lifi.swap(params),
|
|
2423
|
+
authorization,
|
|
2202
2424
|
earn: {
|
|
2203
2425
|
deposit: (params) => requireEarn().deposit(params),
|
|
2204
2426
|
bulkDeposit: (items, options) => requireEarn().bulkDeposit(items, options),
|
|
@@ -2235,9 +2457,6 @@ function createStableReader(config) {
|
|
|
2235
2457
|
};
|
|
2236
2458
|
}
|
|
2237
2459
|
|
|
2238
|
-
// src/constants.ts
|
|
2239
|
-
var STABLE_USDT_ADDRESS = "0x779ded0c9e1022225f8e0630b35a9b54be713736";
|
|
2240
|
-
var STABLE_VAULT_ADDRESS = "0xb7Df8db22A5DBBFA9ebeb94b3910aec6a4f05c08";
|
|
2241
2460
|
|
|
2242
2461
|
|
|
2243
2462
|
|
|
@@ -2253,4 +2472,15 @@ var STABLE_VAULT_ADDRESS = "0xb7Df8db22A5DBBFA9ebeb94b3910aec6a4f05c08";
|
|
|
2253
2472
|
|
|
2254
2473
|
|
|
2255
2474
|
|
|
2256
|
-
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
|
|
2478
|
+
|
|
2479
|
+
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
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.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.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;
|