@naviprotocol/wallet-client 1.0.5-dev.5 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,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 _ } 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 X, parseReserve as Re, parseObligation as Se } from "@suilend/sdk";
10
- import { getCoinMetadataMap as Oe, MAX_U64 as Ae } from "@suilend/sui-fe";
11
- import { executeAuction as xe } from "shio-sdk";
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 ke {
26
+ class Be {
29
27
  /**
30
28
  * Creates a new custom transport instance
31
29
  *
@@ -44,7 +42,7 @@ class ke {
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 ke {
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 Ne 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 Ne 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, f) => g.plus(f), 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, f) => {
250
- i.transferObjects([u[f]], 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 Ne 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 Ne 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,273 +327,184 @@ class Ne extends A {
326
327
  super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
327
328
  }
328
329
  }
329
- async function Y(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 f = await te(n, {
358
+ const d = await V(n, {
353
359
  env: this.config.env
354
360
  });
355
- if (!f)
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, y = (S = t == null ? void 0 : t.amount) != null ? S : Number(o.supplyBalance), d = 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
- y
361
- ), h = Number(d.amount_out);
362
- if (h <= 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(h * (1 - b)), P = Math.floor(C / (1 + f.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), [F] = 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, F, {
373
- amount: P
378
+ await A(r, n, F, {
379
+ amount: g
374
380
  });
375
- const j = await u.withdrawCoinPTB(r, s.suiCoinType, y), I = await G(
381
+ const j = await Y(r, s, m), _ = await $(
376
382
  i,
377
383
  r,
378
- C,
384
+ y,
379
385
  j,
380
- d
386
+ b
381
387
  ), U = r.moveCall({
382
388
  target: "0x2::coin::into_balance",
383
- arguments: [I],
389
+ arguments: [_],
384
390
  typeArguments: [n.suiCoinType]
385
- }), [M] = await ne(r, n, E, U), [W] = r.moveCall({
391
+ }), [W] = await Z(r, n, P, U), [N] = r.moveCall({
386
392
  target: "0x2::coin::from_balance",
387
- arguments: [M],
393
+ arguments: [W],
388
394
  typeArguments: [n.suiCoinType]
389
395
  });
390
- return await N(r, n, W), r;
396
+ return await A(r, n, N), r;
391
397
  }
392
- async function Z(r, e, a, t) {
393
- var S, H, D;
398
+ async function J(r, e, a, t) {
399
+ var x, G;
394
400
  if (!this.walletClient)
395
401
  throw new Error("Wallet client not found");
396
402
  await this.walletClient.balance.updatePortfolio();
397
- 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);
398
- if (!u)
399
- throw new Error(`Protocol ${l} not found`);
400
- 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);
401
404
  if (console.log("migrateBetweenBorrowPTB", {
402
- fromPoolLending: o
403
- }), o.borrowBalance === 0)
405
+ lendingState: l,
406
+ fromPoolLending: i,
407
+ fromPool: n,
408
+ toPool: c,
409
+ address: s
410
+ }), !i || i.borrowBalance === "0")
404
411
  throw new Error("No borrow balance");
405
- if (t != null && t.amount && t.amount > o.borrowBalance)
406
- throw new Error("Amount is more than borrow balance");
407
- const w = await K(), g = await Promise.all([n, c]);
408
- await $(
412
+ if (t != null && t.amount && t.amount > Number(i.borrowBalance))
413
+ throw new Error("Amount is less than borrow balance");
414
+ const o = await Q(), u = await Promise.all([n, c]);
415
+ await q(
409
416
  r,
410
- q(w, {
411
- lendingState: i,
412
- pools: g
417
+ K(o, {
418
+ lendingState: l,
419
+ pools: u
413
420
  })
414
421
  );
415
- let f = (H = t == null ? void 0 : t.amount) != null ? H : Number(o.borrowBalance);
416
- if (Number(o.borrowBalance) === f) {
417
- const ue = o.borrowAPR / 100;
418
- f = Math.ceil(
419
- new R(f).multipliedBy(ue * (60 * 3) / (365 * 24 * 3600)).plus(new R(1).shiftedBy(-n.token.decimals)).plus(f).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()
420
427
  );
421
428
  }
422
- const b = await te(n, {
429
+ const f = await V(n, {
423
430
  env: this.config.env
424
431
  });
425
- if (!b)
432
+ if (!f)
426
433
  throw new Error(`${n.token.symbol} pool not support flashloan`);
427
434
  if (!this.walletClient)
428
435
  throw new Error("Wallet client not found");
429
- const y = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, d = Math.ceil(f * (1 + b.flashloanFee)), h = d, C = await this.walletClient.swap.getQuote(
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(
430
437
  n.suiCoinType,
431
438
  c.suiCoinType,
432
- h
439
+ C
433
440
  );
434
- let P = 1 + y, 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(
435
442
  c.suiCoinType,
436
443
  n.suiCoinType,
437
- v
444
+ h
438
445
  );
439
- for (; Number(E.amount_out) < h; )
440
- P = P * Math.max(h / Number(E.amount_out), 1.001), v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
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(
441
448
  c.suiCoinType,
442
449
  n.suiCoinType,
443
- v
450
+ h
444
451
  );
445
- const [F, j] = await ae(r, n, f), [I] = r.moveCall({
452
+ const [F, j] = await X(r, n, d), [_] = r.moveCall({
446
453
  target: "0x2::coin::from_balance",
447
454
  arguments: [F],
448
455
  typeArguments: [n.suiCoinType]
449
456
  });
450
- await u.repayCoinPTB(r, n.suiCoinType, I, f);
451
- const U = await se(r, c, v), M = await G(
457
+ await ee(r, n, _, {
458
+ amount: d
459
+ });
460
+ const U = await te(r, c, h), W = await $(
452
461
  s,
453
462
  r,
454
- d,
463
+ b,
455
464
  U,
456
- E
457
- ), W = r.moveCall({
465
+ P
466
+ ), N = r.moveCall({
458
467
  target: "0x2::coin::into_balance",
459
- arguments: [M],
468
+ arguments: [W],
460
469
  typeArguments: [n.suiCoinType]
461
- }), [x] = await ne(r, n, j, W), [k] = r.moveCall({
470
+ }), [S] = await Z(r, n, j, N), [O] = r.moveCall({
462
471
  target: "0x2::coin::from_balance",
463
- arguments: [x],
472
+ arguments: [S],
464
473
  typeArguments: [n.suiCoinType]
465
474
  });
466
- return r.transferObjects([k], s), r;
475
+ return r.transferObjects([O], s), r;
467
476
  }
468
- async function ee(r, e, a, t) {
469
- var u, o;
477
+ async function z(r, e, a, t) {
478
+ var o, u;
470
479
  if (!this.walletClient)
471
480
  throw new Error("Wallet client not found");
472
481
  await this.walletClient.balance.updatePortfolio(), this.walletClient.address;
473
482
  const s = await this.getPool(a), n = this.walletClient.balance.portfolio.getBalance(e);
474
483
  if (n.amount.eq(0))
475
484
  throw new Error(`No balance of ${e}`);
476
- if (console.log("migrateBalanceToSupplyPTB", {
477
- balance: n.amount.toNumber()
478
- }), t != null && t.amount && n.amount.lt(t.amount))
479
- throw new Error("Amount is greater than balance");
480
- 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;
481
- 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, {
482
489
  balance: c,
483
490
  useGasCoin: !0
484
491
  });
485
492
  if (p(e) !== p(s.suiCoinType)) {
486
- const w = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
487
- 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(
488
495
  r,
489
- w,
490
- l,
491
- i
492
- );
493
- }
494
- return await N(r, s, l), r;
495
- }
496
- class _e {
497
- constructor(e) {
498
- this.name = "navi", this.walletClient = e;
499
- }
500
- async getPool(e) {
501
- const a = await this.walletClient.lending.getPool(e), s = (await this.walletClient.lending.getLendingState()).find(
502
- (i) => i.pool.suiCoinType === p(e)
503
- ), n = s ? new R(s.supplyBalance).toNumber() : 0, c = s ? new R(s.borrowBalance).toNumber() : 0;
504
- return {
505
- supplyBalance: n,
506
- borrowBalance: c,
507
- borrowAPR: parseFloat(a.borrowIncentiveApyInfo.apy)
508
- };
509
- }
510
- async depositCoinPTB(e, a, t, s) {
511
- throw new Error("Not implemented");
512
- }
513
- async withdrawCoinPTB(e, a, t) {
514
- return ie(e, a, t);
515
- }
516
- async borrowCoinPTB(e, a, t) {
517
- throw new Error("Not implemented");
518
- }
519
- async repayCoinPTB(e, a, t, s) {
520
- le(e, a, t, { amount: s });
521
- }
522
- }
523
- class z {
524
- constructor(e, a, t) {
525
- this.name = "suilend", this.walletClient = e, this.obligationOwnerCap = a, this.suilendClient = t;
526
- }
527
- static async create(e) {
528
- const [a, t] = await Promise.all([
529
- V.initialize(Ee, X, e.client),
530
- V.getObligationOwnerCaps(
531
- e.address,
532
- [X],
533
- e.client
534
- )
535
- ]);
536
- if (t.length === 0)
537
- throw new Error("No existing obligations found for wallet address: " + e.address);
538
- return new z(e, t[0], a);
539
- }
540
- async getPool(e) {
541
- var b, y;
542
- const a = p(e), t = this.suilendClient.lendingMarket.reserves, s = /* @__PURE__ */ new Set();
543
- t.forEach((d) => {
544
- s.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((h) => {
545
- h && s.add(p(h.coinType.name));
546
- }), d.borrowsPoolRewardManager.poolRewards.forEach((h) => {
547
- h && s.add(p(h.coinType.name));
548
- });
549
- });
550
- const n = await Oe(Array.from(s)), i = t.map((d) => Re(d, n)).reduce(
551
- (d, h) => (d[h.coinType] = h, d),
552
- {}
553
- ), l = await this.suilendClient.getObligation(
554
- this.obligationOwnerCap.obligationId
555
- ), u = Se(l, i), o = u.deposits.find((d) => d.coinType === a), w = u.borrows.find((d) => d.coinType === a), g = n[a].decimals;
556
- return {
557
- cTokenExchangeRate: i[a].cTokenExchangeRate.toNumber(),
558
- supplyBalance: (b = o == null ? void 0 : o.depositedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? b : 0,
559
- borrowBalance: (y = w == null ? void 0 : w.borrowedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? y : 0,
560
- borrowAPR: i[a].borrowAprPercent.toNumber()
561
- };
562
- }
563
- async depositCoinPTB(e, a, t, s) {
564
- throw new Error("Not implemented");
565
- }
566
- async withdrawCoinPTB(e, a, t) {
567
- const s = await this.getPool(a), n = t === s.supplyBalance;
568
- return await this.suilendClient.withdraw(
569
- this.obligationOwnerCap.id,
570
- this.obligationOwnerCap.obligationId,
571
- a,
572
- n ? Ae.toString() : Math.ceil(t / s.cTokenExchangeRate).toString(),
573
- e
496
+ d,
497
+ i,
498
+ l
574
499
  );
575
500
  }
576
- async borrowCoinPTB(e, a, t) {
577
- throw new Error("Not implemented");
578
- }
579
- async repayCoinPTB(e, a, t, s) {
580
- this.suilendClient.repay(this.obligationOwnerCap.obligationId, a, t, e), e.transferObjects([t], e.pure.address(this.walletClient.address));
581
- }
501
+ return await A(r, s, i), r;
582
502
  }
583
- class Fe extends A {
503
+ class ve extends R {
584
504
  constructor() {
585
505
  super(), this.name = "lending", this.defaultConfig = {
586
- env: "prod",
587
- protocols: []
588
- }, this._protocols = [], this.migrateBetweenSupplyPTB = Y, this.migrateBetweenBorrowPTB = Z, this.migrateBalanceToSupplyPTB = ee, this.migrateBetweenSupplyPTB = Y.bind(this), this.migrateBetweenBorrowPTB = Z.bind(this), this.migrateBalanceToSupplyPTB = ee.bind(this);
589
- }
590
- /** Get protocols (either from internal storage or config) */
591
- get protocols() {
592
- return this._protocols.length > 0 ? this._protocols : this.config.protocols;
593
- }
594
- async getProtocol(e) {
595
- 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);
596
508
  }
597
509
  /**
598
510
  * Gets all available lending pools
@@ -601,7 +513,7 @@ class Fe extends A {
601
513
  * @returns Array of pool information
602
514
  */
603
515
  async getPools(e) {
604
- return await me({
516
+ return await ue({
605
517
  env: this.config.env,
606
518
  ...e
607
519
  });
@@ -628,30 +540,30 @@ class Fe extends A {
628
540
  * @returns Transaction response or dry run response
629
541
  */
630
542
  async deposit(e, a, t) {
631
- var u, o, w;
543
+ var o, u, d;
632
544
  if (!this.walletClient)
633
545
  throw new Error("Wallet client not found");
634
546
  const s = await T(e, {
635
547
  env: this.config.env
636
548
  });
637
549
  await this.walletClient.module("balance").waitForUpdate();
638
- 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, {
639
551
  balance: a,
640
552
  useGasCoin: !0
641
553
  });
642
- await N(n, s, i, {
554
+ await A(n, s, l, {
643
555
  env: this.config.env,
644
556
  amount: a,
645
557
  accountCap: t == null ? void 0 : t.accountCap
646
558
  });
647
- const l = await this.walletClient.signExecuteTransaction({
559
+ const i = await this.walletClient.signExecuteTransaction({
648
560
  transaction: n,
649
- dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
561
+ dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
650
562
  });
651
- 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", {
652
564
  identifier: e,
653
565
  amount: a
654
- }), this.walletClient.module("balance").updatePortfolio()), l;
566
+ }), this.walletClient.module("balance").updatePortfolio()), i;
655
567
  }
656
568
  /**
657
569
  * Withdraws coins from a lending pool
@@ -662,26 +574,26 @@ class Fe extends A {
662
574
  * @returns Transaction response or dry run response
663
575
  */
664
576
  async withdraw(e, a, t) {
665
- var l, u, o;
577
+ var i, o, u;
666
578
  if (!this.walletClient)
667
579
  throw new Error("Wallet client not found");
668
580
  const s = await T(e, {
669
581
  env: this.config.env
670
- }), n = new m();
582
+ }), n = new w();
671
583
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
672
- const c = await ie(n, s, a, {
584
+ const c = await Y(n, s, a, {
673
585
  env: this.config.env,
674
586
  accountCap: t == null ? void 0 : t.accountCap
675
587
  });
676
588
  n.transferObjects([c], this.walletClient.address);
677
- const i = await this.walletClient.signExecuteTransaction({
589
+ const l = await this.walletClient.signExecuteTransaction({
678
590
  transaction: n,
679
- dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
591
+ dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
680
592
  });
681
- 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", {
682
594
  identifier: e,
683
595
  amount: a
684
- }), this.walletClient.module("balance").updatePortfolio()), i;
596
+ }), this.walletClient.module("balance").updatePortfolio()), l;
685
597
  }
