@naviprotocol/wallet-client 1.3.0-dev.1 → 1.3.0-dev.2

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.esm.js CHANGED
@@ -1,13 +1,13 @@
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 _ } from "@naviprotocol/lending";
4
+ import { withSingleton as Q, getCoins as ge, mergeCoinsPTB as T, 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 v, 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
- import { normalizeStructTag as p } from "@mysten/sui/utils";
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
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";
10
+ import { getCoinMetadataMap as Ae, MAX_U64 as Oe } from "@suilend/sui-fe";
11
11
  import { executeAuction as xe } from "shio-sdk";
12
12
  import { Signer as oe } from "@mysten/sui/cryptography";
13
13
  const ce = fe.create({
@@ -64,7 +64,7 @@ class ke {
64
64
  throw new Error("subscribe not implemented.");
65
65
  }
66
66
  }
67
- class A {
67
+ class O {
68
68
  /**
69
69
  * Gets the current configuration for this module
70
70
  *
@@ -107,19 +107,19 @@ class A {
107
107
  this.walletClient = void 0;
108
108
  }
109
109
  }
110
- class O {
110
+ class A {
111
111
  /**
112
112
  * Creates a new user portfolio
113
113
  *
114
114
  * @param coins - Array of coin objects or existing portfolio to copy from
115
115
  */
116
116
  constructor(e) {
117
- if (e instanceof O)
117
+ if (e instanceof A)
118
118
  this.balances = JSON.parse(JSON.stringify(e.balances));
119
119
  else {
120
120
  const a = {};
121
121
  e == null || e.forEach((t) => {
122
- const s = p(t.coinType);
122
+ const s = P(t.coinType);
123
123
  let n = a[s];
124
124
  n || (n = {
125
125
  coinType: s,
@@ -136,7 +136,7 @@ class O {
136
136
  * @returns UserCoinBalance object with coin type, total amount, and coin objects
137
137
  */
138
138
  getBalance(e) {
139
- return e = p(e), this.balances[e] || { coinType: e, amount: L(0), coins: [] };
139
+ return e = P(e), this.balances[e] || { coinType: e, amount: L(0), coins: [] };
140
140
  }
141
141
  /**
142
142
  * Gets all coin types in the portfolio
@@ -153,7 +153,7 @@ class O {
153
153
  * @returns BigNumber representing the total balance
154
154
  */
155
155
  balanceOf(e) {
156
- e = p(e);
156
+ e = P(e);
157
157
  const a = this.getBalance(e);
158
158
  return (a == null ? void 0 : a.amount) || L(0);
159
159
  }
@@ -166,11 +166,11 @@ class O {
166
166
  * @returns New UserPortfolio instance with copied data
167
167
  */
168
168
  clone() {
169
- const e = JSON.parse(JSON.stringify(this.balances)), a = new O();
169
+ const e = JSON.parse(JSON.stringify(this.balances)), a = new A();
170
170
  return a.balances = e, a;
171
171
  }
172
172
  }
173
- class Ne extends A {
173
+ class Ne extends O {
174
174
  constructor() {
175
175
  super(...arguments), this.name = "balance", this.defaultConfig = {
176
176
  coinPollingInterval: 6e3,
@@ -180,8 +180,8 @@ class Ne extends A {
180
180
  throw new Error("Wallet client not found");
181
181
  this._coins = await ge(this.walletClient.address, {
182
182
  client: this.walletClient.client
183
- }), this._portfolio = new O(this._coins), this.emit("balance:portfolio-updated", {});
184
- }), this._coins = [], this._portfolio = new O(), this.pollingTimer = null, this._updatePromise = null;
183
+ }), this._portfolio = new A(this._coins), this.emit("balance:portfolio-updated", {});
184
+ }), this._coins = [], this._portfolio = new A(), this.pollingTimer = null, this._updatePromise = null;
185
185
  }
186
186
  /**
187
187
  * Gets the current coin objects from the wallet
@@ -232,7 +232,7 @@ class Ne extends A {
232
232
  * @returns Transaction response or dry run response
233
233
  */
234
234
  async sendCoinBatch(e, a, t, s) {
235
- var w;
235
+ var h;
236
236
  if (!this.walletClient)
237
237
  throw new Error("Wallet client not found");
238
238
  if (a.length !== t.length)
@@ -243,7 +243,7 @@ class Ne extends A {
243
243
  throw new Error("Insufficient balance");
244
244
  const i = new m();
245
245
  let l = i.gas;
246
- p(e) !== p("0x2::sui::SUI") && (l = B(i, n.coins, {
246
+ P(e) !== P("0x2::sui::SUI") && (l = T(i, n.coins, {
247
247
  balance: c.toNumber()
248
248
  }));
249
249
  const u = i.splitCoins(l, t);
@@ -251,7 +251,7 @@ class Ne extends A {
251
251
  i.transferObjects([u[f]], g);
252
252
  }), await this.walletClient.signExecuteTransaction({
253
253
  transaction: i,
254
- dryRun: (w = s == null ? void 0 : s.dryRun) != null ? w : !1
254
+ dryRun: (h = s == null ? void 0 : s.dryRun) != null ? h : !1
255
255
  });
256
256
  }
257
257
  /**
@@ -344,10 +344,10 @@ async function Y(r, e, a, t) {
344
344
  throw new Error("No supply balance");
345
345
  if (t != null && t.amount && t.amount > o.supplyBalance)
346
346
  throw new Error("Amount is less than supply balance");
347
- const w = await K(), g = await Promise.all([s, n]);
347
+ const h = await K(), g = await Promise.all([s, n]);
348
348
  await $(
349
349
  r,
350
- q(w, {
350
+ q(h, {
351
351
  lendingState: c,
352
352
  pools: g
353
353
  })
@@ -361,19 +361,19 @@ async function Y(r, e, a, t) {
361
361
  s.suiCoinType,
362
362
  n.suiCoinType,
363
363
  y
364
- ), h = Number(d.amount_out);
365
- if (h <= 0)
364
+ ), w = Number(d.amount_out);
365
+ if (w <= 0)
366
366
  throw new Error("The amount of swapAmountOut must be greater than 0.");
367
- const C = Math.floor(h * (1 - b)), P = Math.floor(C / (1 + f.flashloanFee));
368
- if (P <= 0)
367
+ const C = Math.floor(w * (1 - b)), p = Math.floor(C / (1 + f.flashloanFee));
368
+ if (p <= 0)
369
369
  throw new Error("The calculated borrow amount must be positive.");
370
- const [v, E] = await ae(r, n, P), [F] = r.moveCall({
370
+ const [E, B] = await ae(r, n, p), [F] = r.moveCall({
371
371
  target: "0x2::coin::from_balance",
372
- arguments: [v],
372
+ arguments: [E],
373
373
  typeArguments: [n.suiCoinType]
374
374
  });
375
375
  await N(r, n, F, {
376
- amount: P
376
+ amount: p
377
377
  });
378
378
  const j = await u.withdrawCoinPTB(r, s.suiCoinType, y), I = await G(
379
379
  i,
@@ -385,7 +385,7 @@ async function Y(r, e, a, t) {
385
385
  target: "0x2::coin::into_balance",
386
386
  arguments: [I],
387
387
  typeArguments: [n.suiCoinType]
388
- }), [M] = await ne(r, n, E, U), [W] = r.moveCall({
388
+ }), [M] = await ne(r, n, B, U), [W] = r.moveCall({
389
389
  target: "0x2::coin::from_balance",
390
390
  arguments: [M],
391
391
  typeArguments: [n.suiCoinType]
@@ -407,10 +407,10 @@ async function Z(r, e, a, t) {
407
407
  throw new Error("No borrow balance");
408
408
  if (t != null && t.amount && t.amount > o.borrowBalance)
409
409
  throw new Error("Amount is more than borrow balance");
410
- const w = await K(), g = await Promise.all([n, c]);
410
+ const h = await K(), g = await Promise.all([n, c]);
411
411
  await $(
412
412
  r,
413
- q(w, {
413
+ q(h, {
414
414
  lendingState: i,
415
415
  pools: g
416
416
  })
@@ -429,34 +429,44 @@ async function Z(r, e, a, t) {
429
429
  throw new Error(`${n.token.symbol} pool not support flashloan`);
430
430
  if (!this.walletClient)
431
431
  throw new Error("Wallet client not found");
432
- 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(
432
+ const y = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, d = Math.ceil(f * (1 + b.flashloanFee)), w = d, C = await this.walletClient.swap.getQuote(
433
433
  n.suiCoinType,
434
434
  c.suiCoinType,
435
- h
435
+ w
436
436
  );
437
- let P = 1 + y, v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
437
+ let p = 1 + y, E = Math.ceil(Number(C.amount_out) * p), B = await this.walletClient.swap.getQuote(
438
438
  c.suiCoinType,
439
439
  n.suiCoinType,
440
- v
440
+ E
441
441
  );
442
- for (; Number(E.amount_out) < h; )
443
- 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(
442
+ for (console.log("migrateBetweenBorrowPTB", {
443
+ toQuote: B,
444
+ minSwapAmount: w,
445
+ toQuoteAmount: Number(B.amount_out),
446
+ rate: p
447
+ }); Number(B.amount_out) < w; )
448
+ p = p * Math.max(w / Number(B.amount_out), 1.001), E = Math.ceil(Number(C.amount_out) * p), B = await this.walletClient.swap.getQuote(
444
449
  c.suiCoinType,
445
450
  n.suiCoinType,
446
- v
447
- );
451
+ E
452
+ ), console.log("migrateBetweenBorrowPTB", {
453
+ toQuote: B,
454
+ minSwapAmount: w,
455
+ toQuoteAmount: Number(B.amount_out),
456
+ rate: p
457
+ });
448
458
  const [F, j] = await ae(r, n, f), [I] = r.moveCall({
449
459
  target: "0x2::coin::from_balance",
450
460
  arguments: [F],
451
461
  typeArguments: [n.suiCoinType]
452
462
  });
453
463
  await u.repayCoinPTB(r, n.suiCoinType, I, f);
454
- const U = await se(r, c, v), M = await G(
464
+ const U = await se(r, c, E), M = await G(
455
465
  s,
456
466
  r,
457
467
  d,
458
468
  U,
459
- E
469
+ B
460
470
  ), W = r.moveCall({
461
471
  target: "0x2::coin::into_balance",
462
472
  arguments: [M],
@@ -481,15 +491,15 @@ async function ee(r, e, a, t) {
481
491
  }), t != null && t.amount && n.amount.lt(t.amount))
482
492
  throw new Error("Amount is greater than balance");
483
493
  const c = (u = t == null ? void 0 : t.amount) != null ? u : n.amount.toNumber(), i = (o = t == null ? void 0 : t.slippage) != null ? o : 5e-3;
484
- let l = await B(r, n.coins, {
494
+ let l = await T(r, n.coins, {
485
495
  balance: c,
486
496
  useGasCoin: !0
487
497
  });
488
- if (p(e) !== p(s.suiCoinType)) {
489
- const w = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
498
+ if (P(e) !== P(s.suiCoinType)) {
499
+ const h = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
490
500
  l = await this.walletClient.swap.buildSwapPTBFromQuote(
491
501
  r,
492
- w,
502
+ h,
493
503
  l,
494
504
  i
495
505
  );
@@ -502,7 +512,7 @@ class _e {
502
512
  }
503
513
  async getPool(e) {
504
514
  const a = await this.walletClient.lending.getPool(e), s = (await this.walletClient.lending.getLendingState()).find(
505
- (i) => i.pool.suiCoinType === p(e)
515
+ (i) => i.pool.suiCoinType === P(e)
506
516
  ), n = s ? new R(s.supplyBalance).toNumber() : 0, c = s ? new R(s.borrowBalance).toNumber() : 0;
507
517
  return {
508
518
  supplyBalance: n,
@@ -542,24 +552,24 @@ class z {
542
552
  }
543
553
  async getPool(e) {
544
554
  var b, y;
545
- const a = p(e), t = this.suilendClient.lendingMarket.reserves, s = /* @__PURE__ */ new Set();
555
+ const a = P(e), t = this.suilendClient.lendingMarket.reserves, s = /* @__PURE__ */ new Set();
546
556
  t.forEach((d) => {
547
- s.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((h) => {
548
- h && s.add(p(h.coinType.name));
549
- }), d.borrowsPoolRewardManager.poolRewards.forEach((h) => {
550
- h && s.add(p(h.coinType.name));
557
+ s.add(P(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((w) => {
558
+ w && s.add(P(w.coinType.name));
559
+ }), d.borrowsPoolRewardManager.poolRewards.forEach((w) => {
560
+ w && s.add(P(w.coinType.name));
551
561
  });
552
562
  });
553
- const n = await Oe(Array.from(s)), i = t.map((d) => Re(d, n)).reduce(
554
- (d, h) => (d[h.coinType] = h, d),
563
+ const n = await Ae(Array.from(s)), i = t.map((d) => Re(d, n)).reduce(
564
+ (d, w) => (d[w.coinType] = w, d),
555
565
  {}
556
566
  ), l = await this.suilendClient.getObligation(
557
567
  this.obligationOwnerCap.obligationId
558
- ), u = Se(l, i), o = u.deposits.find((d) => d.coinType === a), w = u.borrows.find((d) => d.coinType === a), g = n[a].decimals;
568
+ ), u = Se(l, i), o = u.deposits.find((d) => d.coinType === a), h = u.borrows.find((d) => d.coinType === a), g = n[a].decimals;
559
569
  return {
560
570
  cTokenExchangeRate: i[a].cTokenExchangeRate.toNumber(),
561
571
  supplyBalance: (b = o == null ? void 0 : o.depositedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? b : 0,
562
- borrowBalance: (y = w == null ? void 0 : w.borrowedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? y : 0,
572
+ borrowBalance: (y = h == null ? void 0 : h.borrowedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? y : 0,
563
573
  borrowAPR: i[a].borrowAprPercent.toNumber()
564
574
  };
565
575
  }
@@ -572,7 +582,7 @@ class z {
572
582
  this.obligationOwnerCap.id,
573
583
  this.obligationOwnerCap.obligationId,
574
584
  a,
575
- n ? Ae.toString() : Math.ceil(t / s.cTokenExchangeRate).toString(),
585
+ n ? Oe.toString() : Math.ceil(t / s.cTokenExchangeRate).toString(),
576
586
  e
577
587
  );
578
588
  }
@@ -583,7 +593,7 @@ class z {
583
593
  this.suilendClient.repay(this.obligationOwnerCap.obligationId, a, t, e), e.transferObjects([t], e.pure.address(this.walletClient.address));
584
594
  }
585
595
  }
586
- class Fe extends A {
596
+ class Fe extends O {
587
597
  constructor() {
588
598
  super(), this.name = "lending", this.defaultConfig = {
589
599
  env: "prod",
@@ -617,7 +627,7 @@ class Fe extends A {
617
627
  * @returns Pool information
618
628
  */
619
629
  async getPool(e, a) {
620
- return await T(e, {
630
+ return await v(e, {
621
631
  env: this.config.env,
622
632
  ...a
623
633
  });
@@ -631,14 +641,14 @@ class Fe extends A {
631
641
  * @returns Transaction response or dry run response
632
642
  */
633
643
  async deposit(e, a, t) {
634
- var u, o, w;
644
+ var u, o, h;
635
645
  if (!this.walletClient)
636
646
  throw new Error("Wallet client not found");
637
- const s = await T(e, {
647
+ const s = await v(e, {
638
648
  env: this.config.env
639
649
  });
640
650
  await this.walletClient.module("balance").waitForUpdate();
641
- const n = new m(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, c.coins, {
651
+ const n = new m(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = T(n, c.coins, {
642
652
  balance: a,
643
653
  useGasCoin: !0
644
654
  });
@@ -651,7 +661,7 @@ class Fe extends A {
651
661
  transaction: n,
652
662
  dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
653
663
  });
654
- return !(t != null && t.dryRun) && ((w = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:deposit-success", {
664
+ return !(t != null && t.dryRun) && ((h = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : h.status) === "success" && (this.emit("lending:deposit-success", {
655
665
  identifier: e,
656
666
  amount: a
657
667
  }), this.walletClient.module("balance").updatePortfolio()), l;
@@ -668,7 +678,7 @@ class Fe extends A {
668
678
  var l, u, o;
669
679
  if (!this.walletClient)
670
680
  throw new Error("Wallet client not found");
671
- const s = await T(e, {
681
+ const s = await v(e, {
672
682
  env: this.config.env
673
683
  }), n = new m();
674
684
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
@@ -698,7 +708,7 @@ class Fe extends A {
698
708
  var l, u, o;
699
709
  if (!this.walletClient)
700
710
  throw new Error("Wallet client not found");
701
- const s = await T(e, {
711
+ const s = await v(e, {
702
712
  env: this.config.env
703
713
  }), n = new m();
704
714
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
@@ -725,13 +735,13 @@ class Fe extends A {
725
735
  * @returns Transaction response or dry run response
726
736
  */
727
737
  async repay(e, a, t) {
728
- var u, o, w;
738
+ var u, o, h;
729
739
  if (!this.walletClient)
730
740
  throw new Error("Wallet client not found");
731
741
  await this.walletClient.module("balance").waitForUpdate();
732
- const s = await T(e, {
742
+ const s = await v(e, {
733
743
  env: this.config.env
734
- }), n = new m(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, c.coins, {
744
+ }), n = new m(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = T(n, c.coins, {
735
745
  balance: a,
736
746
  useGasCoin: !0
737
747
  });
@@ -744,7 +754,7 @@ class Fe extends A {
744
754
  transaction: n,
745
755
  dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
746
756
  });
747
- return !(t != null && t.dryRun) && ((w = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:repay-success", {
757
+ return !(t != null && t.dryRun) && ((h = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : h.status) === "success" && (this.emit("lending:repay-success", {
748
758
  identifier: e,
749
759
  amount: a
750
760
  }), this.walletClient.module("balance").updatePortfolio()), l;
@@ -774,17 +784,17 @@ class Fe extends A {
774
784
  * @returns Transaction response or dry run response
775
785
  */
776
786
  async liquidate(e, a, t, s, n) {
777
- var d, h, C;
787
+ var d, w, C;
778
788
  if (!this.walletClient)
779
789
  throw new Error("Wallet client not found");
780
- const c = await T(e, {
790
+ const c = await v(e, {
781
791
  env: this.config.env
782
- }), i = await T(t, {
792
+ }), i = await v(t, {
783
793
  env: this.config.env
784
- }), l = new m(), u = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), o = B(l, u.coins, {
794
+ }), l = new m(), u = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), o = T(l, u.coins, {
785
795
  balance: a,
786
796
  useGasCoin: !0
787
- }), [w, g] = await be(
797
+ }), [h, g] = await be(
788
798
  l,
789
799
  c,
790
800
  o,
@@ -795,7 +805,7 @@ class Fe extends A {
795
805
  }
796
806
  ), [f] = l.moveCall({
797
807
  target: "0x2::coin::from_balance",
798
- arguments: [w],
808
+ arguments: [h],
799
809
  typeArguments: [i.suiCoinType]
800
810
  }), [b] = l.moveCall({
801
811
  target: "0x2::coin::from_balance",
@@ -807,7 +817,7 @@ class Fe extends A {
807
817
  transaction: l,
808
818
  dryRun: (d = n == null ? void 0 : n.dryRun) != null ? d : !1
809
819
  });
810
- 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", {
820
+ return !(n != null && n.dryRun) && ((C = (w = y.effects) == null ? void 0 : w.status) == null ? void 0 : C.status) === "success" && (this.emit("lending:liquidate-success", {
811
821
  payIdentifier: e,
812
822
  payAmount: a,
813
823
  collateralIdentifier: t,
@@ -945,7 +955,7 @@ class Fe extends A {
945
955
  this._protocols = e;
946
956
  }
947
957
  }
948
- class je extends A {
958
+ class je extends O {
949
959
  constructor() {
950
960
  super(...arguments), this.name = "volo", this.defaultConfig = {
951
961
  packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
@@ -1012,7 +1022,7 @@ class je extends A {
1012
1022
  throw new Error("Stake amount should be greater than 1Sui");
1013
1023
  const t = new m();
1014
1024
  await this.walletClient.module("balance").waitForUpdate();
1015
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1025
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = T(t, s.coins, {
1016
1026
  balance: e,
1017
1027
  useGasCoin: !0
1018
1028
  }), c = await this.stakePTB(t, n);
@@ -1040,7 +1050,7 @@ class je extends A {
1040
1050
  if (e < 1e9)
1041
1051
  throw new Error("Unstake amount should >= 1vSui");
1042
1052
  await this.walletClient.module("balance").waitForUpdate();
1043
- const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
1053
+ const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = T(t, s.coins, {
1044
1054
  balance: e
1045
1055
  }), c = await this.unstakePTB(t, n);
1046
1056
  t.transferObjects([c], this.walletClient.address);
@@ -1053,7 +1063,7 @@ class je extends A {
1053
1063
  }), this.walletClient.module("balance").updatePortfolio()), i;
1054
1064
  }
1055
1065
  }
1056
- class Ie extends A {
1066
+ class Ie extends O {
1057
1067
  constructor() {
1058
1068
  super(...arguments), this.name = "swap", this.defaultConfig = {
1059
1069
  apiKey: "",
@@ -1136,11 +1146,11 @@ class Ie extends A {
1136
1146
  * @returns Transaction response or dry run response
1137
1147
  */
1138
1148
  async swap(e, a, t, s, n) {
1139
- var y, d, h;
1149
+ var y, d, w;
1140
1150
  if (!this.walletClient)
1141
1151
  throw new Error("Wallet client not found");
1142
1152
  await this.walletClient.module("balance").waitForUpdate();
1143
- const c = this.walletClient.module("balance").portfolio.getBalance(e), i = new m(), l = B(i, c.coins, {
1153
+ const c = this.walletClient.module("balance").portfolio.getBalance(e), i = new m(), l = T(i, c.coins, {
1144
1154
  balance: t,
1145
1155
  useGasCoin: !0
1146
1156
  }), u = await this.getQuote(e, a, t), o = await this.buildSwapPTBFromQuote(i, u, l, s);
@@ -1149,9 +1159,9 @@ class Ie extends A {
1149
1159
  transaction: i,
1150
1160
  dryRun: !0
1151
1161
  });
1152
- const w = await i.build({
1162
+ const h = await i.build({
1153
1163
  client: this.walletClient.client
1154
- }), g = await this.walletClient.signer.signTransaction(w), f = [g.signature];
1164
+ }), g = await this.walletClient.signer.signTransaction(h), f = [g.signature];
1155
1165
  try {
1156
1166
  await xe(g.bytes, f);
1157
1167
  } catch (C) {
@@ -1167,7 +1177,7 @@ class Ie extends A {
1167
1177
  }
1168
1178
  });
1169
1179
  if (((d = (y = b.effects) == null ? void 0 : y.status) == null ? void 0 : d.status) === "success") {
1170
- const C = (h = b.events) == null ? void 0 : h.find((P) => P.type.includes("::slippage::SwapEvent"));
1180
+ const C = (w = b.events) == null ? void 0 : w.find((p) => p.type.includes("::slippage::SwapEvent"));
1171
1181
  C && this.emit("swap:swap-success", {
1172
1182
  fromCoinType: e,
1173
1183
  toCoinType: a,
@@ -1179,7 +1189,7 @@ class Ie extends A {
1179
1189
  return b;
1180
1190
  }
1181
1191
  }
1182
- class Ue extends A {
1192
+ class Ue extends O {
1183
1193
  constructor() {
1184
1194
  super(...arguments), this.name = "haedal", this.defaultConfig = {
1185
1195
  packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2",
@@ -1240,7 +1250,7 @@ class Ue extends A {
1240
1250
  throw new Error("Wallet client not found");
1241
1251
  const t = new m();
1242
1252
  await this.walletClient.module("balance").waitForUpdate();
1243
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1253
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = T(t, s.coins, {
1244
1254
  balance: e,
1245
1255
  useGasCoin: !0
1246
1256
  }), c = await this.stakePTB(t, n);
@@ -1262,7 +1272,7 @@ class Ue extends A {
1262
1272
  if (!this.walletClient)
1263
1273
  throw new Error("Wallet client not found");
1264
1274
  await this.walletClient.module("balance").waitForUpdate();
1265
- const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
1275
+ const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = T(t, s.coins, {
1266
1276
  balance: e
1267
1277
  }), c = await this.unstakePTB(t, n);
1268
1278
  t.transferObjects([c], this.walletClient.address);