@naviprotocol/wallet-client 1.3.2-dev.3 → 1.3.2-dev.7

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