686
598
  /**
687
599
  * Borrows coins from a lending pool
@@ -692,26 +604,26 @@ class Fe extends A {
692
604
  * @returns Transaction response or dry run response
693
605
  */
694
606
  async borrow(e, a, t) {
695
- var l, u, o;
607
+ var i, o, u;
696
608
  if (!this.walletClient)
697
609
  throw new Error("Wallet client not found");
698
610
  const s = await T(e, {
699
611
  env: this.config.env
700
- }), n = new m();
612
+ }), n = new w();
701
613
  t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
702
- const c = await se(n, s, a, {
614
+ const c = await te(n, s, a, {
703
615
  env: this.config.env,
704
616
  accountCap: t == null ? void 0 : t.accountCap
705
617
  });
706
618
  n.transferObjects([c], this.walletClient.address);
707
- const i = await this.walletClient.signExecuteTransaction({
619
+ const l = await this.walletClient.signExecuteTransaction({
708
620
  transaction: n,
709
- dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
621
+ dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
710
622
  });
711
- 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", {
712
624
  identifier: e,
713
625
  amount: a
714
- }), this.walletClient.module("balance").updatePortfolio()), i;
626
+ }), this.walletClient.module("balance").updatePortfolio()), l;
715
627
  }
716
628
  /**
717
629
  * Repays borrowed coins to a lending pool
@@ -722,29 +634,29 @@ class Fe extends A {
722
634
  * @returns Transaction response or dry run response
723
635
  */
