@naviprotocol/wallet-client 1.0.0 → 1.0.1-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,28 +1,28 @@
1
- import { getFullnodeUrl as F, SuiClient as W } from "@mysten/sui/client";
2
- import _ from "mitt";
3
- import A from "axios";
4
- import { withSingleton as j, getCoins as K, mergeCoinsPTB as w, getPools as N, getPool as m, depositCoinPTB as q, withdrawCoinPTB as L, borrowCoinPTB as M, repayCoinPTB as $, getHealthFactor as G, liquidatePTB as H, getUserAvailableLendingRewards as O, getUserClaimedRewardHistory as J, claimLendingRewardsPTB as z, getPriceFeeds as D, filterPriceFeeds as Q, updateOraclePricesPTB as V, getLendingState as X, createAccountCapPTB as Y, withCache as k, parseTxValue as R } from "@naviprotocol/lending";
5
- import S, { BigNumber as x } from "bignumber.js";
6
- import { normalizeStructTag as P } from "@mysten/sui/utils";
7
- import { Transaction as d } from "@mysten/sui/transactions";
8
- import { generateRefId as Z, getQuote as ee, buildSwapPTBFromQuote as te } from "@naviprotocol/astros-aggregator-sdk";
9
- import { Signer as U } from "@mysten/sui/cryptography";
10
- const p = A.create({
1
+ import { getFullnodeUrl as ee, SuiClient as te } from "@mysten/sui/client";
2
+ import ae from "mitt";
3
+ import ne from "axios";
4
+ import { withSingleton as I, getCoins as se, mergeCoinsPTB as y, getFlashLoanAsset as G, flashloanPTB as H, depositCoinPTB as x, withdrawCoinPTB as D, repayFlashLoanPTB as J, repayCoinPTB as z, borrowCoinPTB as V, getPools as le, getPool as B, getHealthFactor as re, liquidatePTB as ie, getUserAvailableLendingRewards as Q, getUserClaimedRewardHistory as ce, claimLendingRewardsPTB as oe, getPriceFeeds as ue, filterPriceFeeds as de, updateOraclePricesPTB as he, getLendingState as we, createAccountCapPTB as fe, withCache as X, parseTxValue as k } from "@naviprotocol/lending";
5
+ import P, { BigNumber as N } from "bignumber.js";
6
+ import { normalizeStructTag as T } from "@mysten/sui/utils";
7
+ import { Transaction as h } from "@mysten/sui/transactions";
8
+ import { buildSwapPTBFromQuote as M, generateRefId as ge, getQuote as me } from "@naviprotocol/astros-aggregator-sdk";
9
+ import { Signer as Y } from "@mysten/sui/cryptography";
10
+ const Z = ne.create({
11
11
  timeout: 2e4
12
12
  });
13
- p.interceptors.response.use(
14
- function(o) {
15
- if (o.data.err)
16
- throw new Error(o.data.err);
17
- if (o.data.error)
18
- throw new Error(o.data.error.message);
19
- return o;
13
+ Z.interceptors.response.use(
14
+ function(i) {
15
+ if (i.data.err)
16
+ throw new Error(i.data.err);
17
+ if (i.data.error)
18
+ throw new Error(i.data.error.message);
19
+ return i;
20
20
  },
21
- function(o) {
22
- return Promise.reject(o);
21
+ function(i) {
22
+ return Promise.reject(i);
23
23
  }
24
24
  );
25
- class ae {
25
+ class Ce {
26
26
  /**
27
27
  * Creates a new custom transport instance
28
28
  *
@@ -41,7 +41,7 @@ class ae {
41
41
  * @returns Promise<T> - The response data from the RPC call
42
42
  */
43
43
  async request(e) {
44
- return this.requestId += 1, (await p.post(this.rpcUrl, {
44
+ return this.requestId += 1, (await Z.post(this.rpcUrl, {
45
45
  jsonrpc: "2.0",
46
46
  id: this.requestId,
47
47
  method: e.method,
@@ -61,7 +61,7 @@ class ae {
61
61
  throw new Error("subscribe not implemented.");
62
62
  }
63
63
  }
64
- class T {
64
+ class E {
65
65
  /**
66
66
  * Gets the current configuration for this module
67
67
  *
@@ -104,23 +104,23 @@ class T {
104
104
  this.walletClient = void 0;
105
105
  }
106
106
  }
107
- class B {
107
+ class p {
108
108
  /**
109
109
  * Creates a new user portfolio
110
110
  *
111
111
  * @param coins - Array of coin objects or existing portfolio to copy from
112
112
  */
113
113
  constructor(e) {
114
- if (e instanceof B)
114
+ if (e instanceof p)
115
115
  this.balances = JSON.parse(JSON.stringify(e.balances));
116
116
  else {
117
117
  const a = {};
118
118
  e == null || e.forEach((t) => {
119
- const s = P(t.coinType);
119
+ const s = T(t.coinType);
120
120
  let n = a[s];
121
121
  n || (n = {
122
122
  coinType: s,
123
- amount: x(0),
123
+ amount: N(0),
124
124
  coins: []
125
125
  }, a[s] = n), n.coins.push(t), n.amount = n.amount.plus(t.balance);
126
126
  }), this.balances = a;
@@ -133,7 +133,7 @@ class B {
133
133
  * @returns UserCoinBalance object with coin type, total amount, and coin objects
134
134
  */
135
135
  getBalance(e) {
136
- return e = P(e), this.balances[e] || { coinType: e, amount: x(0), coins: [] };
136
+ return e = T(e), this.balances[e] || { coinType: e, amount: N(0), coins: [] };
137
137
  }
138
138
  /**
139
139
  * Gets all coin types in the portfolio
@@ -150,9 +150,9 @@ class B {
150
150
  * @returns BigNumber representing the total balance
151
151
  */
152
152
  balanceOf(e) {
153
- e = P(e);
153
+ e = T(e);
154
154
  const a = this.getBalance(e);
155
- return (a == null ? void 0 : a.amount) || x(0);
155
+ return (a == null ? void 0 : a.amount) || N(0);
156
156
  }
157
157
  /**
158
158
  * Creates a deep copy of the portfolio
@@ -163,21 +163,21 @@ class B {
163
163
  * @returns New UserPortfolio instance with copied data
164
164
  */
165
165
  clone() {
166
- const e = JSON.parse(JSON.stringify(this.balances)), a = new B();
166
+ const e = JSON.parse(JSON.stringify(this.balances)), a = new p();
167
167
  return a.balances = e, a;
168
168
  }
169
169
  }
170
- class ne extends T {
170
+ class be extends E {
171
171
  constructor() {
172
172
  super(...arguments), this.name = "balance", this.defaultConfig = {
173
173
  coinPollingInterval: 6e3
174
- }, this.updatePortfolio = j(async () => {
174
+ }, this.updatePortfolio = I(async () => {
175
175
  if (!this.walletClient)
176
176
  throw new Error("Wallet client not found");
177
- this._coins = await K(this.walletClient.address, {
177
+ this._coins = await se(this.walletClient.address, {
178
178
  client: this.walletClient.client
179
- }), this._portfolio = new B(this._coins), this.emit("balance:portfolio-updated", {});
180
- }), this._coins = [], this._portfolio = new B(), this.pollingTimer = null, this._updatePromise = null;
179
+ }), this._portfolio = new p(this._coins), this.emit("balance:portfolio-updated", {});
180
+ }), this._coins = [], this._portfolio = new p(), this.pollingTimer = null, this._updatePromise = null;
181
181
  }
182
182
  /**
183
183
  * Gets the current coin objects from the wallet
@@ -228,26 +228,26 @@ class ne extends T {
228
228
  * @returns Transaction response or dry run response
229
229
  */
230
230
  async sendCoinBatch(e, a, t, s) {
231
- var h;
231
+ var d;
232
232
  if (!this.walletClient)
233
233
  throw new Error("Wallet client not found");
234
234
  if (a.length !== t.length)
235
235
  throw new Error("Recipients and amounts must have the same length");
236
236
  await this.waitForUpdate();
237
- const n = this.portfolio.getBalance(e), r = t.reduce((g, f) => g.plus(f), S(0));
238
- if (n.amount.lt(r))
237
+ const n = this.portfolio.getBalance(e), o = t.reduce((f, w) => f.plus(w), P(0));
238
+ if (n.amount.lt(o))
239
239
  throw new Error("Insufficient balance");
240
- const l = new d();
241
- let i = l.gas;
242
- P(e) !== P("0x2::sui::SUI") && (i = w(l, n.coins, {
243
- balance: r.toNumber()
240
+ const r = new h();
241
+ let l = r.gas;
242
+ T(e) !== T("0x2::sui::SUI") && (l = y(r, n.coins, {
243
+ balance: o.toNumber()
244
244
  }));
245
- const c = l.splitCoins(i, t);
246
- return a.forEach((g, f) => {
247
- l.transferObjects([c[f]], g);
245
+ const c = r.splitCoins(l, t);
246
+ return a.forEach((f, w) => {
247
+ r.transferObjects([c[w]], f);
248
248
  }), await this.walletClient.signExecuteTransaction({
249
- transaction: l,
250
- dryRun: (h = s == null ? void 0 : s.dryRun) != null ? h : !1
249
+ transaction: r,
250
+ dryRun: (d = s == null ? void 0 : s.dryRun) != null ? d : !1
251
251
  });
252
252
  }
253
253
  /**
@@ -273,18 +273,18 @@ class ne extends T {
273
273
  * @returns Transaction response or dry run response
274
274
  */
275
275
  async transferObjectBatch(e, a, t) {
276
- var r;
276
+ var o;
277
277
  if (!this.walletClient)
278
278
  throw new Error("Wallet client not found");
279
279
  if (e.length !== a.length)
280
280
  throw new Error("Objects and recipients must have the same length");
281
281
  await this.waitForUpdate();
282
- const s = new d();
283
- return e.forEach((l, i) => {
284
- s.transferObjects([s.object(l)], a[i]);
282
+ const s = new h();
283
+ return e.forEach((r, l) => {
284
+ s.transferObjects([s.object(r)], a[l]);
285
285
  }), await this.walletClient.signExecuteTransaction({
286
286
  transaction: s,
287
- dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
287
+ dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
288
288
  });
289
289
  }
290
290
  /**
@@ -323,11 +323,154 @@ class ne extends T {
323
323
  super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
324
324
  }
325
325
  }
326
- class se extends T {
326
+ const ye = 27;
327
+ function Be(i, e = 2) {
328
+ return i ? new P(i.toString()).shiftedBy(-1 * ye).multipliedBy(100).decimalPlaces(e, P.ROUND_DOWN).toFixed(e) : "0.00";
329
+ }
330
+ async function q(i, e, a, t) {
331
+ var R, S;
332
+ if (!this.walletClient)
333
+ throw new Error("Wallet client not found");
334
+ const s = await this.getPool(e), n = await this.getPool(a), r = (await this.getLendingState()).find((O) => O.pool.id === s.id), l = this.walletClient.address;
335
+ if (!r || r.supplyBalance === "0")
336
+ throw new Error("No supply balance");
337
+ if (t != null && t.amount && t.amount < Number(r.supplyBalance))
338
+ throw new Error("Amount is less than supply balance");
339
+ const c = await G(n, {
340
+ env: this.config.env
341
+ });
342
+ if (!(c != null && c.flashloanFee))
343
+ throw new Error(`${s.token.symbol} pool not support flashloan`);
344
+ const u = (R = t == null ? void 0 : t.slippage) != null ? R : 5e-3, d = (S = t == null ? void 0 : t.amount) != null ? S : Number(r.supplyBalance), f = await this.walletClient.swap.getQuote(
345
+ s.suiCoinType,
346
+ n.suiCoinType,
347
+ d
348
+ ), w = Number(f.amount_out);
349
+ if (w <= 0)
350
+ throw new Error("The amount of swapAmountOut must be greater than 0.");
351
+ const b = Math.floor(w * (1 - u)), g = Math.floor(b / (1 + c.flashloanFee));
352
+ if (g <= 0)
353
+ throw new Error("The calculated borrow amount must be positive.");
354
+ const [m, C] = await H(i, n, g), [v] = i.moveCall({
355
+ target: "0x2::coin::from_balance",
356
+ arguments: [m],
357
+ typeArguments: [n.suiCoinType]
358
+ });
359
+ await x(i, n, v, {
360
+ amount: g
361
+ });
362
+ const A = await D(i, s, d), j = await M(
363
+ l,
364
+ i,
365
+ b,
366
+ A,
367
+ f
368
+ ), F = i.moveCall({
369
+ target: "0x2::coin::into_balance",
370
+ arguments: [j],
371
+ typeArguments: [n.suiCoinType]
372
+ }), [_] = await J(i, n, C, F), [U] = i.moveCall({
373
+ target: "0x2::coin::from_balance",
374
+ arguments: [_],
375
+ typeArguments: [n.suiCoinType]
376
+ });
377
+ return await x(i, n, U), i;
378
+ }
379
+ async function K(i, e, a, t) {
380
+ var O, L;
381
+ if (!this.walletClient)
382
+ throw new Error("Wallet client not found");
383
+ const s = this.walletClient.address, n = await this.getPool(e), o = await this.getPool(a), l = (await this.getLendingState()).find((W) => W.pool.id === n.id);
384
+ if (!l || l.borrowBalance === "0")
385
+ throw new Error("No borrow balance");
386
+ if (t != null && t.amount && t.amount < Number(l.borrowBalance))
387
+ throw new Error("Amount is less than borrow balance");
388
+ let c = (O = t == null ? void 0 : t.amount) != null ? O : Number(l.borrowBalance);
389
+ if (Number(l.borrowBalance) === c) {
390
+ const W = parseFloat(Be(n.currentBorrowRate, 8)) / 100;
391
+ c = Math.ceil(
392
+ new P(c).multipliedBy(W * (60 * 3) / (365 * 24 * 3600)).plus(new P(1).shiftedBy(-n.token.decimals)).plus(c).toNumber()
393
+ );
394
+ }
395
+ const u = await G(n, {
396
+ env: this.config.env
397
+ });
398
+ if (!u)
399
+ throw new Error(`${n.token.symbol} pool not support flashloan`);
400
+ if (!this.walletClient)
401
+ throw new Error("Wallet client not found");
402
+ const d = (L = t == null ? void 0 : t.slippage) != null ? L : 5e-3, f = Math.ceil(c * (1 + u.flashloanFee)), w = f, b = await this.walletClient.swap.getQuote(
403
+ n.suiCoinType,
404
+ o.suiCoinType,
405
+ w
406
+ );
407
+ let g = 1 + d, m = Math.ceil(Number(b.amount_out) * g), C = await this.walletClient.swap.getQuote(
408
+ o.suiCoinType,
409
+ n.suiCoinType,
410
+ m
411
+ );
412
+ for (; Number(C.amount_out) < w; )
413
+ g = g * Math.max(w / Number(C.amount_out), 1.001), m = Math.ceil(Number(b.amount_out) * g), C = await this.walletClient.swap.getQuote(
414
+ o.suiCoinType,
415
+ n.suiCoinType,
416
+ m
417
+ );
418
+ const [v, A] = await H(i, n, c), [j] = i.moveCall({
419
+ target: "0x2::coin::from_balance",
420
+ arguments: [v],
421
+ typeArguments: [n.suiCoinType]
422
+ });
423
+ await z(i, n, j, {
424
+ amount: c
425
+ });
426
+ const F = await V(i, o, m), _ = await M(
427
+ s,
428
+ i,
429
+ f,
430
+ F,
431
+ C
432
+ ), U = i.moveCall({
433
+ target: "0x2::coin::into_balance",
434
+ arguments: [_],
435
+ typeArguments: [n.suiCoinType]
436
+ }), [R] = await J(i, n, A, U), [S] = i.moveCall({
437
+ target: "0x2::coin::from_balance",
438
+ arguments: [R],
439
+ typeArguments: [n.suiCoinType]
440
+ });
441
+ return i.transferObjects([S], s), i;
442
+ }
443
+ async function $(i, e, a, t) {
444
+ var c, u;
445
+ if (!this.walletClient)
446
+ throw new Error("Wallet client not found");
447
+ this.walletClient.address;
448
+ const s = await this.getPool(a), n = this.walletClient.balance.portfolio.getBalance(e);
449
+ if (n.amount.eq(0))
450
+ throw new Error(`No balance of ${e}`);
451
+ if (t != null && t.amount && n.amount.lt(t.amount))
452
+ throw new Error("Amount is less than balance");
453
+ const o = (c = t == null ? void 0 : t.amount) != null ? c : n.amount.toNumber(), r = (u = t == null ? void 0 : t.slippage) != null ? u : 5e-3;
454
+ let l = await y(i, n.coins, {
455
+ balance: o,
456
+ useGasCoin: !0
457
+ });
458
+ if (T(e) !== T(s.suiCoinType)) {
459
+ const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, o);
460
+ l = await this.walletClient.swap.buildSwapPTBFromQuote(
461
+ i,
462
+ d,
463
+ l,
464
+ r
465
+ );
466
+ }
467
+ return await x(i, s, l), i;
468
+ }
469
+ class Te extends E {
327
470
  constructor() {
328
- super(...arguments), this.name = "lending", this.defaultConfig = {
471
+ super(), this.name = "lending", this.defaultConfig = {
329
472
  env: "prod"
330
- };
473
+ }, this.migrateSupplyPTB = q, this.migrateBorrowPTB = K, this.migrateBalanceToSupplyPTB = $, this.migrateSupplyPTB = q.bind(this), this.migrateBorrowPTB = K.bind(this), this.migrateBalanceToSupplyPTB = $.bind(this);
331
474
  }
332
475
  /**
333
476
  * Gets all available lending pools
@@ -336,7 +479,7 @@ class se extends T {
336
479
  * @returns Array of pool information
337
480
  */
338
481
  async getPools(e) {
339
- return await N({
482
+ return await le({
340
483
  env: this.config.env,
341
484
  ...e
342
485
  });
@@ -349,7 +492,7 @@ class se extends T {
349
492
  * @returns Pool information
350
493
  */
351
494
  async getPool(e, a) {
352
- return await m(e, {
495
+ return await B(e, {
353
496
  env: this.config.env,
354
497
  ...a
355
498
  });
@@ -363,30 +506,30 @@ class se extends T {
363
506
  * @returns Transaction response or dry run response
364
507
  */
365
508
  async deposit(e, a, t) {
366
- var c, u, h;
509
+ var c, u, d;
367
510
  if (!this.walletClient)
368
511
  throw new Error("Wallet client not found");
369
- const s = await m(e, {
512
+ const s = await B(e, {
370
513
  env: this.config.env
371
514
  });
372
515
  await this.walletClient.module("balance").waitForUpdate();
373
- const n = new d(), r = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = w(n, r.coins, {
516
+ const n = new h(), o = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), r = y(n, o.coins, {
374
517
  balance: a,
375
518
  useGasCoin: !0
376
519
  });
377
- await q(n, s, l, {
520
+ await x(n, s, r, {
378
521
  env: this.config.env,
379
522
  amount: a,
380
523
  accountCap: t == null ? void 0 : t.accountCap
381
524
  });
382
- const i = await this.walletClient.signExecuteTransaction({
525
+ const l = await this.walletClient.signExecuteTransaction({
383
526
  transaction: n,
384
527
  dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
385
528
  });
386
- return !(t != null && t.dryRun) && ((h = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : h.status) === "success" && (this.emit("lending:deposit-success", {
529
+ return !(t != null && t.dryRun) && ((d = (u = l.effects) == null ? void 0 : u.status) == null ? void 0 : d.status) === "success" && (this.emit("lending:deposit-success", {
387
530
  identifier: e,
388
531
  amount: a
389
- }), this.walletClient.module("balance").updatePortfolio()), i;
532
+ }), this.walletClient.module("balance").updatePortfolio()), l;
390
533
  }
391
534
  /**
392
535
  * Withdraws coins from a lending pool
@@ -397,26 +540,26 @@ class se extends T {
397
540
  * @returns Transaction response or dry run response
398
541
  */
399
542
  async withdraw(e, a, t) {
400
- var i, c, u;
543
+ var l, c, u;
401
544
  if (!this.walletClient)
402
545
  throw new Error("Wallet client not found");
403
- const s = await m(e, {
546
+ const s = await B(e, {
404
547
  env: this.config.env
405
- }), n = new d();
548
+ }), n = new h();
406
549
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
407
- const r = await L(n, s, a, {
550
+ const o = await D(n, s, a, {
408
551
  env: this.config.env,
409
552
  accountCap: t == null ? void 0 : t.accountCap
410
553
  });
411
- n.transferObjects([r], this.walletClient.address);
412
- const l = await this.walletClient.signExecuteTransaction({
554
+ n.transferObjects([o], this.walletClient.address);
555
+ const r = await this.walletClient.signExecuteTransaction({
413
556
  transaction: n,
414
- dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
557
+ dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
415
558
  });
416
- return !(t != null && t.dryRun) && ((u = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:withdraw-success", {
559
+ return !(t != null && t.dryRun) && ((u = (c = r.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:withdraw-success", {
417
560
  identifier: e,
418
561
  amount: a
419
- }), this.walletClient.module("balance").updatePortfolio()), l;
562
+ }), this.walletClient.module("balance").updatePortfolio()), r;
420
563
  }
421
564
  /**
422
565
  * Borrows coins from a lending pool
@@ -427,26 +570,26 @@ class se extends T {
427
570
  * @returns Transaction response or dry run response
428
571
  */
429
572
  async borrow(e, a, t) {
430
- var i, c, u;
573
+ var l, c, u;
431
574
  if (!this.walletClient)
432
575
  throw new Error("Wallet client not found");
433
- const s = await m(e, {
576
+ const s = await B(e, {
434
577
  env: this.config.env
435
- }), n = new d();
578
+ }), n = new h();
436
579
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
437
- const r = await M(n, s, a, {
580
+ const o = await V(n, s, a, {
438
581
  env: this.config.env,
439
582
  accountCap: t == null ? void 0 : t.accountCap
440
583
  });
441
- n.transferObjects([r], this.walletClient.address);
442
- const l = await this.walletClient.signExecuteTransaction({
584
+ n.transferObjects([o], this.walletClient.address);
585
+ const r = await this.walletClient.signExecuteTransaction({
443
586
  transaction: n,
444
- dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
587
+ dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
445
588
  });
446
- return !(t != null && t.dryRun) && ((u = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:borrow-success", {
589
+ return !(t != null && t.dryRun) && ((u = (c = r.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:borrow-success", {
447
590
  identifier: e,
448
591
  amount: a
449
- }), this.walletClient.module("balance").updatePortfolio()), l;
592
+ }), this.walletClient.module("balance").updatePortfolio()), r;
450
593
  }
451
594
  /**
452
595
  * Repays borrowed coins to a lending pool
@@ -457,29 +600,29 @@ class se extends T {
457
600
  * @returns Transaction response or dry run response
458
601
  */
459
602
  async repay(e, a, t) {
460
- var c, u, h;
603
+ var c, u, d;
461
604
  if (!this.walletClient)
462
605
  throw new Error("Wallet client not found");
463
606
  await this.walletClient.module("balance").waitForUpdate();
464
- const s = await m(e, {
607
+ const s = await B(e, {
465
608
  env: this.config.env
466
- }), n = new d(), r = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = w(n, r.coins, {
609
+ }), n = new h(), o = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), r = y(n, o.coins, {
467
610
  balance: a,
468
611
  useGasCoin: !0
469
612
  });
470
- await $(n, s, l, {
613
+ await z(n, s, r, {
471
614
  env: this.config.env,
472
615
  amount: a,
473
616
  accountCap: t == null ? void 0 : t.accountCap
474
617
  });
475
- const i = await this.walletClient.signExecuteTransaction({
618
+ const l = await this.walletClient.signExecuteTransaction({
476
619
  transaction: n,
477
620
  dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
478
621
  });
479
- return !(t != null && t.dryRun) && ((h = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : h.status) === "success" && (this.emit("lending:repay-success", {
622
+ return !(t != null && t.dryRun) && ((d = (u = l.effects) == null ? void 0 : u.status) == null ? void 0 : d.status) === "success" && (this.emit("lending:repay-success", {
480
623
  identifier: e,
481
624
  amount: a
482
- }), this.walletClient.module("balance").updatePortfolio()), i;
625
+ }), this.walletClient.module("balance").updatePortfolio()), l;
483
626
  }
484
627
  /**
485
628
  * Gets the current health factor for the user
@@ -490,7 +633,7 @@ class se extends T {
490
633
  if (!this.walletClient)
491
634
  throw new Error("Wallet client not found");
492
635
  const e = this.walletClient.address;
493
- return await G(e, {
636
+ return await re(e, {
494
637
  env: this.config.env,
495
638
  client: this.walletClient.client
496
639
  });
@@ -506,45 +649,45 @@ class se extends T {
506
649
  * @returns Transaction response or dry run response
507
650
  */
508
651
  async liquidate(e, a, t, s, n) {
509
- var b, y, v;
652
+ var m, C, v;
510
653
  if (!this.walletClient)
511
654
  throw new Error("Wallet client not found");
512
- const r = await m(e, {
655
+ const o = await B(e, {
513
656
  env: this.config.env
514
- }), l = await m(t, {
657
+ }), r = await B(t, {
515
658
  env: this.config.env
516
- }), i = new d(), c = this.walletClient.module("balance").portfolio.getBalance(r.suiCoinType), u = w(i, c.coins, {
659
+ }), l = new h(), c = this.walletClient.module("balance").portfolio.getBalance(o.suiCoinType), u = y(l, c.coins, {
517
660
  balance: a,
518
661
  useGasCoin: !0
519
- }), [h, g] = await H(
520
- i,
521
- r,
522
- u,
662
+ }), [d, f] = await ie(
523
663
  l,
664
+ o,
665
+ u,
666
+ r,
524
667
  s,
525
668
  {
526
669
  env: this.config.env
527
670
  }
528
- ), [f] = i.moveCall({
529
- target: "0x2::coin::from_balance",
530
- arguments: [h],
531
- typeArguments: [l.suiCoinType]
532
- }), [E] = i.moveCall({
671
+ ), [w] = l.moveCall({
533
672
  target: "0x2::coin::from_balance",
534
- arguments: [g],
673
+ arguments: [d],
535
674
  typeArguments: [r.suiCoinType]
675
+ }), [b] = l.moveCall({
676
+ target: "0x2::coin::from_balance",
677
+ arguments: [f],
678
+ typeArguments: [o.suiCoinType]
536
679
  });
537
- i.transferObjects([f, E], this.walletClient.address);
538
- const C = await this.walletClient.signExecuteTransaction({
539
- transaction: i,
540
- dryRun: (b = n == null ? void 0 : n.dryRun) != null ? b : !1
680
+ l.transferObjects([w, b], this.walletClient.address);
681
+ const g = await this.walletClient.signExecuteTransaction({
682
+ transaction: l,
683
+ dryRun: (m = n == null ? void 0 : n.dryRun) != null ? m : !1
541
684
  });
542
- return !(n != null && n.dryRun) && ((v = (y = C.effects) == null ? void 0 : y.status) == null ? void 0 : v.status) === "success" && (this.emit("lending:liquidate-success", {
685
+ return !(n != null && n.dryRun) && ((v = (C = g.effects) == null ? void 0 : C.status) == null ? void 0 : v.status) === "success" && (this.emit("lending:liquidate-success", {
543
686
  payIdentifier: e,
544
687
  payAmount: a,
545
688
  collateralIdentifier: t,
546
689
  liquidationAddress: s
547
- }), this.walletClient.module("balance").updatePortfolio()), C;
690
+ }), this.walletClient.module("balance").updatePortfolio()), g;
548
691
  }
549
692
  /**
550
693
  * Gets the available lending rewards for the current user.
@@ -556,7 +699,7 @@ class se extends T {
556
699
  async getAvailableRewards(e) {
557
700
  if (!this.walletClient)
558
701
  throw new Error("Wallet client not found");
559
- return O(this.walletClient.address, {
702
+ return Q(this.walletClient.address, {
560
703
  ...e,
561
704
  env: this.config.env
562
705
  });
@@ -571,7 +714,7 @@ class se extends T {
571
714
  async getClaimedRewardHistory(e) {
572
715
  if (!this.walletClient)
573
716
  throw new Error("Wallet client not found");
574
- return J(this.walletClient.address, {
717
+ return ce(this.walletClient.address, {
575
718
  ...e
576
719
  });
577
720
  }
@@ -582,13 +725,13 @@ class se extends T {
582
725
  * @returns Transaction response or dry run response
583
726
  */
584
727
  async claimAllRewards(e) {
585
- var n, r, l;
728
+ var n, o, r;
586
729
  if (!this.walletClient)
587
730
  throw new Error("Wallet client not found");
588
- const a = new d(), t = await O(this.walletClient.address, {
731
+ const a = new h(), t = await Q(this.walletClient.address, {
589
732
  env: this.config.env
590
733
  });
591
- await z(a, t, {
734
+ await oe(a, t, {
592
735
  env: this.config.env,
593
736
  accountCap: e == null ? void 0 : e.accountCap
594
737
  });
@@ -596,20 +739,20 @@ class se extends T {
596
739
  transaction: a,
597
740
  dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
598
741
  });
599
- return !(e != null && e.dryRun) && ((l = (r = s.effects) == null ? void 0 : r.status) == null ? void 0 : l.status) === "success" && (this.emit("lending:claim-rewards-success", {
742
+ return !(e != null && e.dryRun) && ((r = (o = s.effects) == null ? void 0 : o.status) == null ? void 0 : r.status) === "success" && (this.emit("lending:claim-rewards-success", {
600
743
  rewards: t
601
744
  }), this.walletClient.module("balance").updatePortfolio()), s;
602
745
  }
603
746
  async updateOraclePTB(e, a) {
604
- const t = await D({
747
+ const t = await ue({
605
748
  env: this.config.env
606
749
  }), s = await this.getLendingState({
607
750
  cacheTime: 60 * 1e3
608
- }), n = Q(t, {
751
+ }), n = de(t, {
609
752
  lendingState: s,
610
753
  pools: a
611
754
  });
612
- await V(e, n, {
755
+ await he(e, n, {
613
756
  env: this.config.env,
614
757
  updatePythPriceFeeds: !0
615
758
  });
@@ -625,7 +768,7 @@ class se extends T {
625
768
  var s;
626
769
  if (!this.walletClient)
627
770
  throw new Error("Wallet client not found");
628
- const a = new d();
771
+ const a = new h();
629
772
  return await this.updateOraclePTB(a, e == null ? void 0 : e.pools), await this.walletClient.signExecuteTransaction({
630
773
  transaction: a,
631
774
  dryRun: (s = e == null ? void 0 : e.dryRun) != null ? s : !1
@@ -640,7 +783,7 @@ class se extends T {
640
783
  async getLendingState(e) {
641
784
  if (!this.walletClient)
642
785
  throw new Error("Wallet client not found");
643
- return await X(this.walletClient.address, {
786
+ return await we(this.walletClient.address, {
644
787
  env: this.config.env,
645
788
  ...e,
646
789
  client: this.walletClient.client
@@ -656,22 +799,22 @@ class se extends T {
656
799
  var n;
657
800
  if (!this.walletClient)
658
801
  throw new Error("Wallet client not found");
659
- const a = new d(), t = await Y(a);
802
+ const a = new h(), t = await fe(a);
660
803
  return a.transferObjects([t], this.walletClient.address), await this.walletClient.signExecuteTransaction({
661
804
  transaction: a,
662
805
  dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
663
806
  });
664
807
  }
665
808
  }
666
- class le extends T {
809
+ class ve extends E {
667
810
  constructor() {
668
811
  super(...arguments), this.name = "volo", this.defaultConfig = {
669
812
  packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
670
813
  poolId: "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5",
671
814
  metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
672
815
  coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
673
- }, this.getStats = k(
674
- j(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
816
+ }, this.getStats = X(
817
+ I(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
675
818
  );
676
819
  }
677
820
  /**
@@ -688,7 +831,7 @@ class le extends T {
688
831
  e.object(this.config.poolId),
689
832
  e.object(this.config.metadataId),
690
833
  e.object("0x05"),
691
- R(a, e.object)
834
+ k(a, e.object)
692
835
  ],
693
836
  typeArguments: []
694
837
  });
@@ -708,7 +851,7 @@ class le extends T {
708
851
  e.object(this.config.poolId),
709
852
  e.object(this.config.metadataId),
710
853
  e.object("0x05"),
711
- R(a, e.object)
854
+ k(a, e.object)
712
855
  ],
713
856
  typeArguments: []
714
857
  });
@@ -723,25 +866,25 @@ class le extends T {
723
866
  * @throws Error if wallet client not found or stake amount is too low
724
867
  */
725
868
  async stake(e, a) {
726
- var i, c, u;
869
+ var l, c, u;
727
870
  if (!this.walletClient)
728
871
  throw new Error("Wallet client not found");
729
872
  if (e < 1e9)
730
873
  throw new Error("Stake amount should be greater than 1Sui");
731
- const t = new d();
874
+ const t = new h();
732
875
  await this.walletClient.module("balance").waitForUpdate();
733
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = w(t, s.coins, {
876
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = y(t, s.coins, {
734
877
  balance: e,
735
878
  useGasCoin: !0
736
- }), r = await this.stakePTB(t, n);
737
- t.transferObjects([r], this.walletClient.address);
738
- const l = await this.walletClient.signExecuteTransaction({
879
+ }), o = await this.stakePTB(t, n);
880
+ t.transferObjects([o], this.walletClient.address);
881
+ const r = await this.walletClient.signExecuteTransaction({
739
882
  transaction: t,
740
- dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
883
+ dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
741
884
  });
742
- return !(a != null && a.dryRun) && ((u = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:stake-success", {
885
+ return !(a != null && a.dryRun) && ((u = (c = r.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:stake-success", {
743
886
  suiAmount: e
744
- }), this.walletClient.module("balance").updatePortfolio()), l;
887
+ }), this.walletClient.module("balance").updatePortfolio()), r;
745
888
  }
746
889
  /**
747
890
  * Unstake vSUI tokens to receive SUI tokens
@@ -752,26 +895,26 @@ class le extends T {
752
895
  * @throws Error if wallet client not found or unstake amount is too low
753
896
  */
754
897
  async unstake(e, a) {
755
- var i, c, u;
898
+ var l, c, u;
756
899
  if (!this.walletClient)
757
900
  throw new Error("Wallet client not found");
758
901
  if (e < 1e9)
759
902
  throw new Error("Unstake amount should >= 1vSui");
760
903
  await this.walletClient.module("balance").waitForUpdate();
761
- const t = new d(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = w(t, s.coins, {
904
+ const t = new h(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = y(t, s.coins, {
762
905
  balance: e
763
- }), r = await this.unstakePTB(t, n);
764
- t.transferObjects([r], this.walletClient.address);
765
- const l = await this.walletClient.signExecuteTransaction({
906
+ }), o = await this.unstakePTB(t, n);
907
+ t.transferObjects([o], this.walletClient.address);
908
+ const r = await this.walletClient.signExecuteTransaction({
766
909
  transaction: t,
767
- dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
910
+ dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
768
911
  });
769
- return !(a != null && a.dryRun) && ((u = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:unstake-success", {
912
+ return !(a != null && a.dryRun) && ((u = (c = r.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:unstake-success", {
770
913
  vSuiAmount: e
771
- }), this.walletClient.module("balance").updatePortfolio()), l;
914
+ }), this.walletClient.module("balance").updatePortfolio()), r;
772
915
  }
773
916
  }
774
- class ie extends T {
917
+ class Pe extends E {
775
918
  constructor() {
776
919
  super(...arguments), this.name = "swap", this.defaultConfig = {
777
920
  apiKey: "",
@@ -788,7 +931,53 @@ class ie extends T {
788
931
  * @returns Referral ID if API key is configured, otherwise 0
789
932
  */
790
933
  get referral() {
791
- return this.config.apiKey ? Z(this.config.apiKey) : 0;
934
+ return this.config.apiKey ? ge(this.config.apiKey) : 0;
935
+ }
936
+ /**
937
+ * Get the swap options
938
+ * @returns The swap options
939
+ */
940
+ get swapOptions() {
941
+ return {
942
+ baseUrl: this.config.baseUrl,
943
+ dexList: this.config.dexList,
944
+ depth: this.config.depth,
945
+ serviceFee: this.config.serviceFee
946
+ };
947
+ }
948
+ /**
949
+ * Get a quote for a swap
950
+ * @param fromCoinType - The type of the coin being swapped from
951
+ * @param toCoinType - The type of the coin being swapped to
952
+ * @param fromAmount - The amount of the coin being swapped from
953
+ * @returns A promise that resolves with the quote
954
+ */
955
+ async getQuote(e, a, t) {
956
+ return me(e, a, t, this.config.apiKey, this.swapOptions);
957
+ }
958
+ /**
959
+ * Builds a swap transaction from a quote
960
+ * @param tx - The transaction to build the swap from
961
+ * @param quote - The quote to build the swap from
962
+ * @param fromCoin - The coin to swap from
963
+ * @param slippage - The slippage tolerance
964
+ * @returns The swap transaction
965
+ */
966
+ async buildSwapPTBFromQuote(e, a, t, s) {
967
+ if (!this.walletClient)
968
+ throw new Error("Wallet client not found");
969
+ const n = new P(a.amount_out).multipliedBy(1 - s).toFixed(0);
970
+ return await M(
971
+ this.walletClient.address,
972
+ e,
973
+ Number(n),
974
+ t,
975
+ a,
976
+ this.referral,
977
+ !1,
978
+ this.config.apiKey,
979
+ this.swapOptions
980
+ );
792
981
  }
793
982
  /**
794
983
  * Executes a swap between two coin types
@@ -808,61 +997,40 @@ class ie extends T {
808
997
  * @returns Transaction response or dry run response
809
998
  */
810
999
  async swap(e, a, t, s, n) {
811
- var E, C, b, y;
1000
+ var f, w, b, g;
812
1001
  if (!this.walletClient)
813
1002
  throw new Error("Wallet client not found");
814
1003
  await this.walletClient.module("balance").waitForUpdate();
815
- const r = this.walletClient.module("balance").portfolio.getBalance(e), l = new d(), i = w(l, r.coins, {
1004
+ const o = this.walletClient.module("balance").portfolio.getBalance(e), r = new h(), l = y(r, o.coins, {
816
1005
  balance: t,
817
1006
  useGasCoin: !0
818
- }), c = {
819
- baseUrl: this.config.baseUrl,
820
- dexList: this.config.dexList,
821
- depth: this.config.depth,
822
- serviceFee: this.config.serviceFee
823
- }, u = await ee(
824
- e,
825
- a,
826
- t,
827
- this.config.apiKey,
828
- c
829
- ), h = new S(u.amount_out).multipliedBy(1 - s).toFixed(0), g = await te(
830
- this.walletClient.address,
831
- l,
832
- Number(h),
833
- i,
834
- u,
835
- this.referral,
836
- !1,
837
- this.config.apiKey,
838
- c
839
- );
840
- l.transferObjects([g], this.walletClient.address);
841
- const f = await this.walletClient.signExecuteTransaction({
842
- transaction: l,
843
- dryRun: (E = n == null ? void 0 : n.dryRun) != null ? E : !1
1007
+ }), c = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(r, c, l, s);
1008
+ r.transferObjects([u], this.walletClient.address);
1009
+ const d = await this.walletClient.signExecuteTransaction({
1010
+ transaction: r,
1011
+ dryRun: (f = n == null ? void 0 : n.dryRun) != null ? f : !1
844
1012
  });
845
- if (!(n != null && n.dryRun) && ((b = (C = f.effects) == null ? void 0 : C.status) == null ? void 0 : b.status) === "success") {
846
- const v = (y = f.events) == null ? void 0 : y.find((I) => I.type.includes("::slippage::SwapEvent"));
847
- v && this.emit("swap:swap-success", {
1013
+ if (!(n != null && n.dryRun) && ((b = (w = d.effects) == null ? void 0 : w.status) == null ? void 0 : b.status) === "success") {
1014
+ const m = (g = d.events) == null ? void 0 : g.find((C) => C.type.includes("::slippage::SwapEvent"));
1015
+ m && this.emit("swap:swap-success", {
848
1016
  fromCoinType: e,
849
1017
  toCoinType: a,
850
1018
  fromAmount: t,
851
1019
  slippage: s,
852
- toAmount: Number(v.parsedJson.amount_out)
1020
+ toAmount: Number(m.parsedJson.amount_out)
853
1021
  }), this.walletClient.module("balance").updatePortfolio();
854
1022
  }
855
- return f;
1023
+ return d;
856
1024
  }
857
1025
  }
858
- class re extends T {
1026
+ class pe extends E {
859
1027
  constructor() {
860
1028
  super(...arguments), this.name = "haedal", this.defaultConfig = {
861
1029
  packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2",
862
1030
  configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
863
1031
  coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
864
- }, this.getApy = k(
865
- j(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
1032
+ }, this.getApy = X(
1033
+ I(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
866
1034
  );
867
1035
  }
868
1036
  /**
@@ -878,7 +1046,7 @@ class re extends T {
878
1046
  arguments: [
879
1047
  e.object("0x05"),
880
1048
  e.object(this.config.configId),
881
- R(a, e.object),
1049
+ k(a, e.object),
882
1050
  e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
883
1051
  ],
884
1052
  typeArguments: []
@@ -898,7 +1066,7 @@ class re extends T {
898
1066
  arguments: [
899
1067
  e.object("0x05"),
900
1068
  e.object(this.config.configId),
901
- R(a, e.object)
1069
+ k(a, e.object)
902
1070
  ],
903
1071
  typeArguments: []
904
1072
  });
@@ -911,21 +1079,21 @@ class re extends T {
911
1079
  * @param options Optional dry run
912
1080
  */
913
1081
  async stake(e, a) {
914
- var i, c, u;
1082
+ var l, c, u;
915
1083
  if (!this.walletClient)
916
1084
  throw new Error("Wallet client not found");
917
- const t = new d();
1085
+ const t = new h();
918
1086
  await this.walletClient.module("balance").waitForUpdate();
919
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = w(t, s.coins, {
1087
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = y(t, s.coins, {
920
1088
  balance: e,
921
1089
  useGasCoin: !0
922
- }), r = await this.stakePTB(t, n);
923
- t.transferObjects([r], this.walletClient.address);
924
- const l = await this.walletClient.signExecuteTransaction({
1090
+ }), o = await this.stakePTB(t, n);
1091
+ t.transferObjects([o], this.walletClient.address);
1092
+ const r = await this.walletClient.signExecuteTransaction({
925
1093
  transaction: t,
926
- dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1094
+ dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
927
1095
  });
928
- return !(a != null && a.dryRun) && ((u = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), l;
1096
+ return !(a != null && a.dryRun) && ((u = (c = r.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), r;
929
1097
  }
930
1098
  /**
931
1099
  * Unstake haSUI for SUI
@@ -934,47 +1102,47 @@ class re extends T {
934
1102
  * @param options Optional dry run
935
1103
  */
936
1104
  async unstake(e, a) {
937
- var i, c, u;
1105
+ var l, c, u;
938
1106
  if (!this.walletClient)
939
1107
  throw new Error("Wallet client not found");
940
1108
  await this.walletClient.module("balance").waitForUpdate();
941
- const t = new d(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = w(t, s.coins, {
1109
+ const t = new h(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = y(t, s.coins, {
942
1110
  balance: e
943
- }), r = await this.unstakePTB(t, n);
944
- t.transferObjects([r], this.walletClient.address);
945
- const l = await this.walletClient.signExecuteTransaction({
1111
+ }), o = await this.unstakePTB(t, n);
1112
+ t.transferObjects([o], this.walletClient.address);
1113
+ const r = await this.walletClient.signExecuteTransaction({
946
1114
  transaction: t,
947
- dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1115
+ dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
948
1116
  });
949
- return !(a != null && a.dryRun) && ((u = (c = l.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), l;
1117
+ return !(a != null && a.dryRun) && ((u = (c = r.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), r;
950
1118
  }
951
1119
  }
952
- const ce = {
1120
+ const Ee = {
953
1121
  /** Balance management module */
954
- balance: new ne(),
1122
+ balance: new be(),
955
1123
  /** Lending protocol module */
956
- lending: new se(),
1124
+ lending: new Te(),
957
1125
  /** Volo protocol module */
958
- volo: new le(),
1126
+ volo: new ve(),
959
1127
  /** DEX swapping module */
960
- swap: new ie(),
1128
+ swap: new Pe(),
961
1129
  /** Haedal protocol module */
962
- haedal: new re()
963
- }, ue = {
964
- url: F("mainnet")
1130
+ haedal: new pe()
1131
+ }, Re = {
1132
+ url: ee("mainnet")
965
1133
  };
966
- class ye {
1134
+ class We {
967
1135
  /**
968
1136
  * Creates a new wallet client instance
969
1137
  * @param options - Configuration options for the wallet client
970
1138
  */
971
1139
  constructor(e) {
972
- this.modules = ce, this.userConfigs = {}, this.events = _();
1140
+ this.modules = Ee, this.userConfigs = {}, this.events = ae();
973
1141
  const a = {
974
- ...ue,
1142
+ ...Re,
975
1143
  ...e.client
976
1144
  };
977
- a.transport = a.transport || new ae(a.url), this.client = new W(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
1145
+ a.transport = a.transport || new Ce(a.url), this.client = new te(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
978
1146
  if (t !== s.name)
979
1147
  throw new Error(`Module name ${t} does not match module name ${s.name}`);
980
1148
  s.install(this);
@@ -1004,7 +1172,7 @@ class ye {
1004
1172
  const { dryRun: a = !1, ...t } = e;
1005
1173
  if (a) {
1006
1174
  let s;
1007
- return e.transaction instanceof d ? (e.transaction.setSenderIfNotSet(this.address), s = await e.transaction.build({
1175
+ return e.transaction instanceof h ? (e.transaction.setSenderIfNotSet(this.address), s = await e.transaction.build({
1008
1176
  client: this.client
1009
1177
  })) : s = e.transaction, this.client.dryRunTransactionBlock({
1010
1178
  transactionBlock: s
@@ -1050,7 +1218,7 @@ class ye {
1050
1218
  return e in this.modules;
1051
1219
  }
1052
1220
  }
1053
- class ve extends U {
1221
+ class Ne extends Y {
1054
1222
  /**
1055
1223
  * Creates a new watch-only signer
1056
1224
  *
@@ -1114,7 +1282,7 @@ class ve extends U {
1114
1282
  return {};
1115
1283
  }
1116
1284
  }
1117
- class Pe extends U {
1285
+ class Ie extends Y {
1118
1286
  /**
1119
1287
  * Creates a new watch-only signer
1120
1288
  *
@@ -1167,8 +1335,8 @@ class Pe extends U {
1167
1335
  }
1168
1336
  }
1169
1337
  export {
1170
- ye as WalletClient,
1171
- ve as WatchSigner,
1172
- Pe as WebSigner
1338
+ We as WalletClient,
1339
+ Ne as WatchSigner,
1340
+ Ie as WebSigner
1173
1341
  };
1174
1342
  //# sourceMappingURL=index.esm.js.map