@naviprotocol/wallet-client 1.0.3-dev.3 → 1.0.4

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,11 +1,12 @@
1
1
  import { getFullnodeUrl as le, SuiClient as ie } from "@mysten/sui/client";
2
2
  import re from "mitt";
3
3
  import ce from "axios";
4
- import { withSingleton as L, getCoins as oe, mergeCoinsPTB as y, getPriceFeeds as Q, updateOraclePricesPTB as q, filterPriceFeeds as K, getFlashLoanAsset as V, flashloanPTB as X, depositCoinPTB as F, withdrawCoinPTB as Y, repayFlashLoanPTB as Z, repayCoinPTB as ee, borrowCoinPTB as te, getPools as ue, getPool as P, getHealthFactor as de, liquidatePTB as we, getUserAvailableLendingRewards as H, getUserClaimedRewardHistory as he, claimLendingRewardsPTB as fe, getLendingState as ge, createAccountCapPTB as me, withCache as ae, parseTxValue as x } from "@naviprotocol/lending";
5
- import p, { BigNumber as M } from "bignumber.js";
6
- import { normalizeStructTag as T } from "@mysten/sui/utils";
4
+ import { withSingleton as L, getCoins as oe, mergeCoinsPTB as B, getPriceFeeds as Q, updateOraclePricesPTB as q, filterPriceFeeds as K, getFlashLoanAsset as V, flashloanPTB as X, depositCoinPTB as A, withdrawCoinPTB as Y, repayFlashLoanPTB as Z, repayCoinPTB as ee, borrowCoinPTB as te, getPools as ue, getPool as T, getHealthFactor as de, liquidatePTB as we, getUserAvailableLendingRewards as H, getUserClaimedRewardHistory as he, claimLendingRewardsPTB as fe, getLendingState as ge, createAccountCapPTB as me, withCache as ae, parseTxValue as k } from "@naviprotocol/lending";
5
+ import v, { BigNumber as M } from "bignumber.js";
6
+ import { normalizeStructTag as p } from "@mysten/sui/utils";
7
7
  import { Transaction as w } from "@mysten/sui/transactions";
8
8
  import { buildSwapPTBFromQuote as $, generateRefId as Ce, getQuote as be } from "@naviprotocol/astros-aggregator-sdk";
9
+ import { executeAuction as ye } from "shio-sdk";
9
10
  import { Signer as ne } from "@mysten/sui/cryptography";
