@naviprotocol/wallet-client 1.0.2 → 1.0.3-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,7 +1,7 @@
|
|
|
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 L, getCoins as oe, mergeCoinsPTB as y, getPriceFeeds as Q, updateOraclePricesPTB as q, filterPriceFeeds as K, getFlashLoanAsset as V, flashloanPTB as X, depositCoinPTB 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 A, 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 x } from "@naviprotocol/lending";
|
|
5
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";
|
|
@@ -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 {
|
|
@@ -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,22 @@ 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(
|
|
331
|
-
var S,
|
|
330
|
+
async function D(r, e, a, t) {
|
|
331
|
+
var S, F;
|
|
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((
|
|
335
|
+
const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), l = c.find((O) => O.pool.id === s.id), i = this.walletClient.address;
|
|
336
336
|
if (!l || l.supplyBalance === "0")
|
|
337
337
|
throw new Error("No supply balance");
|
|
338
338
|
if (t != null && t.amount && t.amount > Number(l.supplyBalance))
|
|
339
339
|
throw new Error("Amount is less than supply balance");
|
|
340
340
|
const o = await Q(), u = await Promise.all([s, n]);
|
|
341
341
|
await q(
|
|
342
|
-
|
|
342
|
+
r,
|
|
343
343
|
K(o, {
|
|
344
344
|
lendingState: c,
|
|
345
345
|
pools: u
|
|
@@ -348,9 +348,17 @@ async function D(i, e, a, t) {
|
|
|
348
348
|
const d = await V(n, {
|
|
349
349
|
env: this.config.env
|
|
350
350
|
});
|
|
351
|
-
if (
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
if (console.log("migrateBetweenSupplyPTB", {
|
|
352
|
+
toPool: n,
|
|
353
|
+
toPoolFlashloanAsset: d,
|
|
354
|
+
fromPool: s,
|
|
355
|
+
fromPoolLending: l,
|
|
356
|
+
options: t,
|
|
357
|
+
from: e,
|
|
358
|
+
to: a
|
|
359
|
+
}), !d)
|
|
360
|
+
throw new Error(`${n.token.symbol} pool not support flashloan`);
|
|
361
|
+
const h = (S = t == null ? void 0 : t.slippage) != null ? S : 5e-3, f = (F = t == null ? void 0 : t.amount) != null ? F : Number(l.supplyBalance), b = await this.walletClient.swap.getQuote(
|
|
354
362
|
s.suiCoinType,
|
|
355
363
|
n.suiCoinType,
|
|
356
364
|
f
|
|
@@ -360,51 +368,51 @@ async function D(i, e, a, t) {
|
|
|
360
368
|
const C = Math.floor(m * (1 - h)), g = Math.floor(C / (1 + d.flashloanFee));
|
|
361
369
|
if (g <= 0)
|
|
362
370
|
throw new Error("The calculated borrow amount must be positive.");
|
|
363
|
-
const [B, v] = await X(
|
|
371
|
+
const [B, v] = await X(r, n, g), [k] = r.moveCall({
|
|
364
372
|
target: "0x2::coin::from_balance",
|
|
365
373
|
arguments: [B],
|
|
366
374
|
typeArguments: [n.suiCoinType]
|
|
367
375
|
});
|
|
368
|
-
await
|
|
376
|
+
await A(r, n, k, {
|
|
369
377
|
amount: g
|
|
370
378
|
});
|
|
371
|
-
const j = await Y(
|
|
372
|
-
r,
|
|
379
|
+
const j = await Y(r, s, f), U = await $(
|
|
373
380
|
i,
|
|
381
|
+
r,
|
|
374
382
|
C,
|
|
375
383
|
j,
|
|
376
384
|
b
|
|
377
|
-
), _ =
|
|
385
|
+
), _ = r.moveCall({
|
|
378
386
|
target: "0x2::coin::into_balance",
|
|
379
387
|
arguments: [U],
|
|
380
388
|
typeArguments: [n.suiCoinType]
|
|
381
|
-
}), [W] = await Z(
|
|
389
|
+
}), [W] = await Z(r, n, v, _), [N] = r.moveCall({
|
|
382
390
|
target: "0x2::coin::from_balance",
|
|
383
391
|
arguments: [W],
|
|
384
392
|
typeArguments: [n.suiCoinType]
|
|
385
393
|
});
|
|
386
|
-
return await
|
|
394
|
+
return await A(r, n, N), r;
|
|
387
395
|
}
|
|
388
|
-
async function J(
|
|
389
|
-
var
|
|
396
|
+
async function J(r, e, a, t) {
|
|
397
|
+
var O, G;
|
|
390
398
|
if (!this.walletClient)
|
|
391
399
|
throw new Error("Wallet client not found");
|
|
392
400
|
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 (!
|
|
401
|
+
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);
|
|
402
|
+
if (!i || i.borrowBalance === "0")
|
|
395
403
|
throw new Error("No borrow balance");
|
|
396
|
-
if (t != null && t.amount && t.amount > Number(
|
|
404
|
+
if (t != null && t.amount && t.amount > Number(i.borrowBalance))
|
|
397
405
|
throw new Error("Amount is less than borrow balance");
|
|
398
406
|
const o = await Q(), u = await Promise.all([n, c]);
|
|
399
407
|
await q(
|
|
400
|
-
|
|
408
|
+
r,
|
|
401
409
|
K(o, {
|
|
402
410
|
lendingState: l,
|
|
403
411
|
pools: u
|
|
404
412
|
})
|
|
405
413
|
);
|
|
406
|
-
let d = (
|
|
407
|
-
if (Number(
|
|
414
|
+
let d = (O = t == null ? void 0 : t.amount) != null ? O : Number(i.borrowBalance);
|
|
415
|
+
if (Number(i.borrowBalance) === d) {
|
|
408
416
|
const I = parseFloat(Te(n.currentBorrowRate, 8)) / 100;
|
|
409
417
|
d = Math.ceil(
|
|
410
418
|
new p(d).multipliedBy(I * (60 * 3) / (365 * 24 * 3600)).plus(new p(1).shiftedBy(-n.token.decimals)).plus(d).toNumber()
|
|
@@ -417,6 +425,16 @@ async function J(i, e, a, t) {
|
|
|
417
425
|
throw new Error(`${n.token.symbol} pool not support flashloan`);
|
|
418
426
|
if (!this.walletClient)
|
|
419
427
|
throw new Error("Wallet client not found");
|
|
428
|
+
console.log("migrateBetweenBorrowPTB", {
|
|
429
|
+
toPool: c,
|
|
430
|
+
fromPoolFlashloanAsset: h,
|
|
431
|
+
fromPool: n,
|
|
432
|
+
formAmount: d,
|
|
433
|
+
fromPoolLending: i,
|
|
434
|
+
options: t,
|
|
435
|
+
from: e,
|
|
436
|
+
to: a
|
|
437
|
+
});
|
|
420
438
|
const f = (G = t == null ? void 0 : t.slippage) != null ? G : 5e-3, b = Math.ceil(d * (1 + h.flashloanFee)), m = b, C = await this.walletClient.swap.getQuote(
|
|
421
439
|
n.suiCoinType,
|
|
422
440
|
c.suiCoinType,
|
|
@@ -433,32 +451,32 @@ async function J(i, e, a, t) {
|
|
|
433
451
|
n.suiCoinType,
|
|
434
452
|
B
|
|
435
453
|
);
|
|
436
|
-
const [
|
|
454
|
+
const [k, j] = await X(r, n, d), [U] = r.moveCall({
|
|
437
455
|
target: "0x2::coin::from_balance",
|
|
438
|
-
arguments: [
|
|
456
|
+
arguments: [k],
|
|
439
457
|
typeArguments: [n.suiCoinType]
|
|
440
458
|
});
|
|
441
|
-
await ee(
|
|
459
|
+
await ee(r, n, U, {
|
|
442
460
|
amount: d
|
|
443
461
|
});
|
|
444
|
-
const _ = await te(
|
|
462
|
+
const _ = await te(r, c, B), W = await $(
|
|
445
463
|
s,
|
|
446
|
-
|
|
464
|
+
r,
|
|
447
465
|
b,
|
|
448
466
|
_,
|
|
449
467
|
v
|
|
450
|
-
), N =
|
|
468
|
+
), N = r.moveCall({
|
|
451
469
|
target: "0x2::coin::into_balance",
|
|
452
470
|
arguments: [W],
|
|
453
471
|
typeArguments: [n.suiCoinType]
|
|
454
|
-
}), [S] = await Z(
|
|
472
|
+
}), [S] = await Z(r, n, j, N), [F] = r.moveCall({
|
|
455
473
|
target: "0x2::coin::from_balance",
|
|
456
474
|
arguments: [S],
|
|
457
475
|
typeArguments: [n.suiCoinType]
|
|
458
476
|
});
|
|
459
|
-
return
|
|
477
|
+
return r.transferObjects([F], s), r;
|
|
460
478
|
}
|
|
461
|
-
async function z(
|
|
479
|
+
async function z(r, e, a, t) {
|
|
462
480
|
var o, u;
|
|
463
481
|
if (!this.walletClient)
|
|
464
482
|
throw new Error("Wallet client not found");
|
|
@@ -469,20 +487,20 @@ async function z(i, e, a, t) {
|
|
|
469
487
|
if (t != null && t.amount && n.amount.lt(t.amount))
|
|
470
488
|
throw new Error("Amount is less than balance");
|
|
471
489
|
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
|
|
490
|
+
let i = await y(r, n.coins, {
|
|
473
491
|
balance: c,
|
|
474
492
|
useGasCoin: !0
|
|
475
493
|
});
|
|
476
494
|
if (T(e) !== T(s.suiCoinType)) {
|
|
477
495
|
const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
|
|
478
|
-
|
|
479
|
-
i,
|
|
480
|
-
d,
|
|
496
|
+
i = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
481
497
|
r,
|
|
498
|
+
d,
|
|
499
|
+
i,
|
|
482
500
|
l
|
|
483
501
|
);
|
|
484
502
|
}
|
|
485
|
-
return await
|
|
503
|
+
return await A(r, s, i), r;
|
|
486
504
|
}
|
|
487
505
|
class ve extends R {
|
|
488
506
|
constructor() {
|
|
@@ -535,19 +553,19 @@ class ve extends R {
|
|
|
535
553
|
balance: a,
|
|
536
554
|
useGasCoin: !0
|
|
537
555
|
});
|
|
538
|
-
await
|
|
556
|
+
await A(n, s, l, {
|
|
539
557
|
env: this.config.env,
|
|
540
558
|
amount: a,
|
|
541
559
|
accountCap: t == null ? void 0 : t.accountCap
|
|
542
560
|
});
|
|
543
|
-
const
|
|
561
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
544
562
|
transaction: n,
|
|
545
563
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
546
564
|
});
|
|
547
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
565
|
+
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
566
|
identifier: e,
|
|
549
567
|
amount: a
|
|
550
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
568
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
551
569
|
}
|
|
552
570
|
/**
|
|
553
571
|
* Withdraws coins from a lending pool
|
|
@@ -558,7 +576,7 @@ class ve extends R {
|
|
|
558
576
|
* @returns Transaction response or dry run response
|
|
559
577
|
*/
|
|
560
578
|
async withdraw(e, a, t) {
|
|
561
|
-
var
|
|
579
|
+
var i, o, u;
|
|
562
580
|
if (!this.walletClient)
|
|
563
581
|
throw new Error("Wallet client not found");
|
|
564
582
|
const s = await P(e, {
|
|
@@ -572,7 +590,7 @@ class ve extends R {
|
|
|
572
590
|
n.transferObjects([c], this.walletClient.address);
|
|
573
591
|
const l = await this.walletClient.signExecuteTransaction({
|
|
574
592
|
transaction: n,
|
|
575
|
-
dryRun: (
|
|
593
|
+
dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
|
|
576
594
|
});
|
|
577
595
|
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
596
|
identifier: e,
|
|
@@ -588,7 +606,7 @@ class ve extends R {
|
|
|
588
606
|
* @returns Transaction response or dry run response
|
|
589
607
|
*/
|
|
590
608
|
async borrow(e, a, t) {
|
|
591
|
-
var
|
|
609
|
+
var i, o, u;
|
|
592
610
|
if (!this.walletClient)
|
|
593
611
|
throw new Error("Wallet client not found");
|
|
594
612
|
const s = await P(e, {
|
|
@@ -602,7 +620,7 @@ class ve extends R {
|
|
|
602
620
|
n.transferObjects([c], this.walletClient.address);
|
|
603
621
|
const l = await this.walletClient.signExecuteTransaction({
|
|
604
622
|
transaction: n,
|
|
605
|
-
dryRun: (
|
|
623
|
+
dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
|
|
606
624
|
});
|
|
607
625
|
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
626
|
identifier: e,
|
|
@@ -633,14 +651,14 @@ class ve extends R {
|
|
|
633
651
|
amount: a,
|
|
634
652
|
accountCap: t == null ? void 0 : t.accountCap
|
|
635
653
|
});
|
|
636
|
-
const
|
|
654
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
637
655
|
transaction: n,
|
|
638
656
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
639
657
|
});
|
|
640
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
658
|
+
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
659
|
identifier: e,
|
|
642
660
|
amount: a
|
|
643
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
661
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
644
662
|
}
|
|
645
663
|
/**
|
|
646
664
|
* Gets the current health factor for the user
|
|
@@ -674,11 +692,11 @@ class ve extends R {
|
|
|
674
692
|
env: this.config.env
|
|
675
693
|
}), l = await P(t, {
|
|
676
694
|
env: this.config.env
|
|
677
|
-
}),
|
|
695
|
+
}), i = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = y(i, o.coins, {
|
|
678
696
|
balance: a,
|
|
679
697
|
useGasCoin: !0
|
|
680
698
|
}), [d, h] = await we(
|
|
681
|
-
|
|
699
|
+
i,
|
|
682
700
|
c,
|
|
683
701
|
u,
|
|
684
702
|
l,
|
|
@@ -686,18 +704,18 @@ class ve extends R {
|
|
|
686
704
|
{
|
|
687
705
|
env: this.config.env
|
|
688
706
|
}
|
|
689
|
-
), [f] =
|
|
707
|
+
), [f] = i.moveCall({
|
|
690
708
|
target: "0x2::coin::from_balance",
|
|
691
709
|
arguments: [d],
|
|
692
710
|
typeArguments: [l.suiCoinType]
|
|
693
|
-
}), [b] =
|
|
711
|
+
}), [b] = i.moveCall({
|
|
694
712
|
target: "0x2::coin::from_balance",
|
|
695
713
|
arguments: [h],
|
|
696
714
|
typeArguments: [c.suiCoinType]
|
|
697
715
|
});
|
|
698
|
-
|
|
716
|
+
i.transferObjects([f, b], this.walletClient.address);
|
|
699
717
|
const m = await this.walletClient.signExecuteTransaction({
|
|
700
|
-
transaction:
|
|
718
|
+
transaction: i,
|
|
701
719
|
dryRun: (C = n == null ? void 0 : n.dryRun) != null ? C : !1
|
|
702
720
|
});
|
|
703
721
|
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", {
|
|
@@ -849,7 +867,7 @@ class pe extends R {
|
|
|
849
867
|
e.object(this.config.poolId),
|
|
850
868
|
e.object(this.config.metadataId),
|
|
851
869
|
e.object("0x05"),
|
|
852
|
-
|
|
870
|
+
x(a, e.object)
|
|
853
871
|
],
|
|
854
872
|
typeArguments: []
|
|
855
873
|
});
|
|
@@ -869,7 +887,7 @@ class pe extends R {
|
|
|
869
887
|
e.object(this.config.poolId),
|
|
870
888
|
e.object(this.config.metadataId),
|
|
871
889
|
e.object("0x05"),
|
|
872
|
-
|
|
890
|
+
x(a, e.object)
|
|
873
891
|
],
|
|
874
892
|
typeArguments: []
|
|
875
893
|
});
|
|
@@ -884,7 +902,7 @@ class pe extends R {
|
|
|
884
902
|
* @throws Error if wallet client not found or stake amount is too low
|
|
885
903
|
*/
|
|
886
904
|
async stake(e, a) {
|
|
887
|
-
var
|
|
905
|
+
var i, o, u;
|
|
888
906
|
if (!this.walletClient)
|
|
889
907
|
throw new Error("Wallet client not found");
|
|
890
908
|
if (e < 1e9)
|
|
@@ -898,7 +916,7 @@ class pe extends R {
|
|
|
898
916
|
t.transferObjects([c], this.walletClient.address);
|
|
899
917
|
const l = await this.walletClient.signExecuteTransaction({
|
|
900
918
|
transaction: t,
|
|
901
|
-
dryRun: (
|
|
919
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
902
920
|
});
|
|
903
921
|
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
922
|
suiAmount: e
|
|
@@ -913,7 +931,7 @@ class pe extends R {
|
|
|
913
931
|
* @throws Error if wallet client not found or unstake amount is too low
|
|
914
932
|
*/
|
|
915
933
|
async unstake(e, a) {
|
|
916
|
-
var
|
|
934
|
+
var i, o, u;
|
|
917
935
|
if (!this.walletClient)
|
|
918
936
|
throw new Error("Wallet client not found");
|
|
919
937
|
if (e < 1e9)
|
|
@@ -925,7 +943,7 @@ class pe extends R {
|
|
|
925
943
|
t.transferObjects([c], this.walletClient.address);
|
|
926
944
|
const l = await this.walletClient.signExecuteTransaction({
|
|
927
945
|
transaction: t,
|
|
928
|
-
dryRun: (
|
|
946
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
929
947
|
});
|
|
930
948
|
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
949
|
vSuiAmount: e
|
|
@@ -1019,10 +1037,10 @@ class Ee extends R {
|
|
|
1019
1037
|
if (!this.walletClient)
|
|
1020
1038
|
throw new Error("Wallet client not found");
|
|
1021
1039
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1022
|
-
const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(),
|
|
1040
|
+
const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(), i = y(l, c.coins, {
|
|
1023
1041
|
balance: t,
|
|
1024
1042
|
useGasCoin: !0
|
|
1025
|
-
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o,
|
|
1043
|
+
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o, i, s);
|
|
1026
1044
|
l.transferObjects([u], this.walletClient.address);
|
|
1027
1045
|
const d = await this.walletClient.signExecuteTransaction({
|
|
1028
1046
|
transaction: l,
|
|
@@ -1064,7 +1082,7 @@ class Re extends R {
|
|
|
1064
1082
|
arguments: [
|
|
1065
1083
|
e.object("0x05"),
|
|
1066
1084
|
e.object(this.config.configId),
|
|
1067
|
-
|
|
1085
|
+
x(a, e.object),
|
|
1068
1086
|
e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1069
1087
|
],
|
|
1070
1088
|
typeArguments: []
|
|
@@ -1084,7 +1102,7 @@ class Re extends R {
|
|
|
1084
1102
|
arguments: [
|
|
1085
1103
|
e.object("0x05"),
|
|
1086
1104
|
e.object(this.config.configId),
|
|
1087
|
-
|
|
1105
|
+
x(a, e.object)
|
|
1088
1106
|
],
|
|
1089
1107
|
typeArguments: []
|
|
1090
1108
|
});
|
|
@@ -1097,7 +1115,7 @@ class Re extends R {
|
|
|
1097
1115
|
* @param options Optional dry run
|
|
1098
1116
|
*/
|
|
1099
1117
|
async stake(e, a) {
|
|
1100
|
-
var
|
|
1118
|
+
var i, o, u;
|
|
1101
1119
|
if (!this.walletClient)
|
|
1102
1120
|
throw new Error("Wallet client not found");
|
|
1103
1121
|
const t = new w();
|
|
@@ -1109,7 +1127,7 @@ class Re extends R {
|
|
|
1109
1127
|
t.transferObjects([c], this.walletClient.address);
|
|
1110
1128
|
const l = await this.walletClient.signExecuteTransaction({
|
|
1111
1129
|
transaction: t,
|
|
1112
|
-
dryRun: (
|
|
1130
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
1113
1131
|
});
|
|
1114
1132
|
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
1133
|
}
|
|
@@ -1120,7 +1138,7 @@ class Re extends R {
|
|
|
1120
1138
|
* @param options Optional dry run
|
|
1121
1139
|
*/
|
|
1122
1140
|
async unstake(e, a) {
|
|
1123
|
-
var
|
|
1141
|
+
var i, o, u;
|
|
1124
1142
|
if (!this.walletClient)
|
|
1125
1143
|
throw new Error("Wallet client not found");
|
|
1126
1144
|
await this.walletClient.module("balance").waitForUpdate();
|
|
@@ -1130,7 +1148,7 @@ class Re extends R {
|
|
|
1130
1148
|
t.transferObjects([c], this.walletClient.address);
|
|
1131
1149
|
const l = await this.walletClient.signExecuteTransaction({
|
|
1132
1150
|
transaction: t,
|
|
1133
|
-
dryRun: (
|
|
1151
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
1134
1152
|
});
|
|
1135
1153
|
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
1154
|
}
|
|
@@ -1146,7 +1164,7 @@ const Se = {
|
|
|
1146
1164
|
swap: new Ee(),
|
|
1147
1165
|
/** Haedal protocol module */
|
|
1148
1166
|
haedal: new Re()
|
|
1149
|
-
},
|
|
1167
|
+
}, Fe = {
|
|
1150
1168
|
url: le("mainnet")
|
|
1151
1169
|
};
|
|
1152
1170
|
class Ie {
|
|
@@ -1157,7 +1175,7 @@ class Ie {
|
|
|
1157
1175
|
constructor(e) {
|
|
1158
1176
|
this.modules = Se, this.userConfigs = {}, this.events = re();
|
|
1159
1177
|
const a = {
|
|
1160
|
-
...
|
|
1178
|
+
...Fe,
|
|
1161
1179
|
...e.client
|
|
1162
1180
|
};
|
|
1163
1181
|
a.transport = a.transport || new ye(a.url), this.client = new ie(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
|