@naviprotocol/wallet-client 1.0.5-dev.4 → 1.1.3

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,19 +1,17 @@
1
- import { getFullnodeUrl as de, SuiClient as we } from "@mysten/sui/client";
2
- import he from "mitt";
3
- import fe from "axios";
4
- import { withSingleton as Q, getCoins as ge, mergeCoinsPTB as B, getPriceFeeds as K, updateOraclePricesPTB as $, filterPriceFeeds as q, getFlashLoanAsset as te, flashloanPTB as ae, depositCoinPTB as N, repayFlashLoanPTB as ne, borrowCoinPTB as se, withdrawCoinPTB as ie, repayCoinPTB as le, getPools as me, getPool as T, getHealthFactor as Ce, liquidatePTB as be, getUserAvailableLendingRewards as J, getUserClaimedRewardHistory as ye, claimLendingRewardsPTB as pe, getLendingState as Pe, createAccountCapPTB as Be, withCache as re, parseTxValue as F } from "@naviprotocol/lending";
5
- import R, { BigNumber as L } from "bignumber.js";
1
+ import { getFullnodeUrl as le, SuiClient as ie } from "@mysten/sui/client";
2
+ import re from "mitt";
3
+ import ce from "axios";
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
6
  import { normalizeStructTag as p } from "@mysten/sui/utils";
