@naviprotocol/wallet-client 1.4.9 → 2.0.0-beta.0

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,31 +1,29 @@
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({
1
+ import { getJsonRpcFullnodeUrl as ct, SuiJsonRpcClient as ut } from "@mysten/sui/jsonRpc";
2
+ import wt from "mitt";
3
+ import dt from "axios";
4
+ import { withSingleton as Q, getCoins as V, mergeCoinsPTB as m, getPriceFeeds as $, updateOraclePricesPTB as q, filterPriceFeeds as K, depositCoinPTB as A, getFlashLoanAsset as X, flashloanPTB as Y, repayFlashLoanPTB as Z, borrowCoinPTB as tt, withdrawCoinPTB as et, repayCoinPTB as nt, 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 at, parseTxValue as x } from "@naviprotocol/lending";
5
+ import E, { BigNumber as L } from "bignumber.js";
6
+ import { normalizeStructTag as b } from "@mysten/sui/utils";
7
+ import { Transaction as d } from "@mysten/sui/transactions";
8
+ import { buildSwapPTBFromQuote as z, generateRefId as yt, getQuote as Pt } from "@naviprotocol/astros-aggregator-sdk";
9
+ import { executeAuction as Bt } from "shio-sdk";
10
+ import { Signer as st } from "@mysten/sui/cryptography";
11
+ const it = dt.create({
14
12
  timeout: 2e4
15
13
  });
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;
14
+ it.interceptors.response.use(
15
+ function(i) {
16
+ if (i.data.err)
17
+ throw new Error(i.data.err);
18
+ if (i.data.error)
19
+ throw new Error(i.data.error.message);
20
+ return i;
23
21
  },
24
- function(o) {
25
- return Promise.reject(o);
22
+ function(i) {
23
+ return Promise.reject(i);
26
24
  }
27
25
  );
28
- class Ot {
26
+ class Tt {
29
27
  /**
30
28
  * Creates a new custom transport instance
31
29
  *
@@ -44,7 +42,7 @@ class Ot {
44
42
  * @returns Promise<T> - The response data from the RPC call
45
43
  */
46
44
  async request(t) {
47
- return this.requestId += 1, (await ot.post(this.rpcUrl, {
45
+ return this.requestId += 1, (await it.post(this.rpcUrl, {
48
46
  jsonrpc: "2.0",
49
47
  id: this.requestId,
50
48
  method: t.method,
@@ -64,7 +62,7 @@ class Ot {
64
62
  throw new Error("subscribe not implemented.");
65
63
  }
66
64
  }
67
- class A {
65
+ class O {
68
66
  /**
69
67
  * Gets the current configuration for this module
70
68
  *
@@ -118,11 +116,11 @@ class R {
118
116
  else {
119
117
  const e = {};
120
118
  t?.forEach((n) => {
121
- const s = m(n.coinType);
119
+ const s = b(n.coinType);
122
120
  let a = e[s];
123
121
  a || (a = {
124
122
  coinType: s,
125
- amount: M(0),
123
+ amount: L(0),
126
124
  coins: []
127
125
  }, e[s] = a), a.coins.push(n), a.amount = a.amount.plus(n.balance);
128
126
  }), this.balances = e;
@@ -135,7 +133,7 @@ class R {
135
133
  * @returns UserCoinBalance object with coin type, total amount, and coin objects
136
134
  */
137
135
  getBalance(t) {
138
- return t = m(t), this.balances[t] || { coinType: t, amount: M(0), coins: [] };
136
+ return t = b(t), this.balances[t] || { coinType: t, amount: L(0), coins: [] };
139
137
  }
140
138
  /**
141
139
  * Gets all coin types in the portfolio
@@ -152,7 +150,7 @@ class R {
152
150
  * @returns BigNumber representing the total balance
153
151
  */
154
152
  balanceOf(t) {
155
- return t = m(t), this.getBalance(t)?.amount || M(0);
153
+ return t = b(t), this.getBalance(t)?.amount || L(0);
156
154
  }
157
155
  /**
158
156
  * Creates a deep copy of the portfolio
@@ -167,15 +165,15 @@ class R {
167
165
  return e.balances = t, e;
168
166
  }
169
167
  }
170
- class At extends A {
168
+ class vt extends O {
171
169
  constructor() {
172
170
  super(...arguments), this.name = "balance", this.defaultConfig = {
173
171
  coinPollingInterval: 6e3,
174
172
  disableCoinPolling: !1
175
- }, this.updatePortfolio = W(async () => {
173
+ }, this.updatePortfolio = Q(async () => {
176
174
  if (!this.walletClient)
177
175
  throw new Error("Wallet client not found");
178
- this._coins = await X(this.walletClient.address, {
176
+ this._coins = await V(this.walletClient.address, {
179
177
  client: this.walletClient.client
180
178
  }), this._portfolio = new R(this._coins), this.emit("balance:portfolio-updated", {});
181
179
  }), this._coins = [], this._portfolio = new R(), this.pollingTimer = null, this._updatePromise = null;
@@ -234,19 +232,19 @@ class At extends A {
234
232
  if (e.length !== n.length)
235
233
  throw new Error("Recipients and amounts must have the same length");
236
234
  await this.waitForUpdate();
237
- const a = this.portfolio.getBalance(t), l = n.reduce((g, h) => g.plus(h), E(0));
235
+ const a = this.portfolio.getBalance(t), l = n.reduce((f, w) => f.plus(w), E(0));
238
236
  if (a.amount.lt(l))
239
237
  throw new Error("Insufficient balance");
240
- const i = new f();
241
- let r = i.gas;
242
- m(t) !== m("0x2::sui::SUI") && (r = C(i, a.coins, {
238
+ const o = new d();
239
+ let r = o.gas;
240
+ b(t) !== b("0x2::sui::SUI") && (r = m(o, a.coins, {
243
241
  balance: l.toNumber()
244
242
  }));
245
- const w = i.splitCoins(r, n);
246
- return e.forEach((g, h) => {
247
- i.transferObjects([w[h]], g);
243
+ const u = o.splitCoins(r, n);
244
+ return e.forEach((f, w) => {
245
+ o.transferObjects([u[w]], f);
248
246
  }), await this.walletClient.signExecuteTransaction({
249
- transaction: i,
247
+ transaction: o,
250
248
  dryRun: s?.dryRun ?? !1
251
249
  });
252
250
  }
@@ -278,9 +276,9 @@ class At extends A {
278
276
  if (t.length !== e.length)
279
277
  throw new Error("Objects and recipients must have the same length");
280
278
  await this.waitForUpdate();
281
- const s = new f();
282
- return t.forEach((l, i) => {
283
- s.transferObjects([s.object(l)], e[i]);
279
+ const s = new d();
280
+ return t.forEach((l, o) => {
281
+ s.transferObjects([s.object(l)], e[o]);
284
282
  }), await this.walletClient.signExecuteTransaction({
285
283
  transaction: s,
286
284
  dryRun: n?.dryRun ?? !1
@@ -324,186 +322,186 @@ class At extends A {
324
322
  super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
325
323
  }
326
324
  }
327
- async function D(o, t, e, n) {
325
+ async function J(i, t, e, n) {
328
326
  if (!this.walletClient)
329
327
  throw new Error("Wallet client not found");
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)
328
+ const s = await this.getPool(t), a = await this.getPool(e), l = await this.getLendingState(), o = this.walletClient.address, r = n?.protocol ?? "navi", u = await this.getProtocol(r);
329
+ if (!u)
332
330
  throw new Error(`Protocol ${r} not found`);
333
- const u = await w.getPool(s.coinType);
331
+ const c = await u.getPool(s.coinType);
334
332
  if (console.log("migrateBetweenSupplyPTB", {
335
- fromPoolLending: u
336
- }), r === "navi" && u.supplyBalance === 0)
333
+ fromPoolLending: c
334
+ }), r === "navi" && c.supplyBalance === 0)
337
335
  throw new Error("No supply balance");
338
- if (n?.amount && n.amount > u.supplyBalance)
336
+ if (n?.amount && n.amount > c.supplyBalance)
339
337
  throw new Error("Amount is less than supply balance");
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, {
338
+ const f = n?.slippage ?? 5e-3, w = n?.amount ?? Number(c.supplyBalance), h = await $(), p = await Promise.all([s, a]);
339
+ if (await q(
340
+ i,
341
+ K(h, {
344
342
  lendingState: l,
345
- pools: c
343
+ pools: p
346
344
  })
347
345
  ), r !== "navi" && s.id === a.id) {
348
- const U = await w.withdrawCoinPTB(
349
- o,
346
+ const I = await u.withdrawCoinPTB(
347
+ i,
350
348
  s.suiCoinType,
351
- h
349
+ w
352
350
  );
353
- return await O(o, a, U, {
354
- amount: h
355
- }), o;
351
+ return await A(i, a, I, {
352
+ amount: w
353
+ }), i;
356
354
  }
357
- const d = await Y(a, {
355
+ const g = await X(a, {
358
356
  env: this.config.env
359
357
  });
360
- if (!d)
358
+ if (!g)
361
359
  throw new Error(`${a.token.symbol} pool not support flashloan`);
362
360
  const y = await this.walletClient.swap.getQuote(
363
361
  s.suiCoinType,
364
362
  a.suiCoinType,
365
- h
363
+ w
366
364
  ), B = Number(y.amount_out);
367
365
  if (B <= 0)
368
366
  throw new Error("The amount of swapAmountOut must be greater than 0.");
369
- const S = Math.floor(B * (1 - g)), b = Math.floor(S / (1 + d.flashloanFee));
370
- if (b <= 0)
367
+ const S = Math.floor(B * (1 - f)), C = Math.floor(S / (1 + g.flashloanFee));
368
+ if (C <= 0)
371
369
  throw new Error("The calculated borrow amount must be positive.");
372
- const [T, v] = await Z(o, a, b), [k] = o.moveCall({
370
+ const [T, v] = await Y(i, a, C), [F] = i.moveCall({
373
371
  target: "0x2::coin::from_balance",
374
372
  arguments: [T],
375
373
  typeArguments: [a.suiCoinType]
376
374
  });
377
- await O(o, a, k, {
378
- amount: b
375
+ await A(i, a, F, {
376
+ amount: C
379
377
  });
380
- const N = await w.withdrawCoinPTB(o, s.suiCoinType, h), F = await $(
381
- i,
378
+ const k = await u.withdrawCoinPTB(i, s.suiCoinType, w), _ = await z(
382
379
  o,
380
+ i,
383
381
  S,
384
- N,
382
+ k,
385
383
  y
386
- ), _ = o.moveCall({
384
+ ), U = i.moveCall({
387
385
  target: "0x2::coin::into_balance",
388
- arguments: [F],
386
+ arguments: [_],
389
387
  typeArguments: [a.suiCoinType]
390
- }), [j] = await tt(o, a, v, _), [I] = o.moveCall({
388
+ }), [N] = await Z(i, a, v, U), [W] = i.moveCall({
391
389
  target: "0x2::coin::from_balance",
392
- arguments: [j],
390
+ arguments: [N],
393
391
  typeArguments: [a.suiCoinType]
394
392
  });
395
- return await O(o, a, I), o;
393
+ return await A(i, a, W), i;
396
394
  }
397
- async function J(o, t, e, n) {
395
+ async function H(i, t, e, n) {
398
396
  if (!this.walletClient)
399
397
  throw new Error("Wallet client not found");
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)
398
+ const s = this.walletClient.address, a = await this.getPool(t), l = await this.getPool(e), o = await this.getLendingState(), r = n?.protocol ?? "navi", u = await this.getProtocol(r);
399
+ if (!u)
402
400
  throw new Error(`Protocol ${r} not found`);
403
- const u = await w.getPool(a.coinType);
401
+ const c = await u.getPool(a.coinType);
404
402
  if (console.log("migrateBetweenBorrowPTB", {
405
- fromPoolLending: u
406
- }), u.borrowBalance === 0)
403
+ fromPoolLending: c
404
+ }), c.borrowBalance === 0)
407
405
  throw new Error("No borrow balance");
408
- if (n?.amount && n.amount > u.borrowBalance)
406
+ if (n?.amount && n.amount > c.borrowBalance)
409
407
  throw new Error("Amount is more than borrow balance");
410
- const g = await L(), h = await Promise.all([a, l]);
411
- await Q(
412
- o,
413
- K(g, {
414
- lendingState: i,
415
- pools: h
408
+ const f = await $(), w = await Promise.all([a, l]);
409
+ await q(
410
+ i,
411
+ K(f, {
412
+ lendingState: o,
413
+ pools: w
416
414
  })
417
415
  );
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()
416
+ let h = n?.amount ?? Number(c.borrowBalance);
417
+ if (Number(c.borrowBalance) === h) {
418
+ const rt = c.borrowAPR / 100;
419
+ h = Math.ceil(
420
+ new E(h).multipliedBy(rt * (60 * 3) / (365 * 24 * 3600)).plus(new E(1).shiftedBy(-a.token.decimals)).plus(h).toNumber()
423
421
  );
424
422
  }
425
- const c = await Y(a, {
423
+ const p = await X(a, {
426
424
  env: this.config.env
427
425
  });
428
- if (!c)
426
+ if (!p)
429
427
  throw new Error(`${a.token.symbol} pool not support flashloan`);
430
428
  if (!this.walletClient)
431
429
  throw new Error("Wallet client not found");
432
- const d = n?.slippage ?? 5e-3, y = Math.ceil(p * (1 + c.flashloanFee)), B = y, S = await this.walletClient.swap.getQuote(
430
+ const g = n?.slippage ?? 5e-3, y = Math.ceil(h * (1 + p.flashloanFee)), B = y, S = await this.walletClient.swap.getQuote(
433
431
  a.suiCoinType,
434
432
  l.suiCoinType,
435
433
  B
436
434
  );
437
- let b = 1 + d, T = Math.ceil(Number(S.amount_out) * b), v = await this.walletClient.swap.getQuote(
435
+ let C = 1 + g, T = Math.ceil(Number(S.amount_out) * C), v = await this.walletClient.swap.getQuote(
438
436
  l.suiCoinType,
439
437
  a.suiCoinType,
440
438
  T
441
439
  );
442
440
  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(
441
+ C = C * Math.max(B / Number(v.amount_out), 1.001), T = Math.ceil(Number(S.amount_out) * C), v = await this.walletClient.swap.getQuote(
444
442
  l.suiCoinType,
445
443
  a.suiCoinType,
446
444
  T
447
445
  );
448
- const [k, N] = await Z(o, a, p), [F] = o.moveCall({
446
+ const [F, k] = await Y(i, a, h), [_] = i.moveCall({
449
447
  target: "0x2::coin::from_balance",
450
- arguments: [k],
448
+ arguments: [F],
451
449
  typeArguments: [a.suiCoinType]
452
450
  });
453
- await w.repayCoinPTB(o, a.suiCoinType, F, p);
454
- const _ = await et(o, l, T), j = await $(
451
+ await u.repayCoinPTB(i, a.suiCoinType, _, h);
452
+ const U = await tt(i, l, T), N = await z(
455
453
  s,
456
- o,
454
+ i,
457
455
  y,
458
- _,
456
+ U,
459
457
  v
460
- ), I = o.moveCall({
458
+ ), W = i.moveCall({
461
459
  target: "0x2::coin::into_balance",
462
- arguments: [j],
460
+ arguments: [N],
463
461
  typeArguments: [a.suiCoinType]
464
- }), [U] = await tt(o, a, N, I), [lt] = o.moveCall({
462
+ }), [I] = await Z(i, a, k, W), [lt] = i.moveCall({
465
463
  target: "0x2::coin::from_balance",
466
- arguments: [U],
464
+ arguments: [I],
467
465
  typeArguments: [a.suiCoinType]
468
466
  });
469
- return o.transferObjects([lt], s), o;
467
+ return i.transferObjects([lt], s), i;
470
468
  }
471
- async function V(o, t, e, n) {
469
+ async function D(i, t, e, n) {
472
470
  if (!this.walletClient)
473
471
  throw new Error("Wallet client not found");
474
- const s = await X(this.walletClient.address, {
472
+ const s = await V(this.walletClient.address, {
475
473
  client: this.walletClient.client,
476
474
  coinType: t
477
- }), a = await this.getPool(e), i = new R(s).getBalance(t);
478
- if (i.amount.eq(0))
475
+ }), a = await this.getPool(e), o = new R(s).getBalance(t);
476
+ if (o.amount.eq(0))
479
477
  throw new Error(`No balance of ${t}`);
480
478
  if (console.log("migrateBalanceToSupplyPTB", {
481
- balance: i.amount.toNumber()
482
- }), n?.amount && i.amount.lt(n.amount))
479
+ balance: o.amount.toNumber()
480
+ }), n?.amount && o.amount.lt(n.amount))
483
481
  throw new Error("Amount is greater than balance");
484
- const r = n?.amount ?? i.amount.toNumber(), w = n?.slippage ?? 5e-3;
485
- let u = await C(o, i.coins, {
482
+ const r = n?.amount ?? o.amount.toNumber(), u = n?.slippage ?? 5e-3;
483
+ let c = await m(i, o.coins, {
486
484
  balance: r,
487
485
  useGasCoin: !0
488
486
  });
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(
492
- o,
493
- g,
494
- u,
495
- w
487
+ if (b(t) !== b(a.suiCoinType)) {
488
+ const f = await this.walletClient.swap.getQuote(t, a.suiCoinType, r);
489
+ c = await this.walletClient.swap.buildSwapPTBFromQuote(
490
+ i,
491
+ f,
492
+ c,
493
+ u
496
494
  );
497
495
  }
498
- return await O(o, a, u), o;
496
+ return await A(i, a, c), i;
499
497
  }
500
- class xt {
498
+ class Et {
501
499
  constructor(t) {
502
500
  this.name = "navi", this.walletClient = t;
503
501
  }
504
502
  async getPool(t) {
505
503
  const e = await this.walletClient.lending.getPool(t), s = (await this.walletClient.lending.getLendingState()).find(
506
- (i) => i.pool.suiCoinType === m(t)
504
+ (o) => o.pool.suiCoinType === b(t)
507
505
  ), a = s ? new E(s.supplyBalance).toNumber() : 0, l = s ? new E(s.borrowBalance).toNumber() : 0;
508
506
  return {
509
507
  supplyBalance: a,
@@ -515,85 +513,30 @@ class xt {
515
513
  throw new Error("Not implemented");
516
514
  }
517
515
  async withdrawCoinPTB(t, e, n) {
518
- return nt(t, e, n);
516
+ return et(t, e, n);
519
517
  }
520
518
  async borrowCoinPTB(t, e, n) {
521
519
  throw new Error("Not implemented");
522
520
  }
523
521
  async repayCoinPTB(t, e, n, s) {
524
- at(t, e, n, { amount: s });
522
+ nt(t, e, n, { amount: s });
525
523
  }
526
524
  }
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
538
- )
539
- ]);
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));
551
- });
552
- });
553
- const a = await Et(Array.from(s)), i = n.map((c) => Tt(c, a)).reduce(
554
- (c, d) => (c[d.coinType] = d, c),
555
- {}
556
- ), r = await this.suilendClient.getObligation(
557
- this.obligationOwnerCap.obligationId
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;
559
- return {
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()
564
- };
565
- }
566
- async depositCoinPTB(t, e, n, s) {
567
- throw new Error("Not implemented");
568
- }
569
- async withdrawCoinPTB(t, e, n) {
570
- const s = await this.getPool(e), a = n === s.supplyBalance;
571
- return await this.suilendClient.withdraw(
572
- this.obligationOwnerCap.id,
573
- this.obligationOwnerCap.obligationId,
574
- e,
575
- a ? Rt.toString() : Math.ceil(n / s.cTokenExchangeRate).toString(),
576
- t
577
- );
578
- }
579
- async borrowCoinPTB(t, e, n) {
580
- throw new Error("Not implemented");
581
- }
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));
584
- }
585
- }
586
- class kt extends A {
525
+ class Rt extends O {
587
526
  constructor() {
588
527
  super(), this.name = "lending", this.defaultConfig = {
589
528
  env: "prod",
590
- protocols: []
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);
529
+ protocols: [],
530
+ enableSuilend: !0
531
+ }, this._protocols = [], this.migrateBetweenSupplyPTB = J, this.migrateBetweenBorrowPTB = H, this.migrateBalanceToSupplyPTB = D, this.migrateBetweenSupplyPTB = J.bind(this), this.migrateBetweenBorrowPTB = H.bind(this), this.migrateBalanceToSupplyPTB = D.bind(this);
592
532
  }
593
533
  /** Get protocols (either from internal storage or config) */
594
534
  get protocols() {
595
535
  return this._protocols.length > 0 ? this._protocols : this.config.protocols;
596
536
  }
537
+ install(t) {
538
+ super.install(t), this._protocols = [];
539
+ }
597
540
  async getProtocol(t) {
598
541
  return (!this.protocols || this.protocols.length === 0) && await this.initializeProtocols(), this.protocols.find((e) => e.name === t);
599
542
  }
@@ -637,11 +580,11 @@ class kt extends A {
637
580
  env: this.config.env
638
581
  });
639
582
  await this.walletClient.module("balance").waitForUpdate();
640
- const a = new f(), l = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = C(a, l.coins, {
583
+ const a = new d(), l = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), o = m(a, l.coins, {
641
584
  balance: e,
642
585
  useGasCoin: !0
643
586
  });
644
- await O(a, s, i, {
587
+ await A(a, s, o, {
645
588
  env: this.config.env,
646
589
  amount: e,
647
590
  accountCap: n?.accountCap
@@ -668,21 +611,21 @@ class kt extends A {
668
611
  throw new Error("Wallet client not found");
669
612
  const s = await P(t, {
670
613
  env: this.config.env
671
- }), a = new f();
614
+ }), a = new d();
672
615
  n?.disableUpdateOracle || await this.updateOraclePTB(a, [s]);
673
- const l = await nt(a, s, e, {
616
+ const l = await et(a, s, e, {
674
617
  env: this.config.env,
675
618
  accountCap: n?.accountCap
676
619
  });
677
620
  a.transferObjects([l], this.walletClient.address);
678
- const i = await this.walletClient.signExecuteTransaction({
621
+ const o = await this.walletClient.signExecuteTransaction({
679
622
  transaction: a,
680
623
  dryRun: n?.dryRun ?? !1
681
624
  });
682
- return !n?.dryRun && i.effects?.status?.status === "success" && (this.emit("lending:withdraw-success", {
625
+ return !n?.dryRun && o.effects?.status?.status === "success" && (this.emit("lending:withdraw-success", {
683
626
  identifier: t,
684
627
  amount: e
685
- }), this.walletClient.module("balance").updatePortfolio()), i;
628
+ }), this.walletClient.module("balance").updatePortfolio()), o;
686
629
  }
687
630
  /**
688
631
  * Borrows coins from a lending pool
@@ -697,21 +640,21 @@ class kt extends A {
697
640
  throw new Error("Wallet client not found");
698
641
  const s = await P(t, {
699
642
  env: this.config.env
700
- }), a = new f();
643
+ }), a = new d();
701
644
  n?.disableUpdateOracle || await this.updateOraclePTB(a, [s]);
702
- const l = await et(a, s, e, {
645
+ const l = await tt(a, s, e, {
703
646
  env: this.config.env,
704
647
  accountCap: n?.accountCap
705
648
  });
706
649
  a.transferObjects([l], this.walletClient.address);
707
- const i = await this.walletClient.signExecuteTransaction({
650
+ const o = await this.walletClient.signExecuteTransaction({
708
651
  transaction: a,
709
652
  dryRun: n?.dryRun ?? !1
710
653
  });
711
- return !n?.dryRun && i.effects?.status?.status === "success" && (this.emit("lending:borrow-success", {
654
+ return !n?.dryRun && o.effects?.status?.status === "success" && (this.emit("lending:borrow-success", {
712
655
  identifier: t,
713
656
  amount: e
714
- }), this.walletClient.module("balance").updatePortfolio()), i;
657
+ }), this.walletClient.module("balance").updatePortfolio()), o;
715
658
  }
716
659
  /**
717
660
  * Repays borrowed coins to a lending pool
@@ -727,11 +670,11 @@ class kt extends A {
727
670
  await this.walletClient.module("balance").waitForUpdate();
728
671
  const s = await P(t, {
729
672
  env: this.config.env
730
- }), a = new f(), l = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = C(a, l.coins, {
673
+ }), a = new d(), l = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), o = m(a, l.coins, {
731
674
  balance: e,
732
675
  useGasCoin: !0
733
676
  });
734
- await at(a, s, i, {
677
+ await nt(a, s, o, {
735
678
  env: this.config.env,
736
679
  amount: e,
737
680
  accountCap: n?.accountCap
@@ -774,40 +717,40 @@ class kt extends A {
774
717
  throw new Error("Wallet client not found");
775
718
  const l = await P(t, {
776
719
  env: this.config.env
777
- }), i = await P(n, {
720
+ }), o = await P(n, {
778
721
  env: this.config.env
779
- }), r = new f(), w = this.walletClient.module("balance").portfolio.getBalance(l.suiCoinType), u = C(r, w.coins, {
722
+ }), r = new d(), u = this.walletClient.module("balance").portfolio.getBalance(l.suiCoinType), c = m(r, u.coins, {
780
723
  balance: e,
781
724
  useGasCoin: !0
782
- }), [g, h] = await gt(
725
+ }), [f, w] = await gt(
783
726
  r,
784
727
  l,
785
- u,
786
- i,
728
+ c,
729
+ o,
787
730
  s,
788
731
  {
789
732
  env: this.config.env
790
733
  }
791
- ), [p] = r.moveCall({
734
+ ), [h] = r.moveCall({
792
735
  target: "0x2::coin::from_balance",
793
- arguments: [g],
794
- typeArguments: [i.suiCoinType]
795
- }), [c] = r.moveCall({
736
+ arguments: [f],
737
+ typeArguments: [o.suiCoinType]
738
+ }), [p] = r.moveCall({
796
739
  target: "0x2::coin::from_balance",
797
- arguments: [h],
740
+ arguments: [w],
798
741
  typeArguments: [l.suiCoinType]
799
742
  });
800
- r.transferObjects([p, c], this.walletClient.address);
801
- const d = await this.walletClient.signExecuteTransaction({
743
+ r.transferObjects([h, p], this.walletClient.address);
744
+ const g = await this.walletClient.signExecuteTransaction({
802
745
  transaction: r,
803
746
  dryRun: a?.dryRun ?? !1
804
747
  });
805
- return !a?.dryRun && d.effects?.status?.status === "success" && (this.emit("lending:liquidate-success", {
748
+ return !a?.dryRun && g.effects?.status?.status === "success" && (this.emit("lending:liquidate-success", {
806
749
  payIdentifier: t,
807
750
  payAmount: e,
808
751
  collateralIdentifier: n,
809
752
  liquidationAddress: s
810
- }), this.walletClient.module("balance").updatePortfolio()), d;
753
+ }), this.walletClient.module("balance").updatePortfolio()), g;
811
754
  }
812
755
  /**
813
756
  * Gets the available lending rewards for the current user.
@@ -847,7 +790,7 @@ class kt extends A {
847
790
  async claimAllRewards(t) {
848
791
  if (!this.walletClient)
849
792
  throw new Error("Wallet client not found");
850
- const e = new f(), n = await G(this.walletClient.address, {
793
+ const e = new d(), n = await G(this.walletClient.address, {
851
794
  env: this.config.env
852
795
  });
853
796
  await mt(e, n, {
@@ -863,7 +806,7 @@ class kt extends A {
863
806
  }), this.walletClient.module("balance").updatePortfolio()), s;
864
807
  }
865
808
  async updateOraclePTB(t, e) {
866
- const n = await L({
809
+ const n = await $({
867
810
  env: this.config.env
868
811
  }), s = await this.getLendingState({
869
812
  cacheTime: 60 * 1e3
@@ -871,7 +814,7 @@ class kt extends A {
871
814
  lendingState: s,
872
815
  pools: e
873
816
  });
874
- await Q(t, a, {
817
+ await q(t, a, {
875
818
  env: this.config.env,
876
819
  updatePythPriceFeeds: !0
877
820
  });
@@ -886,7 +829,7 @@ class kt extends A {
886
829
  async updateOracle(t) {
887
830
  if (!this.walletClient)
888
831
  throw new Error("Wallet client not found");
889
- const e = new f();
832
+ const e = new d();
890
833
  return await this.updateOraclePTB(e, t?.pools), await this.walletClient.signExecuteTransaction({
891
834
  transaction: e,
892
835
  dryRun: t?.dryRun ?? !1
@@ -916,7 +859,7 @@ class kt extends A {
916
859
  async createAccountCap(t) {
917
860
  if (!this.walletClient)
918
861
  throw new Error("Wallet client not found");
919
- const e = new f(), n = await bt(e);
862
+ const e = new d(), n = await bt(e);
920
863
  return e.transferObjects([n], this.walletClient.address), await this.walletClient.signExecuteTransaction({
921
864
  transaction: e,
922
865
  dryRun: t?.dryRun ?? !1
@@ -928,24 +871,30 @@ class kt extends A {
928
871
  return;
929
872
  }
930
873
  const t = [];
931
- t.push(new xt(this.walletClient));
932
- try {
933
- t.push(await q.create(this.walletClient));
934
- } catch (e) {
935
- console.warn("Failed to initialize SuilendProtocol:", e);
936
- }
874
+ if (t.push(new Et(this.walletClient)), this.config.enableSuilend)
875
+ try {
876
+ const { default: e } = await import("./suilend-Df4FukWs.js");
877
+ t.push(
878
+ await e.create(this.walletClient, {
879
+ grpcClient: this.config.suilendGrpcClient,
880
+ grpcUrl: this.config.suilendGrpcUrl
881
+ })
882
+ );
883
+ } catch (e) {
884
+ console.warn("Failed to initialize SuilendProtocol:", e);
885
+ }
937
886
  this._protocols = t;
938
887
  }
939
888
  }
940
- class Nt extends A {
889
+ class St extends O {
941
890
  constructor() {
942
891
  super(...arguments), this.name = "volo", this.defaultConfig = {
943
892
  packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
944
893
  poolId: "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5",
945
894
  metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
946
895
  coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
947
- }, this.getStats = st(
948
- W(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((e) => e.json())).data)
896
+ }, this.getStats = at(
897
+ Q(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((e) => e.json())).data)
949
898
  );
950
899
  }
951
900
  /**
@@ -1001,20 +950,20 @@ class Nt extends A {
1001
950
  throw new Error("Wallet client not found");
1002
951
  if (t < 1e9)
1003
952
  throw new Error("Stake amount should be greater than 1Sui");
1004
- const n = new f();
953
+ const n = new d();
1005
954
  await this.walletClient.module("balance").waitForUpdate();
1006
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), a = C(n, s.coins, {
955
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), a = m(n, s.coins, {
1007
956
  balance: t,
1008
957
  useGasCoin: !0
1009
958
  }), l = await this.stakePTB(n, a);
1010
959
  n.transferObjects([l], this.walletClient.address);
1011
- const i = await this.walletClient.signExecuteTransaction({
960
+ const o = await this.walletClient.signExecuteTransaction({
1012
961
  transaction: n,
1013
962
  dryRun: e?.dryRun ?? !1
1014
963
  });
1015
- return !e?.dryRun && i.effects?.status?.status === "success" && (this.emit("volo:stake-success", {
964
+ return !e?.dryRun && o.effects?.status?.status === "success" && (this.emit("volo:stake-success", {
1016
965
  suiAmount: t
1017
- }), this.walletClient.module("balance").updatePortfolio()), i;
966
+ }), this.walletClient.module("balance").updatePortfolio()), o;
1018
967
  }
1019
968
  /**
1020
969
  * Unstake vSUI tokens to receive SUI tokens
@@ -1030,20 +979,67 @@ class Nt extends A {
1030
979
  if (t < 1e9)
1031
980
  throw new Error("Unstake amount should >= 1vSui");
1032
981
  await this.walletClient.module("balance").waitForUpdate();
1033
- const n = new f(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), a = C(n, s.coins, {
982
+ const n = new d(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), a = m(n, s.coins, {
1034
983
  balance: t
1035
984
  }), l = await this.unstakePTB(n, a);
1036
985
  n.transferObjects([l], this.walletClient.address);
1037
- const i = await this.walletClient.signExecuteTransaction({
986
+ const o = await this.walletClient.signExecuteTransaction({
1038
987
  transaction: n,
1039
988
  dryRun: e?.dryRun ?? !1
1040
989
  });
1041
- return !e?.dryRun && i.effects?.status?.status === "success" && (this.emit("volo:unstake-success", {
990
+ return !e?.dryRun && o.effects?.status?.status === "success" && (this.emit("volo:unstake-success", {
1042
991
  vSuiAmount: t
1043
- }), this.walletClient.module("balance").updatePortfolio()), i;
992
+ }), this.walletClient.module("balance").updatePortfolio()), o;
1044
993
  }
1045
994
  }
1046
- class Ft extends A {
995
+ const ot = {
996
+ showEffects: !0,
997
+ showEvents: !0,
998
+ showBalanceChanges: !0,
999
+ showObjectChanges: !0
1000
+ };
1001
+ function At(i) {
1002
+ return {
1003
+ ...ot,
1004
+ ...i
1005
+ };
1006
+ }
1007
+ function M(i, t) {
1008
+ const n = jt(t ?? {}), s = Ot(n);
1009
+ return {
1010
+ ...n,
1011
+ kind: i,
1012
+ effects: s,
1013
+ events: xt(n.events),
1014
+ balanceChanges: Array.isArray(n.balanceChanges) ? n.balanceChanges : [],
1015
+ objectChanges: Array.isArray(n.objectChanges) ? n.objectChanges : []
1016
+ };
1017
+ }
1018
+ function jt(i) {
1019
+ const t = i.Transaction;
1020
+ if (j(t))
1021
+ return t;
1022
+ const e = i.FailedTransaction;
1023
+ return j(e) ? e : i;
1024
+ }
1025
+ function Ot(i) {
1026
+ if (j(i.effects))
1027
+ return i.effects;
1028
+ if (j(i.status))
1029
+ return {
1030
+ status: i.status
1031
+ };
1032
+ }
1033
+ function xt(i) {
1034
+ return Array.isArray(i) ? i.map((t) => !j(t) || t.parsedJson !== void 0 || t.json === void 0 ? t : {
1035
+ ...t,
1036
+ parsedJson: t.json
1037
+ }) : [];
1038
+ }
1039
+ function j(i) {
1040
+ return typeof i == "object" && i !== null;
1041
+ }
1042
+ class Ft extends O {
1047
1043
  constructor() {
1048
1044
  super(...arguments), this.name = "swap", this.defaultConfig = {
1049
1045
  apiKey: "",
@@ -1096,7 +1092,7 @@ class Ft extends A {
1096
1092
  if (!this.walletClient)
1097
1093
  throw new Error("Wallet client not found");
1098
1094
  const a = new E(e.amount_out).multipliedBy(1 - s).toFixed(0);
1099
- return await $(
1095
+ return await z(
1100
1096
  this.walletClient.address,
1101
1097
  t,
1102
1098
  Number(a),
@@ -1129,53 +1125,49 @@ class Ft extends A {
1129
1125
  if (!this.walletClient)
1130
1126
  throw new Error("Wallet client not found");
1131
1127
  await this.walletClient.module("balance").waitForUpdate();
1132
- const l = this.walletClient.module("balance").portfolio.getBalance(t), i = new f(), r = C(i, l.coins, {
1128
+ const l = this.walletClient.module("balance").portfolio.getBalance(t), o = new d(), r = m(o, l.coins, {
1133
1129
  balance: n,
1134
1130
  useGasCoin: !0
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)
1131
+ }), u = await this.getQuote(t, e, n), c = await this.buildSwapPTBFromQuote(o, u, r, s);
1132
+ if (o.transferObjects([c], this.walletClient.address), o.setSender(this.walletClient.address), a?.dryRun)
1137
1133
  return await this.walletClient.signExecuteTransaction({
1138
- transaction: i,
1134
+ transaction: o,
1139
1135
  dryRun: !0
1140
1136
  });
1141
- const g = await i.build({
1137
+ const f = await o.build({
1142
1138
  client: this.walletClient.client
1143
- }), h = await this.walletClient.signer.signTransaction(g), p = [h.signature];
1139
+ }), w = await this.walletClient.signer.signTransaction(f), h = [w.signature];
1144
1140
  try {
1145
- await St(h.bytes, p);
1146
- } catch (d) {
1147
- console.error(d);
1141
+ await Bt(w.bytes, h);
1142
+ } catch (g) {
1143
+ console.error(g);
1148
1144
  }
1149
- const c = await this.walletClient.client.executeTransactionBlock({
1150
- transactionBlock: h.bytes,
1151
- signature: p,
1152
- options: {
1153
- showEffects: !0,
1154
- showEvents: !0,
1155
- showBalanceChanges: !0
1156
- }
1145
+ const p = await this.walletClient.client.executeTransactionBlock({
1146
+ transactionBlock: w.bytes,
1147
+ signature: h,
1148
+ options: ot
1157
1149
  });
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", {
1150
+ if (p.effects?.status?.status === "success") {
1151
+ const g = p.events?.find((y) => y.type.includes("::slippage::SwapEvent"));
1152
+ g && this.emit("swap:swap-success", {
1161
1153
  fromCoinType: t,
1162
1154
  toCoinType: e,
1163
1155
  fromAmount: n,
1164
1156
  slippage: s,
1165
- toAmount: Number(d.parsedJson.amount_out)
1157
+ toAmount: Number(g.parsedJson.amount_out)
1166
1158
  }), this.walletClient.module("balance").updatePortfolio();
1167
1159
  }
1168
- return c;
1160
+ return M("execute", p);
1169
1161
  }
1170
1162
  }
1171
- class _t extends A {
1163
+ class kt extends O {
1172
1164
  constructor() {
1173
1165
  super(...arguments), this.name = "haedal", this.defaultConfig = {
1174
1166
  packageId: "0x19e6ea7f5ced4f090e20da794cc80349a03e638940ddb95155a4e301f5f4967c",
1175
1167
  configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
1176
1168
  coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
1177
- }, this.getApy = st(
1178
- W(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((e) => e.json())).data.apy)
1169
+ }, this.getApy = at(
1170
+ Q(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((e) => e.json())).data.apy)
1179
1171
  );
1180
1172
  }
1181
1173
  /**
@@ -1226,18 +1218,18 @@ class _t extends A {
1226
1218
  async stake(t, e) {
1227
1219
  if (!this.walletClient)
1228
1220
  throw new Error("Wallet client not found");
1229
- const n = new f();
1221
+ const n = new d();
1230
1222
  await this.walletClient.module("balance").waitForUpdate();
1231
- const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), a = C(n, s.coins, {
1223
+ const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), a = m(n, s.coins, {
1232
1224
  balance: t,
1233
1225
  useGasCoin: !0
1234
1226
  }), l = await this.stakePTB(n, a);
1235
1227
  n.transferObjects([l], this.walletClient.address);
1236
- const i = await this.walletClient.signExecuteTransaction({
1228
+ const o = await this.walletClient.signExecuteTransaction({
1237
1229
  transaction: n,
1238
1230
  dryRun: e?.dryRun ?? !1
1239
1231
  });
1240
- return !e?.dryRun && i.effects?.status?.status === "success" && (this.emit("haedal:stake-success", { suiAmount: t }), this.walletClient.module("balance").updatePortfolio()), i;
1232
+ return !e?.dryRun && o.effects?.status?.status === "success" && (this.emit("haedal:stake-success", { suiAmount: t }), this.walletClient.module("balance").updatePortfolio()), o;
1241
1233
  }
1242
1234
  /**
1243
1235
  * Unstake haSUI for SUI
@@ -1249,43 +1241,44 @@ class _t extends A {
1249
1241
  if (!this.walletClient)
1250
1242
  throw new Error("Wallet client not found");
1251
1243
  await this.walletClient.module("balance").waitForUpdate();
1252
- const n = new f(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), a = C(n, s.coins, {
1244
+ const n = new d(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), a = m(n, s.coins, {
1253
1245
  balance: t
1254
1246
  }), l = await this.unstakePTB(n, a);
1255
1247
  n.transferObjects([l], this.walletClient.address);
1256
- const i = await this.walletClient.signExecuteTransaction({
1248
+ const o = await this.walletClient.signExecuteTransaction({
1257
1249
  transaction: n,
1258
1250
  dryRun: e?.dryRun ?? !1
1259
1251
  });
1260
- return !e?.dryRun && i.effects?.status?.status === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: t }), this.walletClient.module("balance").updatePortfolio()), i;
1252
+ return !e?.dryRun && o.effects?.status?.status === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: t }), this.walletClient.module("balance").updatePortfolio()), o;
1261
1253
  }
1262
1254
  }
1263
- const jt = {
1255
+ const _t = {
1264
1256
  /** Balance management module */
1265
- balance: new At(),
1257
+ balance: new vt(),
1266
1258
  /** Lending protocol module */
1267
- lending: new kt(),
1259
+ lending: new Rt(),
1268
1260
  /** Volo protocol module */
1269
- volo: new Nt(),
1261
+ volo: new St(),
1270
1262
  /** DEX swapping module */
1271
1263
  swap: new Ft(),
1272
1264
  /** Haedal protocol module */
1273
- haedal: new _t()
1274
- }, It = {
1265
+ haedal: new kt()
1266
+ }, Ut = {
1267
+ network: "mainnet",
1275
1268
  url: ct("mainnet")
1276
1269
  };
1277
- class Jt {
1270
+ class Gt {
1278
1271
  /**
1279
1272
  * Creates a new wallet client instance
1280
1273
  * @param options - Configuration options for the wallet client
1281
1274
  */
1282
1275
  constructor(t) {
1283
- this.modules = jt, this.userConfigs = {}, this.events = dt();
1276
+ this.modules = _t, this.userConfigs = {}, this.events = wt();
1284
1277
  const e = {
1285
- ...It,
1278
+ ...Ut,
1286
1279
  ...t.client
1287
1280
  };
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]) => {
1281
+ !e.transport && e.url && (e.transport = new Tt(e.url)), this.client = new ut(e), this.clientUrl = e.url, this.signer = t.signer, this.userConfigs = t.configs || {}, Object.entries(this.modules).forEach(([n, s]) => {
1289
1282
  if (n !== s.name)
1290
1283
  throw new Error(`Module name ${n} does not match module name ${s.name}`);
1291
1284
  s.install(this);
@@ -1314,17 +1307,21 @@ class Jt {
1314
1307
  async signExecuteTransaction(t) {
1315
1308
  const { dryRun: e = !1, ...n } = t;
1316
1309
  if (e) {
1317
- let s;
1318
- return t.transaction instanceof f ? (t.transaction.setSenderIfNotSet(this.address), s = await t.transaction.build({
1310
+ let a;
1311
+ t.transaction instanceof d ? (t.transaction.setSenderIfNotSet(this.address), a = await t.transaction.build({
1319
1312
  client: this.client
1320
- })) : s = t.transaction, this.client.dryRunTransactionBlock({
1321
- transactionBlock: s
1313
+ })) : a = t.transaction;
1314
+ const l = await this.client.dryRunTransactionBlock({
1315
+ transactionBlock: a
1322
1316
  });
1317
+ return M("dryRun", l);
1323
1318
  }
1324
- return this.client.signAndExecuteTransaction({
1319
+ const s = await this.client.signAndExecuteTransaction({
1325
1320
  ...n,
1321
+ options: At(n.options),
1326
1322
  signer: this.signer
1327
1323
  });
1324
+ return M("execute", s);
1328
1325
  }
1329
1326
  /**
1330
1327
  * Gets the wallet address from the signer's public key
@@ -1361,7 +1358,7 @@ class Jt {
1361
1358
  return t in this.modules;
1362
1359
  }
1363
1360
  }
1364
- class Vt extends it {
1361
+ class Jt extends st {
1365
1362
  /**
1366
1363
  * Creates a new watch-only signer
1367
1364
  *
@@ -1425,7 +1422,7 @@ class Vt extends it {
1425
1422
  return {};
1426
1423
  }
1427
1424
  }
1428
- class Xt extends it {
1425
+ class Ht extends st {
1429
1426
  /**
1430
1427
  * Creates a new watch-only signer
1431
1428
  *
@@ -1478,8 +1475,8 @@ class Xt extends it {
1478
1475
  }
1479
1476
  }
1480
1477
  export {
1481
- Jt as WalletClient,
1482
- Vt as WatchSigner,
1483
- Xt as WebSigner
1478
+ Gt as WalletClient,
1479
+ Jt as WatchSigner,
1480
+ Ht as WebSigner
1484
1481
  };
1485
1482
  //# sourceMappingURL=index.esm.js.map