724
636
  async repay(e, a, t) {
725
- var u, o, w;
637
+ var o, u, d;
726
638
  if (!this.walletClient)
727
639
  throw new Error("Wallet client not found");
728
640
  await this.walletClient.module("balance").waitForUpdate();
729
641
  const s = await T(e, {
730
642
  env: this.config.env
731
- }), 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, {
732
644
  balance: a,
733
645
  useGasCoin: !0
734
646
  });
735
- await le(n, s, i, {
647
+ await ee(n, s, l, {
736
648
  env: this.config.env,
737
649
  amount: a,
738
650
  accountCap: t == null ? void 0 : t.accountCap
739
651
  });
740
- const l = await this.walletClient.signExecuteTransaction({
652
+ const i = await this.walletClient.signExecuteTransaction({
741
653
  transaction: n,
742
- dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
654
+ dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
743
655
  });
744
- 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", {
745
657
  identifier: e,
746
658
  amount: a
747
- }), this.walletClient.module("balance").updatePortfolio()), l;
659
+ }), this.walletClient.module("balance").updatePortfolio()), i;
748
660
  }
749
661
  /**
750
662
  * Gets the current health factor for the user
@@ -755,7 +667,7 @@ class Fe extends A {
755
667
  if (!this.walletClient)
756
668
  throw new Error("Wallet client not found");
757
669
  const e = this.walletClient.address;
758
- return await Ce(e, {
670
+ return await de(e, {
759
671
  env: this.config.env,
760
672
  client: this.walletClient.client
761
673
  });
@@ -771,45 +683,45 @@ class Fe extends A {
771
683
  * @returns Transaction response or dry run response
772
684
  */
