@naviprotocol/wallet-client 1.4.5 → 1.4.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,38 +1,38 @@
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 K, getCoins as te, mergeCoinsPTB as B, getPriceFeeds as $, updateOraclePricesPTB as q, filterPriceFeeds as G, depositCoinPTB as A, getFlashLoanAsset as ae, flashloanPTB as ne, 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 Q } from "bignumber.js";
6
- import { normalizeStructTag as p } from "@mysten/sui/utils";
7
- import { Transaction as m } from "@mysten/sui/transactions";
8
- import { buildSwapPTBFromQuote as z, 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({
1
+ import { getFullnodeUrl as ct, SuiClient as ut } from "@mysten/sui/client";
2
+ import dt from "mitt";
3
+ import wt from "axios";
4
+ import { withSingleton as W, getCoins as X, mergeCoinsPTB as C, getPriceFeeds as L, updateOraclePricesPTB as Q, filterPriceFeeds as K, depositCoinPTB as O, getFlashLoanAsset as Y, flashloanPTB as Z, repayFlashLoanPTB as tt, borrowCoinPTB as et, withdrawCoinPTB as nt, repayCoinPTB as at, getPools as ht, getPool as P, getHealthFactor as ft, liquidatePTB as gt, getUserAvailableLendingRewards as G, getUserClaimedRewardHistory as pt, claimLendingRewardsPTB as mt, getLendingState as Ct, createAccountCapPTB as bt, withCache as st, parseTxValue as x } from "@naviprotocol/lending";
5
+ import E, { BigNumber as M } from "bignumber.js";
6
+ import { normalizeStructTag as m } from "@mysten/sui/utils";
7
+ import { Transaction as f } from "@mysten/sui/transactions";
8
+ import { buildSwapPTBFromQuote as $, generateRefId as yt, getQuote as Pt } from "@naviprotocol/astros-aggregator-sdk";
9
+ import { SuilendClient as z, LENDING_MARKET_ID as Bt, LENDING_MARKET_TYPE as H, parseReserve as Tt, parseObligation as vt } from "@suilend/sdk";
10
+ import { getCoinMetadataMap as Et, MAX_U64 as Rt } from "@suilend/sui-fe";
11
+ import { executeAuction as St } from "shio-sdk";
12
+ import { Signer as it } from "@mysten/sui/cryptography";
13
+ const ot = wt.create({
14
14
  timeout: 2e4
15
15
  });
16
- ue.interceptors.response.use(
17
- function(l) {
18
- if (l.data.err)
19
- throw new Error(l.data.err);
20
- if (l.data.error)
21
- throw new Error(l.data.error.message);
22
- return l;
16
+ ot.interceptors.response.use(
17
+ function(o) {
18
+ if (o.data.err)
19
+ throw new Error(o.data.err);
20
+ if (o.data.error)
21
+ throw new Error(o.data.error.message);
22
+ return o;
23
23
  },
24
- function(l) {
25
- return Promise.reject(l);
24
+ function(o) {
25
+ return Promise.reject(o);
26
26
  }
27
27
  );
28
- class ke {
28
+ class Ot {
29
29
  /**
30
30
  * Creates a new custom transport instance
31
31
  *
32
32
  * @param rpcUrl - The RPC endpoint URL for the Sui node
33
33
  */
34
- constructor(e) {
35
- this.requestId = 0, this.rpcUrl = e;
34
+ constructor(t) {
35
+ this.requestId = 0, this.rpcUrl = t;
36
36
  }
37
37
  /**
38
38
  * Makes an RPC request to the Sui node
@@ -43,12 +43,12 @@ class ke {
43
43
  * @param input - The transport request options containing method and parameters
44
44
  * @returns Promise<T> - The response data from the RPC call
45
45
  */
46
- async request(e) {
47
- return this.requestId += 1, (await ue.post(this.rpcUrl, {
46
+ async request(t) {
47
+ return this.requestId += 1, (await ot.post(this.rpcUrl, {
48
48
  jsonrpc: "2.0",
49
49
  id: this.requestId,
50
- method: e.method,
51
- params: e.params
50
+ method: t.method,
51
+ params: t.params
52
52
  })).data.result;
53
53
  }
54
54
  /**
@@ -64,7 +64,7 @@ class ke {
64
64
  throw new Error("subscribe not implemented.");
65
65
  }
66
66
  }
67
- class x {
67
+ class A {
68
68
  /**
69
69
  * Gets the current configuration for this module
70
70
  *
@@ -82,9 +82,8 @@ class x {
82
82
  * @param event - The event name to emit
83
83
  * @param data - The event data to emit
84
84
  */
85
- emit(e, a) {
86
- var t;
87
- (t = this.walletClient) == null || t.events.emit(e, a);
85
+ emit(t, e) {
86
+ this.walletClient?.events.emit(t, e);
88
87
  }
89
88
  /**
90
89
  * Installs this module into a wallet client
@@ -94,8 +93,8 @@ class x {
94
93
  *
95
94
  * @param walletClient - The wallet client instance to install into
96
95
  */
97
- install(e) {
98
- this.walletClient = e;
96
+ install(t) {
97
+ this.walletClient = t;
99
98
  }
100
99
  /**
101
100
  * Uninstalls this module from the wallet client
@@ -107,26 +106,26 @@ class x {
107
106
  this.walletClient = void 0;
108
107
  }
109
108
  }
110
- class S {
109
+ class R {
111
110
  /**
112
111
  * Creates a new user portfolio
113
112
  *
114
113
  * @param coins - Array of coin objects or existing portfolio to copy from
115
114
  */
116
- constructor(e) {
117
- if (e instanceof S)
118
- this.balances = JSON.parse(JSON.stringify(e.balances));
115
+ constructor(t) {
116
+ if (t instanceof R)
117
+ this.balances = JSON.parse(JSON.stringify(t.balances));
119
118
  else {
120
- const a = {};
121
- e == null || e.forEach((t) => {
122
- const s = p(t.coinType);
123
- let n = a[s];
124
- n || (n = {
119
+ const e = {};
120
+ t?.forEach((n) => {
121
+ const s = m(n.coinType);
122
+ let a = e[s];
123
+ a || (a = {
125
124
  coinType: s,
126
- amount: Q(0),
125
+ amount: M(0),
127
126
  coins: []
128
- }, a[s] = n), n.coins.push(t), n.amount = n.amount.plus(t.balance);
129
- }), this.balances = a;
127
+ }, e[s] = a), a.coins.push(n), a.amount = a.amount.plus(n.balance);
128
+ }), this.balances = e;
130
129
  }
131
130
  }
132
131
  /**
@@ -135,8 +134,8 @@ class S {
135
134
  * @param coinType - The coin type to query
136
135
  * @returns UserCoinBalance object with coin type, total amount, and coin objects
137
136
  */
138
- getBalance(e) {
139
- return e = p(e), this.balances[e] || { coinType: e, amount: Q(0), coins: [] };
137
+ getBalance(t) {
138
+ return t = m(t), this.balances[t] || { coinType: t, amount: M(0), coins: [] };
140
139
  }
141
140
  /**
142
141
  * Gets all coin types in the portfolio
@@ -144,7 +143,7 @@ class S {
144
143
  * @returns Array of coin type strings
145
144
  */
146
145
  getCoinTypes() {
147
- return Object.values(this.balances).map((e) => e.coinType);
146
+ return Object.values(this.balances).map((t) => t.coinType);
148
147
  }
149
148
  /**
150
149
  * Gets the total balance amount for a specific coin type
@@ -152,10 +151,8 @@ class S {
152
151
  * @param coinType - The coin type to query
153
152
  * @returns BigNumber representing the total balance
154
153
  */
155
- balanceOf(e) {
156
- e = p(e);
157
- const a = this.getBalance(e);
158
- return (a == null ? void 0 : a.amount) || Q(0);
154
+ balanceOf(t) {
155
+ return t = m(t), this.getBalance(t)?.amount || M(0);
159
156
  }
160
157
  /**
161
158
  * Creates a deep copy of the portfolio
@@ -166,22 +163,22 @@ class S {
166
163
  * @returns New UserPortfolio instance with copied data
167
164
  */
168
165
  clone() {
169
- const e = JSON.parse(JSON.stringify(this.balances)), a = new S();
170
- return a.balances = e, a;
166
+ const t = JSON.parse(JSON.stringify(this.balances)), e = new R();
167
+ return e.balances = t, e;
171
168
  }
172
169
  }
173
- class Ne extends x {
170
+ class At extends A {
174
171
  constructor() {
175
172
  super(...arguments), this.name = "balance", this.defaultConfig = {
176
173
  coinPollingInterval: 6e3,
177
174
  disableCoinPolling: !1
178
- }, this.updatePortfolio = K(async () => {
175
+ }, this.updatePortfolio = W(async () => {
179
176
  if (!this.walletClient)
180
177
  throw new Error("Wallet client not found");
181
- this._coins = await te(this.walletClient.address, {
178
+ this._coins = await X(this.walletClient.address, {
182
179
  client: this.walletClient.client
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;
180
+ }), this._portfolio = new R(this._coins), this.emit("balance:portfolio-updated", {});
181
+ }), this._coins = [], this._portfolio = new R(), this.pollingTimer = null, this._updatePromise = null;
185
182
  }
186
183
  /**
187
184
  * Gets the current coin objects from the wallet
@@ -219,8 +216,8 @@ class Ne extends x {
219
216
  * @param options - Optional parameters including dry run mode
220
217
  * @returns Transaction response or dry run response
221
218
  */
222
- async sendCoin(e, a, t, s) {
223
- return this.sendCoinBatch(e, [a], [t], s);
219
+ async sendCoin(t, e, n, s) {
220
+ return this.sendCoinBatch(t, [e], [n], s);
224
221
  }
225
222
  /**
226
223
  * Sends coins to multiple recipients in a single transaction
@@ -231,27 +228,26 @@ class Ne extends x {
231
228
  * @param options - Optional parameters including dry run mode
232
229
  * @returns Transaction response or dry run response
233
230
  */
234
- async sendCoinBatch(e, a, t, s) {
235
- var w;
231
+ async sendCoinBatch(t, e, n, s) {
236
232
  if (!this.walletClient)
237
233
  throw new Error("Wallet client not found");
238
- if (a.length !== t.length)
234
+ if (e.length !== n.length)
239
235
  throw new Error("Recipients and amounts must have the same length");
240
236
  await this.waitForUpdate();
241
- const n = this.portfolio.getBalance(e), u = t.reduce((h, f) => h.plus(f), R(0));
242
- if (n.amount.lt(u))
237
+ const a = this.portfolio.getBalance(t), l = n.reduce((g, h) => g.plus(h), E(0));
238
+ if (a.amount.lt(l))
243
239
  throw new Error("Insufficient balance");
244
- const i = new m();
240
+ const i = new f();
245
241
  let r = i.gas;
246
- p(e) !== p("0x2::sui::SUI") && (r = B(i, n.coins, {
247
- balance: u.toNumber()
242
+ m(t) !== m("0x2::sui::SUI") && (r = C(i, a.coins, {
243
+ balance: l.toNumber()
248
244
  }));
249
- const c = i.splitCoins(r, t);
250
- return a.forEach((h, f) => {
251
- i.transferObjects([c[f]], h);
245
+ const w = i.splitCoins(r, n);
246
+ return e.forEach((g, h) => {
247
+ i.transferObjects([w[h]], g);
252
248
  }), await this.walletClient.signExecuteTransaction({
253
249
  transaction: i,
254
- dryRun: (w = s == null ? void 0 : s.dryRun) != null ? w : !1
250
+ dryRun: s?.dryRun ?? !1
255
251
  });
256
252
  }
257
253
  /**
@@ -262,8 +258,8 @@ class Ne extends x {
262
258
  * @param options - Optional parameters including dry run mode
263
259
  * @returns Transaction response or dry run response
264
260
  */
265
- async transferObject(e, a, t) {
266
- return this.transferObjectBatch([e], [a], t);
261
+ async transferObject(t, e, n) {
262
+ return this.transferObjectBatch([t], [e], n);
267
263
  }
268
264
  /**
269
265
  * Transfers multiple objects to their respective recipients in a single transaction
@@ -276,19 +272,18 @@ class Ne extends x {
276
272
  * @param options - Optional parameters including dry run mode
277
273
  * @returns Transaction response or dry run response
278
274
  */
279
- async transferObjectBatch(e, a, t) {
280
- var u;
275
+ async transferObjectBatch(t, e, n) {
281
276
  if (!this.walletClient)
282
277
  throw new Error("Wallet client not found");
283
- if (e.length !== a.length)
278
+ if (t.length !== e.length)
284
279
  throw new Error("Objects and recipients must have the same length");
285
280
  await this.waitForUpdate();
286
- const s = new m();
287
- return e.forEach((i, r) => {
288
- s.transferObjects([s.object(i)], a[r]);
281
+ const s = new f();
282
+ return t.forEach((l, i) => {
283
+ s.transferObjects([s.object(l)], e[i]);
289
284
  }), await this.walletClient.signExecuteTransaction({
290
285
  transaction: s,
291
- dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
286
+ dryRun: n?.dryRun ?? !1
292
287
  });
293
288
  }
294
289
  /**
@@ -302,8 +297,8 @@ class Ne extends x {
302
297
  if (this.config.disableCoinPolling)
303
298
  return;
304
299
  await this.updatePortfolio();
305
- } catch (e) {
306
- console.error(e);
300
+ } catch (t) {
301
+ console.error(t);
307
302
  } finally {
308
303
  this.pollingTimer = setTimeout(this.startPolling, this.config.coinPollingInterval);
309
304
  }
@@ -313,10 +308,10 @@ class Ne extends x {
313
308
  *
314
309
  * @param walletClient - The wallet client instance to install into
315
310
  */
316
- install(e) {
317
- super.install(e), this.startPolling = this.startPolling.bind(this), this.startPolling(), this._updatePromise = new Promise((a) => {
318
- e.events.on("balance:portfolio-updated", () => {
319
- a();
311
+ install(t) {
312
+ super.install(t), this.startPolling = this.startPolling.bind(this), this.startPolling(), this._updatePromise = new Promise((e) => {
313
+ t.events.on("balance:portfolio-updated", () => {
314
+ e();
320
315
  });
321
316
  });
322
317
  }
@@ -329,282 +324,278 @@ class Ne extends x {
329
324
  super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
330
325
  }
331
326
  }
332
- async function Y(l, e, a, t) {
333
- var k, N, O;
327
+ async function D(o, t, e, n) {
334
328
  if (!this.walletClient)
335
329
  throw new Error("Wallet client not found");
336
- const s = await this.getPool(e), n = await this.getPool(a), u = await this.getLendingState(), i = this.walletClient.address, r = (k = t == null ? void 0 : t.protocol) != null ? k : "navi", c = await this.getProtocol(r);
337
- if (!c)
330
+ const s = await this.getPool(t), a = await this.getPool(e), l = await this.getLendingState(), i = this.walletClient.address, r = n?.protocol ?? "navi", w = await this.getProtocol(r);
331
+ if (!w)
338
332
  throw new Error(`Protocol ${r} not found`);
339
- const o = await c.getPool(s.coinType);
333
+ const u = await w.getPool(s.coinType);
340
334
  if (console.log("migrateBetweenSupplyPTB", {
341
- fromPoolLending: o
342
- }), r === "navi" && o.supplyBalance === 0)
335
+ fromPoolLending: u
336
+ }), r === "navi" && u.supplyBalance === 0)
343
337
  throw new Error("No supply balance");
344
- if (t != null && t.amount && t.amount > o.supplyBalance)
338
+ if (n?.amount && n.amount > u.supplyBalance)
345
339
  throw new Error("Amount is less than supply balance");
346
- const w = (N = t == null ? void 0 : t.slippage) != null ? N : 5e-3, h = (O = t == null ? void 0 : t.amount) != null ? O : Number(o.supplyBalance), f = await $(), b = await Promise.all([s, n]);
347
- if (await q(
348
- l,
349
- G(f, {
350
- lendingState: u,
351
- pools: b
340
+ const g = n?.slippage ?? 5e-3, h = n?.amount ?? Number(u.supplyBalance), p = await L(), c = await Promise.all([s, a]);
341
+ if (await Q(
342
+ o,
343
+ K(p, {
344
+ lendingState: l,
345
+ pools: c
352
346
  })
353
- ), r !== "navi" && s.id === n.id) {
354
- const F = await c.withdrawCoinPTB(
355
- l,
347
+ ), r !== "navi" && s.id === a.id) {
348
+ const U = await w.withdrawCoinPTB(
349
+ o,
356
350
  s.suiCoinType,
357
351
  h
358
352
  );
359
- return await A(l, n, F, {
353
+ return await O(o, a, U, {
360
354
  amount: h
361
- }), l;
355
+ }), o;
362
356
  }
363
- const y = await ae(n, {
357
+ const d = await Y(a, {
364
358
  env: this.config.env
365
359
  });
366
- if (!y)
367
- throw new Error(`${n.token.symbol} pool not support flashloan`);
368
- const d = await this.walletClient.swap.getQuote(
360
+ if (!d)
361
+ throw new Error(`${a.token.symbol} pool not support flashloan`);
362
+ const y = await this.walletClient.swap.getQuote(
369
363
  s.suiCoinType,
370
- n.suiCoinType,
364
+ a.suiCoinType,
371
365
  h
372
- ), g = Number(d.amount_out);
373
- if (g <= 0)
366
+ ), B = Number(y.amount_out);
367
+ if (B <= 0)
374
368
  throw new Error("The amount of swapAmountOut must be greater than 0.");
375
- const C = Math.floor(g * (1 - w)), P = Math.floor(C / (1 + y.flashloanFee));
376
- if (P <= 0)
369
+ const S = Math.floor(B * (1 - g)), b = Math.floor(S / (1 + d.flashloanFee));
370
+ if (b <= 0)
377
371
  throw new Error("The calculated borrow amount must be positive.");
378
- const [v, E] = await ne(l, n, P), [j] = l.moveCall({
372
+ const [T, v] = await Z(o, a, b), [k] = o.moveCall({
379
373
  target: "0x2::coin::from_balance",
380
- arguments: [v],
381
- typeArguments: [n.suiCoinType]
374
+ arguments: [T],
375
+ typeArguments: [a.suiCoinType]
382
376
  });
383
- await A(l, n, j, {
384
- amount: P
377
+ await O(o, a, k, {
378
+ amount: b
385
379
  });
386
- const I = await c.withdrawCoinPTB(l, s.suiCoinType, h), U = await z(
380
+ const N = await w.withdrawCoinPTB(o, s.suiCoinType, h), F = await $(
387
381
  i,
388
- l,
389
- C,
390
- I,
391
- d
392
- ), M = l.moveCall({
382
+ o,
383
+ S,
384
+ N,
385
+ y
386
+ ), _ = o.moveCall({
393
387
  target: "0x2::coin::into_balance",
394
- arguments: [U],
395
- typeArguments: [n.suiCoinType]
396
- }), [W] = await se(l, n, E, M), [L] = l.moveCall({
388
+ arguments: [F],
389
+ typeArguments: [a.suiCoinType]
390
+ }), [j] = await tt(o, a, v, _), [I] = o.moveCall({
397
391
  target: "0x2::coin::from_balance",
398
- arguments: [W],
399
- typeArguments: [n.suiCoinType]
392
+ arguments: [j],
393
+ typeArguments: [a.suiCoinType]
400
394
  });
401
- return await A(l, n, L), l;
395
+ return await O(o, a, I), o;
402
396
  }
403
- async function Z(l, e, a, t) {
404
- var O, F, D;
397
+ async function J(o, t, e, n) {
405
398
  if (!this.walletClient)
406
399
  throw new Error("Wallet client not found");
407
- const s = this.walletClient.address, n = await this.getPool(e), u = await this.getPool(a), i = await this.getLendingState(), r = (O = t == null ? void 0 : t.protocol) != null ? O : "navi", c = await this.getProtocol(r);
408
- if (!c)
400
+ const s = this.walletClient.address, a = await this.getPool(t), l = await this.getPool(e), i = await this.getLendingState(), r = n?.protocol ?? "navi", w = await this.getProtocol(r);
401
+ if (!w)
409
402
  throw new Error(`Protocol ${r} not found`);
410
- const o = await c.getPool(n.coinType);
403
+ const u = await w.getPool(a.coinType);
411
404
  if (console.log("migrateBetweenBorrowPTB", {
412
- fromPoolLending: o
413
- }), o.borrowBalance === 0)
405
+ fromPoolLending: u
406
+ }), u.borrowBalance === 0)
414
407
  throw new Error("No borrow balance");
415
- if (t != null && t.amount && t.amount > o.borrowBalance)
408
+ if (n?.amount && n.amount > u.borrowBalance)
416
409
  throw new Error("Amount is more than borrow balance");
417
- const w = await $(), h = await Promise.all([n, u]);
418
- await q(
419
- l,
420
- G(w, {
410
+ const g = await L(), h = await Promise.all([a, l]);
411
+ await Q(
412
+ o,
413
+ K(g, {
421
414
  lendingState: i,
422
415
  pools: h
423
416
  })
424
417
  );
425
- let f = (F = t == null ? void 0 : t.amount) != null ? F : Number(o.borrowBalance);
426
- if (Number(o.borrowBalance) === f) {
427
- const de = o.borrowAPR / 100;
428
- f = Math.ceil(
429
- new R(f).multipliedBy(de * (60 * 3) / (365 * 24 * 3600)).plus(new R(1).shiftedBy(-n.token.decimals)).plus(f).toNumber()
418
+ let p = n?.amount ?? Number(u.borrowBalance);
419
+ if (Number(u.borrowBalance) === p) {
420
+ const rt = u.borrowAPR / 100;
421
+ p = Math.ceil(
422
+ new E(p).multipliedBy(rt * (60 * 3) / (365 * 24 * 3600)).plus(new E(1).shiftedBy(-a.token.decimals)).plus(p).toNumber()
430
423
  );
431
424
  }
432
- const b = await ae(n, {
425
+ const c = await Y(a, {
433
426
  env: this.config.env
434
427
  });
435
- if (!b)
436
- throw new Error(`${n.token.symbol} pool not support flashloan`);
428
+ if (!c)
429
+ throw new Error(`${a.token.symbol} pool not support flashloan`);
437
430
  if (!this.walletClient)
438
431
  throw new Error("Wallet client not found");
439
- const y = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, d = Math.ceil(f * (1 + b.flashloanFee)), g = d, C = await this.walletClient.swap.getQuote(
440
- n.suiCoinType,
441
- u.suiCoinType,
442
- g
432
+ const d = n?.slippage ?? 5e-3, y = Math.ceil(p * (1 + c.flashloanFee)), B = y, S = await this.walletClient.swap.getQuote(
433
+ a.suiCoinType,
434
+ l.suiCoinType,
435
+ B
443
436
  );
444
- let P = 1 + y, v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
445
- u.suiCoinType,
446
- n.suiCoinType,
447
- v
437
+ let b = 1 + d, T = Math.ceil(Number(S.amount_out) * b), v = await this.walletClient.swap.getQuote(
438
+ l.suiCoinType,
439
+ a.suiCoinType,
440
+ T
448
441
  );
449
- for (; Number(E.amount_out) < g; )
450
- P = P * Math.max(g / Number(E.amount_out), 1.001), v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
451
- u.suiCoinType,
452
- n.suiCoinType,
453
- v
442
+ for (; Number(v.amount_out) < B; )
443
+ b = b * Math.max(B / Number(v.amount_out), 1.001), T = Math.ceil(Number(S.amount_out) * b), v = await this.walletClient.swap.getQuote(
444
+ l.suiCoinType,
445
+ a.suiCoinType,
446
+ T
454
447
  );
455
- const [j, I] = await ne(l, n, f), [U] = l.moveCall({
448
+ const [k, N] = await Z(o, a, p), [F] = o.moveCall({
456
449
  target: "0x2::coin::from_balance",
457
- arguments: [j],
458
- typeArguments: [n.suiCoinType]
450
+ arguments: [k],
451
+ typeArguments: [a.suiCoinType]
459
452
  });
460
- await c.repayCoinPTB(l, n.suiCoinType, U, f);
461
- const M = await ie(l, u, v), W = await z(
453
+ await w.repayCoinPTB(o, a.suiCoinType, F, p);
454
+ const _ = await et(o, l, T), j = await $(
462
455
  s,
463
- l,
464
- d,
465
- M,
466
- E
467
- ), L = l.moveCall({
456
+ o,
457
+ y,
458
+ _,
459
+ v
460
+ ), I = o.moveCall({
468
461
  target: "0x2::coin::into_balance",
469
- arguments: [W],
470
- typeArguments: [n.suiCoinType]
471
- }), [k] = await se(l, n, I, L), [N] = l.moveCall({
462
+ arguments: [j],
463
+ typeArguments: [a.suiCoinType]
464
+ }), [U] = await tt(o, a, N, I), [lt] = o.moveCall({
472
465
  target: "0x2::coin::from_balance",
473
- arguments: [k],
474
- typeArguments: [n.suiCoinType]
466
+ arguments: [U],
467
+ typeArguments: [a.suiCoinType]
475
468
  });
476
- return l.transferObjects([N], s), l;
469
+ return o.transferObjects([lt], s), o;
477
470
  }
478
- async function ee(l, e, a, t) {
479
- var w, h;
471
+ async function V(o, t, e, n) {
480
472
  if (!this.walletClient)
481
473
  throw new Error("Wallet client not found");
482
- const s = await te(this.walletClient.address, {
474
+ const s = await X(this.walletClient.address, {
483
475
  client: this.walletClient.client,
484
- coinType: e
485
- }), n = await this.getPool(a), i = new S(s).getBalance(e);
476
+ coinType: t
477
+ }), a = await this.getPool(e), i = new R(s).getBalance(t);
486
478
  if (i.amount.eq(0))
487
- throw new Error(`No balance of ${e}`);
479
+ throw new Error(`No balance of ${t}`);
488
480
  if (console.log("migrateBalanceToSupplyPTB", {
489
481
  balance: i.amount.toNumber()
490
- }), t != null && t.amount && i.amount.lt(t.amount))
482
+ }), n?.amount && i.amount.lt(n.amount))
491
483
  throw new Error("Amount is greater than balance");
492
- const r = (w = t == null ? void 0 : t.amount) != null ? w : i.amount.toNumber(), c = (h = t == null ? void 0 : t.slippage) != null ? h : 5e-3;
493
- let o = await B(l, i.coins, {
484
+ const r = n?.amount ?? i.amount.toNumber(), w = n?.slippage ?? 5e-3;
485
+ let u = await C(o, i.coins, {
494
486
  balance: r,
495
487
  useGasCoin: !0
496
488
  });
497
- if (p(e) !== p(n.suiCoinType)) {
498
- const f = await this.walletClient.swap.getQuote(e, n.suiCoinType, r);
499
- o = await this.walletClient.swap.buildSwapPTBFromQuote(
500
- l,
501
- f,
489
+ if (m(t) !== m(a.suiCoinType)) {
490
+ const g = await this.walletClient.swap.getQuote(t, a.suiCoinType, r);
491
+ u = await this.walletClient.swap.buildSwapPTBFromQuote(
502
492
  o,
503
- c
493
+ g,
494
+ u,
495
+ w
504
496
  );
505
497
  }
506
- return await A(l, n, o), l;
498
+ return await O(o, a, u), o;
507
499
  }
508
- class Fe {
509
- constructor(e) {
510
- this.name = "navi", this.walletClient = e;
511
- }
512
- async getPool(e) {
513
- const a = await this.walletClient.lending.getPool(e), s = (await this.walletClient.lending.getLendingState()).find(
514
- (i) => i.pool.suiCoinType === p(e)
515
- ), n = s ? new R(s.supplyBalance).toNumber() : 0, u = s ? new R(s.borrowBalance).toNumber() : 0;
500
+ class xt {
501
+ constructor(t) {
502
+ this.name = "navi", this.walletClient = t;
503
+ }
504
+ async getPool(t) {
505
+ const e = await this.walletClient.lending.getPool(t), s = (await this.walletClient.lending.getLendingState()).find(
506
+ (i) => i.pool.suiCoinType === m(t)
507
+ ), a = s ? new E(s.supplyBalance).toNumber() : 0, l = s ? new E(s.borrowBalance).toNumber() : 0;
516
508
  return {
517
- supplyBalance: n,
518
- borrowBalance: u,
519
- borrowAPR: parseFloat(a.borrowIncentiveApyInfo.apy)
509
+ supplyBalance: a,
510
+ borrowBalance: l,
511
+ borrowAPR: parseFloat(e.borrowIncentiveApyInfo.apy)
520
512
  };
521
513
  }
522
- async depositCoinPTB(e, a, t, s) {
514
+ async depositCoinPTB(t, e, n, s) {
523
515
  throw new Error("Not implemented");
524
516
  }
525
- async withdrawCoinPTB(e, a, t) {
526
- return le(e, a, t);
517
+ async withdrawCoinPTB(t, e, n) {
518
+ return nt(t, e, n);
527
519
  }
528
- async borrowCoinPTB(e, a, t) {
520
+ async borrowCoinPTB(t, e, n) {
529
521
  throw new Error("Not implemented");
530
522
  }
531
- async repayCoinPTB(e, a, t, s) {
532
- re(e, a, t, { amount: s });
523
+ async repayCoinPTB(t, e, n, s) {
524
+ at(t, e, n, { amount: s });
533
525
  }
534
526
  }
535
- class H {
536
- constructor(e, a, t) {
537
- this.name = "suilend", this.walletClient = e, this.obligationOwnerCap = a, this.suilendClient = t;
538
- }
539
- static async create(e) {
540
- const [a, t] = await Promise.all([
541
- V.initialize(Ee, X, e.client),
542
- V.getObligationOwnerCaps(
543
- e.address,
544
- [X],
545
- e.client
527
+ class q {
528
+ constructor(t, e, n) {
529
+ this.name = "suilend", this.walletClient = t, this.obligationOwnerCap = e, this.suilendClient = n;
530
+ }
531
+ static async create(t) {
532
+ const [e, n] = await Promise.all([
533
+ z.initialize(Bt, H, t.client),
534
+ z.getObligationOwnerCaps(
535
+ t.address,
536
+ [H],
537
+ t.client
546
538
  )
547
539
  ]);
548
- if (t.length === 0)
549
- throw new Error("No existing obligations found for wallet address: " + e.address);
550
- return new H(e, t[0], a);
551
- }
552
- async getPool(e) {
553
- var b, y;
554
- const a = p(e), t = this.suilendClient.lendingMarket.reserves, s = /* @__PURE__ */ new Set();
555
- t.forEach((d) => {
556
- s.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((g) => {
557
- g && s.add(p(g.coinType.name));
558
- }), d.borrowsPoolRewardManager.poolRewards.forEach((g) => {
559
- g && s.add(p(g.coinType.name));
540
+ if (n.length === 0)
541
+ throw new Error("No existing obligations found for wallet address: " + t.address);
542
+ return new q(t, n[0], e);
543
+ }
544
+ async getPool(t) {
545
+ const e = m(t), n = this.suilendClient.lendingMarket.reserves, s = /* @__PURE__ */ new Set();
546
+ n.forEach((c) => {
547
+ s.add(m(c.coinType.name)), c.depositsPoolRewardManager.poolRewards.forEach((d) => {
548
+ d && s.add(m(d.coinType.name));
549
+ }), c.borrowsPoolRewardManager.poolRewards.forEach((d) => {
550
+ d && s.add(m(d.coinType.name));
560
551
  });
561
552
  });
562
- const n = await Oe(Array.from(s)), i = t.map((d) => Re(d, n)).reduce(
563
- (d, g) => (d[g.coinType] = g, d),
553
+ const a = await Et(Array.from(s)), i = n.map((c) => Tt(c, a)).reduce(
554
+ (c, d) => (c[d.coinType] = d, c),
564
555
  {}
565
556
  ), r = await this.suilendClient.getObligation(
566
557
  this.obligationOwnerCap.obligationId
567
- ), c = Se(r, i), o = c.deposits.find((d) => d.coinType === a), w = c.borrows.find((d) => d.coinType === a), h = n[a].decimals;
558
+ ), w = vt(r, i), u = w.deposits.find((c) => c.coinType === e), g = w.borrows.find((c) => c.coinType === e), h = a[e].decimals;
568
559
  return {
569
- cTokenExchangeRate: i[a].cTokenExchangeRate.toNumber(),
570
- supplyBalance: (b = o == null ? void 0 : o.depositedAmount.shiftedBy(h).decimalPlaces(0).toNumber()) != null ? b : 0,
571
- borrowBalance: (y = w == null ? void 0 : w.borrowedAmount.shiftedBy(h).decimalPlaces(0).toNumber()) != null ? y : 0,
572
- borrowAPR: i[a].borrowAprPercent.toNumber()
560
+ cTokenExchangeRate: i[e].cTokenExchangeRate.toNumber(),
561
+ supplyBalance: u?.depositedAmount.shiftedBy(h).decimalPlaces(0).toNumber() ?? 0,
562
+ borrowBalance: g?.borrowedAmount.shiftedBy(h).decimalPlaces(0).toNumber() ?? 0,
563
+ borrowAPR: i[e].borrowAprPercent.toNumber()
573
564
  };
574
565
  }
575
- async depositCoinPTB(e, a, t, s) {
566
+ async depositCoinPTB(t, e, n, s) {
576
567
  throw new Error("Not implemented");
577
568
  }
578
- async withdrawCoinPTB(e, a, t) {
579
- const s = await this.getPool(a), n = t === s.supplyBalance;
569
+ async withdrawCoinPTB(t, e, n) {
570
+ const s = await this.getPool(e), a = n === s.supplyBalance;
580
571
  return await this.suilendClient.withdraw(
581
572
  this.obligationOwnerCap.id,
582
573
  this.obligationOwnerCap.obligationId,
583
- a,
584
- n ? Ae.toString() : Math.ceil(t / s.cTokenExchangeRate).toString(),
585
- e
574
+ e,
575
+ a ? Rt.toString() : Math.ceil(n / s.cTokenExchangeRate).toString(),
576
+ t
586
577
  );
587
578
  }
588
- async borrowCoinPTB(e, a, t) {
579
+ async borrowCoinPTB(t, e, n) {
589
580
  throw new Error("Not implemented");
590
581
  }
591
- async repayCoinPTB(e, a, t, s) {
592
- this.suilendClient.repay(this.obligationOwnerCap.obligationId, a, t, e), e.transferObjects([t], e.pure.address(this.walletClient.address));
582
+ async repayCoinPTB(t, e, n, s) {
583
+ this.suilendClient.repay(this.obligationOwnerCap.obligationId, e, n, t), t.transferObjects([n], t.pure.address(this.walletClient.address));
593
584
  }
594
585
  }
595
- class _e extends x {
586
+ class kt extends A {
596
587
  constructor() {
597
588
  super(), this.name = "lending", this.defaultConfig = {
598
589
  env: "prod",
599
590
  protocols: []
600
- }, 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);
591
+ }, this._protocols = [], this.migrateBetweenSupplyPTB = D, this.migrateBetweenBorrowPTB = J, this.migrateBalanceToSupplyPTB = V, this.migrateBetweenSupplyPTB = D.bind(this), this.migrateBetweenBorrowPTB = J.bind(this), this.migrateBalanceToSupplyPTB = V.bind(this);
601
592
  }
602
593
  /** Get protocols (either from internal storage or config) */
603
594
  get protocols() {
604
595
  return this._protocols.length > 0 ? this._protocols : this.config.protocols;
605
596
  }
606
- async getProtocol(e) {
607
- return (!this.protocols || this.protocols.length === 0) && await this.initializeProtocols(), this.protocols.find((a) => a.name === e);
597
+ async getProtocol(t) {
598
+ return (!this.protocols || this.protocols.length === 0) && await this.initializeProtocols(), this.protocols.find((e) => e.name === t);
608
599
  }
609
600
  /**
610
601
  * Gets all available lending pools
@@ -612,10 +603,10 @@ class _e extends x {
612
603
  * @param options - Optional caching options
613
604
  * @returns Array of pool information
614
605
  */
615
- async getPools(e) {
616
- return await me({
606
+ async getPools(t) {
607
+ return await ht({
617
608
  env: this.config.env,
618
- ...e
609
+ ...t
619
610
  });
620
611
  }
621
612
  /**
@@ -625,10 +616,10 @@ class _e extends x {
625
616
  * @param options - Optional caching options
626
617
  * @returns Pool information
627
618
  */
628
- async getPool(e, a) {
629
- return await T(e, {
619
+ async getPool(t, e) {
620
+ return await P(t, {
630
621
  env: this.config.env,
631
- ...a
622
+ ...e
632
623
  });
633
624
  }
634
625
  /**
@@ -639,30 +630,29 @@ class _e extends x {
639
630
  * @param options - Optional parameters including dry run mode and account capability
640
631
  * @returns Transaction response or dry run response
641
632
  */
642
- async deposit(e, a, t) {
643
- var c, o, w;
633
+ async deposit(t, e, n) {
644
634
  if (!this.walletClient)
645
635
  throw new Error("Wallet client not found");
646
- const s = await T(e, {
636
+ const s = await P(t, {
647
637
  env: this.config.env
648
638
  });
649
639
  await this.walletClient.module("balance").waitForUpdate();
650
- const n = new m(), u = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, u.coins, {
651
- balance: a,
640
+ const a = new f(), l = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = C(a, l.coins, {
641
+ balance: e,
652
642
  useGasCoin: !0
653
643
  });
654
- await A(n, s, i, {
644
+ await O(a, s, i, {
655
645
  env: this.config.env,
656
- amount: a,
657
- accountCap: t == null ? void 0 : t.accountCap
646
+ amount: e,
647
+ accountCap: n?.accountCap
658
648
  });
659
649
  const r = await this.walletClient.signExecuteTransaction({
660
- transaction: n,
661
- dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
650
+ transaction: a,
651
+ dryRun: n?.dryRun ?? !1
662
652
  });
663
- return !(t != null && t.dryRun) && ((w = (o = r.effects) == null ? void 0 : o.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:deposit-success", {
664
- identifier: e,
665
- amount: a
653
+ return !n?.dryRun && r.effects?.status?.status === "success" && (this.emit("lending:deposit-success", {
654
+ identifier: t,
655
+ amount: e
666
656
  }), this.walletClient.module("balance").updatePortfolio()), r;
667
657
  }
668
658
  /**
@@ -673,26 +663,25 @@ class _e extends x {
673
663
  * @param options - Optional parameters including dry run mode and account capability
674
664
  * @returns Transaction response or dry run response
675
665
  */
676
- async withdraw(e, a, t) {
677
- var r, c, o;
666
+ async withdraw(t, e, n) {
678
667
  if (!this.walletClient)
679
668
  throw new Error("Wallet client not found");
680
- const s = await T(e, {
669
+ const s = await P(t, {
681
670
  env: this.config.env
682
- }), n = new m();
683
- t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
684
- const u = await le(n, s, a, {
671
+ }), a = new f();
672
+ n?.disableUpdateOracle || await this.updateOraclePTB(a, [s]);
673
+ const l = await nt(a, s, e, {
685
674
  env: this.config.env,
686
- accountCap: t == null ? void 0 : t.accountCap
675
+ accountCap: n?.accountCap
687
676
  });
688
- n.transferObjects([u], this.walletClient.address);
677
+ a.transferObjects([l], this.walletClient.address);
689
678
  const i = await this.walletClient.signExecuteTransaction({
690
- transaction: n,
691
- dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
679
+ transaction: a,
680
+ dryRun: n?.dryRun ?? !1
692
681
  });
693
- return !(t != null && t.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:withdraw-success", {
694
- identifier: e,
695
- amount: a
682
+ return !n?.dryRun && i.effects?.status?.status === "success" && (this.emit("lending:withdraw-success", {
683
+ identifier: t,
684
+ amount: e
696
685
  }), this.walletClient.module("balance").updatePortfolio()), i;
697
686
  }
698
687
  /**
@@ -703,26 +692,25 @@ class _e extends x {
703
692
  * @param options - Optional parameters including dry run mode and account capability
704
693
  * @returns Transaction response or dry run response
705
694
  */
706
- async borrow(e, a, t) {
707
- var r, c, o;
695
+ async borrow(t, e, n) {
708
696
  if (!this.walletClient)
709
697
  throw new Error("Wallet client not found");
710
- const s = await T(e, {
698
+ const s = await P(t, {
711
699
  env: this.config.env
712
- }), n = new m();
713
- t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
714
- const u = await ie(n, s, a, {
700
+ }), a = new f();
701
+ n?.disableUpdateOracle || await this.updateOraclePTB(a, [s]);
702
+ const l = await et(a, s, e, {
715
703
  env: this.config.env,
716
- accountCap: t == null ? void 0 : t.accountCap
704
+ accountCap: n?.accountCap
717
705
  });
718
- n.transferObjects([u], this.walletClient.address);
706
+ a.transferObjects([l], this.walletClient.address);
719
707
  const i = await this.walletClient.signExecuteTransaction({
720
- transaction: n,
721
- dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
708
+ transaction: a,
709
+ dryRun: n?.dryRun ?? !1
722
710
  });
723
- return !(t != null && t.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:borrow-success", {
724
- identifier: e,
725
- amount: a
711
+ return !n?.dryRun && i.effects?.status?.status === "success" && (this.emit("lending:borrow-success", {
712
+ identifier: t,
713
+ amount: e
726
714
  }), this.walletClient.module("balance").updatePortfolio()), i;
727
715
  }
728
716
  /**
@@ -733,29 +721,28 @@ class _e extends x {
733
721
  * @param options - Optional parameters including dry run mode and account capability
734
722
  * @returns Transaction response or dry run response
735
723
  */
736
- async repay(e, a, t) {
737
- var c, o, w;
724
+ async repay(t, e, n) {
738
725
  if (!this.walletClient)
739
726
  throw new Error("Wallet client not found");
740
727
  await this.walletClient.module("balance").waitForUpdate();
741
- const s = await T(e, {
728
+ const s = await P(t, {
742
729
  env: this.config.env
743
- }), n = new m(), u = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, u.coins, {
744
- balance: a,
730
+ }), a = new f(), l = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = C(a, l.coins, {
731
+ balance: e,
745
732
  useGasCoin: !0
746
733
  });
747
- await re(n, s, i, {
734
+ await at(a, s, i, {
748
735
  env: this.config.env,
749
- amount: a,
750
- accountCap: t == null ? void 0 : t.accountCap
736
+ amount: e,
737
+ accountCap: n?.accountCap
751
738
  });
752
739
  const r = await this.walletClient.signExecuteTransaction({
753
- transaction: n,
754
- dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
740
+ transaction: a,
741
+ dryRun: n?.dryRun ?? !1
755
742
  });
756
- return !(t != null && t.dryRun) && ((w = (o = r.effects) == null ? void 0 : o.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:repay-success", {
757
- identifier: e,
758
- amount: a
743
+ return !n?.dryRun && r.effects?.status?.status === "success" && (this.emit("lending:repay-success", {
744
+ identifier: t,
745
+ amount: e
759
746
  }), this.walletClient.module("balance").updatePortfolio()), r;
760
747
  }
761
748
  /**
@@ -766,8 +753,8 @@ class _e extends x {
766
753
  async getHealthFactor() {
767
754
  if (!this.walletClient)
768
755
  throw new Error("Wallet client not found");
769
- const e = this.walletClient.address;
770
- return await Ce(e, {
756
+ const t = this.walletClient.address;
757
+ return await ft(t, {
771
758
  env: this.config.env,
772
759
  client: this.walletClient.client
773
760
  });
@@ -782,46 +769,45 @@ class _e extends x {
782
769
  * @param options - Optional parameters including dry run mode
783
770
  * @returns Transaction response or dry run response
784
771
  */
785
- async liquidate(e, a, t, s, n) {
786
- var d, g, C;
772
+ async liquidate(t, e, n, s, a) {
787
773
  if (!this.walletClient)
788
774
  throw new Error("Wallet client not found");
789
- const u = await T(e, {
775
+ const l = await P(t, {
790
776
  env: this.config.env
791
- }), i = await T(t, {
777
+ }), i = await P(n, {
792
778
  env: this.config.env
793
- }), r = new m(), c = this.walletClient.module("balance").portfolio.getBalance(u.suiCoinType), o = B(r, c.coins, {
794
- balance: a,
779
+ }), r = new f(), w = this.walletClient.module("balance").portfolio.getBalance(l.suiCoinType), u = C(r, w.coins, {
780
+ balance: e,
795
781
  useGasCoin: !0
796
- }), [w, h] = await be(
782
+ }), [g, h] = await gt(
797
783
  r,
784
+ l,
798
785
  u,
799
- o,
800
786
  i,
801
787
  s,
802
788
  {
803
789
  env: this.config.env
804
790
  }
805
- ), [f] = r.moveCall({
791
+ ), [p] = r.moveCall({
806
792
  target: "0x2::coin::from_balance",
807
- arguments: [w],
793
+ arguments: [g],
808
794
  typeArguments: [i.suiCoinType]
809
- }), [b] = r.moveCall({
795
+ }), [c] = r.moveCall({
810
796
  target: "0x2::coin::from_balance",
811
797
  arguments: [h],
812
- typeArguments: [u.suiCoinType]
798
+ typeArguments: [l.suiCoinType]
813
799
  });
814
- r.transferObjects([f, b], this.walletClient.address);
815
- const y = await this.walletClient.signExecuteTransaction({
800
+ r.transferObjects([p, c], this.walletClient.address);
801
+ const d = await this.walletClient.signExecuteTransaction({
816
802
  transaction: r,
817
- dryRun: (d = n == null ? void 0 : n.dryRun) != null ? d : !1
803
+ dryRun: a?.dryRun ?? !1
818
804
  });
819
- return !(n != null && n.dryRun) && ((C = (g = y.effects) == null ? void 0 : g.status) == null ? void 0 : C.status) === "success" && (this.emit("lending:liquidate-success", {
820
- payIdentifier: e,
821
- payAmount: a,
822
- collateralIdentifier: t,
805
+ return !a?.dryRun && d.effects?.status?.status === "success" && (this.emit("lending:liquidate-success", {
806
+ payIdentifier: t,
807
+ payAmount: e,
808
+ collateralIdentifier: n,
823
809
  liquidationAddress: s
824
- }), this.walletClient.module("balance").updatePortfolio()), y;
810
+ }), this.walletClient.module("balance").updatePortfolio()), d;
825
811
  }
826
812
  /**
827
813
  * Gets the available lending rewards for the current user.
@@ -830,11 +816,11 @@ class _e extends x {
830
816
  * @returns The available lending rewards for the user.
831
817
  * @throws If the wallet client is not found.
832
818
  */
833
- async getAvailableRewards(e) {
819
+ async getAvailableRewards(t) {
834
820
  if (!this.walletClient)
835
821
  throw new Error("Wallet client not found");
836
- return J(this.walletClient.address, {
837
- ...e,
822
+ return G(this.walletClient.address, {
823
+ ...t,
838
824
  env: this.config.env
839
825
  });
840
826
  }
@@ -845,11 +831,11 @@ class _e extends x {
845
831
  * @returns The claimed reward history for the user.
846
832
  * @throws If the wallet client is not found.
847
833
  */
848
- async getClaimedRewardHistory(e) {
834
+ async getClaimedRewardHistory(t) {
849
835
  if (!this.walletClient)
850
836
  throw new Error("Wallet client not found");
851
- return ye(this.walletClient.address, {
852
- ...e
837
+ return pt(this.walletClient.address, {
838
+ ...t
853
839
  });
854
840
  }
855
841
  /**
@@ -858,35 +844,34 @@ class _e extends x {
858
844
  * @param options - Optional parameters including dry run mode and account capability
859
845
  * @returns Transaction response or dry run response
860
846
  */
861
- async claimAllRewards(e) {
862
- var n, u, i;
847
+ async claimAllRewards(t) {
863
848
  if (!this.walletClient)
864
849
  throw new Error("Wallet client not found");
865
- const a = new m(), t = await J(this.walletClient.address, {
850
+ const e = new f(), n = await G(this.walletClient.address, {
866
851
  env: this.config.env
867
852
  });
868
- await pe(a, t, {
853
+ await mt(e, n, {
869
854
  env: this.config.env,
870
- accountCap: e == null ? void 0 : e.accountCap
855
+ accountCap: t?.accountCap
871
856
  });
872
857
  const s = await this.walletClient.signExecuteTransaction({
873
- transaction: a,
874
- dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
858
+ transaction: e,
859
+ dryRun: t?.dryRun ?? !1
875
860
  });
876
- return !(e != null && e.dryRun) && ((i = (u = s.effects) == null ? void 0 : u.status) == null ? void 0 : i.status) === "success" && (this.emit("lending:claim-rewards-success", {
877
- rewards: t
861
+ return !t?.dryRun && s.effects?.status?.status === "success" && (this.emit("lending:claim-rewards-success", {
862
+ rewards: n
878
863
  }), this.walletClient.module("balance").updatePortfolio()), s;
879
864
  }
880
- async updateOraclePTB(e, a) {
881
- const t = await $({
865
+ async updateOraclePTB(t, e) {
866
+ const n = await L({
882
867
  env: this.config.env
883
868
  }), s = await this.getLendingState({
884
869
  cacheTime: 60 * 1e3
885
- }), n = G(t, {
870
+ }), a = K(n, {
886
871
  lendingState: s,
887
- pools: a
872
+ pools: e
888
873
  });
889
- await q(e, n, {
874
+ await Q(t, a, {
890
875
  env: this.config.env,
891
876
  updatePythPriceFeeds: !0
892
877
  });
@@ -898,14 +883,13 @@ class _e extends x {
898
883
  * @param options.dryRun - Whether to perform a dry run
899
884
  * @returns Transaction response or dry run response
900
885
  */
901
- async updateOracle(e) {
902
- var s;
886
+ async updateOracle(t) {
903
887
  if (!this.walletClient)
904
888
  throw new Error("Wallet client not found");
905
- const a = new m();
906
- return await this.updateOraclePTB(a, e == null ? void 0 : e.pools), await this.walletClient.signExecuteTransaction({
907
- transaction: a,
908
- dryRun: (s = e == null ? void 0 : e.dryRun) != null ? s : !1
889
+ const e = new f();
890
+ return await this.updateOraclePTB(e, t?.pools), await this.walletClient.signExecuteTransaction({
891
+ transaction: e,
892
+ dryRun: t?.dryRun ?? !1
909
893
  });
910
894
  }
911
895
  /**
@@ -914,12 +898,12 @@ class _e extends x {
914
898
  * @param options - Optional caching options
915
899
  * @returns User's lending state information
916
900
  */
917
- async getLendingState(e) {
901
+ async getLendingState(t) {
918
902
  if (!this.walletClient)
919
903
  throw new Error("Wallet client not found");
920
- return await Pe(this.walletClient.address, {
904
+ return await Ct(this.walletClient.address, {
921
905
  env: this.config.env,
922
- ...e,
906
+ ...t,
923
907
  client: this.walletClient.client
924
908
  });
925
909
  }
@@ -929,14 +913,13 @@ class _e extends x {
929
913
  * @param options - Optional parameters including dry run mode
930
914
  * @returns Transaction response or dry run response
931
915
  */
932
- async createAccountCap(e) {
933
- var n;
916
+ async createAccountCap(t) {
934
917
  if (!this.walletClient)
935
918
  throw new Error("Wallet client not found");
936
- const a = new m(), t = await Be(a);
937
- return a.transferObjects([t], this.walletClient.address), await this.walletClient.signExecuteTransaction({
938
- transaction: a,
939
- dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
919
+ const e = new f(), n = await bt(e);
920
+ return e.transferObjects([n], this.walletClient.address), await this.walletClient.signExecuteTransaction({
921
+ transaction: e,
922
+ dryRun: t?.dryRun ?? !1
940
923
  });
941
924
  }
942
925
  async initializeProtocols() {
@@ -944,25 +927,25 @@ class _e extends x {
944
927
  console.warn("Wallet client not available during protocol initialization");
945
928
  return;
946
929
  }
947
- const e = [];
948
- e.push(new Fe(this.walletClient));
930
+ const t = [];
931
+ t.push(new xt(this.walletClient));
949
932
  try {
950
- e.push(await H.create(this.walletClient));
951
- } catch (a) {
952
- console.warn("Failed to initialize SuilendProtocol:", a);
933
+ t.push(await q.create(this.walletClient));
934
+ } catch (e) {
935
+ console.warn("Failed to initialize SuilendProtocol:", e);
953
936
  }
954
- this._protocols = e;
937
+ this._protocols = t;
955
938
  }
956
939
  }
957
- class je extends x {
940
+ class Nt extends A {
958
941
  constructor() {
959
942
  super(...arguments), this.name = "volo", this.defaultConfig = {
960
943
  packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
961
944
  poolId: "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5",
962
945
  metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
963
946
  coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
964
- }, this.getStats = oe(
965
- K(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
947
+ }, this.getStats = st(
948
+ W(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((e) => e.json())).data)
966
949
  );
967
950
  }
968
951
  /**
@@ -972,18 +955,18 @@ class je extends x {
972
955
  * @param suiCoin - The SUI coin object to stake
973
956
  * @returns The vSUI coin object received from staking
974
957
  */
975
- async stakePTB(e, a) {
976
- const [t] = e.moveCall({
958
+ async stakePTB(t, e) {
959
+ const [n] = t.moveCall({
977
960
  target: `${this.config.packageId}::stake_pool::stake`,
978
961
  arguments: [
979
- e.object(this.config.poolId),
980
- e.object(this.config.metadataId),
981
- e.object("0x05"),
982
- _(a, e.object)
962
+ t.object(this.config.poolId),
963
+ t.object(this.config.metadataId),
964
+ t.object("0x05"),
965
+ x(e, t.object)
983
966
  ],
984
967
  typeArguments: []
985
968
  });
986
- return t;
969
+ return n;
987
970
  }
988
971
  /**
989
972
  * Adds unstaking operation to a transaction black
@@ -992,18 +975,18 @@ class je extends x {
992
975
  * @param vSuiCoin - The vSUI coin object to unstake
993
976
  * @returns The SUI coin object received from unstaking
994
977
  */
995
- async unstakePTB(e, a) {
996
- const [t] = e.moveCall({
978
+ async unstakePTB(t, e) {
979
+ const [n] = t.moveCall({
997
980
  target: `${this.config.packageId}::stake_pool::unstake`,
998
981
  arguments: [
999
- e.object(this.config.poolId),
1000
- e.object(this.config.metadataId),
1001
- e.object("0x05"),
1002
- _(a, e.object)
982
+ t.object(this.config.poolId),
983
+ t.object(this.config.metadataId),
984
+ t.object("0x05"),
985
+ x(e, t.object)
1003
986
  ],
1004
987
  typeArguments: []
1005
988
  });
1006
- return t;
989
+ return n;
1007
990
  }
1008
991
  /**
1009
992
  * Stake SUI tokens to receive vSUI tokens
@@ -1013,25 +996,24 @@ class je extends x {
1013
996
  * @returns Transaction response or dry run response
1014
997
  * @throws Error if wallet client not found or stake amount is too low
1015
998
  */
1016
- async stake(e, a) {
1017
- var r, c, o;
999
+ async stake(t, e) {
1018
1000
  if (!this.walletClient)
1019
1001
  throw new Error("Wallet client not found");
1020
- if (e < 1e9)
1002
+ if (t < 1e9)
1021
1003
  throw new Error("Stake amount should be greater than 1Sui");
1022
- const t = new m();
1004
+ const n = new f();
1023
1005
  await this.walletClient.module("balance").waitForUpdate();
1024
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1025
- balance: e,
1006
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), a = C(n, s.coins, {
1007
+ balance: t,
1026
1008
  useGasCoin: !0
1027
- }), u = await this.stakePTB(t, n);
1028
- t.transferObjects([u], this.walletClient.address);
1009
+ }), l = await this.stakePTB(n, a);
1010
+ n.transferObjects([l], this.walletClient.address);
1029
1011
  const i = await this.walletClient.signExecuteTransaction({
1030
- transaction: t,
1031
- dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
1012
+ transaction: n,
1013
+ dryRun: e?.dryRun ?? !1
1032
1014
  });
1033
- return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:stake-success", {
1034
- suiAmount: e
1015
+ return !e?.dryRun && i.effects?.status?.status === "success" && (this.emit("volo:stake-success", {
1016
+ suiAmount: t
1035
1017
  }), this.walletClient.module("balance").updatePortfolio()), i;
1036
1018
  }
1037
1019
  /**
@@ -1042,27 +1024,26 @@ class je extends x {
1042
1024
  * @returns Transaction response or dry run response
1043
1025
  * @throws Error if wallet client not found or unstake amount is too low
1044
1026
  */
1045
- async unstake(e, a) {
1046
- var r, c, o;
1027
+ async unstake(t, e) {
1047
1028
  if (!this.walletClient)
1048
1029
  throw new Error("Wallet client not found");
1049
- if (e < 1e9)
1030
+ if (t < 1e9)
1050
1031
  throw new Error("Unstake amount should >= 1vSui");
1051
1032
  await this.walletClient.module("balance").waitForUpdate();
1052
- const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
1053
- balance: e
1054
- }), u = await this.unstakePTB(t, n);
1055
- t.transferObjects([u], this.walletClient.address);
1033
+ const n = new f(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), a = C(n, s.coins, {
1034
+ balance: t
1035
+ }), l = await this.unstakePTB(n, a);
1036
+ n.transferObjects([l], this.walletClient.address);
1056
1037
  const i = await this.walletClient.signExecuteTransaction({
1057
- transaction: t,
1058
- dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
1038
+ transaction: n,
1039
+ dryRun: e?.dryRun ?? !1
1059
1040
  });
1060
- return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:unstake-success", {
1061
- vSuiAmount: e
1041
+ return !e?.dryRun && i.effects?.status?.status === "success" && (this.emit("volo:unstake-success", {
1042
+ vSuiAmount: t
1062
1043
  }), this.walletClient.module("balance").updatePortfolio()), i;
1063
1044
  }
1064
1045
  }
1065
- class Ie extends x {
1046
+ class Ft extends A {
1066
1047
  constructor() {
1067
1048
  super(...arguments), this.name = "swap", this.defaultConfig = {
1068
1049
  apiKey: "",
@@ -1079,7 +1060,7 @@ class Ie extends x {
1079
1060
  * @returns Referral ID if API key is configured, otherwise 0
1080
1061
  */
1081
1062
  get referral() {
1082
- return this.config.apiKey ? Te(this.config.apiKey) : 0;
1063
+ return this.config.apiKey ? yt(this.config.apiKey) : 0;
1083
1064
  }
1084
1065
  /**
1085
1066
  * Get the swap options
@@ -1100,8 +1081,8 @@ class Ie extends x {
1100
1081
  * @param fromAmount - The amount of the coin being swapped from
1101
1082
  * @returns A promise that resolves with the quote
1102
1083
  */
1103
- async getQuote(e, a, t) {
1104
- return ve(e, a, t, this.config.apiKey, this.swapOptions);
1084
+ async getQuote(t, e, n) {
1085
+ return Pt(t, e, n, this.config.apiKey, this.swapOptions);
1105
1086
  }
1106
1087
  /**
1107
1088
  * Builds a swap transaction from a quote
@@ -1111,16 +1092,16 @@ class Ie extends x {
1111
1092
  * @param slippage - The slippage tolerance
1112
1093
  * @returns The swap transaction
1113
1094
  */
1114
- async buildSwapPTBFromQuote(e, a, t, s) {
1095
+ async buildSwapPTBFromQuote(t, e, n, s) {
1115
1096
  if (!this.walletClient)
1116
1097
  throw new Error("Wallet client not found");
1117
- const n = new R(a.amount_out).multipliedBy(1 - s).toFixed(0);
1118
- return await z(
1098
+ const a = new E(e.amount_out).multipliedBy(1 - s).toFixed(0);
1099
+ return await $(
1119
1100
  this.walletClient.address,
1120
- e,
1121
- Number(n),
1122
1101
  t,
1123
- a,
1102
+ Number(a),
1103
+ n,
1104
+ e,
1124
1105
  this.referral,
1125
1106
  !1,
1126
1107
  this.config.apiKey,
@@ -1144,58 +1125,57 @@ class Ie extends x {
1144
1125
  * @param options - Optional parameters including dry run mode
1145
1126
  * @returns Transaction response or dry run response
1146
1127
  */
1147
- async swap(e, a, t, s, n) {
1148
- var y, d, g;
1128
+ async swap(t, e, n, s, a) {
1149
1129
  if (!this.walletClient)
1150
1130
  throw new Error("Wallet client not found");
1151
1131
  await this.walletClient.module("balance").waitForUpdate();
1152
- const u = this.walletClient.module("balance").portfolio.getBalance(e), i = new m(), r = B(i, u.coins, {
1153
- balance: t,
1132
+ const l = this.walletClient.module("balance").portfolio.getBalance(t), i = new f(), r = C(i, l.coins, {
1133
+ balance: n,
1154
1134
  useGasCoin: !0
1155
- }), c = await this.getQuote(e, a, t), o = await this.buildSwapPTBFromQuote(i, c, r, s);
1156
- if (i.transferObjects([o], this.walletClient.address), i.setSender(this.walletClient.address), n != null && n.dryRun)
1135
+ }), w = await this.getQuote(t, e, n), u = await this.buildSwapPTBFromQuote(i, w, r, s);
1136
+ if (i.transferObjects([u], this.walletClient.address), i.setSender(this.walletClient.address), a?.dryRun)
1157
1137
  return await this.walletClient.signExecuteTransaction({
1158
1138
  transaction: i,
1159
1139
  dryRun: !0
1160
1140
  });
1161
- const w = await i.build({
1141
+ const g = await i.build({
1162
1142
  client: this.walletClient.client
1163
- }), h = await this.walletClient.signer.signTransaction(w), f = [h.signature];
1143
+ }), h = await this.walletClient.signer.signTransaction(g), p = [h.signature];
1164
1144
  try {
1165
- await xe(h.bytes, f);
1166
- } catch (C) {
1167
- console.error(C);
1145
+ await St(h.bytes, p);
1146
+ } catch (d) {
1147
+ console.error(d);
1168
1148
  }
1169
- const b = await this.walletClient.client.executeTransactionBlock({
1149
+ const c = await this.walletClient.client.executeTransactionBlock({
1170
1150
  transactionBlock: h.bytes,
1171
- signature: f,
1151
+ signature: p,
1172
1152
  options: {
1173
1153
  showEffects: !0,
1174
1154
  showEvents: !0,
1175
1155
  showBalanceChanges: !0
1176
1156
  }
1177
1157
  });
1178
- if (((d = (y = b.effects) == null ? void 0 : y.status) == null ? void 0 : d.status) === "success") {
1179
- const C = (g = b.events) == null ? void 0 : g.find((P) => P.type.includes("::slippage::SwapEvent"));
1180
- C && this.emit("swap:swap-success", {
1181
- fromCoinType: e,
1182
- toCoinType: a,
1183
- fromAmount: t,
1158
+ if (c.effects?.status?.status === "success") {
1159
+ const d = c.events?.find((y) => y.type.includes("::slippage::SwapEvent"));
1160
+ d && this.emit("swap:swap-success", {
1161
+ fromCoinType: t,
1162
+ toCoinType: e,
1163
+ fromAmount: n,
1184
1164
  slippage: s,
1185
- toAmount: Number(C.parsedJson.amount_out)
1165
+ toAmount: Number(d.parsedJson.amount_out)
1186
1166
  }), this.walletClient.module("balance").updatePortfolio();
1187
1167
  }
1188
- return b;
1168
+ return c;
1189
1169
  }
1190
1170
  }
1191
- class Ue extends x {
1171
+ class _t extends A {
1192
1172
  constructor() {
1193
1173
  super(...arguments), this.name = "haedal", this.defaultConfig = {
1194
1174
  packageId: "0x19e6ea7f5ced4f090e20da794cc80349a03e638940ddb95155a4e301f5f4967c",
1195
1175
  configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
1196
1176
  coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
1197
- }, this.getApy = oe(
1198
- K(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
1177
+ }, this.getApy = st(
1178
+ W(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((e) => e.json())).data.apy)
1199
1179
  );
1200
1180
  }
1201
1181
  /**
@@ -1205,18 +1185,18 @@ class Ue extends x {
1205
1185
  * @param suiCoin - Sui coin object to stake
1206
1186
  * @returns haSUI coin object
1207
1187
  */
1208
- async stakePTB(e, a) {
1209
- const [t] = e.moveCall({
1188
+ async stakePTB(t, e) {
1189
+ const [n] = t.moveCall({
1210
1190
  target: `${this.config.packageId}::staking::request_stake_coin`,
1211
1191
  arguments: [
1212
- e.object("0x05"),
1213
- e.object(this.config.configId),
1214
- _(a, e.object),
1215
- e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
1192
+ t.object("0x05"),
1193
+ t.object(this.config.configId),
1194
+ x(e, t.object),
1195
+ t.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
1216
1196
  ],
1217
1197
  typeArguments: []
1218
1198
  });
1219
- return t;
1199
+ return n;
1220
1200
  }
1221
1201
  /**
1222
1202
  * Builds a transaction block for unstaking haSUI to SUI
@@ -1225,17 +1205,17 @@ class Ue extends x {
1225
1205
  * @param haSUICoin - haSUI coin object to unstake
1226
1206
  * @returns SUI coin object
1227
1207
  */
1228
- async unstakePTB(e, a) {
1229
- const [t] = e.moveCall({
1208
+ async unstakePTB(t, e) {
1209
+ const [n] = t.moveCall({
1230
1210
  target: `${this.config.packageId}::staking::request_unstake_instant_coin`,
1231
1211
  arguments: [
1232
- e.object("0x05"),
1233
- e.object(this.config.configId),
1234
- _(a, e.object)
1212
+ t.object("0x05"),
1213
+ t.object(this.config.configId),
1214
+ x(e, t.object)
1235
1215
  ],
1236
1216
  typeArguments: []
1237
1217
  });
1238
- return t;
1218
+ return n;
1239
1219
  }
1240
1220
  /**
1241
1221
  * Stake SUI for haSUI
@@ -1243,22 +1223,21 @@ class Ue extends x {
1243
1223
  * @param suiAmount - Amount of SUI to stake
1244
1224
  * @param options Optional dry run
1245
1225
  */
1246
- async stake(e, a) {
1247
- var r, c, o;
1226
+ async stake(t, e) {
1248
1227
  if (!this.walletClient)
1249
1228
  throw new Error("Wallet client not found");
1250
- const t = new m();
1229
+ const n = new f();
1251
1230
  await this.walletClient.module("balance").waitForUpdate();
1252
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
1253
- balance: e,
1231
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), a = C(n, s.coins, {
1232
+ balance: t,
1254
1233
  useGasCoin: !0
1255
- }), u = await this.stakePTB(t, n);
1256
- t.transferObjects([u], this.walletClient.address);
1234
+ }), l = await this.stakePTB(n, a);
1235
+ n.transferObjects([l], this.walletClient.address);
1257
1236
  const i = await this.walletClient.signExecuteTransaction({
1258
- transaction: t,
1259
- dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
1237
+ transaction: n,
1238
+ dryRun: e?.dryRun ?? !1
1260
1239
  });
1261
- return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
1240
+ return !e?.dryRun && i.effects?.status?.status === "success" && (this.emit("haedal:stake-success", { suiAmount: t }), this.walletClient.module("balance").updatePortfolio()), i;
1262
1241
  }
1263
1242
  /**
1264
1243
  * Unstake haSUI for SUI
@@ -1266,50 +1245,49 @@ class Ue extends x {
1266
1245
  * @param haSUIAmount - Amount of haSUI to unstake
1267
1246
  * @param options Optional dry run
1268
1247
  */
1269
- async unstake(e, a) {
1270
- var r, c, o;
1248
+ async unstake(t, e) {
1271
1249
  if (!this.walletClient)
1272
1250
  throw new Error("Wallet client not found");
1273
1251
  await this.walletClient.module("balance").waitForUpdate();
1274
- const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
1275
- balance: e
1276
- }), u = await this.unstakePTB(t, n);
1277
- t.transferObjects([u], this.walletClient.address);
1252
+ const n = new f(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), a = C(n, s.coins, {
1253
+ balance: t
1254
+ }), l = await this.unstakePTB(n, a);
1255
+ n.transferObjects([l], this.walletClient.address);
1278
1256
  const i = await this.walletClient.signExecuteTransaction({
1279
- transaction: t,
1280
- dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
1257
+ transaction: n,
1258
+ dryRun: e?.dryRun ?? !1
1281
1259
  });
1282
- return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
1260
+ return !e?.dryRun && i.effects?.status?.status === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: t }), this.walletClient.module("balance").updatePortfolio()), i;
1283
1261
  }
1284
1262
  }
1285
- const Me = {
1263
+ const jt = {
1286
1264
  /** Balance management module */
1287
- balance: new Ne(),
1265
+ balance: new At(),
1288
1266
  /** Lending protocol module */
1289
- lending: new _e(),
1267
+ lending: new kt(),
1290
1268
  /** Volo protocol module */
1291
- volo: new je(),
1269
+ volo: new Nt(),
1292
1270
  /** DEX swapping module */
1293
- swap: new Ie(),
1271
+ swap: new Ft(),
1294
1272
  /** Haedal protocol module */
1295
- haedal: new Ue()
1296
- }, We = {
1297
- url: we("mainnet")
1273
+ haedal: new _t()
1274
+ }, It = {
1275
+ url: ct("mainnet")
1298
1276
  };
1299
- class Ye {
1277
+ class Jt {
1300
1278
  /**
1301
1279
  * Creates a new wallet client instance
1302
1280
  * @param options - Configuration options for the wallet client
1303
1281
  */
1304
- constructor(e) {
1305
- this.modules = Me, this.userConfigs = {}, this.events = fe();
1306
- const a = {
1307
- ...We,
1308
- ...e.client
1282
+ constructor(t) {
1283
+ this.modules = jt, this.userConfigs = {}, this.events = dt();
1284
+ const e = {
1285
+ ...It,
1286
+ ...t.client
1309
1287
  };
1310
- 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, s]) => {
1311
- if (t !== s.name)
1312
- throw new Error(`Module name ${t} does not match module name ${s.name}`);
1288
+ e.transport = e.transport || new Ot(e.url), this.client = new ut(e), this.signer = t.signer, this.userConfigs = t.configs || {}, Object.entries(this.modules).forEach(([n, s]) => {
1289
+ if (n !== s.name)
1290
+ throw new Error(`Module name ${n} does not match module name ${s.name}`);
1313
1291
  s.install(this);
1314
1292
  });
1315
1293
  }
@@ -1333,18 +1311,18 @@ class Ye {
1333
1311
  * @param options - Transaction execution options including dry run support
1334
1312
  * @returns Promise with transaction execution result
1335
1313
  */
1336
- async signExecuteTransaction(e) {
1337
- const { dryRun: a = !1, ...t } = e;
1338
- if (a) {
1314
+ async signExecuteTransaction(t) {
1315
+ const { dryRun: e = !1, ...n } = t;
1316
+ if (e) {
1339
1317
  let s;
1340
- return e.transaction instanceof m ? (e.transaction.setSenderIfNotSet(this.address), s = await e.transaction.build({
1318
+ return t.transaction instanceof f ? (t.transaction.setSenderIfNotSet(this.address), s = await t.transaction.build({
1341
1319
  client: this.client
1342
- })) : s = e.transaction, this.client.dryRunTransactionBlock({
1320
+ })) : s = t.transaction, this.client.dryRunTransactionBlock({
1343
1321
  transactionBlock: s
1344
1322
  });
1345
1323
  }
1346
1324
  return this.client.signAndExecuteTransaction({
1347
- ...t,
1325
+ ...n,
1348
1326
  signer: this.signer
1349
1327
  });
1350
1328
  }
@@ -1360,18 +1338,18 @@ class Ye {
1360
1338
  * @param name - The name of the module to retrieve
1361
1339
  * @returns The requested module instance
1362
1340
  */
1363
- module(e) {
1364
- return this.modules[e];
1341
+ module(t) {
1342
+ return this.modules[t];
1365
1343
  }
1366
1344
  /**
1367
1345
  * Gets the configuration for a specific module
1368
1346
  * @param name - The name of the module
1369
1347
  * @returns The merged configuration (default + user config)
1370
1348
  */
1371
- config(e) {
1349
+ config(t) {
1372
1350
  return {
1373
- ...this.modules[e].defaultConfig,
1374
- ...this.userConfigs[e]
1351
+ ...this.modules[t].defaultConfig,
1352
+ ...this.userConfigs[t]
1375
1353
  };
1376
1354
  }
1377
1355
  /**
@@ -1379,18 +1357,18 @@ class Ye {
1379
1357
  * @param name - The name of the module to check
1380
1358
  * @returns True if the module exists, false otherwise
1381
1359
  */
1382
- hasModule(e) {
1383
- return e in this.modules;
1360
+ hasModule(t) {
1361
+ return t in this.modules;
1384
1362
  }
1385
1363
  }
1386
- class Ze extends ce {
1364
+ class Vt extends it {
1387
1365
  /**
1388
1366
  * Creates a new watch-only signer
1389
1367
  *
1390
1368
  * @param address - The wallet address to watch
1391
1369
  */
1392
- constructor(e) {
1393
- super(), this.address = e;
1370
+ constructor(t) {
1371
+ super(), this.address = t;
1394
1372
  }
1395
1373
  /**
1396
1374
  * Signs transaction bytes (not implemented for watch-only mode)
@@ -1401,7 +1379,7 @@ class Ze extends ce {
1401
1379
  * @param bytes - Transaction bytes to sign
1402
1380
  * @returns Promise<Uint8Array> - Empty signature (not valid)
1403
1381
  */
1404
- async sign(e) {
1382
+ async sign(t) {
1405
1383
  return Promise.resolve(new Uint8Array(0));
1406
1384
  }
1407
1385
  /**
@@ -1443,18 +1421,18 @@ class Ze extends ce {
1443
1421
  * @param options - Sign and execute options
1444
1422
  * @returns Promise<any> - Empty result (not a real transaction result)
1445
1423
  */
1446
- async signAndExecuteTransaction({ transaction: e, client: a }) {
1424
+ async signAndExecuteTransaction({ transaction: t, client: e }) {
1447
1425
  return {};
1448
1426
  }
1449
1427
  }
1450
- class et extends ce {
1428
+ class Xt extends it {
1451
1429
  /**
1452
1430
  * Creates a new watch-only signer
1453
1431
  *
1454
1432
  * @param address - The wallet address to watch
1455
1433
  */
1456
- constructor(e) {
1457
- super(), this.address = e;
1434
+ constructor(t) {
1435
+ super(), this.address = t;
1458
1436
  }
1459
1437
  /**
1460
1438
  * Signs transaction bytes (not implemented for watch-only mode)
@@ -1465,7 +1443,7 @@ class et extends ce {
1465
1443
  * @param bytes - Transaction bytes to sign
1466
1444
  * @returns Promise<Uint8Array> - Empty signature (not valid)
1467
1445
  */
1468
- async sign(e) {
1446
+ async sign(t) {
1469
1447
  return Promise.resolve(new Uint8Array(0));
1470
1448
  }
1471
1449
  /**
@@ -1500,8 +1478,8 @@ class et extends ce {
1500
1478
  }
1501
1479
  }
1502
1480
  export {
1503
- Ye as WalletClient,
1504
- Ze as WatchSigner,
1505
- et as WebSigner
1481
+ Jt as WalletClient,
1482
+ Vt as WatchSigner,
1483
+ Xt as WebSigner
1506
1484
  };
1507
1485
  //# sourceMappingURL=index.esm.js.map