@naviprotocol/wallet-client 1.0.5-dev.3 → 1.0.5-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +89 -91
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/lendingModule/migrate.d.ts.map +1 -1
- package/dist/modules/lendingModule/protocols/suilend.d.ts +3 -1
- package/dist/modules/lendingModule/protocols/suilend.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { getFullnodeUrl as de, SuiClient as we } from "@mysten/sui/client";
|
|
2
2
|
import he from "mitt";
|
|
3
3
|
import fe from "axios";
|
|
4
|
-
import { withSingleton as Q, getCoins as ge, mergeCoinsPTB as B, getPriceFeeds as K, updateOraclePricesPTB as $, filterPriceFeeds as q, getFlashLoanAsset as te, flashloanPTB as ae, depositCoinPTB as N, repayFlashLoanPTB as ne, borrowCoinPTB as se, withdrawCoinPTB as ie, repayCoinPTB as le, getPools as me, getPool as T, getHealthFactor as Ce, liquidatePTB as be, getUserAvailableLendingRewards as J, getUserClaimedRewardHistory as ye, claimLendingRewardsPTB as pe, getLendingState as Pe, createAccountCapPTB as Be, withCache as re, parseTxValue as
|
|
4
|
+
import { withSingleton as Q, getCoins as ge, mergeCoinsPTB as B, getPriceFeeds as K, updateOraclePricesPTB as $, filterPriceFeeds as q, getFlashLoanAsset as te, flashloanPTB as ae, depositCoinPTB as N, repayFlashLoanPTB as ne, borrowCoinPTB as se, withdrawCoinPTB as ie, repayCoinPTB as le, getPools as me, getPool as T, getHealthFactor as Ce, liquidatePTB as be, getUserAvailableLendingRewards as J, getUserClaimedRewardHistory as ye, claimLendingRewardsPTB as pe, getLendingState as Pe, createAccountCapPTB as Be, withCache as re, parseTxValue as _ } from "@naviprotocol/lending";
|
|
5
5
|
import R, { BigNumber as L } from "bignumber.js";
|
|
6
6
|
import { normalizeStructTag as p } from "@mysten/sui/utils";
|
|
7
7
|
import { Transaction as m } from "@mysten/sui/transactions";
|
|
8
8
|
import { buildSwapPTBFromQuote as G, generateRefId as Te, getQuote as ve } from "@naviprotocol/astros-aggregator-sdk";
|
|
9
|
-
import { SuilendClient as V, LENDING_MARKET_ID as Ee, LENDING_MARKET_TYPE as
|
|
10
|
-
import { getCoinMetadataMap as Oe } from "@suilend/sui-fe";
|
|
11
|
-
import { executeAuction as
|
|
9
|
+
import { SuilendClient as V, LENDING_MARKET_ID as Ee, LENDING_MARKET_TYPE as X, parseReserve as Re, parseObligation as Se } from "@suilend/sdk";
|
|
10
|
+
import { getCoinMetadataMap as Oe, MAX_U64 as Ae } from "@suilend/sui-fe";
|
|
11
|
+
import { executeAuction as xe } from "shio-sdk";
|
|
12
12
|
import { Signer as oe } from "@mysten/sui/cryptography";
|
|
13
13
|
const ce = fe.create({
|
|
14
14
|
timeout: 2e4
|
|
@@ -25,7 +25,7 @@ ce.interceptors.response.use(
|
|
|
25
25
|
return Promise.reject(r);
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
|
-
class
|
|
28
|
+
class ke {
|
|
29
29
|
/**
|
|
30
30
|
* Creates a new custom transport instance
|
|
31
31
|
*
|
|
@@ -170,7 +170,7 @@ class O {
|
|
|
170
170
|
return a.balances = e, a;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
class
|
|
173
|
+
class Ne extends A {
|
|
174
174
|
constructor() {
|
|
175
175
|
super(...arguments), this.name = "balance", this.defaultConfig = {
|
|
176
176
|
coinPollingInterval: 6e3
|
|
@@ -237,7 +237,7 @@ class ke extends A {
|
|
|
237
237
|
if (a.length !== t.length)
|
|
238
238
|
throw new Error("Recipients and amounts must have the same length");
|
|
239
239
|
await this.waitForUpdate();
|
|
240
|
-
const n = this.portfolio.getBalance(e), c = t.reduce((g,
|
|
240
|
+
const n = this.portfolio.getBalance(e), c = t.reduce((g, f) => g.plus(f), R(0));
|
|
241
241
|
if (n.amount.lt(c))
|
|
242
242
|
throw new Error("Insufficient balance");
|
|
243
243
|
const i = new m();
|
|
@@ -246,8 +246,8 @@ class ke extends A {
|
|
|
246
246
|
balance: c.toNumber()
|
|
247
247
|
}));
|
|
248
248
|
const u = i.splitCoins(l, t);
|
|
249
|
-
return a.forEach((g,
|
|
250
|
-
i.transferObjects([u[
|
|
249
|
+
return a.forEach((g, f) => {
|
|
250
|
+
i.transferObjects([u[f]], g);
|
|
251
251
|
}), await this.walletClient.signExecuteTransaction({
|
|
252
252
|
transaction: i,
|
|
253
253
|
dryRun: (w = s == null ? void 0 : s.dryRun) != null ? w : !1
|
|
@@ -326,7 +326,7 @@ class ke extends A {
|
|
|
326
326
|
super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
async function
|
|
329
|
+
async function Y(r, e, a, t) {
|
|
330
330
|
var x, k, S;
|
|
331
331
|
if (!this.walletClient)
|
|
332
332
|
throw new Error("Wallet client not found");
|
|
@@ -349,49 +349,45 @@ async function X(r, e, a, t) {
|
|
|
349
349
|
pools: g
|
|
350
350
|
})
|
|
351
351
|
);
|
|
352
|
-
const
|
|
352
|
+
const f = await te(n, {
|
|
353
353
|
env: this.config.env
|
|
354
354
|
});
|
|
355
|
-
if (!
|
|
355
|
+
if (!f)
|
|
356
356
|
throw new Error(`${n.token.symbol} pool not support flashloan`);
|
|
357
|
-
const b = (k = t == null ? void 0 : t.slippage) != null ? k : 5e-3,
|
|
357
|
+
const b = (k = t == null ? void 0 : t.slippage) != null ? k : 5e-3, y = (S = t == null ? void 0 : t.amount) != null ? S : Number(o.supplyBalance), d = await this.walletClient.swap.getQuote(
|
|
358
358
|
s.suiCoinType,
|
|
359
359
|
n.suiCoinType,
|
|
360
|
-
|
|
361
|
-
),
|
|
362
|
-
if (
|
|
360
|
+
y
|
|
361
|
+
), h = Number(d.amount_out);
|
|
362
|
+
if (h <= 0)
|
|
363
363
|
throw new Error("The amount of swapAmountOut must be greater than 0.");
|
|
364
|
-
const C = Math.floor(
|
|
364
|
+
const C = Math.floor(h * (1 - b)), P = Math.floor(C / (1 + f.flashloanFee));
|
|
365
365
|
if (P <= 0)
|
|
366
366
|
throw new Error("The calculated borrow amount must be positive.");
|
|
367
|
-
const [v, E] = await ae(r, n, P), [
|
|
367
|
+
const [v, E] = await ae(r, n, P), [F] = r.moveCall({
|
|
368
368
|
target: "0x2::coin::from_balance",
|
|
369
369
|
arguments: [v],
|
|
370
370
|
typeArguments: [n.suiCoinType]
|
|
371
371
|
});
|
|
372
|
-
await N(r, n,
|
|
372
|
+
await N(r, n, F, {
|
|
373
373
|
amount: P
|
|
374
374
|
});
|
|
375
|
-
const j = await u.withdrawCoinPTB(
|
|
376
|
-
r,
|
|
377
|
-
s.token.coinType,
|
|
378
|
-
d
|
|
379
|
-
), I = await G(
|
|
375
|
+
const j = await u.withdrawCoinPTB(r, s.suiCoinType, y), I = await G(
|
|
380
376
|
i,
|
|
381
377
|
r,
|
|
382
378
|
C,
|
|
383
379
|
j,
|
|
384
|
-
|
|
380
|
+
d
|
|
385
381
|
), U = r.moveCall({
|
|
386
382
|
target: "0x2::coin::into_balance",
|
|
387
383
|
arguments: [I],
|
|
388
384
|
typeArguments: [n.suiCoinType]
|
|
389
|
-
}), [
|
|
385
|
+
}), [M] = await ne(r, n, E, U), [W] = r.moveCall({
|
|
390
386
|
target: "0x2::coin::from_balance",
|
|
391
|
-
arguments: [
|
|
387
|
+
arguments: [M],
|
|
392
388
|
typeArguments: [n.suiCoinType]
|
|
393
389
|
});
|
|
394
|
-
return await N(r, n,
|
|
390
|
+
return await N(r, n, W), r;
|
|
395
391
|
}
|
|
396
392
|
async function Z(r, e, a, t) {
|
|
397
393
|
var S, H, D;
|
|
@@ -407,7 +403,7 @@ async function Z(r, e, a, t) {
|
|
|
407
403
|
}), o.borrowBalance === 0)
|
|
408
404
|
throw new Error("No borrow balance");
|
|
409
405
|
if (t != null && t.amount && t.amount > o.borrowBalance)
|
|
410
|
-
throw new Error("Amount is
|
|
406
|
+
throw new Error("Amount is more than borrow balance");
|
|
411
407
|
const w = await K(), g = await Promise.all([n, c]);
|
|
412
408
|
await $(
|
|
413
409
|
r,
|
|
@@ -416,11 +412,11 @@ async function Z(r, e, a, t) {
|
|
|
416
412
|
pools: g
|
|
417
413
|
})
|
|
418
414
|
);
|
|
419
|
-
let
|
|
420
|
-
if (Number(o.borrowBalance) ===
|
|
415
|
+
let f = (H = t == null ? void 0 : t.amount) != null ? H : Number(o.borrowBalance);
|
|
416
|
+
if (Number(o.borrowBalance) === f) {
|
|
421
417
|
const ue = o.borrowAPR / 100;
|
|
422
|
-
|
|
423
|
-
new R(
|
|
418
|
+
f = Math.ceil(
|
|
419
|
+
new R(f).multipliedBy(ue * (60 * 3) / (365 * 24 * 3600)).plus(new R(1).shiftedBy(-n.token.decimals)).plus(f).toNumber()
|
|
424
420
|
);
|
|
425
421
|
}
|
|
426
422
|
const b = await te(n, {
|
|
@@ -430,39 +426,39 @@ async function Z(r, e, a, t) {
|
|
|
430
426
|
throw new Error(`${n.token.symbol} pool not support flashloan`);
|
|
431
427
|
if (!this.walletClient)
|
|
432
428
|
throw new Error("Wallet client not found");
|
|
433
|
-
const
|
|
429
|
+
const y = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, d = Math.ceil(f * (1 + b.flashloanFee)), h = d, C = await this.walletClient.swap.getQuote(
|
|
434
430
|
n.suiCoinType,
|
|
435
431
|
c.suiCoinType,
|
|
436
|
-
|
|
432
|
+
h
|
|
437
433
|
);
|
|
438
|
-
let P = 1 +
|
|
434
|
+
let P = 1 + y, v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
|
|
439
435
|
c.suiCoinType,
|
|
440
436
|
n.suiCoinType,
|
|
441
437
|
v
|
|
442
438
|
);
|
|
443
|
-
for (; Number(E.amount_out) <
|
|
444
|
-
P = P * Math.max(
|
|
439
|
+
for (; Number(E.amount_out) < h; )
|
|
440
|
+
P = P * Math.max(h / Number(E.amount_out), 1.001), v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
|
|
445
441
|
c.suiCoinType,
|
|
446
442
|
n.suiCoinType,
|
|
447
443
|
v
|
|
448
444
|
);
|
|
449
|
-
const [
|
|
445
|
+
const [F, j] = await ae(r, n, f), [I] = r.moveCall({
|
|
450
446
|
target: "0x2::coin::from_balance",
|
|
451
|
-
arguments: [
|
|
447
|
+
arguments: [F],
|
|
452
448
|
typeArguments: [n.suiCoinType]
|
|
453
449
|
});
|
|
454
|
-
await u.repayCoinPTB(r, n.
|
|
455
|
-
const U = await se(r, c, v),
|
|
450
|
+
await u.repayCoinPTB(r, n.suiCoinType, I, f);
|
|
451
|
+
const U = await se(r, c, v), M = await G(
|
|
456
452
|
s,
|
|
457
453
|
r,
|
|
458
|
-
|
|
454
|
+
d,
|
|
459
455
|
U,
|
|
460
456
|
E
|
|
461
|
-
),
|
|
457
|
+
), W = r.moveCall({
|
|
462
458
|
target: "0x2::coin::into_balance",
|
|
463
|
-
arguments: [
|
|
459
|
+
arguments: [M],
|
|
464
460
|
typeArguments: [n.suiCoinType]
|
|
465
|
-
}), [x] = await ne(r, n, j,
|
|
461
|
+
}), [x] = await ne(r, n, j, W), [k] = r.moveCall({
|
|
466
462
|
target: "0x2::coin::from_balance",
|
|
467
463
|
arguments: [x],
|
|
468
464
|
typeArguments: [n.suiCoinType]
|
|
@@ -497,7 +493,7 @@ async function ee(r, e, a, t) {
|
|
|
497
493
|
}
|
|
498
494
|
return await N(r, s, l), r;
|
|
499
495
|
}
|
|
500
|
-
class
|
|
496
|
+
class _e {
|
|
501
497
|
constructor(e) {
|
|
502
498
|
this.name = "navi", this.walletClient = e;
|
|
503
499
|
}
|
|
@@ -530,10 +526,10 @@ class z {
|
|
|
530
526
|
}
|
|
531
527
|
static async create(e) {
|
|
532
528
|
const [a, t] = await Promise.all([
|
|
533
|
-
V.initialize(Ee,
|
|
529
|
+
V.initialize(Ee, X, e.client),
|
|
534
530
|
V.getObligationOwnerCaps(
|
|
535
531
|
e.address,
|
|
536
|
-
[
|
|
532
|
+
[X],
|
|
537
533
|
e.client
|
|
538
534
|
)
|
|
539
535
|
]);
|
|
@@ -542,24 +538,25 @@ class z {
|
|
|
542
538
|
return new z(e, t[0], a);
|
|
543
539
|
}
|
|
544
540
|
async getPool(e) {
|
|
545
|
-
var
|
|
541
|
+
var b, y;
|
|
546
542
|
const a = p(e), t = this.suilendClient.lendingMarket.reserves, s = /* @__PURE__ */ new Set();
|
|
547
543
|
t.forEach((d) => {
|
|
548
|
-
s.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((
|
|
549
|
-
|
|
550
|
-
}), d.borrowsPoolRewardManager.poolRewards.forEach((
|
|
551
|
-
|
|
544
|
+
s.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((h) => {
|
|
545
|
+
h && s.add(p(h.coinType.name));
|
|
546
|
+
}), d.borrowsPoolRewardManager.poolRewards.forEach((h) => {
|
|
547
|
+
h && s.add(p(h.coinType.name));
|
|
552
548
|
});
|
|
553
549
|
});
|
|
554
550
|
const n = await Oe(Array.from(s)), i = t.map((d) => Re(d, n)).reduce(
|
|
555
|
-
(d,
|
|
551
|
+
(d, h) => (d[h.coinType] = h, d),
|
|
556
552
|
{}
|
|
557
553
|
), l = await this.suilendClient.getObligation(
|
|
558
554
|
this.obligationOwnerCap.obligationId
|
|
559
555
|
), u = Se(l, i), o = u.deposits.find((d) => d.coinType === a), w = u.borrows.find((d) => d.coinType === a), g = n[a].decimals;
|
|
560
556
|
return {
|
|
561
|
-
|
|
562
|
-
|
|
557
|
+
cTokenExchangeRate: i[a].cTokenExchangeRate.toNumber(),
|
|
558
|
+
supplyBalance: (b = o == null ? void 0 : o.depositedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? b : 0,
|
|
559
|
+
borrowBalance: (y = w == null ? void 0 : w.borrowedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? y : 0,
|
|
563
560
|
borrowAPR: i[a].borrowAprPercent.toNumber()
|
|
564
561
|
};
|
|
565
562
|
}
|
|
@@ -567,11 +564,12 @@ class z {
|
|
|
567
564
|
throw new Error("Not implemented");
|
|
568
565
|
}
|
|
569
566
|
async withdrawCoinPTB(e, a, t) {
|
|
567
|
+
const s = await this.getPool(a), n = t === s.supplyBalance;
|
|
570
568
|
return await this.suilendClient.withdraw(
|
|
571
569
|
this.obligationOwnerCap.id,
|
|
572
570
|
this.obligationOwnerCap.obligationId,
|
|
573
571
|
a,
|
|
574
|
-
t.toString(),
|
|
572
|
+
n ? Ae.toString() : Math.ceil(t / s.cTokenExchangeRate).toString(),
|
|
575
573
|
e
|
|
576
574
|
);
|
|
577
575
|
}
|
|
@@ -587,7 +585,7 @@ class Fe extends A {
|
|
|
587
585
|
super(), this.name = "lending", this.defaultConfig = {
|
|
588
586
|
env: "prod",
|
|
589
587
|
protocols: []
|
|
590
|
-
}, this._protocols = [], this.migrateBetweenSupplyPTB =
|
|
588
|
+
}, this._protocols = [], this.migrateBetweenSupplyPTB = Y, this.migrateBetweenBorrowPTB = Z, this.migrateBalanceToSupplyPTB = ee, this.migrateBetweenSupplyPTB = Y.bind(this), this.migrateBetweenBorrowPTB = Z.bind(this), this.migrateBalanceToSupplyPTB = ee.bind(this);
|
|
591
589
|
}
|
|
592
590
|
/** Get protocols (either from internal storage or config) */
|
|
593
591
|
get protocols() {
|
|
@@ -773,7 +771,7 @@ class Fe extends A {
|
|
|
773
771
|
* @returns Transaction response or dry run response
|
|
774
772
|
*/
|
|
775
773
|
async liquidate(e, a, t, s, n) {
|
|
776
|
-
var
|
|
774
|
+
var d, h, C;
|
|
777
775
|
if (!this.walletClient)
|
|
778
776
|
throw new Error("Wallet client not found");
|
|
779
777
|
const c = await T(e, {
|
|
@@ -792,7 +790,7 @@ class Fe extends A {
|
|
|
792
790
|
{
|
|
793
791
|
env: this.config.env
|
|
794
792
|
}
|
|
795
|
-
), [
|
|
793
|
+
), [f] = l.moveCall({
|
|
796
794
|
target: "0x2::coin::from_balance",
|
|
797
795
|
arguments: [w],
|
|
798
796
|
typeArguments: [i.suiCoinType]
|
|
@@ -801,17 +799,17 @@ class Fe extends A {
|
|
|
801
799
|
arguments: [g],
|
|
802
800
|
typeArguments: [c.suiCoinType]
|
|
803
801
|
});
|
|
804
|
-
l.transferObjects([
|
|
805
|
-
const
|
|
802
|
+
l.transferObjects([f, b], this.walletClient.address);
|
|
803
|
+
const y = await this.walletClient.signExecuteTransaction({
|
|
806
804
|
transaction: l,
|
|
807
|
-
dryRun: (
|
|
805
|
+
dryRun: (d = n == null ? void 0 : n.dryRun) != null ? d : !1
|
|
808
806
|
});
|
|
809
|
-
return !(n != null && n.dryRun) && ((C = (
|
|
807
|
+
return !(n != null && n.dryRun) && ((C = (h = y.effects) == null ? void 0 : h.status) == null ? void 0 : C.status) === "success" && (this.emit("lending:liquidate-success", {
|
|
810
808
|
payIdentifier: e,
|
|
811
809
|
payAmount: a,
|
|
812
810
|
collateralIdentifier: t,
|
|
813
811
|
liquidationAddress: s
|
|
814
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
812
|
+
}), this.walletClient.module("balance").updatePortfolio()), y;
|
|
815
813
|
}
|
|
816
814
|
/**
|
|
817
815
|
* Gets the available lending rewards for the current user.
|
|
@@ -935,7 +933,7 @@ class Fe extends A {
|
|
|
935
933
|
return;
|
|
936
934
|
}
|
|
937
935
|
const e = [];
|
|
938
|
-
e.push(new
|
|
936
|
+
e.push(new _e(this.walletClient));
|
|
939
937
|
try {
|
|
940
938
|
e.push(await z.create(this.walletClient));
|
|
941
939
|
} catch (a) {
|
|
@@ -944,7 +942,7 @@ class Fe extends A {
|
|
|
944
942
|
this._protocols = e;
|
|
945
943
|
}
|
|
946
944
|
}
|
|
947
|
-
class
|
|
945
|
+
class je extends A {
|
|
948
946
|
constructor() {
|
|
949
947
|
super(...arguments), this.name = "volo", this.defaultConfig = {
|
|
950
948
|
packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
|
|
@@ -969,7 +967,7 @@ class _e extends A {
|
|
|
969
967
|
e.object(this.config.poolId),
|
|
970
968
|
e.object(this.config.metadataId),
|
|
971
969
|
e.object("0x05"),
|
|
972
|
-
|
|
970
|
+
_(a, e.object)
|
|
973
971
|
],
|
|
974
972
|
typeArguments: []
|
|
975
973
|
});
|
|
@@ -989,7 +987,7 @@ class _e extends A {
|
|
|
989
987
|
e.object(this.config.poolId),
|
|
990
988
|
e.object(this.config.metadataId),
|
|
991
989
|
e.object("0x05"),
|
|
992
|
-
|
|
990
|
+
_(a, e.object)
|
|
993
991
|
],
|
|
994
992
|
typeArguments: []
|
|
995
993
|
});
|
|
@@ -1052,7 +1050,7 @@ class _e extends A {
|
|
|
1052
1050
|
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1053
1051
|
}
|
|
1054
1052
|
}
|
|
1055
|
-
class
|
|
1053
|
+
class Ie extends A {
|
|
1056
1054
|
constructor() {
|
|
1057
1055
|
super(...arguments), this.name = "swap", this.defaultConfig = {
|
|
1058
1056
|
apiKey: "",
|
|
@@ -1135,7 +1133,7 @@ class je extends A {
|
|
|
1135
1133
|
* @returns Transaction response or dry run response
|
|
1136
1134
|
*/
|
|
1137
1135
|
async swap(e, a, t, s, n) {
|
|
1138
|
-
var
|
|
1136
|
+
var y, d, h;
|
|
1139
1137
|
if (!this.walletClient)
|
|
1140
1138
|
throw new Error("Wallet client not found");
|
|
1141
1139
|
await this.walletClient.module("balance").waitForUpdate();
|
|
@@ -1150,23 +1148,23 @@ class je extends A {
|
|
|
1150
1148
|
});
|
|
1151
1149
|
const w = await i.build({
|
|
1152
1150
|
client: this.walletClient.client
|
|
1153
|
-
}), g = await this.walletClient.signer.signTransaction(w),
|
|
1151
|
+
}), g = await this.walletClient.signer.signTransaction(w), f = [g.signature];
|
|
1154
1152
|
try {
|
|
1155
|
-
await
|
|
1153
|
+
await xe(g.bytes, f);
|
|
1156
1154
|
} catch (C) {
|
|
1157
1155
|
console.error(C);
|
|
1158
1156
|
}
|
|
1159
1157
|
const b = await this.walletClient.client.executeTransactionBlock({
|
|
1160
1158
|
transactionBlock: g.bytes,
|
|
1161
|
-
signature:
|
|
1159
|
+
signature: f,
|
|
1162
1160
|
options: {
|
|
1163
1161
|
showEffects: !0,
|
|
1164
1162
|
showEvents: !0,
|
|
1165
1163
|
showBalanceChanges: !0
|
|
1166
1164
|
}
|
|
1167
1165
|
});
|
|
1168
|
-
if (((
|
|
1169
|
-
const C = (
|
|
1166
|
+
if (((d = (y = b.effects) == null ? void 0 : y.status) == null ? void 0 : d.status) === "success") {
|
|
1167
|
+
const C = (h = b.events) == null ? void 0 : h.find((P) => P.type.includes("::slippage::SwapEvent"));
|
|
1170
1168
|
C && this.emit("swap:swap-success", {
|
|
1171
1169
|
fromCoinType: e,
|
|
1172
1170
|
toCoinType: a,
|
|
@@ -1178,7 +1176,7 @@ class je extends A {
|
|
|
1178
1176
|
return b;
|
|
1179
1177
|
}
|
|
1180
1178
|
}
|
|
1181
|
-
class
|
|
1179
|
+
class Ue extends A {
|
|
1182
1180
|
constructor() {
|
|
1183
1181
|
super(...arguments), this.name = "haedal", this.defaultConfig = {
|
|
1184
1182
|
packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2",
|
|
@@ -1201,7 +1199,7 @@ class Ie extends A {
|
|
|
1201
1199
|
arguments: [
|
|
1202
1200
|
e.object("0x05"),
|
|
1203
1201
|
e.object(this.config.configId),
|
|
1204
|
-
|
|
1202
|
+
_(a, e.object),
|
|
1205
1203
|
e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1206
1204
|
],
|
|
1207
1205
|
typeArguments: []
|
|
@@ -1221,7 +1219,7 @@ class Ie extends A {
|
|
|
1221
1219
|
arguments: [
|
|
1222
1220
|
e.object("0x05"),
|
|
1223
1221
|
e.object(this.config.configId),
|
|
1224
|
-
|
|
1222
|
+
_(a, e.object)
|
|
1225
1223
|
],
|
|
1226
1224
|
typeArguments: []
|
|
1227
1225
|
});
|
|
@@ -1272,17 +1270,17 @@ class Ie extends A {
|
|
|
1272
1270
|
return !(a != null && a.dryRun) && ((o = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1273
1271
|
}
|
|
1274
1272
|
}
|
|
1275
|
-
const
|
|
1273
|
+
const Me = {
|
|
1276
1274
|
/** Balance management module */
|
|
1277
|
-
balance: new
|
|
1275
|
+
balance: new Ne(),
|
|
1278
1276
|
/** Lending protocol module */
|
|
1279
1277
|
lending: new Fe(),
|
|
1280
1278
|
/** Volo protocol module */
|
|
1281
|
-
volo: new
|
|
1279
|
+
volo: new je(),
|
|
1282
1280
|
/** DEX swapping module */
|
|
1283
|
-
swap: new
|
|
1281
|
+
swap: new Ie(),
|
|
1284
1282
|
/** Haedal protocol module */
|
|
1285
|
-
haedal: new
|
|
1283
|
+
haedal: new Ue()
|
|
1286
1284
|
}, We = {
|
|
1287
1285
|
url: de("mainnet")
|
|
1288
1286
|
};
|
|
@@ -1292,12 +1290,12 @@ class Ye {
|
|
|
1292
1290
|
* @param options - Configuration options for the wallet client
|
|
1293
1291
|
*/
|
|
1294
1292
|
constructor(e) {
|
|
1295
|
-
this.modules =
|
|
1293
|
+
this.modules = Me, this.userConfigs = {}, this.events = he();
|
|
1296
1294
|
const a = {
|
|
1297
1295
|
...We,
|
|
1298
1296
|
...e.client
|
|
1299
1297
|
};
|
|
1300
|
-
a.transport = a.transport || new
|
|
1298
|
+
a.transport = a.transport || new ke(a.url), this.client = new we(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
|
|
1301
1299
|
if (t !== s.name)
|
|
1302
1300
|
throw new Error(`Module name ${t} does not match module name ${s.name}`);
|
|
1303
1301
|
s.install(this);
|
|
@@ -1373,7 +1371,7 @@ class Ye {
|
|
|
1373
1371
|
return e in this.modules;
|
|
1374
1372
|
}
|
|
1375
1373
|
}
|
|
1376
|
-
class
|
|
1374
|
+
class Ze extends oe {
|
|
1377
1375
|
/**
|
|
1378
1376
|
* Creates a new watch-only signer
|
|
1379
1377
|
*
|
|
@@ -1437,7 +1435,7 @@ class Xe extends oe {
|
|
|
1437
1435
|
return {};
|
|
1438
1436
|
}
|
|
1439
1437
|
}
|
|
1440
|
-
class
|
|
1438
|
+
class et extends oe {
|
|
1441
1439
|
/**
|
|
1442
1440
|
* Creates a new watch-only signer
|
|
1443
1441
|
*
|
|
@@ -1491,7 +1489,7 @@ class Ze extends oe {
|
|
|
1491
1489
|
}
|
|
1492
1490
|
export {
|
|
1493
1491
|
Ye as WalletClient,
|
|
1494
|
-
|
|
1495
|
-
|
|
1492
|
+
Ze as WatchSigner,
|
|
1493
|
+
et as WebSigner
|
|
1496
1494
|
};
|
|
1497
1495
|
//# sourceMappingURL=index.esm.js.map
|