773
685
  async liquidate(e, a, t, s, n) {
774
- var d, h, C;
686
+ var y, g, h;
775
687
  if (!this.walletClient)
776
688
  throw new Error("Wallet client not found");
777
689
  const c = await T(e, {
778
690
  env: this.config.env
779
- }), i = await T(t, {
691
+ }), l = await T(t, {
780
692
  env: this.config.env
781
- }), 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, {
782
694
  balance: a,
783
695
  useGasCoin: !0
784
- }), [w, g] = await be(
785
- l,
786
- c,
787
- o,
696
+ }), [d, f] = await we(
788
697
  i,
698
+ c,
699
+ u,
700
+ l,
789
701
  s,
790
702
  {
791
703
  env: this.config.env
792
704
  }
793
- ), [f] = l.moveCall({
705
+ ), [m] = i.moveCall({
794
706
  target: "0x2::coin::from_balance",
795
- arguments: [w],
796
- typeArguments: [i.suiCoinType]
797
- }), [b] = l.moveCall({
707
+ arguments: [d],
708
+ typeArguments: [l.suiCoinType]
709
+ }), [b] = i.moveCall({
798
710
  target: "0x2::coin::from_balance",
799
- arguments: [g],
711
+ arguments: [f],
800
712
  typeArguments: [c.suiCoinType]
801
713
  });
802
- l.transferObjects([f, b], this.walletClient.address);
803
- const y = await this.walletClient.signExecuteTransaction({
804
- transaction: l,
805
- dryRun: (d = n == null ? void 0 : n.dryRun) != null ? d : !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
806
718
  });
807
- return !(n != null && n.dryRun) && ((C = (h = y.effects) == null ? void 0 : h.status) == null ? void 0 : C.status) === "success" && (this.emit("lending:liquidate-success", {
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", {
808
720
  payIdentifier: e,
809
721
  payAmount: a,
810
722
  collateralIdentifier: t,
811
723
  liquidationAddress: s
812
- }), this.walletClient.module("balance").updatePortfolio()), y;
724
+ }), this.walletClient.module("balance").updatePortfolio()), C;
813
725
  }
