@naviprotocol/wallet-client 1.4.3 → 1.4.5-dev.1

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,31 +1,31 @@
1
1
  import { getFullnodeUrl as we, SuiClient as he } from "@mysten/sui/client";
2
2
  import fe from "mitt";
3
3
  import ge from "axios";
4
- import { withSingleton as K, getCoins as te, mergeCoinsPTB as B, getPriceFeeds as $, updateOraclePricesPTB as q, filterPriceFeeds as G, depositCoinPTB as A, getFlashLoanAsset as ae, flashloanPTB as ne, repayFlashLoanPTB as se, borrowCoinPTB as ie, withdrawCoinPTB as le, repayCoinPTB as re, 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 oe, parseTxValue as _ } from "@naviprotocol/lending";
4
+ import { withSingleton as D, getCoins as te, mergeCoinsPTB as B, getPriceFeeds as K, updateOraclePricesPTB as $, filterPriceFeeds as q, depositCoinPTB as O, getFlashLoanAsset as ae, flashloanPTB as ne, repayFlashLoanPTB as se, borrowCoinPTB as ie, withdrawCoinPTB as le, repayCoinPTB as re, 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 oe, parseTxValue as j } from "@naviprotocol/lending";
5
5
  import R, { BigNumber as Q } from "bignumber.js";
6
6
  import { normalizeStructTag as p } from "@mysten/sui/utils";
7
7
  import { Transaction as m } from "@mysten/sui/transactions";
8
- import { buildSwapPTBFromQuote as z, generateRefId as Te, getQuote as ve } from "@naviprotocol/astros-aggregator-sdk";
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";
11
- import { executeAuction as xe } from "shio-sdk";
10
+ import { getCoinMetadataMap as ke, MAX_U64 as Oe } from "@suilend/sui-fe";
11
+ import { executeAuction as Ae } from "shio-sdk";
12
12
  import { Signer as ce } from "@mysten/sui/cryptography";
13
13
  const ue = ge.create({
14
14
  timeout: 2e4
15
15
  });
