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