814
726
  /**
815
727
  * Gets the available lending rewards for the current user.
@@ -821,7 +733,7 @@ class Fe extends A {
821
733
  async getAvailableRewards(e) {
822
734
  if (!this.walletClient)
823
735
  throw new Error("Wallet client not found");
824
- return J(this.walletClient.address, {
736
+ return H(this.walletClient.address, {
825
737
  ...e,
826
738
  env: this.config.env
827
739
  });
@@ -836,7 +748,7 @@ class Fe extends A {
836
748
  async getClaimedRewardHistory(e) {
837
749
  if (!this.walletClient)
838
750
  throw new Error("Wallet client not found");
839
- return ye(this.walletClient.address, {
751
+ return he(this.walletClient.address, {
840
752
  ...e
841
753
  });
842
754
  }
@@ -847,13 +759,13 @@ class Fe extends A {
847
759
  * @returns Transaction response or dry run response
848
760
  */
849
761
  async claimAllRewards(e) {
850
- var n, c, i;
762
+ var n, c, l;
851
763
  if (!this.walletClient)
852
764
  throw new Error("Wallet client not found");
853
- const a = new m(), t = await J(this.walletClient.address, {
765
+ const a = new w(), t = await H(this.walletClient.address, {
854
766
  env: this.config.env
855
767
  });
856
- await pe(a, t, {
768
+ await fe(a, t, {
857
769
  env: this.config.env,
858
770
  accountCap: e == null ? void 0 : e.accountCap
859
771
  });
@@ -861,20 +773,20 @@ class Fe extends A {
861
773
  transaction: a,
862
774
  dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
863
775
  });
864
- 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", {
865
777
  rewards: t
866
778
  }), this.walletClient.module("balance").updatePortfolio()), s;
867
779
  }