7
- import { Transaction as m } from "@mysten/sui/transactions";
8
- import { buildSwapPTBFromQuote as G, generateRefId as Te, getQuote as ve } from "@naviprotocol/astros-aggregator-sdk";
9
- import { SuilendClient as V, LENDING_MARKET_ID as Ee, LENDING_MARKET_TYPE as Y, parseReserve as Re, parseObligation as Se } from "@suilend/sdk";
10
- import { getCoinMetadataMap as Oe } from "@suilend/sui-fe";
11
- import { executeAuction as Ae } from "shio-sdk";
12
- import { Signer as oe } from "@mysten/sui/cryptography";
13
- const ce = fe.create({
7
+ import { Transaction as w } from "@mysten/sui/transactions";
8
+ import { buildSwapPTBFromQuote as $, generateRefId as Ce, getQuote as be } from "@naviprotocol/astros-aggregator-sdk";
9
+ import { executeAuction as ye } from "shio-sdk";
10
+ import { Signer as ne } from "@mysten/sui/cryptography";
11
+ const se = ce.create({
14
12
  timeout: 2e4
15
13
  });
16
- ce.interceptors.response.use(
14
+ se.interceptors.response.use(
17
15
  function(r) {
18
16
  if (r.data.err)
19
17
  throw new Error(r.data.err);
@@ -25,7 +23,7 @@ ce.interceptors.response.use(
25
23
  return Promise.reject(r);
26
24
  }
27
25
  );
28
- class xe {
26
+ class Be {
29
27
  /**
30
28
  * Creates a new custom transport instance
31
29
  *
@@ -44,7 +42,7 @@ class xe {
44
42
  * @returns Promise<T> - The response data from the RPC call
45
43
  */
46
44
  async request(e) {
47
- return this.requestId += 1, (await ce.post(this.rpcUrl, {
45
+ return this.requestId += 1, (await se.post(this.rpcUrl, {
48
46
  jsonrpc: "2.0",
49
47
  id: this.requestId,
50
48
  method: e.method,
@@ -64,7 +62,7 @@ class xe {
64
62
  throw new Error("subscribe not implemented.");
65
63
  }
66
64
  }
67
- class A {
65
+ class R {
68
66
  /**
69
67
  * Gets the current configuration for this module
70
68
  *
@@ -107,14 +105,14 @@ class A {
107
105
  this.walletClient = void 0;
108
106
  }
109
107
  }
110
- class O {
108
+ class E {
111
109
  /**
112
110
  * Creates a new user portfolio
113
111
  *
114
112
  * @param coins - Array of coin objects or existing portfolio to copy from
115
113
  */
116
114
  constructor(e) {
117
- if (e instanceof O)
115
+ if (e instanceof E)
118
116
  this.balances = JSON.parse(JSON.stringify(e.balances));
119
117
  else {
120
118
  const a = {};
@@ -123,7 +121,7 @@ class O {
123
121
  let n = a[s];
124
122
  n || (n = {
125
123
  coinType: s,
126
- amount: L(0),
124
+ amount: M(0),
127
125
  coins: []
128
126
  }, a[s] = n), n.coins.push(t), n.amount = n.amount.plus(t.balance);
129
127
  }), this.balances = a;
@@ -136,7 +134,7 @@ class O {
136
134
  * @returns UserCoinBalance object with coin type, total amount, and coin objects
137
135
  */
138
136
  getBalance(e) {
139
- return e = p(e), this.balances[e] || { coinType: e, amount: L(0), coins: [] };
137
+ return e = p(e), this.balances[e] || { coinType: e, amount: M(0), coins: [] };
140
138
  }
141
139
  /**
142
140
  * Gets all coin types in the portfolio
@@ -155,7 +153,7 @@ class O {
155
153
  balanceOf(e) {
156
154
  e = p(e);
157
155
  const a = this.getBalance(e);
158
- return (a == null ? void 0 : a.amount) || L(0);
156
+ return (a == null ? void 0 : a.amount) || M(0);
159
157
  }
160
158
  /**
161
159
  * Creates a deep copy of the portfolio
@@ -166,21 +164,22 @@ class O {
166
164
  * @returns New UserPortfolio instance with copied data
167
165
  */
168
166
  clone() {
169
- const e = JSON.parse(JSON.stringify(this.balances)), a = new O();
167
+ const e = JSON.parse(JSON.stringify(this.balances)), a = new E();
170
168
  return a.balances = e, a;
171
169
  }
172
170
  }
173
- class ke extends A {
171
+ class Pe extends R {
174
172
  constructor() {
175
173
  super(...arguments), this.name = "balance", this.defaultConfig = {
176
- coinPollingInterval: 6e3
177
- }, this.updatePortfolio = Q(async () => {
174
+ coinPollingInterval: 6e3,
175
+ disableCoinPolling: !1
176
+ }, this.updatePortfolio = L(async () => {
178
177
  if (!this.walletClient)
179
178
  throw new Error("Wallet client not found");
180
- this._coins = await ge(this.walletClient.address, {
179
+ this._coins = await oe(this.walletClient.address, {
181
180
  client: this.walletClient.client
182
- }), this._portfolio = new O(this._coins), this.emit("balance:portfolio-updated", {});
183
- }), this._coins = [], this._portfolio = new O(), this.pollingTimer = null, this._updatePromise = null;
181
+ }), this._portfolio = new E(this._coins), this.emit("balance:portfolio-updated", {});
182
+ }), this._coins = [], this._portfolio = new E(), this.pollingTimer = null, this._updatePromise = null;
184
183
  }
185
184
  /**
186
185
  * Gets the current coin objects from the wallet
@@ -231,26 +230,26 @@ class ke extends A {
231
230
  * @returns Transaction response or dry run response
232
231
  */
233
232
  async sendCoinBatch(e, a, t, s) {
234
- var w;
233
+ var d;
235
234
  if (!this.walletClient)
236
235
  throw new Error("Wallet client not found");
237
236
  if (a.length !== t.length)
238
237
  throw new Error("Recipients and amounts must have the same length");
239
238
  await this.waitForUpdate();
240
- const n = this.portfolio.getBalance(e), c = t.reduce((g, h) => g.plus(h), R(0));
239
+ const n = this.portfolio.getBalance(e), c = t.reduce((f, m) => f.plus(m), v(0));
241
240
  if (n.amount.lt(c))
242
241
  throw new Error("Insufficient balance");
243
- const i = new m();
244
- let l = i.gas;
245
- p(e) !== p("0x2::sui::SUI") && (l = B(i, n.coins, {
242
+ const l = new w();
243
+ let i = l.gas;
244
+ p(e) !== p("0x2::sui::SUI") && (i = B(l, n.coins, {
246
245
  balance: c.toNumber()
247
246
  }));
248
- const u = i.splitCoins(l, t);
249
- return a.forEach((g, h) => {
250
- i.transferObjects([u[h]], g);
247
+ const o = l.splitCoins(i, t);
248
+ return a.forEach((f, m) => {
249
+ l.transferObjects([o[m]], f);
251
250
  }), await this.walletClient.signExecuteTransaction({
252
- transaction: i,
253
- dryRun: (w = s == null ? void 0 : s.dryRun) != null ? w : !1
251
+ transaction: l,
252
+ dryRun: (d = s == null ? void 0 : s.dryRun) != null ? d : !1
254
253
  });
255
254
  }
256
255
  /**
@@ -282,9 +281,9 @@ class ke extends A {
282
281
  if (e.length !== a.length)
283
282
  throw new Error("Objects and recipients must have the same length");
284
283
  await this.waitForUpdate();
285
- const s = new m();
286
- return e.forEach((i, l) => {
287
- s.transferObjects([s.object(i)], a[l]);
284
+ const s = new w();
285
+ return e.forEach((l, i) => {
286
+ s.transferObjects([s.object(l)], a[i]);
288
287
  }), await this.walletClient.signExecuteTransaction({
289
288
  transaction: s,
290
289
  dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
@@ -298,6 +297,8 @@ class ke extends A {
298
297
  */
299
298
  async startPolling() {
300
299
  try {
300
+ if (this.config.disableCoinPolling)
301
+ return;
301
302
  await this.updatePortfolio();
302
303
  } catch (e) {
303
304
  console.error(e);
@@ -326,275 +327,184 @@ class ke extends A {
326
327
  super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
327
328
  }
328
329
  }
329
- async function X(r, e, a, t) {
330
- var x, k, S;
330
+ const Te = 27;
331
+ function pe(r, e = 2) {
332
+ return r ? new v(r.toString()).shiftedBy(-1 * Te).multipliedBy(100).decimalPlaces(e, v.ROUND_DOWN).toFixed(e) : "0.00";
333
+ }
334
+ async function D(r, e, a, t) {
335
+ var S, O;
331
336
  if (!this.walletClient)
332
337
  throw new Error("Wallet client not found");
333
338
  await this.walletClient.balance.updatePortfolio();
334
- const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), i = this.walletClient.address, l = (x = t == null ? void 0 : t.protocol) != null ? x : "navi", u = await this.getProtocol(l);
335
- if (!u)
336
- throw new Error(`Protocol ${l} not found`);
337
- const o = await u.getPool(s.coinType);
339
+ 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;
338
340
  if (console.log("migrateBetweenSupplyPTB", {
339
- fromPoolLending: o
340
- }), l === "navi" && o.supplyBalance === 0)
341
+ lendingState: c,
342
+ fromPoolLending: l,
343
+ fromPool: s,
344
+ toPool: n,
345
+ address: i
346
+ }), !l || l.supplyBalance === "0")
341
347
  throw new Error("No supply balance");
342
- if (t != null && t.amount && t.amount > o.supplyBalance)
348
+ if (t != null && t.amount && t.amount > Number(l.supplyBalance))
343
349
  throw new Error("Amount is less than supply balance");
344
- const w = await K(), g = await Promise.all([s, n]);
345
- await $(
350
+ const o = await Q(), u = await Promise.all([s, n]);
351
+ await q(
346
352
  r,
347
- q(w, {
353
+ K(o, {
348
354
  lendingState: c,
349
- pools: g
355
+ pools: u
350
356
  })
351
357
  );
352
- const h = await te(n, {
358
+ const d = await V(n, {
353
359
  env: this.config.env
354
360
  });
355
- if (!h)
361
+ if (!d)
356
362
  throw new Error(`${n.token.symbol} pool not support flashloan`);
357
- const b = (k = t == null ? void 0 : t.slippage) != null ? k : 5e-3, d = (S = t == null ? void 0 : t.amount) != null ? S : Number(o.supplyBalance), f = await this.walletClient.swap.getQuote(
363
+ 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(
358
364
  s.suiCoinType,
359
365
  n.suiCoinType,
360
- d
361
- ), y = Number(f.amount_out);
362
- if (y <= 0)
366
+ m
367
+ ), C = Number(b.amount_out);
368
+ if (C <= 0)
363
369
  throw new Error("The amount of swapAmountOut must be greater than 0.");
364
- const C = Math.floor(y * (1 - b)), P = Math.floor(C / (1 + h.flashloanFee));
365
- if (P <= 0)
370
+ const y = Math.floor(C * (1 - f)), g = Math.floor(y / (1 + d.flashloanFee));
371
+ if (g <= 0)
366
372
  throw new Error("The calculated borrow amount must be positive.");
367
- const [v, E] = await ae(r, n, P), [_] = r.moveCall({
373
+ const [h, P] = await X(r, n, g), [F] = r.moveCall({
368
374
  target: "0x2::coin::from_balance",
369
- arguments: [v],
375
+ arguments: [h],
370
376
  typeArguments: [n.suiCoinType]
371
377
  });
372
- await N(r, n, _, {
373
- amount: P
378
+ await A(r, n, F, {
379
+ amount: g
374
380
  });
375
- const j = await u.withdrawCoinPTB(
376
- r,
377
- s.token.coinType,
378
- d
379
- ), I = await G(
381
+ const j = await Y(r, s, m), _ = await $(
380
382
  i,
381
383
  r,
382
- C,
384
+ y,
383
385
  j,
384
- f
386
+ b
385
387
  ), U = r.moveCall({
386
388
  target: "0x2::coin::into_balance",
387
- arguments: [I],
389
+ arguments: [_],
388
390
  typeArguments: [n.suiCoinType]
389
- }), [W] = await ne(r, n, E, U), [M] = r.moveCall({
391
+ }), [W] = await Z(r, n, P, U), [N] = r.moveCall({
390
392
  target: "0x2::coin::from_balance",
391
393
  arguments: [W],
392
394
  typeArguments: [n.suiCoinType]
393
395
  });
394
- return await N(r, n, M), r;
396
+ return await A(r, n, N), r;
395
397
  }
396
- async function Z(r, e, a, t) {
397
- var S, H, D;
398
+ async function J(r, e, a, t) {
399
+ var x, G;
398
400
  if (!this.walletClient)
399
401
  throw new Error("Wallet client not found");
400
402
  await this.walletClient.balance.updatePortfolio();
401
- const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a), i = await this.getLendingState(), l = (S = t == null ? void 0 : t.protocol) != null ? S : "navi", u = await this.getProtocol(l);
402
- if (!u)
403
- throw new Error(`Protocol ${l} not found`);
404
- const o = await u.getPool(n.coinType);
403
+ const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a), l = await this.getLendingState(), i = l.find((I) => I.pool.id === n.id);
405
404
  if (console.log("migrateBetweenBorrowPTB", {
406
- fromPoolLending: o
407
- }), o.borrowBalance === 0)
405
+ lendingState: l,
406
+ fromPoolLending: i,
407
+ fromPool: n,
408
+ toPool: c,
409
+ address: s
410
+ }), !i || i.borrowBalance === "0")
408
411
  throw new Error("No borrow balance");
409
- if (t != null && t.amount && t.amount > o.borrowBalance)
412
+ if (t != null && t.amount && t.amount > Number(i.borrowBalance))
410
413
  throw new Error("Amount is less than borrow balance");
411
- const w = await K(), g = await Promise.all([n, c]);
412
- await $(
414
+ const o = await Q(), u = await Promise.all([n, c]);
415
+ await q(
413
416
  r,
414
- q(w, {
415
- lendingState: i,
416
- pools: g
417
+ K(o, {
418
+ lendingState: l,
419
+ pools: u
417
420
  })
418
421
  );
419
- let h = (H = t == null ? void 0 : t.amount) != null ? H : Number(o.borrowBalance);
420
- if (Number(o.borrowBalance) === h) {
421
- const ue = o.borrowAPR / 100;
422
- h = Math.ceil(
423
- new R(h).multipliedBy(ue * (60 * 3) / (365 * 24 * 3600)).plus(new R(1).shiftedBy(-n.token.decimals)).plus(h).toNumber()
422
+ let d = (x = t == null ? void 0 : t.amount) != null ? x : Number(i.borrowBalance);
423
+ if (Number(i.borrowBalance) === d) {
424
+ const I = parseFloat(pe(n.currentBorrowRate, 8)) / 100;
425
+ d = Math.ceil(
426
+ new v(d).multipliedBy(I * (60 * 3) / (365 * 24 * 3600)).plus(new v(1).shiftedBy(-n.token.decimals)).plus(d).toNumber()
424
427
  );
425
428
  }
426
- const b = await te(n, {
429
+ const f = await V(n, {
427
430
  env: this.config.env
428
431
  });
429
- if (!b)
432
+ if (!f)
430
433
  throw new Error(`${n.token.symbol} pool not support flashloan`);
431
434
  if (!this.walletClient)
432
435
  throw new Error("Wallet client not found");
433
- const d = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, f = Math.ceil(h * (1 + b.flashloanFee)), y = f, C = await this.walletClient.swap.getQuote(
436
+ 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(
434
437
  n.suiCoinType,
435
438
  c.suiCoinType,
436
- y
439
+ C
437
440
  );
438
- let P = 1 + d, v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
441
+ let g = 1 + m, h = Math.ceil(Number(y.amount_out) * g), P = await this.walletClient.swap.getQuote(
439
442
  c.suiCoinType,
440
443
  n.suiCoinType,
441
- v
444
+ h
442
445
  );
443
- for (; Number(E.amount_out) < y; )
444
- P = P * Math.max(y / Number(E.amount_out), 1.001), v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
446
+ for (; Number(P.amount_out) < C; )
447
+ 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(
445
448
  c.suiCoinType,
446
449
  n.suiCoinType,
447
- v
450
+ h
448
451
  );
449
- const [_, j] = await ae(r, n, h), [I] = r.moveCall({
452
+ const [F, j] = await X(r, n, d), [_] = r.moveCall({
450
453
  target: "0x2::coin::from_balance",
451
- arguments: [_],
454
+ arguments: [F],
452
455
  typeArguments: [n.suiCoinType]
453
456
  });
454
- await u.repayCoinPTB(r, n.token.coinType, I, h);
455
- const U = await se(r, c, v), W = await G(
457
+ await ee(r, n, _, {
458
+ amount: d
459
+ });
460
+ const U = await te(r, c, h), W = await $(
456
461
  s,
457
462
  r,
458
- f,
463
+ b,
459
464
  U,
460
- E
461
- ), M = r.moveCall({
465
+ P
466
+ ), N = r.moveCall({
462
467
  target: "0x2::coin::into_balance",
463
468
  arguments: [W],
464
469
  typeArguments: [n.suiCoinType]
465
- }), [x] = await ne(r, n, j, M), [k] = r.moveCall({
470
+ }), [S] = await Z(r, n, j, N), [O] = r.moveCall({
466
471
  target: "0x2::coin::from_balance",
467
- arguments: [x],
472
+ arguments: [S],
468
473
  typeArguments: [n.suiCoinType]
469
474
  });
470
- return r.transferObjects([k], s), r;
475
+ return r.transferObjects([O], s), r;
471
476
  }
472
- async function ee(r, e, a, t) {
473
- var u, o;
477
+ async function z(r, e, a, t) {
478
+ var o, u;
474
479
  if (!this.walletClient)
475
480
  throw new Error("Wallet client not found");
476
481
  await this.walletClient.balance.updatePortfolio(), this.walletClient.address;
477
482
  const s = await this.getPool(a), n = this.walletClient.balance.portfolio.getBalance(e);
478
483
  if (n.amount.eq(0))
479
484
  throw new Error(`No balance of ${e}`);
480
- if (console.log("migrateBalanceToSupplyPTB", {
481
- balance: n.amount.toNumber()
482
- }), t != null && t.amount && n.amount.lt(t.amount))
483
- throw new Error("Amount is greater than balance");
484
- const c = (u = t == null ? void 0 : t.amount) != null ? u : n.amount.toNumber(), i = (o = t == null ? void 0 : t.slippage) != null ? o : 5e-3;
485
- let l = await B(r, n.coins, {
485
+ if (t != null && t.amount && n.amount.lt(t.amount))
486
+ throw new Error("Amount is less than balance");
487
+ 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;
488
+ let i = await B(r, n.coins, {
486
489
  balance: c,
487
490
  useGasCoin: !0
488
491
  });
489
492
  if (p(e) !== p(s.suiCoinType)) {
490
- const w = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
491
- l = await this.walletClient.swap.buildSwapPTBFromQuote(
493
+ const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
494
+ i = await this.walletClient.swap.buildSwapPTBFromQuote(
492
495
  r,
493
- w,
494
- l,
495
- i
496
- );
497
- }
498
- return await N(r, s, l), r;
499
- }
500
- class Ne {
501
- constructor(e) {
502
- this.name = "navi", this.walletClient = e;
503
- }
504
- async getPool(e) {
505
- const a = await this.walletClient.lending.getPool(e), s = (await this.walletClient.lending.getLendingState()).find(
506
- (i) => i.pool.suiCoinType === p(e)
507
- ), n = s ? new R(s.supplyBalance).toNumber() : 0, c = s ? new R(s.borrowBalance).toNumber() : 0;
508
- return {
509
- supplyBalance: n,
510
- borrowBalance: c,
511
- borrowAPR: parseFloat(a.borrowIncentiveApyInfo.apy)
512
- };
513
- }
514
- async depositCoinPTB(e, a, t, s) {
515
- throw new Error("Not implemented");
516
- }
517
- async withdrawCoinPTB(e, a, t) {
518
- return ie(e, a, t);
519
- }
520
- async borrowCoinPTB(e, a, t) {
521
- throw new Error("Not implemented");
522
- }
523
- async repayCoinPTB(e, a, t, s) {
524
- le(e, a, t, { amount: s });
525
- }
526
- }
527
- class z {
528
- constructor(e, a, t) {
529
- this.name = "suilend", this.walletClient = e, this.obligationOwnerCap = a, this.suilendClient = t;
530
- }
531
- static async create(e) {
532
- const [a, t] = await Promise.all([
533
- V.initialize(Ee, Y, e.client),
534
- V.getObligationOwnerCaps(
535
- e.address,
536
- [Y],
537
- e.client
538
- )
539
- ]);
540
- if (t.length === 0)
541
- throw new Error("No existing obligations found for wallet address: " + e.address);
542
- return new z(e, t[0], a);
543
- }
544
- async getPool(e) {
545
- var h, b;
546
- const a = p(e), t = this.suilendClient.lendingMarket.reserves, s = /* @__PURE__ */ new Set();
547
- t.forEach((d) => {
548
- s.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((f) => {
549
- f && s.add(p(f.coinType.name));
550
- }), d.borrowsPoolRewardManager.poolRewards.forEach((f) => {
551
- f && s.add(p(f.coinType.name));
552
- });
553
- });
554
- const n = await Oe(Array.from(s)), i = t.map((d) => Re(d, n)).reduce(
555
- (d, f) => (d[f.coinType] = f, d),
556
- {}
557
- ), l = await this.suilendClient.getObligation(
558
- this.obligationOwnerCap.obligationId
559
- ), u = Se(l, i), o = u.deposits.find((d) => d.coinType === a), w = u.borrows.find((d) => d.coinType === a), g = n[a].decimals;
560
- return {
561
- supplyBalance: (h = o == null ? void 0 : o.depositedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? h : 0,
562
- borrowBalance: (b = w == null ? void 0 : w.borrowedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? b : 0,
563
- borrowAPR: i[a].borrowAprPercent.toNumber()
564
- };
565
- }
566
- async depositCoinPTB(e, a, t, s) {
567
- throw new Error("Not implemented");
568
- }
569
- async withdrawCoinPTB(e, a, t) {
570
- return await this.suilendClient.withdraw(
571
- this.obligationOwnerCap.id,
572
- this.obligationOwnerCap.obligationId,
573
- a,
574
- t.toString(),
575
- e
496
+ d,
497
+ i,
498
+ l
576
499
  );
577
500
  }
578
- async borrowCoinPTB(e, a, t) {
579
- throw new Error("Not implemented");
580
- }
581
- async repayCoinPTB(e, a, t, s) {
582
- this.suilendClient.repay(this.obligationOwnerCap.obligationId, a, t, e), e.transferObjects([t], e.pure.address(this.walletClient.address));
583
- }
501
+ return await A(r, s, i), r;
584
502
  }
585
- class Fe extends A {
503
+ class ve extends R {
586
504
  constructor() {
587
505
  super(), this.name = "lending", this.defaultConfig = {
588
- env: "prod",
589
- protocols: []
590
- }, this._protocols = [], this.migrateBetweenSupplyPTB = X, this.migrateBetweenBorrowPTB = Z, this.migrateBalanceToSupplyPTB = ee, this.migrateBetweenSupplyPTB = X.bind(this), this.migrateBetweenBorrowPTB = Z.bind(this), this.migrateBalanceToSupplyPTB = ee.bind(this);
591
- }
592
- /** Get protocols (either from internal storage or config) */
593
- get protocols() {
594
- return this._protocols.length > 0 ? this._protocols : this.config.protocols;
595
- }
596
- async getProtocol(e) {
597
- return (!this.protocols || this.protocols.length === 0) && await this.initializeProtocols(), this.protocols.find((a) => a.name === e);
506
+ env: "prod"
507
+ }, this.migrateBetweenSupplyPTB = D, this.migrateBetweenBorrowPTB = J, this.migrateBalanceToSupplyPTB = z, this.migrateBetweenSupplyPTB = D.bind(this), this.migrateBetweenBorrowPTB = J.bind(this), this.migrateBalanceToSupplyPTB = z.bind(this);
598
508
  }
599
509
  /**
600
510
  * Gets all available lending pools
@@ -603,7 +513,7 @@ class Fe extends A {
603
513
  * @returns Array of pool information
604
514
  */
605
515
  async getPools(e) {
606
- return await me({
516
+ return await ue({
607
517
  env: this.config.env,
608
518
  ...e
609
519
  });
@@ -630,30 +540,30 @@ class Fe extends A {
630
540
  * @returns Transaction response or dry run response
631
541
  */
632
542
  async deposit(e, a, t) {
633
- var u, o, w;
543
+ var o, u, d;
634
544
  if (!this.walletClient)
635
545
  throw new Error("Wallet client not found");
636
546
  const s = await T(e, {
637
547
  env: this.config.env
638
548
  });
639
549
  await this.walletClient.module("balance").waitForUpdate();
640
- const n = new m(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, c.coins, {
550
+ const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = B(n, c.coins, {
641
551
  balance: a,
642
552
  useGasCoin: !0
643
553
  });
644
- await N(n, s, i, {
554
+ await A(n, s, l, {
645
555
  env: this.config.env,
646
556
  amount: a,
647
557
  accountCap: t == null ? void 0 : t.accountCap
648
558
  });
649
- const l = await this.walletClient.signExecuteTransaction({
559
+ const i = await this.walletClient.signExecuteTransaction({
650
560
  transaction: n,
651
- dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
561
+ dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
652
562
  });
653
- return !(t != null && t.dryRun) && ((w = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:deposit-success", {
563
+ return !(t != null && t.dryRun) && ((d = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : d.status) === "success" && (this.emit("lending:deposit-success", {
654
564
  identifier: e,
655
565
  amount: a
656
- }), this.walletClient.module("balance").updatePortfolio()), l;
566
+ }), this.walletClient.module("balance").updatePortfolio()), i;
657
567
  }
658
568
  /**
659
569
  * Withdraws coins from a lending pool
@@ -664,26 +574,26 @@ class Fe extends A {
664
574
  * @returns Transaction response or dry run response
665
575
  */
666
576
  async withdraw(e, a, t) {
667
- var l, u, o;
577
+ var i, o, u;
668
578
  if (!this.walletClient)
669
579
  throw new Error("Wallet client not found");
670
580
  const s = await T(e, {
671
581
  env: this.config.env
672
- }), n = new m();
582
+ }), n = new w();
673
583
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
674
- const c = await ie(n, s, a, {
584
+ const c = await Y(n, s, a, {
675
585
  env: this.config.env,
676
586
  accountCap: t == null ? void 0 : t.accountCap
677
587
  });
678
588
  n.transferObjects([c], this.walletClient.address);
679
- const i = await this.walletClient.signExecuteTransaction({
589
+ const l = await this.walletClient.signExecuteTransaction({
680
590
  transaction: n,
681
- dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
591
+ dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
682
592
  });
683
- return !(t != null && t.dryRun) && ((o = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:withdraw-success", {
593
+ return !(t != null && t.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:withdraw-success", {
684
594
  identifier: e,
685
595
  amount: a
686
- }), this.walletClient.module("balance").updatePortfolio()), i;
596
+ }), this.walletClient.module("balance").updatePortfolio()), l;
687
597
  }
688
598
  /**
689
599
  * Borrows coins from a lending pool
@@ -694,26 +604,26 @@ class Fe extends A {
694
604
  * @returns Transaction response or dry run response
695
605
  */
696
606
  async borrow(e, a, t) {
697
- var l, u, o;
607
+ var i, o, u;
698
608
  if (!this.walletClient)
699
609
  throw new Error("Wallet client not found");
700
610
  const s = await T(e, {
701
611
  env: this.config.env
702
- }), n = new m();
612
+ }), n = new w();
703
613
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
704
- const c = await se(n, s, a, {
614
+ const c = await te(n, s, a, {
705
615
  env: this.config.env,
706
616
  accountCap: t == null ? void 0 : t.accountCap
707
617
  });
708
618
  n.transferObjects([c], this.walletClient.address);
709
- const i = await this.walletClient.signExecuteTransaction({
619
+ const l = await this.walletClient.signExecuteTransaction({
710
620
  transaction: n,
711
- dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
621
+ dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
712
622
  });
713
- return !(t != null && t.dryRun) && ((o = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:borrow-success", {
623
+ return !(t != null && t.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:borrow-success", {
714
624
  identifier: e,
715
625
  amount: a
716
- }), this.walletClient.module("balance").updatePortfolio()), i;
626
+ }), this.walletClient.module("balance").updatePortfolio()), l;
717
627
  }
718
628
  /**
719
629
  * Repays borrowed coins to a lending pool
@@ -724,29 +634,29 @@ class Fe extends A {
724
634
  * @returns Transaction response or dry run response
725
635
  */
726
636
  async repay(e, a, t) {
727
- var u, o, w;
637
+ var o, u, d;
728
638
  if (!this.walletClient)
729
639
  throw new Error("Wallet client not found");
730
640
  await this.walletClient.module("balance").waitForUpdate();
731
641
  const s = await T(e, {
732
642
  env: this.config.env
733
- }), n = new m(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, c.coins, {
643
+ }), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = B(n, c.coins, {
734
644
  balance: a,
735
645
  useGasCoin: !0
736
646
  });
737
- await le(n, s, i, {
647
+ await ee(n, s, l, {
738
648
  env: this.config.env,
739
649
  amount: a,
740
650
  accountCap: t == null ? void 0 : t.accountCap
741
651
  });
742
- const l = await this.walletClient.signExecuteTransaction({
652
+ const i = await this.walletClient.signExecuteTransaction({
743
653
  transaction: n,
744
- dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
654
+ dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
745
655
  });
746
- return !(t != null && t.dryRun) && ((w = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:repay-success", {
656
+ return !(t != null && t.dryRun) && ((d = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : d.status) === "success" && (this.emit("lending:repay-success", {
747
657
  identifier: e,
748
658
  amount: a
749
- }), this.walletClient.module("balance").updatePortfolio()), l;
659
+ }), this.walletClient.module("balance").updatePortfolio()), i;
750
660
  }
751
661
  /**
752
662
  * Gets the current health factor for the user
@@ -757,7 +667,7 @@ class Fe extends A {
757
667
  if (!this.walletClient)
758
668
  throw new Error("Wallet client not found");
759
669
  const e = this.walletClient.address;
760
- return await Ce(e, {
670
+ return await de(e, {
761
671
  env: this.config.env,
762
672
  client: this.walletClient.client
763
673
  });
@@ -773,45 +683,45 @@ class Fe extends A {
773
683
  * @returns Transaction response or dry run response
774
684
  */
775
685
  async liquidate(e, a, t, s, n) {
776
- var f, y, C;
686
+ var y, g, h;
777
687
  if (!this.walletClient)
778
688
  throw new Error("Wallet client not found");
779
689
  const c = await T(e, {
780
690
  env: this.config.env
781
- }), i = await T(t, {
691
+ }), l = await T(t, {
782
692
  env: this.config.env
783
- }), l = new m(), u = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), o = B(l, u.coins, {
693
+ }), i = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = B(i, o.coins, {
784
694
  balance: a,
785
695
  useGasCoin: !0
786
- }), [w, g] = await be(
787
- l,
788
- c,
789
- o,
696
+ }), [d, f] = await we(
790
697
  i,
698
+ c,
699
+ u,
700
+ l,
791
701
  s,
792
702
  {
793
703
  env: this.config.env
794
704
  }
795
- ), [h] = l.moveCall({
705
+ ), [m] = i.moveCall({
796
706
  target: "0x2::coin::from_balance",
797
- arguments: [w],
798
- typeArguments: [i.suiCoinType]
799
- }), [b] = l.moveCall({
707
+ arguments: [d],
708
+ typeArguments: [l.suiCoinType]
709
+ }), [b] = i.moveCall({
800
710
  target: "0x2::coin::from_balance",
801
- arguments: [g],
711
+ arguments: [f],
802
712
  typeArguments: [c.suiCoinType]
803
713
  });
804
- l.transferObjects([h, b], this.walletClient.address);
805
- const d = await this.walletClient.signExecuteTransaction({
806
- transaction: l,
807
- dryRun: (f = n == null ? void 0 : n.dryRun) != null ? f : !1
714
+ i.transferObjects([m, b], this.walletClient.address);
715
+ const C = await this.walletClient.signExecuteTransaction({
716
+ transaction: i,
717
+ dryRun: (y = n == null ? void 0 : n.dryRun) != null ? y : !1
808
718
  });
809
- return !(n != null && n.dryRun) && ((C = (y = d.effects) == null ? void 0 : y.status) == null ? void 0 : C.status) === "success" && (this.emit("lending:liquidate-success", {
719
+ 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", {
810
720
  payIdentifier: e,
811
721
  payAmount: a,
812
722
  collateralIdentifier: t,
813
723
  liquidationAddress: s
814
- }), this.walletClient.module("balance").updatePortfolio()), d;
724
+ }), this.walletClient.module("balance").updatePortfolio()), C;
815
725
  }
816
726
  /**
817
727
  * Gets the available lending rewards for the current user.
@@ -823,7 +733,7 @@ class Fe extends A {
823
733
  async getAvailableRewards(e) {
824
734
  if (!this.walletClient)
825
735
  throw new Error("Wallet client not found");
826
- return J(this.walletClient.address, {
736
+ return H(this.walletClient.address, {
827
737
  ...e,
828
738
  env: this.config.env
829
739
  });
@@ -838,7 +748,7 @@ class Fe extends A {
838
748
  async getClaimedRewardHistory(e) {
839
749
  if (!this.walletClient)
840
750
  throw new Error("Wallet client not found");
841
- return ye(this.walletClient.address, {
751
+ return he(this.walletClient.address, {
842
752
  ...e
843
753
  });
844
754
  }
@@ -849,13 +759,13 @@ class Fe extends A {
849
759
  * @returns Transaction response or dry run response
850
760
  */
851
761
  async claimAllRewards(e) {
852
- var n, c, i;
762
+ var n, c, l;
853
763
  if (!this.walletClient)
854
764
  throw new Error("Wallet client not found");
855
- const a = new m(), t = await J(this.walletClient.address, {
765
+ const a = new w(), t = await H(this.walletClient.address, {
856
766
  env: this.config.env
857
767
  });
858
- await pe(a, t, {
768
+ await fe(a, t, {
859
769
  env: this.config.env,
860
770
  accountCap: e == null ? void 0 : e.accountCap
861
771
  });
@@ -863,20 +773,20 @@ class Fe extends A {
863
773
  transaction: a,
864
774
  dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
865
775
  });
866
- return !(e != null && e.dryRun) && ((i = (c = s.effects) == null ? void 0 : c.status) == null ? void 0 : i.status) === "success" && (this.emit("lending:claim-rewards-success", {
776
+ return !(e != null && e.dryRun) && ((l = (c = s.effects) == null ? void 0 : c.status) == null ? void 0 : l.status) === "success" && (this.emit("lending:claim-rewards-success", {
867
777
  rewards: t
868
778
  }), this.walletClient.module("balance").updatePortfolio()), s;
869
779
  }
870
780
  async updateOraclePTB(e, a) {
871
- const t = await K({
781
+ const t = await Q({
872
782
  env: this.config.env
873
783
  }), s = await this.getLendingState({
874
784
  cacheTime: 60 * 1e3
875
- }), n = q(t, {
785
+ }), n = K(t, {
876
786
  lendingState: s,
877
787
  pools: a
878
788
  });
879
- await $(e, n, {
789
+ await q(e, n, {
880
790
  env: this.config.env,
881
791
  updatePythPriceFeeds: !0
882
792
  });
@@ -892,7 +802,7 @@ class Fe extends A {
892
802
  var s;
893
803
  if (!this.walletClient)
894
804
  throw new Error("Wallet client not found");
895
- const a = new m();
805
+ const a = new w();
896
806
  return await this.updateOraclePTB(a, e == null ? void 0 : e.pools), await this.walletClient.signExecuteTransaction({
897
807
  transaction: a,
898
808
  dryRun: (s = e == null ? void 0 : e.dryRun) != null ? s : !1
@@ -907,7 +817,7 @@ class Fe extends A {
907
817
  async getLendingState(e) {
908
818
  if (!this.walletClient)
909
819
  throw new Error("Wallet client not found");
910
- return await Pe(this.walletClient.address, {
820
+ return await ge(this.walletClient.address, {
911
821
  env: this.config.env,
912
822
  ...e,
913
823
  client: this.walletClient.client
@@ -923,36 +833,22 @@ class Fe extends A {
923
833
  var n;
924
834
  if (!this.walletClient)
925
835
  throw new Error("Wallet client not found");
926
- const a = new m(), t = await Be(a);
836
+ const a = new w(), t = await me(a);
927
837
  return a.transferObjects([t], this.walletClient.address), await this.walletClient.signExecuteTransaction({
928
838
  transaction: a,
929
839
  dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
930
840
  });
931
841
  }
932
- async initializeProtocols() {
933
- if (!this.walletClient) {
934
- console.warn("Wallet client not available during protocol initialization");
935
- return;
936
- }
937
- const e = [];
938
- e.push(new Ne(this.walletClient));
939
- try {
940
- e.push(await z.create(this.walletClient));
941
- } catch (a) {
942
- console.warn("Failed to initialize SuilendProtocol:", a);
943
- }
944
- this._protocols = e;
945
- }
946
842
  }
947
- class _e extends A {
843
+ class Ee extends R {
948
844
  constructor() {
949
845
  super(...arguments), this.name = "volo", this.defaultConfig = {
950
846
  packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
951
847
  poolId: "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5",
952
848
  metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
953
849
  coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
954
- }, this.getStats = re(
955
- Q(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
850
+ }, this.getStats = ae(
851
+ L(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
956
852
  );
957
853
  }
958
854
  /**
@@ -969,7 +865,7 @@ class _e extends A {
969
865
  e.object(this.config.poolId),
970
866
  e.object(this.config.metadataId),
971
867
  e.object("0x05"),
972
- F(a, e.object)
868
+ k(a, e.object)
973
869
  ],
974
870
  typeArguments: []
975
871
  });
@@ -989,7 +885,7 @@ class _e extends A {
989
885
  e.object(this.config.poolId),
990
886
  e.object(this.config.metadataId),
991
887
  e.object("0x05"),
992
- F(a, e.object)
888
+ k(a, e.object)
993
889
  ],
994
890
  typeArguments: []
995
891
  });
@@ -1004,25 +900,25 @@ class _e extends A {
1004
900
  * @throws Error if wallet client not found or stake amount is too low
1005
901
  */
1006
902
  async stake(e, a) {
1007
- var l, u, o;
903
+ var i, o, u;
1008
904
  if (!this.walletClient)
1009
905
  throw new Error("Wallet client not found");
1010
906
  if (e < 1e9)
1011
907
  throw new Error("Stake amount should be greater than 1Sui");
1012
- const t = new m();
908
+ const t = new w();
1013
909
  await this.walletClient.module("balance").waitForUpdate();
1014
910
  const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1015
911
  balance: e,
1016
912
  useGasCoin: !0
1017
913
  }), c = await this.stakePTB(t, n);
1018
914
  t.transferObjects([c], this.walletClient.address);
1019
- const i = await this.walletClient.signExecuteTransaction({
915
+ const l = await this.walletClient.signExecuteTransaction({
1020
916
  transaction: t,
1021
- dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
917
+ dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1022
918
  });
1023
- return !(a != null && a.dryRun) && ((o = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:stake-success", {
919
+ return !(a != null && a.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:stake-success", {
1024
920
  suiAmount: e
1025
- }), this.walletClient.module("balance").updatePortfolio()), i;
921
+ }), this.walletClient.module("balance").updatePortfolio()), l;
1026
922
  }
1027
923
  /**
1028
924
  * Unstake vSUI tokens to receive SUI tokens
@@ -1033,26 +929,26 @@ class _e extends A {
1033
929
  * @throws Error if wallet client not found or unstake amount is too low
1034
930
  */
1035
931
  async unstake(e, a) {
1036
- var l, u, o;
932
+ var i, o, u;
1037
933
  if (!this.walletClient)
1038
934
  throw new Error("Wallet client not found");
1039
935
  if (e < 1e9)
1040
936
  throw new Error("Unstake amount should >= 1vSui");
1041
937
  await this.walletClient.module("balance").waitForUpdate();
1042
- const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
938
+ const t = new w(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
1043
939
  balance: e
1044
940
  }), c = await this.unstakePTB(t, n);
1045
941
  t.transferObjects([c], this.walletClient.address);
1046
- const i = await this.walletClient.signExecuteTransaction({
942
+ const l = await this.walletClient.signExecuteTransaction({
1047
943
  transaction: t,
1048
- dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
944
+ dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1049
945
  });
1050
- return !(a != null && a.dryRun) && ((o = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:unstake-success", {
946
+ return !(a != null && a.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:unstake-success", {
1051
947
  vSuiAmount: e
1052
- }), this.walletClient.module("balance").updatePortfolio()), i;
948
+ }), this.walletClient.module("balance").updatePortfolio()), l;
1053
949
  }
1054
950
  }
1055
- class je extends A {
951
+ class Re extends R {
1056
952
  constructor() {
1057
953
  super(...arguments), this.name = "swap", this.defaultConfig = {
1058
954
  apiKey: "",
@@ -1069,7 +965,7 @@ class je extends A {
1069
965
  * @returns Referral ID if API key is configured, otherwise 0
1070
966
  */
1071
967
  get referral() {
1072
- return this.config.apiKey ? Te(this.config.apiKey) : 0;
968
+ return this.config.apiKey ? Ce(this.config.apiKey) : 0;
1073
969
  }
1074
970
  /**
1075
971
  * Get the swap options
@@ -1091,7 +987,7 @@ class je extends A {
1091
987
  * @returns A promise that resolves with the quote
1092
988
  */
1093
989
  async getQuote(e, a, t) {
1094
- return ve(e, a, t, this.config.apiKey, this.swapOptions);
990
+ return be(e, a, t, this.config.apiKey, this.swapOptions);
1095
991
  }
1096
992
  /**
1097
993
  * Builds a swap transaction from a quote
@@ -1104,8 +1000,8 @@ class je extends A {
1104
1000
  async buildSwapPTBFromQuote(e, a, t, s) {
1105
1001
  if (!this.walletClient)
1106
1002
  throw new Error("Wallet client not found");
1107
- const n = new R(a.amount_out).multipliedBy(1 - s).toFixed(0);
1108
- return await G(
1003
+ const n = new v(a.amount_out).multipliedBy(1 - s).toFixed(0);
1004
+ return await $(
1109
1005
  this.walletClient.address,
1110
1006
  e,
1111
1007
  Number(n),
@@ -1135,57 +1031,57 @@ class je extends A {
1135
1031
  * @returns Transaction response or dry run response
1136
1032
  */
1137
1033
  async swap(e, a, t, s, n) {
1138
- var d, f, y;
1034
+ var C, y, g;
1139
1035
  if (!this.walletClient)
1140
1036
  throw new Error("Wallet client not found");
1141
1037
  await this.walletClient.module("balance").waitForUpdate();
1142
- const c = this.walletClient.module("balance").portfolio.getBalance(e), i = new m(), l = B(i, c.coins, {
1038
+ const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(), i = B(l, c.coins, {
1143
1039
  balance: t,
1144
1040
  useGasCoin: !0
1145
- }), u = await this.getQuote(e, a, t), o = await this.buildSwapPTBFromQuote(i, u, l, s);
1146
- if (i.transferObjects([o], this.walletClient.address), i.setSender(this.walletClient.address), n != null && n.dryRun)
1041
+ }), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o, i, s);
1042
+ if (l.transferObjects([u], this.walletClient.address), l.setSender(this.walletClient.address), n != null && n.dryRun)
1147
1043
  return await this.walletClient.signExecuteTransaction({
1148
- transaction: i,
1044
+ transaction: l,
1149
1045
  dryRun: !0
1150
1046
  });
1151
- const w = await i.build({
1047
+ const d = await l.build({
1152
1048
  client: this.walletClient.client
1153
- }), g = await this.walletClient.signer.signTransaction(w), h = [g.signature];
1049
+ }), f = await this.walletClient.signer.signTransaction(d), m = [f.signature];
1154
1050
  try {
1155
- await Ae(g.bytes, h);
1156
- } catch (C) {
1157
- console.error(C);
1051
+ await ye(f.bytes, m);
1052
+ } catch (h) {
1053
+ console.error(h);
1158
1054
  }
1159
1055
  const b = await this.walletClient.client.executeTransactionBlock({
1160
- transactionBlock: g.bytes,
1161
- signature: h,
1056
+ transactionBlock: f.bytes,
1057
+ signature: m,
1162
1058
  options: {
1163
1059
  showEffects: !0,
1164
1060
  showEvents: !0,
1165
1061
  showBalanceChanges: !0
1166
1062
  }
1167
1063
  });
1168
- if (((f = (d = b.effects) == null ? void 0 : d.status) == null ? void 0 : f.status) === "success") {
1169
- const C = (y = b.events) == null ? void 0 : y.find((P) => P.type.includes("::slippage::SwapEvent"));
1170
- C && this.emit("swap:swap-success", {
1064
+ if (((y = (C = b.effects) == null ? void 0 : C.status) == null ? void 0 : y.status) === "success") {
1065
+ const h = (g = b.events) == null ? void 0 : g.find((P) => P.type.includes("::slippage::SwapEvent"));
1066
+ h && this.emit("swap:swap-success", {
1171
1067
  fromCoinType: e,
1172
1068
  toCoinType: a,
1173
1069
  fromAmount: t,
1174
1070
  slippage: s,
1175
- toAmount: Number(C.parsedJson.amount_out)
1071
+ toAmount: Number(h.parsedJson.amount_out)
1176
1072
  }), this.walletClient.module("balance").updatePortfolio();
1177
1073
  }
1178
1074
  return b;
1179
1075
  }
1180
1076
  }
1181
- class Ie extends A {
1077
+ class Se extends R {
1182
1078
  constructor() {
1183
1079
  super(...arguments), this.name = "haedal", this.defaultConfig = {
1184
1080
  packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2",
1185
1081
  configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
1186
1082
  coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
1187
- }, this.getApy = re(
1188
- Q(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
1083
+ }, this.getApy = ae(
1084
+ L(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
1189
1085
  );
1190
1086
  }
1191
1087
  /**
@@ -1201,7 +1097,7 @@ class Ie extends A {
1201
1097
  arguments: [
1202
1098
  e.object("0x05"),
1203
1099
  e.object(this.config.configId),
1204
- F(a, e.object),
1100
+ k(a, e.object),
1205
1101
  e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
1206
1102
  ],
1207
1103
  typeArguments: []
@@ -1221,7 +1117,7 @@ class Ie extends A {
1221
1117
  arguments: [
1222
1118
  e.object("0x05"),
1223
1119
  e.object(this.config.configId),
1224
- F(a, e.object)
1120
+ k(a, e.object)
1225
1121
  ],
1226
1122
  typeArguments: []
1227
1123
  });
@@ -1234,21 +1130,21 @@ class Ie extends A {
1234
1130
  * @param options Optional dry run
1235
1131
  */
1236
1132
  async stake(e, a) {
1237
- var l, u, o;
1133
+ var i, o, u;
1238
1134
  if (!this.walletClient)
1239
1135
  throw new Error("Wallet client not found");
1240
- const t = new m();
1136
+ const t = new w();
1241
1137
  await this.walletClient.module("balance").waitForUpdate();
1242
1138
  const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1243
1139
  balance: e,
1244
1140
  useGasCoin: !0
1245
1141
  }), c = await this.stakePTB(t, n);
1246
1142
  t.transferObjects([c], this.walletClient.address);
1247
- const i = await this.walletClient.signExecuteTransaction({
1143
+ const l = await this.walletClient.signExecuteTransaction({
1248
1144
  transaction: t,
1249
- dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
1145
+ dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1250
1146
  });
1251
- return !(a != null && a.dryRun) && ((o = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
1147
+ return !(a != null && a.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), l;
1252
1148
  }
1253
1149
  /**
1254
1150
  * Unstake haSUI for SUI
@@ -1257,47 +1153,47 @@ class Ie extends A {
1257
1153
  * @param options Optional dry run
1258
1154
  */
1259
1155
  async unstake(e, a) {
1260
- var l, u, o;
1156
+ var i, o, u;
1261
1157
  if (!this.walletClient)
1262
1158
  throw new Error("Wallet client not found");
1263
1159
  await this.walletClient.module("balance").waitForUpdate();
1264
- const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
1160
+ const t = new w(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
1265
1161
  balance: e
1266
1162
  }), c = await this.unstakePTB(t, n);
1267
1163
  t.transferObjects([c], this.walletClient.address);
1268
- const i = await this.walletClient.signExecuteTransaction({
1164
+ const l = await this.walletClient.signExecuteTransaction({
1269
1165
  transaction: t,
1270
- dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
1166
+ dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1271
1167
  });
1272
- return !(a != null && a.dryRun) && ((o = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
1168
+ 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;
1273
1169
  }
1274
1170
  }
1275
- const Ue = {
1171
+ const Oe = {
1276
1172
  /** Balance management module */
1277
- balance: new ke(),
1173
+ balance: new Pe(),
1278
1174
  /** Lending protocol module */
1279
- lending: new Fe(),
1175
+ lending: new ve(),
1280
1176
  /** Volo protocol module */
1281
- volo: new _e(),
1177
+ volo: new Ee(),
1282
1178
  /** DEX swapping module */
1283
- swap: new je(),
1179
+ swap: new Re(),
1284
1180
  /** Haedal protocol module */
1285
- haedal: new Ie()
1286
- }, We = {
1287
- url: de("mainnet")
1181
+ haedal: new Se()
1182
+ }, xe = {
1183
+ url: le("mainnet")
1288
1184
  };
1289
- class Ye {
1185
+ class Le {
1290
1186
  /**
1291
1187
  * Creates a new wallet client instance
1292
1188
  * @param options - Configuration options for the wallet client
1293
1189
  */
1294
1190
  constructor(e) {
1295
- this.modules = Ue, this.userConfigs = {}, this.events = he();
1191
+ this.modules = Oe, this.userConfigs = {}, this.events = re();
1296
1192
  const a = {
1297
- ...We,
1193
+ ...xe,
1298
1194
  ...e.client
1299
1195
  };
1300
- a.transport = a.transport || new xe(a.url), this.client = new we(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
1196
+ 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]) => {
1301
1197
  if (t !== s.name)
1302
1198
  throw new Error(`Module name ${t} does not match module name ${s.name}`);
1303
1199
  s.install(this);
@@ -1327,7 +1223,7 @@ class Ye {
1327
1223
  const { dryRun: a = !1, ...t } = e;
1328
1224
  if (a) {
1329
1225
  let s;
1330
- return e.transaction instanceof m ? (e.transaction.setSenderIfNotSet(this.address), s = await e.transaction.build({
1226
+ return e.transaction instanceof w ? (e.transaction.setSenderIfNotSet(this.address), s = await e.transaction.build({
1331
1227
  client: this.client
1332
1228
  })) : s = e.transaction, this.client.dryRunTransactionBlock({
1333
1229
  transactionBlock: s
@@ -1373,7 +1269,7 @@ class Ye {
1373
1269
  return e in this.modules;
1374
1270
  }
1375
1271
  }
1376
- class Xe extends oe {
1272
+ class Qe extends ne {
1377
1273
  /**
1378
1274
  * Creates a new watch-only signer
1379
1275
  *
@@ -1437,7 +1333,7 @@ class Xe extends oe {
1437
1333
  return {};
1438
1334
  }
1439
1335
  }
1440
- class Ze extends oe {
1336
+ class qe extends ne {
1441
1337
  /**
1442
1338
  * Creates a new watch-only signer
1443
1339
  *
@@ -1490,8 +1386,8 @@ class Ze extends oe {
1490
1386
  }
1491
1387
  }
1492
1388
  export {
1493
- Ye as WalletClient,
1494
- Xe as WatchSigner,
1495
- Ze as WebSigner
1389
+ Le as WalletClient,
1390
+ Qe as WatchSigner,
1391
+ qe as WebSigner
1496
1392
  };
1497
1393
  //# sourceMappingURL=index.esm.js.map