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