@naviprotocol/wallet-client 1.0.3-dev.0 → 1.0.3-dev.2
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,28 @@ 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((
|
|
336
|
-
if (
|
|
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
|
+
if (console.log("migrateBetweenSupplyPTB", {
|
|
337
|
+
lendingState: c,
|
|
338
|
+
fromPoolLending: l,
|
|
339
|
+
fromPool: s,
|
|
340
|
+
toPool: n,
|
|
341
|
+
address: i
|
|
342
|
+
}), !l || l.supplyBalance === "0")
|
|
337
343
|
throw new Error("No supply balance");
|
|
338
344
|
if (t != null && t.amount && t.amount > Number(l.supplyBalance))
|
|
339
345
|
throw new Error("Amount is less than supply balance");
|
|
340
346
|
const o = await Q(), u = await Promise.all([s, n]);
|
|
341
347
|
await q(
|
|
342
|
-
|
|
348
|
+
r,
|
|
343
349
|
K(o, {
|
|
344
350
|
lendingState: c,
|
|
345
351
|
pools: u
|
|
@@ -348,17 +354,9 @@ async function D(i, e, a, t) {
|
|
|
348
354
|
const d = await V(n, {
|
|
349
355
|
env: this.config.env
|
|
350
356
|
});
|
|
351
|
-
if (
|
|
352
|
-
toPool: n,
|
|
353
|
-
toPoolFlashloanAsset: d,
|
|
354
|
-
fromPool: s,
|
|
355
|
-
fromPoolLending: l,
|
|
356
|
-
options: t,
|
|
357
|
-
from: e,
|
|
358
|
-
to: a
|
|
359
|
-
}), !(d != null && d.flashloanFee))
|
|
357
|
+
if (!d)
|
|
360
358
|
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 = (
|
|
359
|
+
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(
|
|
362
360
|
s.suiCoinType,
|
|
363
361
|
n.suiCoinType,
|
|
364
362
|
f
|
|
@@ -368,51 +366,57 @@ async function D(i, e, a, t) {
|
|
|
368
366
|
const C = Math.floor(m * (1 - h)), g = Math.floor(C / (1 + d.flashloanFee));
|
|
369
367
|
if (g <= 0)
|
|
370
368
|
throw new Error("The calculated borrow amount must be positive.");
|
|
371
|
-
const [B, v] = await X(
|
|
369
|
+
const [B, v] = await X(r, n, g), [k] = r.moveCall({
|
|
372
370
|
target: "0x2::coin::from_balance",
|
|
373
371
|
arguments: [B],
|
|
374
372
|
typeArguments: [n.suiCoinType]
|
|
375
373
|
});
|
|
376
|
-
await
|
|
374
|
+
await A(r, n, k, {
|
|
377
375
|
amount: g
|
|
378
376
|
});
|
|
379
|
-
const j = await Y(
|
|
380
|
-
r,
|
|
377
|
+
const j = await Y(r, s, f), U = await $(
|
|
381
378
|
i,
|
|
379
|
+
r,
|
|
382
380
|
C,
|
|
383
381
|
j,
|
|
384
382
|
b
|
|
385
|
-
), _ =
|
|
383
|
+
), _ = r.moveCall({
|
|
386
384
|
target: "0x2::coin::into_balance",
|
|
387
385
|
arguments: [U],
|
|
388
386
|
typeArguments: [n.suiCoinType]
|
|
389
|
-
}), [W] = await Z(
|
|
387
|
+
}), [W] = await Z(r, n, v, _), [N] = r.moveCall({
|
|
390
388
|
target: "0x2::coin::from_balance",
|
|
391
389
|
arguments: [W],
|
|
392
390
|
typeArguments: [n.suiCoinType]
|
|
393
391
|
});
|
|
394
|
-
return await
|
|
392
|
+
return await A(r, n, N), r;
|
|
395
393
|
}
|
|
396
|
-
async function J(
|
|
397
|
-
var
|
|
394
|
+
async function J(r, e, a, t) {
|
|
395
|
+
var O, G;
|
|
398
396
|
if (!this.walletClient)
|
|
399
397
|
throw new Error("Wallet client not found");
|
|
400
398
|
await this.walletClient.balance.waitForUpdate();
|
|
401
|
-
const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a), l = await this.getLendingState(),
|
|
402
|
-
if (
|
|
399
|
+
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);
|
|
400
|
+
if (console.log("migrateBetweenBorrowPTB", {
|
|
401
|
+
lendingState: l,
|
|
402
|
+
fromPoolLending: i,
|
|
403
|
+
fromPool: n,
|
|
404
|
+
toPool: c,
|
|
405
|
+
address: s
|
|
406
|
+
}), !i || i.borrowBalance === "0")
|
|
403
407
|
throw new Error("No borrow balance");
|
|
404
|
-
if (t != null && t.amount && t.amount > Number(
|
|
408
|
+
if (t != null && t.amount && t.amount > Number(i.borrowBalance))
|
|
405
409
|
throw new Error("Amount is less than borrow balance");
|
|
406
410
|
const o = await Q(), u = await Promise.all([n, c]);
|
|
407
411
|
await q(
|
|
408
|
-
|
|
412
|
+
r,
|
|
409
413
|
K(o, {
|
|
410
414
|
lendingState: l,
|
|
411
415
|
pools: u
|
|
412
416
|
})
|
|
413
417
|
);
|
|
414
|
-
let d = (
|
|
415
|
-
if (Number(
|
|
418
|
+
let d = (O = t == null ? void 0 : t.amount) != null ? O : Number(i.borrowBalance);
|
|
419
|
+
if (Number(i.borrowBalance) === d) {
|
|
416
420
|
const I = parseFloat(Te(n.currentBorrowRate, 8)) / 100;
|
|
417
421
|
d = Math.ceil(
|
|
418
422
|
new p(d).multipliedBy(I * (60 * 3) / (365 * 24 * 3600)).plus(new p(1).shiftedBy(-n.token.decimals)).plus(d).toNumber()
|
|
@@ -441,32 +445,32 @@ async function J(i, e, a, t) {
|
|
|
441
445
|
n.suiCoinType,
|
|
442
446
|
B
|
|
443
447
|
);
|
|
444
|
-
const [
|
|
448
|
+
const [k, j] = await X(r, n, d), [U] = r.moveCall({
|
|
445
449
|
target: "0x2::coin::from_balance",
|
|
446
|
-
arguments: [
|
|
450
|
+
arguments: [k],
|
|
447
451
|
typeArguments: [n.suiCoinType]
|
|
448
452
|
});
|
|
449
|
-
await ee(
|
|
453
|
+
await ee(r, n, U, {
|
|
450
454
|
amount: d
|
|
451
455
|
});
|
|
452
|
-
const _ = await te(
|
|
456
|
+
const _ = await te(r, c, B), W = await $(
|
|
453
457
|
s,
|
|
454
|
-
|
|
458
|
+
r,
|
|
455
459
|
b,
|
|
456
460
|
_,
|
|
457
461
|
v
|
|
458
|
-
), N =
|
|
462
|
+
), N = r.moveCall({
|
|
459
463
|
target: "0x2::coin::into_balance",
|
|
460
464
|
arguments: [W],
|
|
461
465
|
typeArguments: [n.suiCoinType]
|
|
462
|
-
}), [S] = await Z(
|
|
466
|
+
}), [S] = await Z(r, n, j, N), [F] = r.moveCall({
|
|
463
467
|
target: "0x2::coin::from_balance",
|
|
464
468
|
arguments: [S],
|
|
465
469
|
typeArguments: [n.suiCoinType]
|
|
466
470
|
});
|
|
467
|
-
return
|
|
471
|
+
return r.transferObjects([F], s), r;
|
|
468
472
|
}
|
|
469
|
-
async function z(
|
|
473
|
+
async function z(r, e, a, t) {
|
|
470
474
|
var o, u;
|
|
471
475
|
if (!this.walletClient)
|
|
472
476
|
throw new Error("Wallet client not found");
|
|
@@ -477,20 +481,20 @@ async function z(i, e, a, t) {
|
|
|
477
481
|
if (t != null && t.amount && n.amount.lt(t.amount))
|
|
478
482
|
throw new Error("Amount is less than balance");
|
|
479
483
|
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;
|
|
480
|
-
let
|
|
484
|
+
let i = await y(r, n.coins, {
|
|
481
485
|
balance: c,
|
|
482
486
|
useGasCoin: !0
|
|
483
487
|
});
|
|
484
488
|
if (T(e) !== T(s.suiCoinType)) {
|
|
485
489
|
const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
|
|
486
|
-
|
|
487
|
-
i,
|
|
488
|
-
d,
|
|
490
|
+
i = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
489
491
|
r,
|
|
492
|
+
d,
|
|
493
|
+
i,
|
|
490
494
|
l
|
|
491
495
|
);
|
|
492
496
|
}
|
|
493
|
-
return await
|
|
497
|
+
return await A(r, s, i), r;
|
|
494
498
|
}
|
|
495
499
|
class ve extends R {
|
|
496
500
|
constructor() {
|
|
@@ -543,19 +547,19 @@ class ve extends R {
|
|
|
543
547
|
balance: a,
|
|
544
548
|
useGasCoin: !0
|
|
545
549
|
});
|
|
546
|
-
await
|
|
550
|
+
await A(n, s, l, {
|
|
547
551
|
env: this.config.env,
|
|
548
552
|
amount: a,
|
|
549
553
|
accountCap: t == null ? void 0 : t.accountCap
|
|
550
554
|
});
|
|
551
|
-
const
|
|
555
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
552
556
|
transaction: n,
|
|
553
557
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
554
558
|
});
|
|
555
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
559
|
+
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", {
|
|
556
560
|
identifier: e,
|
|
557
561
|
amount: a
|
|
558
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
562
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
559
563
|
}
|
|
560
564
|
/**
|
|
561
565
|
* Withdraws coins from a lending pool
|
|
@@ -566,7 +570,7 @@ class ve extends R {
|
|
|
566
570
|
* @returns Transaction response or dry run response
|
|
567
571
|
*/
|
|
568
572
|
async withdraw(e, a, t) {
|
|
569
|
-
var
|
|
573
|
+
var i, o, u;
|
|
570
574
|
if (!this.walletClient)
|
|
571
575
|
throw new Error("Wallet client not found");
|
|
572
576
|
const s = await P(e, {
|
|
@@ -580,7 +584,7 @@ class ve extends R {
|
|
|
580
584
|
n.transferObjects([c], this.walletClient.address);
|
|
581
585
|
const l = await this.walletClient.signExecuteTransaction({
|
|
582
586
|
transaction: n,
|
|
583
|
-
dryRun: (
|
|
587
|
+
dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
|
|
584
588
|
});
|
|
585
589
|
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", {
|
|
586
590
|
identifier: e,
|
|
@@ -596,7 +600,7 @@ class ve extends R {
|
|
|
596
600
|
* @returns Transaction response or dry run response
|
|
597
601
|
*/
|
|
598
602
|
async borrow(e, a, t) {
|
|
599
|
-
var
|
|
603
|
+
var i, o, u;
|
|
600
604
|
if (!this.walletClient)
|
|
601
605
|
throw new Error("Wallet client not found");
|
|
602
606
|
const s = await P(e, {
|
|
@@ -610,7 +614,7 @@ class ve extends R {
|
|
|
610
614
|
n.transferObjects([c], this.walletClient.address);
|
|
611
615
|
const l = await this.walletClient.signExecuteTransaction({
|
|
612
616
|
transaction: n,
|
|
613
|
-
dryRun: (
|
|
617
|
+
dryRun: (i = t == null ? void 0 : t.dryRun) != null ? i : !1
|
|
614
618
|
});
|
|
615
619
|
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", {
|
|
616
620
|
identifier: e,
|
|
@@ -641,14 +645,14 @@ class ve extends R {
|
|
|
641
645
|
amount: a,
|
|
642
646
|
accountCap: t == null ? void 0 : t.accountCap
|
|
643
647
|
});
|
|
644
|
-
const
|
|
648
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
645
649
|
transaction: n,
|
|
646
650
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
647
651
|
});
|
|
648
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
652
|
+
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", {
|
|
649
653
|
identifier: e,
|
|
650
654
|
amount: a
|
|
651
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
655
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
652
656
|
}
|
|
653
657
|
/**
|
|
654
658
|
* Gets the current health factor for the user
|
|
@@ -682,11 +686,11 @@ class ve extends R {
|
|
|
682
686
|
env: this.config.env
|
|
683
687
|
}), l = await P(t, {
|
|
684
688
|
env: this.config.env
|
|
685
|
-
}),
|
|
689
|
+
}), i = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = y(i, o.coins, {
|
|
686
690
|
balance: a,
|
|
687
691
|
useGasCoin: !0
|
|
688
692
|
}), [d, h] = await we(
|
|
689
|
-
|
|
693
|
+
i,
|
|
690
694
|
c,
|
|
691
695
|
u,
|
|
692
696
|
l,
|
|
@@ -694,18 +698,18 @@ class ve extends R {
|
|
|
694
698
|
{
|
|
695
699
|
env: this.config.env
|
|
696
700
|
}
|
|
697
|
-
), [f] =
|
|
701
|
+
), [f] = i.moveCall({
|
|
698
702
|
target: "0x2::coin::from_balance",
|
|
699
703
|
arguments: [d],
|
|
700
704
|
typeArguments: [l.suiCoinType]
|
|
701
|
-
}), [b] =
|
|
705
|
+
}), [b] = i.moveCall({
|
|
702
706
|
target: "0x2::coin::from_balance",
|
|
703
707
|
arguments: [h],
|
|
704
708
|
typeArguments: [c.suiCoinType]
|
|
705
709
|
});
|
|
706
|
-
|
|
710
|
+
i.transferObjects([f, b], this.walletClient.address);
|
|
707
711
|
const m = await this.walletClient.signExecuteTransaction({
|
|
708
|
-
transaction:
|
|
712
|
+
transaction: i,
|
|
709
713
|
dryRun: (C = n == null ? void 0 : n.dryRun) != null ? C : !1
|
|
710
714
|
});
|
|
711
715
|
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", {
|
|
@@ -857,7 +861,7 @@ class pe extends R {
|
|
|
857
861
|
e.object(this.config.poolId),
|
|
858
862
|
e.object(this.config.metadataId),
|
|
859
863
|
e.object("0x05"),
|
|
860
|
-
|
|
864
|
+
x(a, e.object)
|
|
861
865
|
],
|
|
862
866
|
typeArguments: []
|
|
863
867
|
});
|
|
@@ -877,7 +881,7 @@ class pe extends R {
|
|
|
877
881
|
e.object(this.config.poolId),
|
|
878
882
|
e.object(this.config.metadataId),
|
|
879
883
|
e.object("0x05"),
|
|
880
|
-
|
|
884
|
+
x(a, e.object)
|
|
881
885
|
],
|
|
882
886
|
typeArguments: []
|
|
883
887
|
});
|
|
@@ -892,7 +896,7 @@ class pe extends R {
|
|
|
892
896
|
* @throws Error if wallet client not found or stake amount is too low
|
|
893
897
|
*/
|
|
894
898
|
async stake(e, a) {
|
|
895
|
-
var
|
|
899
|
+
var i, o, u;
|
|
896
900
|
if (!this.walletClient)
|
|
897
901
|
throw new Error("Wallet client not found");
|
|
898
902
|
if (e < 1e9)
|
|
@@ -906,7 +910,7 @@ class pe extends R {
|
|
|
906
910
|
t.transferObjects([c], this.walletClient.address);
|
|
907
911
|
const l = await this.walletClient.signExecuteTransaction({
|
|
908
912
|
transaction: t,
|
|
909
|
-
dryRun: (
|
|
913
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
910
914
|
});
|
|
911
915
|
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", {
|
|
912
916
|
suiAmount: e
|
|
@@ -921,7 +925,7 @@ class pe extends R {
|
|
|
921
925
|
* @throws Error if wallet client not found or unstake amount is too low
|
|
922
926
|
*/
|
|
923
927
|
async unstake(e, a) {
|
|
924
|
-
var
|
|
928
|
+
var i, o, u;
|
|
925
929
|
if (!this.walletClient)
|
|
926
930
|
throw new Error("Wallet client not found");
|
|
927
931
|
if (e < 1e9)
|
|
@@ -933,7 +937,7 @@ class pe extends R {
|
|
|
933
937
|
t.transferObjects([c], this.walletClient.address);
|
|
934
938
|
const l = await this.walletClient.signExecuteTransaction({
|
|
935
939
|
transaction: t,
|
|
936
|
-
dryRun: (
|
|
940
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
937
941
|
});
|
|
938
942
|
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", {
|
|
939
943
|
vSuiAmount: e
|
|
@@ -1027,10 +1031,10 @@ class Ee extends R {
|
|
|
1027
1031
|
if (!this.walletClient)
|
|
1028
1032
|
throw new Error("Wallet client not found");
|
|
1029
1033
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1030
|
-
const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(),
|
|
1034
|
+
const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(), i = y(l, c.coins, {
|
|
1031
1035
|
balance: t,
|
|
1032
1036
|
useGasCoin: !0
|
|
1033
|
-
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o,
|
|
1037
|
+
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o, i, s);
|
|
1034
1038
|
l.transferObjects([u], this.walletClient.address);
|
|
1035
1039
|
const d = await this.walletClient.signExecuteTransaction({
|
|
1036
1040
|
transaction: l,
|
|
@@ -1072,7 +1076,7 @@ class Re extends R {
|
|
|
1072
1076
|
arguments: [
|
|
1073
1077
|
e.object("0x05"),
|
|
1074
1078
|
e.object(this.config.configId),
|
|
1075
|
-
|
|
1079
|
+
x(a, e.object),
|
|
1076
1080
|
e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1077
1081
|
],
|
|
1078
1082
|
typeArguments: []
|
|
@@ -1092,7 +1096,7 @@ class Re extends R {
|
|
|
1092
1096
|
arguments: [
|
|
1093
1097
|
e.object("0x05"),
|
|
1094
1098
|
e.object(this.config.configId),
|
|
1095
|
-
|
|
1099
|
+
x(a, e.object)
|
|
1096
1100
|
],
|
|
1097
1101
|
typeArguments: []
|
|
1098
1102
|
});
|
|
@@ -1105,7 +1109,7 @@ class Re extends R {
|
|
|
1105
1109
|
* @param options Optional dry run
|
|
1106
1110
|
*/
|
|
1107
1111
|
async stake(e, a) {
|
|
1108
|
-
var
|
|
1112
|
+
var i, o, u;
|
|
1109
1113
|
if (!this.walletClient)
|
|
1110
1114
|
throw new Error("Wallet client not found");
|
|
1111
1115
|
const t = new w();
|
|
@@ -1117,7 +1121,7 @@ class Re extends R {
|
|
|
1117
1121
|
t.transferObjects([c], this.walletClient.address);
|
|
1118
1122
|
const l = await this.walletClient.signExecuteTransaction({
|
|
1119
1123
|
transaction: t,
|
|
1120
|
-
dryRun: (
|
|
1124
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
1121
1125
|
});
|
|
1122
1126
|
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;
|
|
1123
1127
|
}
|
|
@@ -1128,7 +1132,7 @@ class Re extends R {
|
|
|
1128
1132
|
* @param options Optional dry run
|
|
1129
1133
|
*/
|
|
1130
1134
|
async unstake(e, a) {
|
|
1131
|
-
var
|
|
1135
|
+
var i, o, u;
|
|
1132
1136
|
if (!this.walletClient)
|
|
1133
1137
|
throw new Error("Wallet client not found");
|
|
1134
1138
|
await this.walletClient.module("balance").waitForUpdate();
|
|
@@ -1138,7 +1142,7 @@ class Re extends R {
|
|
|
1138
1142
|
t.transferObjects([c], this.walletClient.address);
|
|
1139
1143
|
const l = await this.walletClient.signExecuteTransaction({
|
|
1140
1144
|
transaction: t,
|
|
1141
|
-
dryRun: (
|
|
1145
|
+
dryRun: (i = a == null ? void 0 : a.dryRun) != null ? i : !1
|
|
1142
1146
|
});
|
|
1143
1147
|
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;
|
|
1144
1148
|
}
|
|
@@ -1154,7 +1158,7 @@ const Se = {
|
|
|
1154
1158
|
swap: new Ee(),
|
|
1155
1159
|
/** Haedal protocol module */
|
|
1156
1160
|
haedal: new Re()
|
|
1157
|
-
},
|
|
1161
|
+
}, Fe = {
|
|
1158
1162
|
url: le("mainnet")
|
|
1159
1163
|
};
|
|
1160
1164
|
class Ie {
|
|
@@ -1165,7 +1169,7 @@ class Ie {
|
|
|
1165
1169
|
constructor(e) {
|
|
1166
1170
|
this.modules = Se, this.userConfigs = {}, this.events = re();
|
|
1167
1171
|
const a = {
|
|
1168
|
-
...
|
|
1172
|
+
...Fe,
|
|
1169
1173
|
...e.client
|
|
1170
1174
|
};
|
|
1171
1175
|
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]) => {
|