10
11
  const se = ce.create({
11
12
  timeout: 2e4
@@ -22,7 +23,7 @@ se.interceptors.response.use(
22
23
  return Promise.reject(r);
23
24
  }
24
25
  );
25
- class ye {
26
+ class Be {
26
27
  /**
27
28
  * Creates a new custom transport instance
28
29
  *
@@ -116,7 +117,7 @@ class E {
116
117
  else {
117
118
  const a = {};
118
119
  e == null || e.forEach((t) => {
119
- const s = T(t.coinType);
120
+ const s = p(t.coinType);
120
121
  let n = a[s];
121
122
  n || (n = {
122
123
  coinType: s,
@@ -133,7 +134,7 @@ class E {
133
134
  * @returns UserCoinBalance object with coin type, total amount, and coin objects
134
135
  */
135
136
  getBalance(e) {
136
- return e = T(e), this.balances[e] || { coinType: e, amount: M(0), coins: [] };
137
+ return e = p(e), this.balances[e] || { coinType: e, amount: M(0), coins: [] };
137
138
  }
138
139
  /**
139
140
  * Gets all coin types in the portfolio
@@ -150,7 +151,7 @@ class E {
150
151
  * @returns BigNumber representing the total balance
151
152
  */
152
153
  balanceOf(e) {
153
- e = T(e);
154
+ e = p(e);
154
155
  const a = this.getBalance(e);
155
156
  return (a == null ? void 0 : a.amount) || M(0);
156
157
  }
@@ -167,7 +168,7 @@ class E {
167
168
  return a.balances = e, a;
168
169
  }
169
170
  }
170
- class Be extends R {
171
+ class Pe extends R {
171
172
  constructor() {
172
173
  super(...arguments), this.name = "balance", this.defaultConfig = {
173
174
  coinPollingInterval: 6e3
@@ -234,17 +235,17 @@ class Be extends R {
234
235
  if (a.length !== t.length)
235
236
  throw new Error("Recipients and amounts must have the same length");
236
237
  await this.waitForUpdate();
237
- const n = this.portfolio.getBalance(e), c = t.reduce((h, f) => h.plus(f), p(0));
238
+ const n = this.portfolio.getBalance(e), c = t.reduce((f, m) => f.plus(m), v(0));
238
239
  if (n.amount.lt(c))
239
240
  throw new Error("Insufficient balance");
240
241
  const l = new w();
241
242
  let i = l.gas;
242
- T(e) !== T("0x2::sui::SUI") && (i = y(l, n.coins, {
243
+ p(e) !== p("0x2::sui::SUI") && (i = B(l, n.coins, {
243
244
  balance: c.toNumber()
244
245
  }));
245
246
  const o = l.splitCoins(i, t);
246
- return a.forEach((h, f) => {
247
- l.transferObjects([o[f]], h);
247
+ return a.forEach((f, m) => {
248
+ l.transferObjects([o[m]], f);
248
249
  }), await this.walletClient.signExecuteTransaction({
249
250
  transaction: l,
250
251
  dryRun: (d = s == null ? void 0 : s.dryRun) != null ? d : !1
@@ -323,16 +324,16 @@ class Be extends R {
323
324
  super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
324
325
  }
325
326
  }
326
- const Pe = 27;
327
- function Te(r, e = 2) {
328
- return r ? new p(r.toString()).shiftedBy(-1 * Pe).multipliedBy(100).decimalPlaces(e, p.ROUND_DOWN).toFixed(e) : "0.00";
327
+ const Te = 27;
328
+ function pe(r, e = 2) {
329
+ return r ? new v(r.toString()).shiftedBy(-1 * Te).multipliedBy(100).decimalPlaces(e, v.ROUND_DOWN).toFixed(e) : "0.00";
329
330
  }
330
331
  async function D(r, e, a, t) {
331
332
  var S, O;
332
333
  if (!this.walletClient)
333
334
  throw new Error("Wallet client not found");
334
335
  await this.walletClient.balance.updatePortfolio();
335
- const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), l = c.find((A) => A.pool.id === s.id), i = this.walletClient.address;
336
+ const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), l = c.find((x) => x.pool.id === s.id), i = this.walletClient.address;
336
337
  if (console.log("migrateBetweenSupplyPTB", {
337
338
  lendingState: c,
338
339
  fromPoolLending: l,
@@ -356,43 +357,43 @@ async function D(r, e, a, t) {
356
357
  });
357
358
  if (!d)
358
359
  throw new Error(`${n.token.symbol} pool not support flashloan`);
359
- const h = (S = t == null ? void 0 : t.slippage) != null ? S : 5e-3, f = (O = t == null ? void 0 : t.amount) != null ? O : Number(l.supplyBalance), b = await this.walletClient.swap.getQuote(
360
+ const f = (S = t == null ? void 0 : t.slippage) != null ? S : 5e-3, m = (O = t == null ? void 0 : t.amount) != null ? O : Number(l.supplyBalance), b = await this.walletClient.swap.getQuote(
360
361
  s.suiCoinType,
361
362
  n.suiCoinType,
362
- f
363
- ), m = Number(b.amount_out);
364
- if (m <= 0)
363
+ m
364
+ ), C = Number(b.amount_out);
365
+ if (C <= 0)
365
366
  throw new Error("The amount of swapAmountOut must be greater than 0.");
366
- const C = Math.floor(m * (1 - h)), g = Math.floor(C / (1 + d.flashloanFee));
367
+ const y = Math.floor(C * (1 - f)), g = Math.floor(y / (1 + d.flashloanFee));
367
368
  if (g <= 0)
368
369
  throw new Error("The calculated borrow amount must be positive.");
369
- const [B, v] = await X(r, n, g), [k] = r.moveCall({
370
+ const [h, P] = await X(r, n, g), [F] = r.moveCall({
370
371
  target: "0x2::coin::from_balance",
371
- arguments: [B],
372
+ arguments: [h],
372
373
  typeArguments: [n.suiCoinType]
373
374
  });
374
- await F(r, n, k, {
375
+ await A(r, n, F, {
375
376
  amount: g
376
377
  });
377
- const j = await Y(r, s, f), _ = await $(
378
+ const j = await Y(r, s, m), _ = await $(
378
379
  i,
379
380
  r,
380
- C,
381
+ y,
381
382
  j,
382
383
  b
383
384
  ), U = r.moveCall({
384
385
  target: "0x2::coin::into_balance",
385
386
  arguments: [_],
386
387
  typeArguments: [n.suiCoinType]
387
- }), [W] = await Z(r, n, v, U), [N] = r.moveCall({
388
+ }), [W] = await Z(r, n, P, U), [N] = r.moveCall({
388
389
  target: "0x2::coin::from_balance",
389
390
  arguments: [W],
390
391
  typeArguments: [n.suiCoinType]
391
392
  });
392
- return await F(r, n, N), r;
393
+ return await A(r, n, N), r;
393
394
  }
394
395
  async function J(r, e, a, t) {
395
- var A, G;
396
+ var x, G;
396
397
  if (!this.walletClient)
397
398
  throw new Error("Wallet client not found");
398
399
  await this.walletClient.balance.updatePortfolio();
@@ -415,50 +416,50 @@ async function J(r, e, a, t) {
415
416
  pools: u
416
417
  })
417
418
  );
418
- let d = (A = t == null ? void 0 : t.amount) != null ? A : Number(i.borrowBalance);
419
+ let d = (x = t == null ? void 0 : t.amount) != null ? x : Number(i.borrowBalance);
419
420
  if (Number(i.borrowBalance) === d) {
420
- const I = parseFloat(Te(n.currentBorrowRate, 8)) / 100;
421
+ const I = parseFloat(pe(n.currentBorrowRate, 8)) / 100;
421
422
  d = Math.ceil(
422
- new p(d).multipliedBy(I * (60 * 3) / (365 * 24 * 3600)).plus(new p(1).shiftedBy(-n.token.decimals)).plus(d).toNumber()
423
+ new v(d).multipliedBy(I * (60 * 3) / (365 * 24 * 3600)).plus(new v(1).shiftedBy(-n.token.decimals)).plus(d).toNumber()
423
424
  );
424
425
  }
425
- const h = await V(n, {
426
+ const f = await V(n, {
426
427
  env: this.config.env
427
428
  });
428
- if (!h)
429
+ if (!f)
429
430
  throw new Error(`${n.token.symbol} pool not support flashloan`);
430
431
  if (!this.walletClient)
431
432
  throw new Error("Wallet client not found");
432
- const f = (G = t == null ? void 0 : t.slippage) != null ? G : 5e-3, b = Math.ceil(d * (1 + h.flashloanFee)), m = b, C = await this.walletClient.swap.getQuote(
433
+ const m = (G = t == null ? void 0 : t.slippage) != null ? G : 5e-3, b = Math.ceil(d * (1 + f.flashloanFee)), C = b, y = await this.walletClient.swap.getQuote(
433
434
  n.suiCoinType,
434
435
  c.suiCoinType,
435
- m
436
+ C
436
437
  );
437
- let g = 1 + f, B = Math.ceil(Number(C.amount_out) * g), v = await this.walletClient.swap.getQuote(
438
+ let g = 1 + m, h = Math.ceil(Number(y.amount_out) * g), P = await this.walletClient.swap.getQuote(
438
439
  c.suiCoinType,
439
440
  n.suiCoinType,
440
- B
441
+ h
441
442
  );
442
- for (; Number(v.amount_out) < m; )
443
- g = g * Math.max(m / Number(v.amount_out), 1.001), B = Math.ceil(Number(C.amount_out) * g), v = await this.walletClient.swap.getQuote(
443
+ for (; Number(P.amount_out) < C; )
444
+ g = g * Math.max(C / Number(P.amount_out), 1.001), h = Math.ceil(Number(y.amount_out) * g), P = await this.walletClient.swap.getQuote(
444
445
  c.suiCoinType,
445
446
  n.suiCoinType,
446
- B
447
+ h
447
448
  );
448
- const [k, j] = await X(r, n, d), [_] = r.moveCall({
449
+ const [F, j] = await X(r, n, d), [_] = r.moveCall({
449
450
  target: "0x2::coin::from_balance",
450
- arguments: [k],
451
+ arguments: [F],
451
452
  typeArguments: [n.suiCoinType]
452
453
  });
453
454
  await ee(r, n, _, {
454
455
  amount: d
455
456
  });
456
- const U = await te(r, c, B), W = await $(
457
+ const U = await te(r, c, h), W = await $(
457
458
  s,
458
459
  r,
459
460
  b,
460
461
  U,
461
- v
462
+ P
462
463
  ), N = r.moveCall({
463
464
  target: "0x2::coin::into_balance",
464
465
  arguments: [W],
@@ -481,11 +482,11 @@ async function z(r, e, a, t) {
481
482
  if (t != null && t.amount && n.amount.lt(t.amount))
482
483
  throw new Error("Amount is less than balance");
483
484
  const c = (o = t == null ? void 0 : t.amount) != null ? o : n.amount.toNumber(), l = (u = t == null ? void 0 : t.slippage) != null ? u : 5e-3;
484
- let i = await y(r, n.coins, {
485
+ let i = await B(r, n.coins, {
485
486
  balance: c,
486
487
  useGasCoin: !0
487
488
  });
488
- if (T(e) !== T(s.suiCoinType)) {
489
+ if (p(e) !== p(s.suiCoinType)) {
489
490
  const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
490
491
  i = await this.walletClient.swap.buildSwapPTBFromQuote(
491
492
  r,
@@ -494,7 +495,7 @@ async function z(r, e, a, t) {
494
495
  l
495
496
  );
496
497
  }
497
- return await F(r, s, i), r;
498
+ return await A(r, s, i), r;
498
499
  }
499
500
  class ve extends R {
500
501
  constructor() {
@@ -522,7 +523,7 @@ class ve extends R {
522
523
  * @returns Pool information
523
524
  */
524
525
  async getPool(e, a) {
525
- return await P(e, {
526
+ return await T(e, {
526
527
  env: this.config.env,
527
528
  ...a
528
529
  });
@@ -539,15 +540,15 @@ class ve extends R {
539
540
  var o, u, d;
540
541
  if (!this.walletClient)
541
542
  throw new Error("Wallet client not found");
542
- const s = await P(e, {
543
+ const s = await T(e, {
543
544
  env: this.config.env
544
545
  });
545
546
  await this.walletClient.module("balance").waitForUpdate();
546
- const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = y(n, c.coins, {
547
+ const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = B(n, c.coins, {
547
548
  balance: a,
548
549
  useGasCoin: !0
549
550
  });
550
- await F(n, s, l, {
551
+ await A(n, s, l, {
551
552
  env: this.config.env,
552
553
  amount: a,
553
554
  accountCap: t == null ? void 0 : t.accountCap
@@ -573,7 +574,7 @@ class ve extends R {
573
574
  var i, o, u;
574
575
  if (!this.walletClient)
575
576
  throw new Error("Wallet client not found");
576
- const s = await P(e, {
577
+ const s = await T(e, {
577
578
  env: this.config.env
578
579
  }), n = new w();
579
580
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
@@ -603,7 +604,7 @@ class ve extends R {
603
604
  var i, o, u;
604
605
  if (!this.walletClient)
605
606
  throw new Error("Wallet client not found");
606
- const s = await P(e, {
607
+ const s = await T(e, {
607
608
  env: this.config.env
608
609
  }), n = new w();
609
610
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
@@ -634,9 +635,9 @@ class ve extends R {
634
635
  if (!this.walletClient)
635
636
  throw new Error("Wallet client not found");
636
637
  await this.walletClient.module("balance").waitForUpdate();
637
- const s = await P(e, {
638
+ const s = await T(e, {
638
639
  env: this.config.env
639
- }), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = y(n, c.coins, {
640
+ }), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = B(n, c.coins, {
640
641
  balance: a,
641
642
  useGasCoin: !0
642
643
  });
@@ -679,17 +680,17 @@ class ve extends R {
679
680
  * @returns Transaction response or dry run response
680
681
  */
681
682
  async liquidate(e, a, t, s, n) {
682
- var C, g, B;
683
+ var y, g, h;
683
684
  if (!this.walletClient)
684
685
  throw new Error("Wallet client not found");
685
- const c = await P(e, {
686
+ const c = await T(e, {
686
687
  env: this.config.env
687
- }), l = await P(t, {
688
+ }), l = await T(t, {
688
689
  env: this.config.env
689
- }), i = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = y(i, o.coins, {
690
+ }), i = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = B(i, o.coins, {
690
691
  balance: a,
691
692
  useGasCoin: !0
692
- }), [d, h] = await we(
693
+ }), [d, f] = await we(
693
694
  i,
694
695
  c,
695
696
  u,
@@ -698,26 +699,26 @@ class ve extends R {
698
699
  {
699
700
  env: this.config.env
700
701
  }
701
- ), [f] = i.moveCall({
702
+ ), [m] = i.moveCall({
702
703
  target: "0x2::coin::from_balance",
703
704
  arguments: [d],
704
705
  typeArguments: [l.suiCoinType]
705
706
  }), [b] = i.moveCall({
706
707
  target: "0x2::coin::from_balance",
707
- arguments: [h],
708
+ arguments: [f],
708
709
  typeArguments: [c.suiCoinType]
709
710
  });
710
- i.transferObjects([f, b], this.walletClient.address);
711
- const m = await this.walletClient.signExecuteTransaction({
711
+ i.transferObjects([m, b], this.walletClient.address);
712
+ const C = await this.walletClient.signExecuteTransaction({
712
713
  transaction: i,
713
- dryRun: (C = n == null ? void 0 : n.dryRun) != null ? C : !1
714
+ dryRun: (y = n == null ? void 0 : n.dryRun) != null ? y : !1
714
715
  });
715
- return !(n != null && n.dryRun) && ((B = (g = m.effects) == null ? void 0 : g.status) == null ? void 0 : B.status) === "success" && (this.emit("lending:liquidate-success", {
716
+ return !(n != null && n.dryRun) && ((h = (g = C.effects) == null ? void 0 : g.status) == null ? void 0 : h.status) === "success" && (this.emit("lending:liquidate-success", {
716
717
  payIdentifier: e,
717
718
  payAmount: a,
718
719
  collateralIdentifier: t,
719
720
  liquidationAddress: s
720
- }), this.walletClient.module("balance").updatePortfolio()), m;
721
+ }), this.walletClient.module("balance").updatePortfolio()), C;
721
722
  }
722
723
  /**
723
724
  * Gets the available lending rewards for the current user.
@@ -836,7 +837,7 @@ class ve extends R {
836
837
  });
837
838
  }
838
839
  }
839
- class pe extends R {
840
+ class Ee extends R {
840
841
  constructor() {
841
842
  super(...arguments), this.name = "volo", this.defaultConfig = {
842
843
  packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
@@ -861,7 +862,7 @@ class pe extends R {
861
862
  e.object(this.config.poolId),
862
863
  e.object(this.config.metadataId),
863
864
  e.object("0x05"),
864
- x(a, e.object)
865
+ k(a, e.object)
865
866
  ],
866
867
  typeArguments: []
867
868
  });
@@ -881,7 +882,7 @@ class pe extends R {
881
882
  e.object(this.config.poolId),
882
883
  e.object(this.config.metadataId),
883
884
  e.object("0x05"),
884
- x(a, e.object)
885
+ k(a, e.object)
885
886
  ],
886
887
  typeArguments: []
887
888
  });
@@ -903,7 +904,7 @@ class pe extends R {
903
904
  throw new Error("Stake amount should be greater than 1Sui");
904
905
  const t = new w();
905
906
  await this.walletClient.module("balance").waitForUpdate();
906
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = y(t, s.coins, {
907
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
907
908
  balance: e,
908
909
  useGasCoin: !0
909
910
  }), c = await this.stakePTB(t, n);
@@ -931,7 +932,7 @@ class pe extends R {
931
932
  if (e < 1e9)
932
933
  throw new Error("Unstake amount should >= 1vSui");
933
934
  await this.walletClient.module("balance").waitForUpdate();
934
- const t = new w(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = y(t, s.coins, {
935
+ const t = new w(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
935
936
  balance: e
936
937
  }), c = await this.unstakePTB(t, n);
937
938
  t.transferObjects([c], this.walletClient.address);
@@ -944,7 +945,7 @@ class pe extends R {
944
945
  }), this.walletClient.module("balance").updatePortfolio()), l;
945
946
  }
946
947
  }
947
- class Ee extends R {
948
+ class Re extends R {
948
949
  constructor() {
949
950
  super(...arguments), this.name = "swap", this.defaultConfig = {
950
951
  apiKey: "",
@@ -996,7 +997,7 @@ class Ee extends R {
996
997
  async buildSwapPTBFromQuote(e, a, t, s) {
997
998
  if (!this.walletClient)
998
999
  throw new Error("Wallet client not found");
999
- const n = new p(a.amount_out).multipliedBy(1 - s).toFixed(0);
1000
+ const n = new v(a.amount_out).multipliedBy(1 - s).toFixed(0);
1000
1001
  return await $(
1001
1002
  this.walletClient.address,
1002
1003
  e,
@@ -1027,33 +1028,50 @@ class Ee extends R {
1027
1028
  * @returns Transaction response or dry run response
1028
1029
  */
1029
1030
  async swap(e, a, t, s, n) {
1030
- var h, f, b, m;
1031
+ var C, y, g;
1031
1032
  if (!this.walletClient)
1032
1033
  throw new Error("Wallet client not found");
1033
1034
  await this.walletClient.module("balance").waitForUpdate();
1034
- const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(), i = y(l, c.coins, {
1035
+ const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(), i = B(l, c.coins, {
1035
1036
  balance: t,
1036
1037
  useGasCoin: !0
1037
1038
  }), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o, i, s);
1038
- l.transferObjects([u], this.walletClient.address);
1039
- const d = await this.walletClient.signExecuteTransaction({
1040
- transaction: l,
1041
- dryRun: (h = n == null ? void 0 : n.dryRun) != null ? h : !1
1039
+ if (l.transferObjects([u], this.walletClient.address), l.setSender(this.walletClient.address), n != null && n.dryRun)
1040
+ return await this.walletClient.signExecuteTransaction({
1041
+ transaction: l,
1042
+ dryRun: !0
1043
+ });
1044
+ const d = await l.build({
1045
+ client: this.walletClient.client
1046
+ }), f = await this.walletClient.signer.signTransaction(d), m = [f.signature];
1047
+ try {
1048
+ await ye(f.bytes, m);
1049
+ } catch (h) {
1050
+ console.error(h);
1051
+ }
1052
+ const b = await this.walletClient.client.executeTransactionBlock({
1053
+ transactionBlock: f.bytes,
1054
+ signature: m,
1055
+ options: {
1056
+ showEffects: !0,
1057
+ showEvents: !0,
1058
+ showBalanceChanges: !0
1059
+ }
1042
1060
  });
1043
- if (!(n != null && n.dryRun) && ((b = (f = d.effects) == null ? void 0 : f.status) == null ? void 0 : b.status) === "success") {
1044
- const C = (m = d.events) == null ? void 0 : m.find((g) => g.type.includes("::slippage::SwapEvent"));
1045
- C && this.emit("swap:swap-success", {
1061
+ if (((y = (C = b.effects) == null ? void 0 : C.status) == null ? void 0 : y.status) === "success") {
1062
+ const h = (g = b.events) == null ? void 0 : g.find((P) => P.type.includes("::slippage::SwapEvent"));
1063
+ h && this.emit("swap:swap-success", {
1046
1064
  fromCoinType: e,
1047
1065
  toCoinType: a,
1048
1066
  fromAmount: t,
1049
1067
  slippage: s,
1050
- toAmount: Number(C.parsedJson.amount_out)
1068
+ toAmount: Number(h.parsedJson.amount_out)
1051
1069
  }), this.walletClient.module("balance").updatePortfolio();
1052
1070
  }
1053
- return d;
1071
+ return b;
1054
1072
  }
1055
1073
  }
1056
- class Re extends R {
1074
+ class Se extends R {
1057
1075
  constructor() {
1058
1076
  super(...arguments), this.name = "haedal", this.defaultConfig = {
1059
1077
  packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2",
@@ -1076,7 +1094,7 @@ class Re extends R {
1076
1094
  arguments: [
1077
1095
  e.object("0x05"),
1078
1096
  e.object(this.config.configId),
1079
- x(a, e.object),
1097
+ k(a, e.object),
1080
1098
  e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
1081
1099
  ],
1082
1100
  typeArguments: []
@@ -1096,7 +1114,7 @@ class Re extends R {
1096
1114
  arguments: [
1097
1115
  e.object("0x05"),
1098
1116
  e.object(this.config.configId),
1099
- x(a, e.object)
1117
+ k(a, e.object)
1100
1118
  ],
1101
1119
  typeArguments: []
1102
1120
  });
@@ -1114,7 +1132,7 @@ class Re extends R {
1114
1132
  throw new Error("Wallet client not found");
1115
1133
  const t = new w();
1116
1134
  await this.walletClient.module("balance").waitForUpdate();
1117
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = y(t, s.coins, {
1135
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1118
1136
  balance: e,
1119
1137
  useGasCoin: !0
1120
1138
  }), c = await this.stakePTB(t, n);
@@ -1136,7 +1154,7 @@ class Re extends R {
1136
1154
  if (!this.walletClient)
1137
1155
  throw new Error("Wallet client not found");
1138
1156
  await this.walletClient.module("balance").waitForUpdate();
1139
- const t = new w(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = y(t, s.coins, {
1157
+ const t = new w(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
1140
1158
  balance: e
1141
1159
  }), c = await this.unstakePTB(t, n);
1142
1160
  t.transferObjects([c], this.walletClient.address);
@@ -1147,32 +1165,32 @@ class Re extends R {
1147
1165
  return !(a != null && a.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), l;
1148
1166
  }
1149
1167
  }
1150
- const Se = {
1168
+ const Oe = {
1151
1169
  /** Balance management module */
1152
- balance: new Be(),
1170
+ balance: new Pe(),
1153
1171
  /** Lending protocol module */
1154
1172
  lending: new ve(),
1155
1173
  /** Volo protocol module */
1156
- volo: new pe(),
1174
+ volo: new Ee(),
1157
1175
  /** DEX swapping module */
1158
- swap: new Ee(),
1176
+ swap: new Re(),
1159
1177
  /** Haedal protocol module */
1160
- haedal: new Re()
1161
- }, Oe = {
1178
+ haedal: new Se()
1179
+ }, xe = {
1162
1180
  url: le("mainnet")
1163
1181
  };
1164
- class Ie {
1182
+ class Le {
1165
1183
  /**
1166
1184
  * Creates a new wallet client instance
1167
1185
  * @param options - Configuration options for the wallet client
1168
1186
  */
1169
1187
  constructor(e) {
1170
- this.modules = Se, this.userConfigs = {}, this.events = re();
1188
+ this.modules = Oe, this.userConfigs = {}, this.events = re();
1171
1189
  const a = {
1172
- ...Oe,
1190
+ ...xe,
1173
1191
  ...e.client
1174
1192
  };
1175
- a.transport = a.transport || new ye(a.url), this.client = new ie(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
1193
+ a.transport = a.transport || new Be(a.url), this.client = new ie(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
1176
1194
  if (t !== s.name)
1177
1195
  throw new Error(`Module name ${t} does not match module name ${s.name}`);
1178
1196
  s.install(this);
@@ -1248,7 +1266,7 @@ class Ie {
1248
1266
  return e in this.modules;
1249
1267
  }
1250
1268
  }
1251
- class Me extends ne {
1269
+ class Qe extends ne {
1252
1270
  /**
1253
1271
  * Creates a new watch-only signer
1254
1272
  *
@@ -1312,7 +1330,7 @@ class Me extends ne {
1312
1330
  return {};
1313
1331
  }
1314
1332
  }
1315
- class Le extends ne {
1333
+ class qe extends ne {
1316
1334
  /**
1317
1335
  * Creates a new watch-only signer
1318
1336
  *
@@ -1365,8 +1383,8 @@ class Le extends ne {
1365
1383
  }
1366
1384
  }
1367
1385
  export {
1368
- Ie as WalletClient,
1369
- Me as WatchSigner,
1370
- Le as WebSigner
1386
+ Le as WalletClient,
1387
+ Qe as WatchSigner,
1388
+ qe as WebSigner
1371
1389
  };
1372
1390
  //# sourceMappingURL=index.esm.js.map