16
16
  ue.interceptors.response.use(
17
- function(l) {
18
- if (l.data.err)
19
- throw new Error(l.data.err);
20
- if (l.data.error)
21
- throw new Error(l.data.error.message);
22
- return l;
17
+ function(i) {
18
+ if (i.data.err)
19
+ throw new Error(i.data.err);
20
+ if (i.data.error)
21
+ throw new Error(i.data.error.message);
22
+ return i;
23
23
  },
24
- function(l) {
25
- return Promise.reject(l);
24
+ function(i) {
25
+ return Promise.reject(i);
26
26
  }
27
27
  );
28
- class ke {
28
+ class Ne {
29
29
  /**
30
30
  * Creates a new custom transport instance
31
31
  *
@@ -64,7 +64,7 @@ class ke {
64
64
  throw new Error("subscribe not implemented.");
65
65
  }
66
66
  }
67
- class x {
67
+ class A {
68
68
  /**
69
69
  * Gets the current configuration for this module
70
70
  *
@@ -170,12 +170,12 @@ class S {
170
170
  return a.balances = e, a;
171
171
  }
172
172
  }
173
- class Ne extends x {
173
+ class Fe extends A {
174
174
  constructor() {
175
175
  super(...arguments), this.name = "balance", this.defaultConfig = {
176
176
  coinPollingInterval: 6e3,
177
177
  disableCoinPolling: !1
178
- }, this.updatePortfolio = K(async () => {
178
+ }, this.updatePortfolio = D(async () => {
179
179
  if (!this.walletClient)
180
180
  throw new Error("Wallet client not found");
181
181
  this._coins = await te(this.walletClient.address, {
@@ -241,16 +241,16 @@ class Ne extends x {
241
241
  const n = this.portfolio.getBalance(e), u = t.reduce((h, f) => h.plus(f), R(0));
242
242
  if (n.amount.lt(u))
243
243
  throw new Error("Insufficient balance");
244
- const i = new m();
245
- let r = i.gas;
246
- p(e) !== p("0x2::sui::SUI") && (r = B(i, n.coins, {
244
+ const l = new m();
245
+ let r = l.gas;
246
+ p(e) !== p("0x2::sui::SUI") && (r = B(l, n.coins, {
247
247
  balance: u.toNumber()
248
248
  }));
249
- const c = i.splitCoins(r, t);
249
+ const c = l.splitCoins(r, t);
250
250
  return a.forEach((h, f) => {
251
- i.transferObjects([c[f]], h);
251
+ l.transferObjects([c[f]], h);
252
252
  }), await this.walletClient.signExecuteTransaction({
253
- transaction: i,
253
+ transaction: l,
254
254
  dryRun: (w = s == null ? void 0 : s.dryRun) != null ? w : !1
255
255
  });
256
256
  }
@@ -284,8 +284,8 @@ class Ne extends x {
284
284
  throw new Error("Objects and recipients must have the same length");
285
285
  await this.waitForUpdate();
286
286
  const s = new m();
287
- return e.forEach((i, r) => {
288
- s.transferObjects([s.object(i)], a[r]);
287
+ return e.forEach((l, r) => {
288
+ s.transferObjects([s.object(l)], a[r]);
289
289
  }), await this.walletClient.signExecuteTransaction({
290
290
  transaction: s,
291
291
  dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
@@ -329,11 +329,11 @@ class Ne extends x {
329
329
  super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
330
330
  }
331
331
  }
332
- async function Y(l, e, a, t) {
333
- var k, N, O;
332
+ async function Y(i, e, a, t) {
333
+ var N, F, k;
334
334
  if (!this.walletClient)
335
335
  throw new Error("Wallet client not found");
336
- const s = await this.getPool(e), n = await this.getPool(a), u = await this.getLendingState(), i = this.walletClient.address, r = (k = t == null ? void 0 : t.protocol) != null ? k : "navi", c = await this.getProtocol(r);
336
+ const s = await this.getPool(e), n = await this.getPool(a), u = await this.getLendingState(), l = this.walletClient.address, r = (N = t == null ? void 0 : t.protocol) != null ? N : "navi", c = await this.getProtocol(r);
337
337
  if (!c)
338
338
  throw new Error(`Protocol ${r} not found`);
339
339
  const o = await c.getPool(s.coinType);
@@ -343,22 +343,22 @@ async function Y(l, e, a, t) {
343
343
  throw new Error("No supply balance");
344
344
  if (t != null && t.amount && t.amount > o.supplyBalance)
345
345
  throw new Error("Amount is less than supply balance");
346
- const w = (N = t == null ? void 0 : t.slippage) != null ? N : 5e-3, h = (O = t == null ? void 0 : t.amount) != null ? O : Number(o.supplyBalance), f = await $(), b = await Promise.all([s, n]);
347
- if (await q(
348
- l,
349
- G(f, {
346
+ const w = (F = t == null ? void 0 : t.slippage) != null ? F : 5e-3, h = (k = t == null ? void 0 : t.amount) != null ? k : Number(o.supplyBalance), f = await K(), b = await Promise.all([s, n]);
347
+ if (await $(
348
+ i,
349
+ q(f, {
350
350
  lendingState: u,
351
351
  pools: b
352
352
  })
353
- ), r !== "navi" && s.id === n.id) {
354
- const F = await c.withdrawCoinPTB(
355
- l,
353
+ ), console.log("migration update price", i.blockData.transactions.length, i.blockData.transactions), r !== "navi" && s.id === n.id) {
354
+ const _ = await c.withdrawCoinPTB(
355
+ i,
356
356
  s.suiCoinType,
357
357
  h
358
358
  );
359
- return await A(l, n, F, {
359
+ return await O(i, n, _, {
360
360
  amount: h
361
- }), l;
361
+ }), i;
362
362
  }
363
363
  const y = await ae(n, {
364
364
  env: this.config.env
@@ -375,36 +375,40 @@ async function Y(l, e, a, t) {
375
375
  const C = Math.floor(g * (1 - w)), P = Math.floor(C / (1 + y.flashloanFee));
376
376
  if (P <= 0)
377
377
  throw new Error("The calculated borrow amount must be positive.");
378
- const [v, E] = await ne(l, n, P), [j] = l.moveCall({
378
+ const [v, E] = await ne(i, n, P), [x] = i.moveCall({
379
379
  target: "0x2::coin::from_balance",
380
380
  arguments: [v],
381
381
  typeArguments: [n.suiCoinType]
382
382
  });
383
- await A(l, n, j, {
383
+ await O(i, n, x, {
384
384
  amount: P
385
385
  });
386
- const I = await c.withdrawCoinPTB(l, s.suiCoinType, h), U = await z(
387
- i,
386
+ const I = await c.withdrawCoinPTB(i, s.suiCoinType, h);
387
+ console.log("migration before swap", i.blockData.transactions.length, i.blockData.transactions);
388
+ const U = await G(
388
389
  l,
390
+ i,
389
391
  C,
390
392
  I,
391
393
  d
392
- ), M = l.moveCall({
394
+ );
395
+ console.log("migration after swap", i.blockData.transactions.length, i.blockData.transactions);
396
+ const M = i.moveCall({
393
397
  target: "0x2::coin::into_balance",
394
398
  arguments: [U],
395
399
  typeArguments: [n.suiCoinType]
396
- }), [W] = await se(l, n, E, M), [L] = l.moveCall({
400
+ }), [W] = await se(i, n, E, M), [L] = i.moveCall({
397
401
  target: "0x2::coin::from_balance",
398
402
  arguments: [W],
399
403
  typeArguments: [n.suiCoinType]
400
404
  });
401
- return await A(l, n, L), l;
405
+ return await O(i, n, L), console.log("migration end", i.blockData.transactions.length, i.blockData.transactions), i;
402
406
  }
403
- async function Z(l, e, a, t) {
404
- var O, F, D;
407
+ async function Z(i, e, a, t) {
408
+ var k, _, H;
405
409
  if (!this.walletClient)
406
410
  throw new Error("Wallet client not found");
407
- const s = this.walletClient.address, n = await this.getPool(e), u = await this.getPool(a), i = await this.getLendingState(), r = (O = t == null ? void 0 : t.protocol) != null ? O : "navi", c = await this.getProtocol(r);
411
+ const s = this.walletClient.address, n = await this.getPool(e), u = await this.getPool(a), l = await this.getLendingState(), r = (k = t == null ? void 0 : t.protocol) != null ? k : "navi", c = await this.getProtocol(r);
408
412
  if (!c)
409
413
  throw new Error(`Protocol ${r} not found`);
410
414
  const o = await c.getPool(n.coinType);
@@ -414,15 +418,15 @@ async function Z(l, e, a, t) {
414
418
  throw new Error("No borrow balance");
415
419
  if (t != null && t.amount && t.amount > o.borrowBalance)
416
420
  throw new Error("Amount is more than borrow balance");
417
- const w = await $(), h = await Promise.all([n, u]);
418
- await q(
419
- l,
420
- G(w, {
421
- lendingState: i,
421
+ const w = await K(), h = await Promise.all([n, u]);
422
+ await $(
423
+ i,
424
+ q(w, {
425
+ lendingState: l,
422
426
  pools: h
423
427
  })
424
428
  );
425
- let f = (F = t == null ? void 0 : t.amount) != null ? F : Number(o.borrowBalance);
429
+ let f = (_ = t == null ? void 0 : t.amount) != null ? _ : Number(o.borrowBalance);
426
430
  if (Number(o.borrowBalance) === f) {
427
431
  const de = o.borrowAPR / 100;
428
432
  f = Math.ceil(
@@ -436,7 +440,7 @@ async function Z(l, e, a, t) {
436
440
  throw new Error(`${n.token.symbol} pool not support flashloan`);
437
441
  if (!this.walletClient)
438
442
  throw new Error("Wallet client not found");
439
- const y = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, d = Math.ceil(f * (1 + b.flashloanFee)), g = d, C = await this.walletClient.swap.getQuote(
443
+ const y = (H = t == null ? void 0 : t.slippage) != null ? H : 5e-3, d = Math.ceil(f * (1 + b.flashloanFee)), g = d, C = await this.walletClient.swap.getQuote(
440
444
  n.suiCoinType,
441
445
  u.suiCoinType,
442
446
  g
@@ -452,66 +456,66 @@ async function Z(l, e, a, t) {
452
456
  n.suiCoinType,
453
457
  v
454
458
  );
455
- const [j, I] = await ne(l, n, f), [U] = l.moveCall({
459
+ const [x, I] = await ne(i, n, f), [U] = i.moveCall({
456
460
  target: "0x2::coin::from_balance",
457
- arguments: [j],
461
+ arguments: [x],
458
462
  typeArguments: [n.suiCoinType]
459
463
  });
460
- await c.repayCoinPTB(l, n.suiCoinType, U, f);
461
- const M = await ie(l, u, v), W = await z(
464
+ await c.repayCoinPTB(i, n.suiCoinType, U, f);
465
+ const M = await ie(i, u, v), W = await G(
462
466
  s,
463
- l,
467
+ i,
464
468
  d,
465
469
  M,
466
470
  E
467
- ), L = l.moveCall({
471
+ ), L = i.moveCall({
468
472
  target: "0x2::coin::into_balance",
469
473
  arguments: [W],
470
474
  typeArguments: [n.suiCoinType]
471
- }), [k] = await se(l, n, I, L), [N] = l.moveCall({
475
+ }), [N] = await se(i, n, I, L), [F] = i.moveCall({
472
476
  target: "0x2::coin::from_balance",
473
- arguments: [k],
477
+ arguments: [N],
474
478
  typeArguments: [n.suiCoinType]
475
479
  });
476
- return l.transferObjects([N], s), l;
480
+ return i.transferObjects([F], s), i;
477
481
  }
478
- async function ee(l, e, a, t) {
482
+ async function ee(i, e, a, t) {
479
483
  var w, h;
480
484
  if (!this.walletClient)
481
485
  throw new Error("Wallet client not found");
482
486
  const s = await te(this.walletClient.address, {
483
487
  client: this.walletClient.client,
484
488
  coinType: e
485
- }), n = await this.getPool(a), i = new S(s).getBalance(e);
486
- if (i.amount.eq(0))
489
+ }), n = await this.getPool(a), l = new S(s).getBalance(e);
490
+ if (l.amount.eq(0))
487
491
  throw new Error(`No balance of ${e}`);
488
492
  if (console.log("migrateBalanceToSupplyPTB", {
489
- balance: i.amount.toNumber()
490
- }), t != null && t.amount && i.amount.lt(t.amount))
493
+ balance: l.amount.toNumber()
494
+ }), t != null && t.amount && l.amount.lt(t.amount))
491
495
  throw new Error("Amount is greater than balance");
492
- const r = (w = t == null ? void 0 : t.amount) != null ? w : i.amount.toNumber(), c = (h = t == null ? void 0 : t.slippage) != null ? h : 5e-3;
493
- let o = await B(l, i.coins, {
496
+ const r = (w = t == null ? void 0 : t.amount) != null ? w : l.amount.toNumber(), c = (h = t == null ? void 0 : t.slippage) != null ? h : 5e-3;
497
+ let o = await B(i, l.coins, {
494
498
  balance: r,
495
499
  useGasCoin: !0
496
500
  });
497
501
  if (p(e) !== p(n.suiCoinType)) {
498
502
  const f = await this.walletClient.swap.getQuote(e, n.suiCoinType, r);
499
503
  o = await this.walletClient.swap.buildSwapPTBFromQuote(
500
- l,
504
+ i,
501
505
  f,
502
506
  o,
503
507
  c
504
508
  );
505
509
  }
506
- return await A(l, n, o), l;
510
+ return await O(i, n, o), i;
507
511
  }
508
- class Fe {
512
+ class _e {
509
513
  constructor(e) {
510
514
  this.name = "navi", this.walletClient = e;
511
515
  }
512
516
  async getPool(e) {
513
517
  const a = await this.walletClient.lending.getPool(e), s = (await this.walletClient.lending.getLendingState()).find(
514
- (i) => i.pool.suiCoinType === p(e)
518
+ (l) => l.pool.suiCoinType === p(e)
515
519
  ), n = s ? new R(s.supplyBalance).toNumber() : 0, u = s ? new R(s.borrowBalance).toNumber() : 0;
516
520
  return {
517
521
  supplyBalance: n,
@@ -532,7 +536,7 @@ class Fe {
532
536
  re(e, a, t, { amount: s });
533
537
  }
534
538
  }
535
- class H {
539
+ class z {
536
540
  constructor(e, a, t) {
537
541
  this.name = "suilend", this.walletClient = e, this.obligationOwnerCap = a, this.suilendClient = t;
538
542
  }
@@ -547,7 +551,7 @@ class H {
547
551
  ]);
548
552
  if (t.length === 0)
549
553
  throw new Error("No existing obligations found for wallet address: " + e.address);
550
- return new H(e, t[0], a);
554
+ return new z(e, t[0], a);
551
555
  }
552
556
  async getPool(e) {
553
557
  var b, y;
@@ -559,17 +563,17 @@ class H {
559
563
  g && s.add(p(g.coinType.name));
560
564
  });
561
565
  });
562
- const n = await Oe(Array.from(s)), i = t.map((d) => Re(d, n)).reduce(
566
+ const n = await ke(Array.from(s)), l = t.map((d) => Re(d, n)).reduce(
563
567
  (d, g) => (d[g.coinType] = g, d),
564
568
  {}
565
569
  ), r = await this.suilendClient.getObligation(
566
570
  this.obligationOwnerCap.obligationId
567
- ), c = Se(r, i), o = c.deposits.find((d) => d.coinType === a), w = c.borrows.find((d) => d.coinType === a), h = n[a].decimals;
571
+ ), c = Se(r, l), o = c.deposits.find((d) => d.coinType === a), w = c.borrows.find((d) => d.coinType === a), h = n[a].decimals;
568
572
  return {
569
- cTokenExchangeRate: i[a].cTokenExchangeRate.toNumber(),
573
+ cTokenExchangeRate: l[a].cTokenExchangeRate.toNumber(),
570
574
  supplyBalance: (b = o == null ? void 0 : o.depositedAmount.shiftedBy(h).decimalPlaces(0).toNumber()) != null ? b : 0,
571
575
  borrowBalance: (y = w == null ? void 0 : w.borrowedAmount.shiftedBy(h).decimalPlaces(0).toNumber()) != null ? y : 0,
572
- borrowAPR: i[a].borrowAprPercent.toNumber()
576
+ borrowAPR: l[a].borrowAprPercent.toNumber()
573
577
  };
574
578
  }
575
579
  async depositCoinPTB(e, a, t, s) {
@@ -581,7 +585,7 @@ class H {
581
585
  this.obligationOwnerCap.id,
582
586
  this.obligationOwnerCap.obligationId,
583
587
  a,
584
- n ? Ae.toString() : Math.ceil(t / s.cTokenExchangeRate).toString(),
588
+ n ? Oe.toString() : Math.ceil(t / s.cTokenExchangeRate).toString(),
585
589
  e
586
590
  );
587
591
  }
@@ -592,7 +596,7 @@ class H {
592
596
  this.suilendClient.repay(this.obligationOwnerCap.obligationId, a, t, e), e.transferObjects([t], e.pure.address(this.walletClient.address));
593
597
  }
594
598
  }
595
- class _e extends x {
599
+ class je extends A {
596
600
  constructor() {
597
601
  super(), this.name = "lending", this.defaultConfig = {
598
602
  env: "prod",
@@ -647,11 +651,11 @@ class _e extends x {
647
651
  env: this.config.env
648
652
  });
649
653
  await this.walletClient.module("balance").waitForUpdate();
650
- const n = new m(), u = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, u.coins, {
654
+ const n = new m(), u = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = B(n, u.coins, {
651
655
  balance: a,
652
656
  useGasCoin: !0
653
657
  });
654
- await A(n, s, i, {
658
+ await O(n, s, l, {
655
659
  env: this.config.env,
656
660
  amount: a,
657
661
  accountCap: t == null ? void 0 : t.accountCap
@@ -686,14 +690,14 @@ class _e extends x {
686
690
  accountCap: t == null ? void 0 : t.accountCap
687
691
  });
688
692
  n.transferObjects([u], this.walletClient.address);
689
- const i = await this.walletClient.signExecuteTransaction({
693
+ const l = await this.walletClient.signExecuteTransaction({
690
694
  transaction: n,
691
695
  dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
692
696
  });
693
- return !(t != null && t.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:withdraw-success", {
697
+ return !(t != null && t.dryRun) && ((o = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:withdraw-success", {
694
698
  identifier: e,
695
699
  amount: a
696
- }), this.walletClient.module("balance").updatePortfolio()), i;
700
+ }), this.walletClient.module("balance").updatePortfolio()), l;
697
701
  }
698
702
  /**
699
703
  * Borrows coins from a lending pool
@@ -716,14 +720,14 @@ class _e extends x {
716
720
  accountCap: t == null ? void 0 : t.accountCap
717
721
  });
718
722
  n.transferObjects([u], this.walletClient.address);
719
- const i = await this.walletClient.signExecuteTransaction({
723
+ const l = await this.walletClient.signExecuteTransaction({
720
724
  transaction: n,
721
725
  dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
722
726
  });
723
- return !(t != null && t.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:borrow-success", {
727
+ return !(t != null && t.dryRun) && ((o = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:borrow-success", {
724
728
  identifier: e,
725
729
  amount: a
726
- }), this.walletClient.module("balance").updatePortfolio()), i;
730
+ }), this.walletClient.module("balance").updatePortfolio()), l;
727
731
  }
728
732
  /**
729
733
  * Repays borrowed coins to a lending pool
@@ -740,11 +744,11 @@ class _e extends x {
740
744
  await this.walletClient.module("balance").waitForUpdate();
741
745
  const s = await T(e, {
742
746
  env: this.config.env
743
- }), n = new m(), u = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, u.coins, {
747
+ }), n = new m(), u = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = B(n, u.coins, {
744
748
  balance: a,
745
749
  useGasCoin: !0
746
750
  });
747
- await re(n, s, i, {
751
+ await re(n, s, l, {
748
752
  env: this.config.env,
749
753
  amount: a,
750
754
  accountCap: t == null ? void 0 : t.accountCap
@@ -788,7 +792,7 @@ class _e extends x {
788
792
  throw new Error("Wallet client not found");
789
793
  const u = await T(e, {
790
794
  env: this.config.env
791
- }), i = await T(t, {
795
+ }), l = await T(t, {
792
796
  env: this.config.env
793
797
  }), r = new m(), c = this.walletClient.module("balance").portfolio.getBalance(u.suiCoinType), o = B(r, c.coins, {
794
798
  balance: a,
@@ -797,7 +801,7 @@ class _e extends x {
797
801
  r,
798
802
  u,
799
803
  o,
800
- i,
804
+ l,
801
805
  s,
802
806
  {
803
807
  env: this.config.env
@@ -805,7 +809,7 @@ class _e extends x {
805
809
  ), [f] = r.moveCall({
806
810
  target: "0x2::coin::from_balance",
807
811
  arguments: [w],
808
- typeArguments: [i.suiCoinType]
812
+ typeArguments: [l.suiCoinType]
809
813
  }), [b] = r.moveCall({
810
814
  target: "0x2::coin::from_balance",
811
815
  arguments: [h],
@@ -859,7 +863,7 @@ class _e extends x {
859
863
  * @returns Transaction response or dry run response
860
864
  */
861
865
  async claimAllRewards(e) {
862
- var n, u, i;
866
+ var n, u, l;
863
867
  if (!this.walletClient)
864
868
  throw new Error("Wallet client not found");
865
869
  const a = new m(), t = await J(this.walletClient.address, {
@@ -873,20 +877,20 @@ class _e extends x {
873
877
  transaction: a,
874
878
  dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
875
879
  });
876
- return !(e != null && e.dryRun) && ((i = (u = s.effects) == null ? void 0 : u.status) == null ? void 0 : i.status) === "success" && (this.emit("lending:claim-rewards-success", {
880
+ return !(e != null && e.dryRun) && ((l = (u = s.effects) == null ? void 0 : u.status) == null ? void 0 : l.status) === "success" && (this.emit("lending:claim-rewards-success", {
877
881
  rewards: t
878
882
  }), this.walletClient.module("balance").updatePortfolio()), s;
879
883
  }
880
884
  async updateOraclePTB(e, a) {
881
- const t = await $({
885
+ const t = await K({
882
886
  env: this.config.env
883
887
  }), s = await this.getLendingState({
884
888
  cacheTime: 60 * 1e3
885
- }), n = G(t, {
889
+ }), n = q(t, {
886
890
  lendingState: s,
887
891
  pools: a
888
892
  });
889
- await q(e, n, {
893
+ await $(e, n, {
890
894
  env: this.config.env,
891
895
  updatePythPriceFeeds: !0
892
896
  });
@@ -945,16 +949,16 @@ class _e extends x {
945
949
  return;
946
950
  }
947
951
  const e = [];
948
- e.push(new Fe(this.walletClient));
952
+ e.push(new _e(this.walletClient));
949
953
  try {
950
- e.push(await H.create(this.walletClient));
954
+ e.push(await z.create(this.walletClient));
951
955
  } catch (a) {
952
956
  console.warn("Failed to initialize SuilendProtocol:", a);
953
957
  }
954
958
  this._protocols = e;
955
959
  }
956
960
  }
957
- class je extends x {
961
+ class xe extends A {
958
962
  constructor() {
959
963
  super(...arguments), this.name = "volo", this.defaultConfig = {
960
964
  packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
@@ -962,7 +966,7 @@ class je extends x {
962
966
  metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
963
967
  coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
964
968
  }, this.getStats = oe(
965
- K(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
969
+ D(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
966
970
  );
967
971
  }
968
972
  /**
@@ -979,7 +983,7 @@ class je extends x {
979
983
  e.object(this.config.poolId),
980
984
  e.object(this.config.metadataId),
981
985
  e.object("0x05"),
982
- _(a, e.object)
986
+ j(a, e.object)
983
987
  ],
984
988
  typeArguments: []
985
989
  });
@@ -999,7 +1003,7 @@ class je extends x {
999
1003
  e.object(this.config.poolId),
1000
1004
  e.object(this.config.metadataId),
1001
1005
  e.object("0x05"),
1002
- _(a, e.object)
1006
+ j(a, e.object)
1003
1007
  ],
1004
1008
  typeArguments: []
1005
1009
  });
@@ -1026,13 +1030,13 @@ class je extends x {
1026
1030
  useGasCoin: !0
1027
1031
  }), u = await this.stakePTB(t, n);
1028
1032
  t.transferObjects([u], this.walletClient.address);
1029
- const i = await this.walletClient.signExecuteTransaction({
1033
+ const l = await this.walletClient.signExecuteTransaction({
1030
1034
  transaction: t,
1031
1035
  dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
1032
1036
  });
1033
- return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:stake-success", {
1037
+ return !(a != null && a.dryRun) && ((o = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:stake-success", {
1034
1038
  suiAmount: e
1035
- }), this.walletClient.module("balance").updatePortfolio()), i;
1039
+ }), this.walletClient.module("balance").updatePortfolio()), l;
1036
1040
  }
1037
1041
  /**
1038
1042
  * Unstake vSUI tokens to receive SUI tokens
@@ -1053,16 +1057,16 @@ class je extends x {
1053
1057
  balance: e
1054
1058
  }), u = await this.unstakePTB(t, n);
1055
1059
  t.transferObjects([u], this.walletClient.address);
1056
- const i = await this.walletClient.signExecuteTransaction({
1060
+ const l = await this.walletClient.signExecuteTransaction({
1057
1061
  transaction: t,
1058
1062
  dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
1059
1063
  });
1060
- return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:unstake-success", {
1064
+ return !(a != null && a.dryRun) && ((o = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:unstake-success", {
1061
1065
  vSuiAmount: e
1062
- }), this.walletClient.module("balance").updatePortfolio()), i;
1066
+ }), this.walletClient.module("balance").updatePortfolio()), l;
1063
1067
  }
1064
1068
  }
1065
- class Ie extends x {
1069
+ class Ie extends A {
1066
1070
  constructor() {
1067
1071
  super(...arguments), this.name = "swap", this.defaultConfig = {
1068
1072
  apiKey: "",
@@ -1115,7 +1119,7 @@ class Ie extends x {
1115
1119
  if (!this.walletClient)
1116
1120
  throw new Error("Wallet client not found");
1117
1121
  const n = new R(a.amount_out).multipliedBy(1 - s).toFixed(0);
1118
- return await z(
1122
+ return await G(
1119
1123
  this.walletClient.address,
1120
1124
  e,
1121
1125
  Number(n),
@@ -1149,20 +1153,20 @@ class Ie extends x {
1149
1153
  if (!this.walletClient)
1150
1154
  throw new Error("Wallet client not found");
1151
1155
  await this.walletClient.module("balance").waitForUpdate();
1152
- const u = this.walletClient.module("balance").portfolio.getBalance(e), i = new m(), r = B(i, u.coins, {
1156
+ const u = this.walletClient.module("balance").portfolio.getBalance(e), l = new m(), r = B(l, u.coins, {
1153
1157
  balance: t,
1154
1158
  useGasCoin: !0
1155
- }), c = await this.getQuote(e, a, t), o = await this.buildSwapPTBFromQuote(i, c, r, s);
1156
- if (i.transferObjects([o], this.walletClient.address), i.setSender(this.walletClient.address), n != null && n.dryRun)
1159
+ }), c = await this.getQuote(e, a, t), o = await this.buildSwapPTBFromQuote(l, c, r, s);
1160
+ if (l.transferObjects([o], this.walletClient.address), l.setSender(this.walletClient.address), n != null && n.dryRun)
1157
1161
  return await this.walletClient.signExecuteTransaction({
1158
- transaction: i,
1162
+ transaction: l,
1159
1163
  dryRun: !0
1160
1164
  });
1161
- const w = await i.build({
1165
+ const w = await l.build({
1162
1166
  client: this.walletClient.client
1163
1167
  }), h = await this.walletClient.signer.signTransaction(w), f = [h.signature];
1164
1168
  try {
1165
- await xe(h.bytes, f);
1169
+ await Ae(h.bytes, f);
1166
1170
  } catch (C) {
1167
1171
  console.error(C);
1168
1172
  }
@@ -1188,14 +1192,14 @@ class Ie extends x {
1188
1192
  return b;
1189
1193
  }
1190
1194
  }
1191
- class Ue extends x {
1195
+ class Ue extends A {
1192
1196
  constructor() {
1193
1197
  super(...arguments), this.name = "haedal", this.defaultConfig = {
1194
1198
  packageId: "0x19e6ea7f5ced4f090e20da794cc80349a03e638940ddb95155a4e301f5f4967c",
1195
1199
  configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
1196
1200
  coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
1197
1201
  }, this.getApy = oe(
1198
- K(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
1202
+ D(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
1199
1203
  );
1200
1204
  }
1201
1205
  /**
@@ -1211,7 +1215,7 @@ class Ue extends x {
1211
1215
  arguments: [
1212
1216
  e.object("0x05"),
1213
1217
  e.object(this.config.configId),
1214
- _(a, e.object),
1218
+ j(a, e.object),
1215
1219
  e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
1216
1220
  ],
1217
1221
  typeArguments: []
@@ -1231,7 +1235,7 @@ class Ue extends x {
1231
1235
  arguments: [
1232
1236
  e.object("0x05"),
1233
1237
  e.object(this.config.configId),
1234
- _(a, e.object)
1238
+ j(a, e.object)
1235
1239
  ],
1236
1240
  typeArguments: []
1237
1241
  });
@@ -1254,11 +1258,11 @@ class Ue extends x {
1254
1258
  useGasCoin: !0
1255
1259
  }), u = await this.stakePTB(t, n);
1256
1260
  t.transferObjects([u], this.walletClient.address);
1257
- const i = await this.walletClient.signExecuteTransaction({
1261
+ const l = await this.walletClient.signExecuteTransaction({
1258
1262
  transaction: t,
1259
1263
  dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
1260
1264
  });
1261
- return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
1265
+ return !(a != null && a.dryRun) && ((o = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), l;
1262
1266
  }
1263
1267
  /**
1264
1268
  * Unstake haSUI for SUI
@@ -1275,20 +1279,20 @@ class Ue extends x {
1275
1279
  balance: e
1276
1280
  }), u = await this.unstakePTB(t, n);
1277
1281
  t.transferObjects([u], this.walletClient.address);
1278
- const i = await this.walletClient.signExecuteTransaction({
1282
+ const l = await this.walletClient.signExecuteTransaction({
1279
1283
  transaction: t,
1280
1284
  dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
1281
1285
  });
1282
- return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
1286
+ return !(a != null && a.dryRun) && ((o = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), l;
1283
1287
  }
1284
1288
  }
1285
1289
  const Me = {
1286
1290
  /** Balance management module */
1287
- balance: new Ne(),
1291
+ balance: new Fe(),
1288
1292
  /** Lending protocol module */
1289
- lending: new _e(),
1293
+ lending: new je(),
1290
1294
  /** Volo protocol module */
1291
- volo: new je(),
1295
+ volo: new xe(),
1292
1296
  /** DEX swapping module */
1293
1297
  swap: new Ie(),
1294
1298
  /** Haedal protocol module */
@@ -1307,7 +1311,7 @@ class Ye {
1307
1311
  ...We,
1308
1312
  ...e.client
1309
1313
  };
1310
- a.transport = a.transport || new ke(a.url), this.client = new he(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
1314
+ a.transport = a.transport || new Ne(a.url), this.client = new he(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
1311
1315
  if (t !== s.name)
1312
1316
  throw new Error(`Module name ${t} does not match module name ${s.name}`);
1313
1317
  s.install(this);