@naviprotocol/wallet-client 1.0.4 → 1.0.5-dev.1

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