868
780
  async updateOraclePTB(e, a) {
869
- const t = await K({
781
+ const t = await Q({
870
782
  env: this.config.env
871
783
  }), s = await this.getLendingState({
872
784
  cacheTime: 60 * 1e3
873
- }), n = q(t, {
785
+ }), n = K(t, {
874
786
  lendingState: s,
875
787
  pools: a
876
788
  });
877
- await $(e, n, {
789
+ await q(e, n, {
878
790
  env: this.config.env,
879
791
  updatePythPriceFeeds: !0
880
792
  });
@@ -890,7 +802,7 @@ class Fe extends A {
890
802
  var s;
891
803
  if (!this.walletClient)
892
804
  throw new Error("Wallet client not found");
893
- const a = new m();
805
+ const a = new w();
894
806
  return await this.updateOraclePTB(a, e == null ? void 0 : e.pools), await this.walletClient.signExecuteTransaction({
895
807
  transaction: a,
896
808
  dryRun: (s = e == null ? void 0 : e.dryRun) != null ? s : !1
@@ -905,7 +817,7 @@ class Fe extends A {
905
817
  async getLendingState(e) {
906
818
  if (!this.walletClient)
907
819
  throw new Error("Wallet client not found");
908
- return await Pe(this.walletClient.address, {
820
+ return await ge(this.walletClient.address, {
909
821
  env: this.config.env,
910
822
  ...e,
911
823
  client: this.walletClient.client
@@ -921,36 +833,22 @@ class Fe extends A {
921
833
  var n;
922
834
  if (!this.walletClient)
923
835
  throw new Error("Wallet client not found");
924
- const a = new m(), t = await Be(a);
836
+ const a = new w(), t = await me(a);
925
837
  return a.transferObjects([t], this.walletClient.address), await this.walletClient.signExecuteTransaction({
926
838
  transaction: a,
927
839
  dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
928
840
  });
929
841
  }
930
- async initializeProtocols() {
931
- if (!this.walletClient) {
932
- console.warn("Wallet client not available during protocol initialization");
933
- return;
934
- }
935
- const e = [];
936
- e.push(new _e(this.walletClient));
937
- try {
938
- e.push(await z.create(this.walletClient));
939
- } catch (a) {
940
- console.warn("Failed to initialize SuilendProtocol:", a);
941
- }
942
- this._protocols = e;
943
- }
944
842
  }
945
- class je extends A {
843
+ class Ee extends R {
946
844
  constructor() {
947
845
  super(...arguments), this.name = "volo", this.defaultConfig = {
948
846
  packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
949
847
  poolId: "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5",
950
848
  metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
951
849
  coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
952
- }, this.getStats = re(
953
- 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)
954
852
  );
955
853
  }
956
854
  /**
@@ -967,7 +865,7 @@ class je extends A {
967
865
  e.object(this.config.poolId),
968
866
  e.object(this.config.metadataId),
969
867
  e.object("0x05"),
970
- _(a, e.object)
868
+ k(a, e.object)
971
869
  ],
972
870
  typeArguments: []
973
871
  });
@@ -987,7 +885,7 @@ class je extends A {
987
885
  e.object(this.config.poolId),
988
886
  e.object(this.config.metadataId),
989
887
  e.object("0x05"),
990
- _(a, e.object)
888
+ k(a, e.object)
991
889
  ],
992
890
  typeArguments: []
993
891
  });
@@ -1002,25 +900,25 @@ class je extends A {
1002
900
  * @throws Error if wallet client not found or stake amount is too low
1003
901
  */
1004
902
  async stake(e, a) {
1005
- var l, u, o;
903
+ var i, o, u;
1006
904
  if (!this.walletClient)
1007
905
  throw new Error("Wallet client not found");
1008
906
  if (e < 1e9)
1009
907
  throw new Error("Stake amount should be greater than 1Sui");
1010
- const t = new m();
908
+ const t = new w();
1011
909
  await this.walletClient.module("balance").waitForUpdate();
1012
910
  const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1013
911
  balance: e,
1014
912
  useGasCoin: !0
1015
913
  }), c = await this.stakePTB(t, n);
1016
914
  t.transferObjects([c], this.walletClient.address);
1017
- const i = await this.walletClient.signExecuteTransaction({
915
+ const l = await this.walletClient.signExecuteTransaction({
1018
916
  transaction: t,
1019
- dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
917
+ dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1020
918
  });
1021
- 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", {
1022
920
  suiAmount: e
1023
- }), this.walletClient.module("balance").updatePortfolio()), i;
921
+ }), this.walletClient.module("balance").updatePortfolio()), l;
1024
922
  }
1025
923
  /**
1026
924
  * Unstake vSUI tokens to receive SUI tokens
@@ -1031,26 +929,26 @@ class je extends A {
1031
929
  * @throws Error if wallet client not found or unstake amount is too low
1032
930
  */
1033
931
  async unstake(e, a) {
1034
- var l, u, o;
932
+ var i, o, u;
1035
933
  if (!this.walletClient)
1036
934
  throw new Error("Wallet client not found");
1037
935
  if (e < 1e9)
1038
936
  throw new Error("Unstake amount should >= 1vSui");
1039
937
  await this.walletClient.module("balance").waitForUpdate();
1040
- 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, {
1041
939
  balance: e
1042
940
  }), c = await this.unstakePTB(t, n);
1043
941
  t.transferObjects([c], this.walletClient.address);
1044
- const i = await this.walletClient.signExecuteTransaction({
942
+ const l = await this.walletClient.signExecuteTransaction({
1045
943
  transaction: t,
1046
- dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
944
+ dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1047
945
  });
1048
- 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", {
1049
947
  vSuiAmount: e
1050
- }), this.walletClient.module("balance").updatePortfolio()), i;
948
+ }), this.walletClient.module("balance").updatePortfolio()), l;
1051
949
  }
1052
950
  }
1053
- class Ie extends A {
951
+ class Re extends R {
1054
952
  constructor() {
1055
953
  super(...arguments), this.name = "swap", this.defaultConfig = {
1056
954
  apiKey: "",
@@ -1067,7 +965,7 @@ class Ie extends A {
1067
965
  * @returns Referral ID if API key is configured, otherwise 0
1068
966
  */
1069
967
  get referral() {
1070
- return this.config.apiKey ? Te(this.config.apiKey) : 0;
968
+ return this.config.apiKey ? Ce(this.config.apiKey) : 0;
1071
969
  }
1072
970
  /**
1073
971
  * Get the swap options
@@ -1089,7 +987,7 @@ class Ie extends A {
1089
987
  * @returns A promise that resolves with the quote
1090
988
  */
1091
989
  async getQuote(e, a, t) {
1092
- return ve(e, a, t, this.config.apiKey, this.swapOptions);
990
+ return be(e, a, t, this.config.apiKey, this.swapOptions);
1093
991
  }
1094
992
  /**
1095
993
  * Builds a swap transaction from a quote
@@ -1102,8 +1000,8 @@ class Ie extends A {
1102
1000
  async buildSwapPTBFromQuote(e, a, t, s) {
1103
1001
  if (!this.walletClient)
1104
1002
  throw new Error("Wallet client not found");
1105
- const n = new R(a.amount_out).multipliedBy(1 - s).toFixed(0);
1106
- return await G(
1003
+ const n = new v(a.amount_out).multipliedBy(1 - s).toFixed(0);
1004
+ return await $(
1107
1005
  this.walletClient.address,
1108
1006
  e,
1109
1007
  Number(n),
@@ -1133,57 +1031,57 @@ class Ie extends A {
1133
1031
  * @returns Transaction response or dry run response
1134
1032
  */
1135
1033
  async swap(e, a, t, s, n) {
1136
- var y, d, h;
1034
+ var C, y, g;
1137
1035
  if (!this.walletClient)
1138
1036
  throw new Error("Wallet client not found");
1139
1037
  await this.walletClient.module("balance").waitForUpdate();
1140
- 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, {
1141
1039
  balance: t,
1142
1040
  useGasCoin: !0
1143
- }), u = await this.getQuote(e, a, t), o = await this.buildSwapPTBFromQuote(i, u, l, s);
1144
- 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)
1145
1043
  return await this.walletClient.signExecuteTransaction({
1146
- transaction: i,
1044
+ transaction: l,
1147
1045
  dryRun: !0
1148
1046
  });
1149
- const w = await i.build({
1047
+ const d = await l.build({
1150
1048
  client: this.walletClient.client
1151
- }), g = await this.walletClient.signer.signTransaction(w), f = [g.signature];
1049
+ }), f = await this.walletClient.signer.signTransaction(d), m = [f.signature];
1152
1050
  try {
1153
- await xe(g.bytes, f);
1154
- } catch (C) {
1155
- console.error(C);
1051
+ await ye(f.bytes, m);
1052
+ } catch (h) {
1053
+ console.error(h);
1156
1054
  }
1157
1055
  const b = await this.walletClient.client.executeTransactionBlock({
1158
- transactionBlock: g.bytes,
1159
- signature: f,
1056
+ transactionBlock: f.bytes,
1057
+ signature: m,
1160
1058
  options: {
1161
1059
  showEffects: !0,
1162
1060
  showEvents: !0,
1163
1061
  showBalanceChanges: !0
1164
1062
  }
1165
1063
  });
1166
- if (((d = (y = b.effects) == null ? void 0 : y.status) == null ? void 0 : d.status) === "success") {
1167
- const C = (h = b.events) == null ? void 0 : h.find((P) => P.type.includes("::slippage::SwapEvent"));
1168
- 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", {
1169
1067
  fromCoinType: e,
1170
1068
  toCoinType: a,
1171
1069
  fromAmount: t,
1172
1070
  slippage: s,
1173
- toAmount: Number(C.parsedJson.amount_out)
1071
+ toAmount: Number(h.parsedJson.amount_out)
1174
1072
  }), this.walletClient.module("balance").updatePortfolio();
1175
1073
  }
1176
1074
  return b;
1177
1075
  }
1178
1076
  }
1179
- class Ue extends A {
1077
+ class Se extends R {
1180
1078
  constructor() {
1181
1079
  super(...arguments), this.name = "haedal", this.defaultConfig = {
1182
1080
  packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2",
1183
1081
  configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
1184
1082
  coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
1185
- }, this.getApy = re(
1186
- 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)
1187
1085
  );
1188
1086
  }
1189
1087
  /**
@@ -1199,7 +1097,7 @@ class Ue extends A {
1199
1097
  arguments: [
1200
1098
  e.object("0x05"),
1201
1099
  e.object(this.config.configId),
1202
- _(a, e.object),
1100
+ k(a, e.object),
1203
1101
  e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
1204
1102
  ],
1205
1103
  typeArguments: []
@@ -1219,7 +1117,7 @@ class Ue extends A {
1219
1117
  arguments: [
1220
1118
  e.object("0x05"),
1221
1119
  e.object(this.config.configId),
1222
- _(a, e.object)
1120
+ k(a, e.object)
1223
1121
  ],
1224
1122
  typeArguments: []
1225
1123
  });
@@ -1232,21 +1130,21 @@ class Ue extends A {
1232
1130
  * @param options Optional dry run
1233
1131
  */
1234
1132
  async stake(e, a) {
1235
- var l, u, o;
1133
+ var i, o, u;
1236
1134
  if (!this.walletClient)
1237
1135
  throw new Error("Wallet client not found");
1238
- const t = new m();
1136
+ const t = new w();
1239
1137
  await this.walletClient.module("balance").waitForUpdate();
1240
1138
  const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1241
1139
  balance: e,
1242
1140
  useGasCoin: !0
1243
1141
  }), c = await this.stakePTB(t, n);
1244
1142
  t.transferObjects([c], this.walletClient.address);
1245
- const i = await this.walletClient.signExecuteTransaction({
1143
+ const l = await this.walletClient.signExecuteTransaction({
1246
1144
  transaction: t,
1247
- dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
1145
+ dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1248
1146
  });
1249
- 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;
1250
1148
  }
1251
1149
  /**
1252
1150
  * Unstake haSUI for SUI
@@ -1255,47 +1153,47 @@ class Ue extends A {
1255
1153
  * @param options Optional dry run
1256
1154
  */
1257
1155
  async unstake(e, a) {
1258
- var l, u, o;
1156
+ var i, o, u;
1259
1157
  if (!this.walletClient)
1260
1158
  throw new Error("Wallet client not found");
1261
1159
  await this.walletClient.module("balance").waitForUpdate();
1262
- 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, {
1263
1161
  balance: e
1264
1162
  }), c = await this.unstakePTB(t, n);
1265
1163
  t.transferObjects([c], this.walletClient.address);
1266
- const i = await this.walletClient.signExecuteTransaction({
1164
+ const l = await this.walletClient.signExecuteTransaction({
1267
1165
  transaction: t,
1268
- dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
1166
+ dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
1269
1167
  });
1270
- 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;
1271
1169
  }
1272
1170
  }
1273
- const Me = {
1171
+ const Oe = {
1274
1172
  /** Balance management module */
1275
- balance: new Ne(),
1173
+ balance: new Pe(),
1276
1174
  /** Lending protocol module */
1277
- lending: new Fe(),
1175
+ lending: new ve(),
1278
1176
  /** Volo protocol module */
1279
- volo: new je(),
1177
+ volo: new Ee(),
1280
1178
  /** DEX swapping module */
1281
- swap: new Ie(),
1179
+ swap: new Re(),
1282
1180
  /** Haedal protocol module */
1283
- haedal: new Ue()
1284
- }, We = {
1285
- url: de("mainnet")
1181
+ haedal: new Se()
1182
+ }, xe = {
1183
+ url: le("mainnet")
1286
1184
  };
1287
- class Ye {
1185
+ class Le {
1288
1186
  /**
1289
1187
  * Creates a new wallet client instance
1290
1188
  * @param options - Configuration options for the wallet client
1291
1189
  */
1292
1190
  constructor(e) {
1293
- this.modules = Me, this.userConfigs = {}, this.events = he();
1191
+ this.modules = Oe, this.userConfigs = {}, this.events = re();
1294
1192
  const a = {
1295
- ...We,
1193
+ ...xe,
1296
1194
  ...e.client
1297
1195
  };
1298
- a.transport = a.transport || new ke(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]) => {
1299
1197
  if (t !== s.name)
1300
1198
  throw new Error(`Module name ${t} does not match module name ${s.name}`);
1301
1199
  s.install(this);
@@ -1325,7 +1223,7 @@ class Ye {
1325
1223
  const { dryRun: a = !1, ...t } = e;
1326
1224
  if (a) {
1327
1225
  let s;
1328
- 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({
1329
1227
  client: this.client
1330
1228
  })) : s = e.transaction, this.client.dryRunTransactionBlock({
1331
1229
  transactionBlock: s
@@ -1371,7 +1269,7 @@ class Ye {
1371
1269
  return e in this.modules;
1372
1270
  }
1373
1271
  }
1374
- class Ze extends oe {
1272
+ class Qe extends ne {
1375
1273
  /**
1376
1274
  * Creates a new watch-only signer
1377
1275
  *
@@ -1435,7 +1333,7 @@ class Ze extends oe {
1435
1333
  return {};
1436
1334
  }
1437
1335
  }
1438
- class et extends oe {
1336
+ class qe extends ne {
1439
1337
  /**
1440
1338
  * Creates a new watch-only signer
1441
1339
  *
@@ -1488,8 +1386,8 @@ class et extends oe {
1488
1386
  }
1489
1387
  }
1490
1388
  export {
1491
- Ye as WalletClient,
1492
- Ze as WatchSigner,
1493
- et as WebSigner
1389
+ Le as WalletClient,
1390
+ Qe as WatchSigner,
1391
+ qe as WebSigner
1494
1392
  };
1495
1393
  //# sourceMappingURL=index.esm.js.map