@naviprotocol/wallet-client 1.0.1 → 1.0.2-dev.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,8 +1,8 @@
|
|
|
1
1
|
import { getFullnodeUrl as le, SuiClient as ie } from "@mysten/sui/client";
|
|
2
2
|
import re from "mitt";
|
|
3
3
|
import ce from "axios";
|
|
4
|
-
import { withSingleton as
|
|
5
|
-
import p, { BigNumber as
|
|
4
|
+
import { withSingleton as M, getCoins as oe, mergeCoinsPTB as y, getPriceFeeds as Q, updateOraclePricesPTB as q, filterPriceFeeds as K, getFlashLoanAsset as V, flashloanPTB as X, depositCoinPTB as x, withdrawCoinPTB as Y, repayFlashLoanPTB as Z, repayCoinPTB as ee, borrowCoinPTB as te, getPools as ue, getPool as P, getHealthFactor as de, liquidatePTB as we, getUserAvailableLendingRewards as H, getUserClaimedRewardHistory as he, claimLendingRewardsPTB as fe, getLendingState as ge, createAccountCapPTB as me, withCache as ae, parseTxValue as k } from "@naviprotocol/lending";
|
|
5
|
+
import p, { BigNumber as L } from "bignumber.js";
|
|
6
6
|
import { normalizeStructTag as T } from "@mysten/sui/utils";
|
|
7
7
|
import { Transaction as w } from "@mysten/sui/transactions";
|
|
8
8
|
import { buildSwapPTBFromQuote as $, generateRefId as Ce, getQuote as be } from "@naviprotocol/astros-aggregator-sdk";
|
|
@@ -11,15 +11,15 @@ const se = ce.create({
|
|
|
11
11
|
timeout: 2e4
|
|
12
12
|
});
|
|
13
13
|
se.interceptors.response.use(
|
|
14
|
-
function(
|
|
15
|
-
if (
|
|
16
|
-
throw new Error(
|
|
17
|
-
if (
|
|
18
|
-
throw new Error(
|
|
19
|
-
return
|
|
14
|
+
function(r) {
|
|
15
|
+
if (r.data.err)
|
|
16
|
+
throw new Error(r.data.err);
|
|
17
|
+
if (r.data.error)
|
|
18
|
+
throw new Error(r.data.error.message);
|
|
19
|
+
return r;
|
|
20
20
|
},
|
|
21
|
-
function(
|
|
22
|
-
return Promise.reject(
|
|
21
|
+
function(r) {
|
|
22
|
+
return Promise.reject(r);
|
|
23
23
|
}
|
|
24
24
|
);
|
|
25
25
|
class ye {
|
|
@@ -120,7 +120,7 @@ class E {
|
|
|
120
120
|
let n = a[s];
|
|
121
121
|
n || (n = {
|
|
122
122
|
coinType: s,
|
|
123
|
-
amount:
|
|
123
|
+
amount: L(0),
|
|
124
124
|
coins: []
|
|
125
125
|
}, a[s] = n), n.coins.push(t), n.amount = n.amount.plus(t.balance);
|
|
126
126
|
}), this.balances = a;
|
|
@@ -133,7 +133,7 @@ class E {
|
|
|
133
133
|
* @returns UserCoinBalance object with coin type, total amount, and coin objects
|
|
134
134
|
*/
|
|
135
135
|
getBalance(e) {
|
|
136
|
-
return e = T(e), this.balances[e] || { coinType: e, amount:
|
|
136
|
+
return e = T(e), this.balances[e] || { coinType: e, amount: L(0), coins: [] };
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Gets all coin types in the portfolio
|
|
@@ -152,7 +152,7 @@ class E {
|
|
|
152
152
|
balanceOf(e) {
|
|
153
153
|
e = T(e);
|
|
154
154
|
const a = this.getBalance(e);
|
|
155
|
-
return (a == null ? void 0 : a.amount) ||
|
|
155
|
+
return (a == null ? void 0 : a.amount) || L(0);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Creates a deep copy of the portfolio
|
|
@@ -171,7 +171,7 @@ class Be extends R {
|
|
|
171
171
|
constructor() {
|
|
172
172
|
super(...arguments), this.name = "balance", this.defaultConfig = {
|
|
173
173
|
coinPollingInterval: 6e3
|
|
174
|
-
}, this.updatePortfolio =
|
|
174
|
+
}, this.updatePortfolio = M(async () => {
|
|
175
175
|
if (!this.walletClient)
|
|
176
176
|
throw new Error("Wallet client not found");
|
|
177
177
|
this._coins = await oe(this.walletClient.address, {
|
|
@@ -238,11 +238,11 @@ class Be extends R {
|
|
|
238
238
|
if (n.amount.lt(c))
|
|
239
239
|
throw new Error("Insufficient balance");
|
|
240
240
|
const l = new w();
|
|
241
|
-
let
|
|
242
|
-
T(e) !== T("0x2::sui::SUI") && (
|
|
241
|
+
let i = l.gas;
|
|
242
|
+
T(e) !== T("0x2::sui::SUI") && (i = y(l, n.coins, {
|
|
243
243
|
balance: c.toNumber()
|
|
244
244
|
}));
|
|
245
|
-
const o = l.splitCoins(
|
|
245
|
+
const o = l.splitCoins(i, t);
|
|
246
246
|
return a.forEach((h, f) => {
|
|
247
247
|
l.transferObjects([o[f]], h);
|
|
248
248
|
}), await this.walletClient.signExecuteTransaction({
|
|
@@ -280,8 +280,8 @@ class Be extends R {
|
|
|
280
280
|
throw new Error("Objects and recipients must have the same length");
|
|
281
281
|
await this.waitForUpdate();
|
|
282
282
|
const s = new w();
|
|
283
|
-
return e.forEach((l,
|
|
284
|
-
s.transferObjects([s.object(l)], a[
|
|
283
|
+
return e.forEach((l, i) => {
|
|
284
|
+
s.transferObjects([s.object(l)], a[i]);
|
|
285
285
|
}), await this.walletClient.signExecuteTransaction({
|
|
286
286
|
transaction: s,
|
|
287
287
|
dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
|
|
@@ -324,22 +324,29 @@ class Be extends R {
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
const Pe = 27;
|
|
327
|
-
function Te(
|
|
328
|
-
return
|
|
327
|
+
function Te(r, e = 2) {
|
|
328
|
+
return r ? new p(r.toString()).shiftedBy(-1 * Pe).multipliedBy(100).decimalPlaces(e, p.ROUND_DOWN).toFixed(e) : "0.00";
|
|
329
329
|
}
|
|
330
|
-
async function D(
|
|
330
|
+
async function D(r, e, a, t) {
|
|
331
331
|
var S, O;
|
|
332
332
|
if (!this.walletClient)
|
|
333
333
|
throw new Error("Wallet client not found");
|
|
334
334
|
await this.walletClient.balance.waitForUpdate();
|
|
335
|
-
const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), l = c.find((F) => F.pool.id === s.id),
|
|
336
|
-
if (
|
|
335
|
+
const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), l = c.find((F) => F.pool.id === s.id), i = this.walletClient.address;
|
|
336
|
+
if (console.log("fromPoolLending", {
|
|
337
|
+
fromPoolLending: l,
|
|
338
|
+
lendingState: c,
|
|
339
|
+
address: i,
|
|
340
|
+
options: t,
|
|
341
|
+
from: e,
|
|
342
|
+
to: a
|
|
343
|
+
}), !l || l.supplyBalance === "0")
|
|
337
344
|
throw new Error("No supply balance");
|
|
338
345
|
if (t != null && t.amount && t.amount > Number(l.supplyBalance))
|
|
339
346
|
throw new Error("Amount is less than supply balance");
|
|
340
347
|
const o = await Q(), u = await Promise.all([s, n]);
|
|
341
348
|
await q(
|
|
342
|
-
|
|
349
|
+
r,
|
|
343
350
|
K(o, {
|
|
344
351
|
lendingState: c,
|
|
345
352
|
pools: u
|
|
@@ -360,51 +367,51 @@ async function D(i, e, a, t) {
|
|
|
360
367
|
const C = Math.floor(m * (1 - h)), g = Math.floor(C / (1 + d.flashloanFee));
|
|
361
368
|
if (g <= 0)
|
|
362
369
|
throw new Error("The calculated borrow amount must be positive.");
|
|
363
|
-
const [B, v] = await X(
|
|
370
|
+
const [B, v] = await X(r, n, g), [A] = r.moveCall({
|
|
364
371
|
target: "0x2::coin::from_balance",
|
|
365
372
|
arguments: [B],
|
|
366
373
|
typeArguments: [n.suiCoinType]
|
|
367
374
|
});
|
|
368
|
-
await x(
|
|
375
|
+
await x(r, n, A, {
|
|
369
376
|
amount: g
|
|
370
377
|
});
|
|
371
|
-
const j = await Y(
|
|
372
|
-
r,
|
|
378
|
+
const j = await Y(r, s, f), U = await $(
|
|
373
379
|
i,
|
|
380
|
+
r,
|
|
374
381
|
C,
|
|
375
382
|
j,
|
|
376
383
|
b
|
|
377
|
-
), _ =
|
|
384
|
+
), _ = r.moveCall({
|
|
378
385
|
target: "0x2::coin::into_balance",
|
|
379
386
|
arguments: [U],
|
|
380
387
|
typeArguments: [n.suiCoinType]
|
|
381
|
-
}), [W] = await Z(
|
|
388
|
+
}), [W] = await Z(r, n, v, _), [N] = r.moveCall({
|
|
382
389
|
target: "0x2::coin::from_balance",
|
|
383
390
|
arguments: [W],
|
|
384
391
|
typeArguments: [n.suiCoinType]
|
|
385
392
|
});
|
|
386
|
-
return await x(
|
|
393
|
+
return await x(r, n, N), r;
|
|
387
394
|
}
|
|
388
|
-
async function J(
|
|
395
|
+
async function J(r, e, a, t) {
|
|
389
396
|
var F, G;
|
|
390
397
|
if (!this.walletClient)
|
|
391
398
|
throw new Error("Wallet client not found");
|
|
392
399
|
await this.walletClient.balance.waitForUpdate();
|
|
393
|
-
const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a), l = await this.getLendingState(),
|
|
394
|
-
if (!
|
|
400
|
+
const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a), l = await this.getLendingState(), i = l.find((I) => I.pool.id === n.id);
|
|
401
|
+
if (!i || i.borrowBalance === "0")
|
|
395
402
|
throw new Error("No borrow balance");
|
|
396
|
-
if (t != null && t.amount && t.amount > Number(
|
|
403
|
+
if (t != null && t.amount && t.amount > Number(i.borrowBalance))
|
|
397
404
|
throw new Error("Amount is less than borrow balance");
|
|
398
405
|
const o = await Q(), u = await Promise.all([n, c]);
|
|
399
406
|
await q(
|
|
400
|
-
|
|
407
|
+
r,
|
|
401
408
|
K(o, {
|
|
402
409
|
lendingState: l,
|
|
403
410
|
pools: u
|
|
404
411
|
})
|
|
405
412
|
);
|
|
406
|
-
let d = (F = t == null ? void 0 : t.amount) != null ? F : Number(
|
|
407
|
-
if (Number(
|
|
413
|
+
let d = (F = t == null ? void 0 : t.amount) != null ? F : Number(i.borrowBalance);
|
|
414
|
+
if (Number(i.borrowBalance) === d) {
|
|
408
415
|
const I = parseFloat(Te(n.currentBorrowRate, 8)) / 100;
|
|
409
416
|
d = Math.ceil(
|
|
410
417
|
new p(d).multipliedBy(I * (60 * 3) / (365 * 24 * 3600)).plus(new p(1).shiftedBy(-n.token.decimals)).plus(d).toNumber()
|
|
@@ -433,32 +440,32 @@ async function J(i, e, a, t) {
|
|
|
433
440
|
n.suiCoinType,
|
|
434
441
|
B
|
|
435
442
|
);
|
|
436
|
-
const [A, j] = await X(
|
|
443
|
+
const [A, j] = await X(r, n, d), [U] = r.moveCall({
|
|
437
444
|
target: "0x2::coin::from_balance",
|
|
438
445
|
arguments: [A],
|
|
439
446
|
typeArguments: [n.suiCoinType]
|
|
440
447
|
});
|
|
441
|
-
await ee(
|
|
448
|
+
await ee(r, n, U, {
|
|
442
449
|
amount: d
|
|
443
450
|
});
|
|
444
|
-
const _ = await te(
|
|
451
|
+
const _ = await te(r, c, B), W = await $(
|
|
445
452
|
s,
|
|
446
|
-
|
|
453
|
+
r,
|
|
447
454
|
b,
|
|
448
455
|
_,
|
|
449
456
|
v
|
|
450
|
-
), N =
|
|
457
|
+
), N = r.moveCall({
|
|
451
458
|
target: "0x2::coin::into_balance",
|
|
452
459
|
arguments: [W],
|
|
453
460
|
typeArguments: [n.suiCoinType]
|
|
454
|
-
}), [S] = await Z(
|
|
461
|
+
}), [S] = await Z(r, n, j, N), [O] = r.moveCall({
|
|
455
462
|
target: "0x2::coin::from_balance",
|
|
456
463
|
arguments: [S],
|
|
457
464
|
typeArguments: [n.suiCoinType]
|
|
458
465
|
});
|
|
459
|
-
return
|
|
466
|
+
return r.transferObjects([O], s), r;
|
|
460
467
|
}
|
|
461
|
-
async function z(
|
|
468
|
+
async function z(r, e, a, t) {
|
|
462
469
|
var o, u;
|
|
463
470
|
if (!this.walletClient)
|
|
464
471
|
throw new Error("Wallet client not found");
|
|
@@ -469,20 +476,20 @@ async function z(i, e, a, t) {
|
|
|
469
476
|
if (t != null && t.amount && n.amount.lt(t.amount))
|
|
470
477
|
throw new Error("Amount is less than balance");
|
|
471
478
|
const c = (o = t == null ? void 0 : t.amount) != null ? o : n.amount.toNumber(), l = (u = t == null ? void 0 : t.slippage) != null ? u : 5e-3;
|
|
472
|
-
let
|
|
479
|
+
let i = await y(r, n.coins, {
|
|
473
480
|
balance: c,
|
|
474
481
|
useGasCoin: !0
|
|
475
482
|
});
|
|
476
483
|
if (T(e) !== T(s.suiCoinType)) {
|
|
477
484
|
const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
|
|
478
|
-
|
|
479
|
-
i,
|
|
480
|
-
d,
|
|
485
|
+
i = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
481
486
|
r,
|
|
487
|
+
d,
|
|
488
|
+
i,
|
|
482
489
|
l
|
|
483
490
|
);
|
|
484
491
|
}
|
|
485
|
-
return await x(
|
|
492
|
+
return await x(r, s, i), r;
|
|
486
493
|
}
|
|
487
494
|
class ve extends R {
|
|
488
495
|
constructor() {
|
|
@@ -540,14 +547,14 @@ class ve extends R {
|
|
|
540
547
|
amount: a,
|
|
541
548
|
accountCap: t == null ? void 0 : t.accountCap
|
|
542
549
|
});
|
|
543
|
-
const
|
|
550
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
544
551
|
transaction: n,
|
|
545
552
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
546
553
|
});
|
|
547
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
554
|
+
return !(t != null && t.dryRun) && ((d = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : d.status) === "success" && (this.emit("lending:deposit-success", {
|
|
548
555
|
identifier: e,
|
|
549
556
|
amount: a
|
|
550
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
557
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
551
558
|
}
|
|
552
559
|
/**
|
|
553
560
|
* Withdraws coins from a lending pool
|
|
@@ -558,7 +565,7 @@ class ve extends R {
|
|
|
558
565
|
* @returns Transaction response or dry run response
|
|
559
566
|
*/
|
|
560
567
|
async withdraw(e, a, t) {
|
|
561
|
-
var
|
|
568
|
+
var i, o, u;
|
|
562
569
|
if (!this.walletClient)
|
|
563
570
|
throw new Error("Wallet client not found");
|
|
564
571
|
const s = await P(e, {
|
|
@@ -572,7 +579,7 @@ class ve extends R {
|
|
|
572
579
|
n.transferObjects([c], this.walletClient.address);
|
|
573
580
|
const l = await this.walletClient.signExecuteTransaction({
|
|
574
581
|
transaction: n,
|
|
575
|
-
dryRun: (
|
|
582
|
+
dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
|
|
576
583
|
});
|
|
577
584
|
return !(t != null && t.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:withdraw-success", {
|
|
578
585
|
identifier: e,
|
|
@@ -588,7 +595,7 @@ class ve extends R {
|
|
|
588
595
|
* @returns Transaction response or dry run response
|
|
589
596
|
*/
|
|
590
597
|
async borrow(e, a, t) {
|
|
591
|
-
var
|
|
598
|
+
var i, o, u;
|
|
592
599
|
if (!this.walletClient)
|
|
593
600
|
throw new Error("Wallet client not found");
|
|
594
601
|
const s = await P(e, {
|
|
@@ -602,7 +609,7 @@ class ve extends R {
|
|
|
602
609
|
n.transferObjects([c], this.walletClient.address);
|
|
603
610
|
const l = await this.walletClient.signExecuteTransaction({
|
|
604
611
|
transaction: n,
|
|
605
|
-
dryRun: (
|
|
612
|
+
dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
|
|
606
613
|
});
|
|
607
614
|
return !(t != null && t.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:borrow-success", {
|
|
608
615
|
identifier: e,
|
|
@@ -633,14 +640,14 @@ class ve extends R {
|
|
|
633
640
|
amount: a,
|
|
634
641
|
accountCap: t == null ? void 0 : t.accountCap
|
|
635
642
|
});
|
|
636
|
-
const
|
|
643
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
637
644
|
transaction: n,
|
|
638
645
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
639
646
|
});
|
|
640
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
647
|
+
return !(t != null && t.dryRun) && ((d = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : d.status) === "success" && (this.emit("lending:repay-success", {
|
|
641
648
|
identifier: e,
|
|
642
649
|
amount: a
|
|
643
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
650
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
644
651
|
}
|
|
645
652
|
/**
|
|
646
653
|
* Gets the current health factor for the user
|
|
@@ -674,11 +681,11 @@ class ve extends R {
|
|
|
674
681
|
env: this.config.env
|
|
675
682
|
}), l = await P(t, {
|
|
676
683
|
env: this.config.env
|
|
677
|
-
}),
|
|
684
|
+
}), i = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = y(i, o.coins, {
|
|
678
685
|
balance: a,
|
|
679
686
|
useGasCoin: !0
|
|
680
687
|
}), [d, h] = await we(
|
|
681
|
-
|
|
688
|
+
i,
|
|
682
689
|
c,
|
|
683
690
|
u,
|
|
684
691
|
l,
|
|
@@ -686,18 +693,18 @@ class ve extends R {
|
|
|
686
693
|
{
|
|
687
694
|
env: this.config.env
|
|
688
695
|
}
|
|
689
|
-
), [f] =
|
|
696
|
+
), [f] = i.moveCall({
|
|
690
697
|
target: "0x2::coin::from_balance",
|
|
691
698
|
arguments: [d],
|
|
692
699
|
typeArguments: [l.suiCoinType]
|
|
693
|
-
}), [b] =
|
|
700
|
+
}), [b] = i.moveCall({
|
|
694
701
|
target: "0x2::coin::from_balance",
|
|
695
702
|
arguments: [h],
|
|
696
703
|
typeArguments: [c.suiCoinType]
|
|
697
704
|
});
|
|
698
|
-
|
|
705
|
+
i.transferObjects([f, b], this.walletClient.address);
|
|
699
706
|
const m = await this.walletClient.signExecuteTransaction({
|
|
700
|
-
transaction:
|
|
707
|
+
transaction: i,
|
|
701
708
|
dryRun: (C = n == null ? void 0 : n.dryRun) != null ? C : !1
|
|
702
709
|
});
|
|
703
710
|
return !(n != null && n.dryRun) && ((B = (g = m.effects) == null ? void 0 : g.status) == null ? void 0 : B.status) === "success" && (this.emit("lending:liquidate-success", {
|
|
@@ -832,7 +839,7 @@ class pe extends R {
|
|
|
832
839
|
metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
|
|
833
840
|
coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
|
|
834
841
|
}, this.getStats = ae(
|
|
835
|
-
|
|
842
|
+
M(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
|
|
836
843
|
);
|
|
837
844
|
}
|
|
838
845
|
/**
|
|
@@ -884,7 +891,7 @@ class pe extends R {
|
|
|
884
891
|
* @throws Error if wallet client not found or stake amount is too low
|
|
885
892
|
*/
|
|
886
893
|
async stake(e, a) {
|
|
887
|
-
var
|
|
894
|
+
var i, o, u;
|
|
888
895
|
if (!this.walletClient)
|
|
889
896
|
throw new Error("Wallet client not found");
|
|
890
897
|
if (e < 1e9)
|
|
@@ -898,7 +905,7 @@ class pe extends R {
|
|
|
898
905
|
t.transferObjects([c], this.walletClient.address);
|
|
899
906
|
const l = await this.walletClient.signExecuteTransaction({
|
|
900
907
|
transaction: t,
|
|
901
|
-
dryRun: (
|
|
908
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
902
909
|
});
|
|
903
910
|
return !(a != null && a.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:stake-success", {
|
|
904
911
|
suiAmount: e
|
|
@@ -913,7 +920,7 @@ class pe extends R {
|
|
|
913
920
|
* @throws Error if wallet client not found or unstake amount is too low
|
|
914
921
|
*/
|
|
915
922
|
async unstake(e, a) {
|
|
916
|
-
var
|
|
923
|
+
var i, o, u;
|
|
917
924
|
if (!this.walletClient)
|
|
918
925
|
throw new Error("Wallet client not found");
|
|
919
926
|
if (e < 1e9)
|
|
@@ -925,7 +932,7 @@ class pe extends R {
|
|
|
925
932
|
t.transferObjects([c], this.walletClient.address);
|
|
926
933
|
const l = await this.walletClient.signExecuteTransaction({
|
|
927
934
|
transaction: t,
|
|
928
|
-
dryRun: (
|
|
935
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
929
936
|
});
|
|
930
937
|
return !(a != null && a.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:unstake-success", {
|
|
931
938
|
vSuiAmount: e
|
|
@@ -1019,10 +1026,10 @@ class Ee extends R {
|
|
|
1019
1026
|
if (!this.walletClient)
|
|
1020
1027
|
throw new Error("Wallet client not found");
|
|
1021
1028
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1022
|
-
const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(),
|
|
1029
|
+
const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(), i = y(l, c.coins, {
|
|
1023
1030
|
balance: t,
|
|
1024
1031
|
useGasCoin: !0
|
|
1025
|
-
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o,
|
|
1032
|
+
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o, i, s);
|
|
1026
1033
|
l.transferObjects([u], this.walletClient.address);
|
|
1027
1034
|
const d = await this.walletClient.signExecuteTransaction({
|
|
1028
1035
|
transaction: l,
|
|
@@ -1048,7 +1055,7 @@ class Re extends R {
|
|
|
1048
1055
|
configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
|
|
1049
1056
|
coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
1050
1057
|
}, this.getApy = ae(
|
|
1051
|
-
|
|
1058
|
+
M(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
|
|
1052
1059
|
);
|
|
1053
1060
|
}
|
|
1054
1061
|
/**
|
|
@@ -1097,7 +1104,7 @@ class Re extends R {
|
|
|
1097
1104
|
* @param options Optional dry run
|
|
1098
1105
|
*/
|
|
1099
1106
|
async stake(e, a) {
|
|
1100
|
-
var
|
|
1107
|
+
var i, o, u;
|
|
1101
1108
|
if (!this.walletClient)
|
|
1102
1109
|
throw new Error("Wallet client not found");
|
|
1103
1110
|
const t = new w();
|
|
@@ -1109,7 +1116,7 @@ class Re extends R {
|
|
|
1109
1116
|
t.transferObjects([c], this.walletClient.address);
|
|
1110
1117
|
const l = await this.walletClient.signExecuteTransaction({
|
|
1111
1118
|
transaction: t,
|
|
1112
|
-
dryRun: (
|
|
1119
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
1113
1120
|
});
|
|
1114
1121
|
return !(a != null && a.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), l;
|
|
1115
1122
|
}
|
|
@@ -1120,7 +1127,7 @@ class Re extends R {
|
|
|
1120
1127
|
* @param options Optional dry run
|
|
1121
1128
|
*/
|
|
1122
1129
|
async unstake(e, a) {
|
|
1123
|
-
var
|
|
1130
|
+
var i, o, u;
|
|
1124
1131
|
if (!this.walletClient)
|
|
1125
1132
|
throw new Error("Wallet client not found");
|
|
1126
1133
|
await this.walletClient.module("balance").waitForUpdate();
|
|
@@ -1130,7 +1137,7 @@ class Re extends R {
|
|
|
1130
1137
|
t.transferObjects([c], this.walletClient.address);
|
|
1131
1138
|
const l = await this.walletClient.signExecuteTransaction({
|
|
1132
1139
|
transaction: t,
|
|
1133
|
-
dryRun: (
|
|
1140
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
1134
1141
|
});
|
|
1135
1142
|
return !(a != null && a.dryRun) && ((u = (o = l.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), l;
|
|
1136
1143
|
}
|
|
@@ -1236,7 +1243,7 @@ class Ie {
|
|
|
1236
1243
|
return e in this.modules;
|
|
1237
1244
|
}
|
|
1238
1245
|
}
|
|
1239
|
-
class
|
|
1246
|
+
class Le extends ne {
|
|
1240
1247
|
/**
|
|
1241
1248
|
* Creates a new watch-only signer
|
|
1242
1249
|
*
|
|
@@ -1300,7 +1307,7 @@ class Me extends ne {
|
|
|
1300
1307
|
return {};
|
|
1301
1308
|
}
|
|
1302
1309
|
}
|
|
1303
|
-
class
|
|
1310
|
+
class Me extends ne {
|
|
1304
1311
|
/**
|
|
1305
1312
|
* Creates a new watch-only signer
|
|
1306
1313
|
*
|
|
@@ -1354,7 +1361,7 @@ class Le extends ne {
|
|
|
1354
1361
|
}
|
|
1355
1362
|
export {
|
|
1356
1363
|
Ie as WalletClient,
|
|
1357
|
-
|
|
1358
|
-
|
|
1364
|
+
Le as WatchSigner,
|
|
1365
|
+
Me as WebSigner
|
|
1359
1366
|
};
|
|
1360
1367
|
//# sourceMappingURL=index.esm.js.map
|