@naviprotocol/wallet-client 1.0.2-dev.2 → 1.0.3-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.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +117 -115
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/lendingModule/migrate.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -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 {
|
|
@@ -237,16 +237,16 @@ class Be extends R {
|
|
|
237
237
|
const n = this.portfolio.getBalance(e), c = t.reduce((h, f) => h.plus(f), p(0));
|
|
238
238
|
if (n.amount.lt(c))
|
|
239
239
|
throw new Error("Insufficient balance");
|
|
240
|
-
const
|
|
241
|
-
let
|
|
242
|
-
T(e) !== T("0x2::sui::SUI") && (
|
|
240
|
+
const l = new w();
|
|
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 =
|
|
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({
|
|
249
|
-
transaction:
|
|
249
|
+
transaction: l,
|
|
250
250
|
dryRun: (d = s == null ? void 0 : s.dryRun) != null ? d : !1
|
|
251
251
|
});
|
|
252
252
|
}
|
|
@@ -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((
|
|
284
|
-
s.transferObjects([s.object(
|
|
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,22 +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(),
|
|
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), r = this.walletClient.address;
|
|
336
|
+
if (!l || l.supplyBalance === "0")
|
|
337
337
|
throw new Error("No supply balance");
|
|
338
|
-
if (t != null && t.amount && t.amount > Number(
|
|
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
|
+
i,
|
|
343
343
|
K(o, {
|
|
344
344
|
lendingState: c,
|
|
345
345
|
pools: u
|
|
@@ -348,9 +348,17 @@ async function D(r, 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 != null && d.flashloanFee))
|
|
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 = (O = t == null ? void 0 : t.amount) != null ? O : Number(l.supplyBalance), b = await this.walletClient.swap.getQuote(
|
|
354
362
|
s.suiCoinType,
|
|
355
363
|
n.suiCoinType,
|
|
356
364
|
f
|
|
@@ -360,62 +368,56 @@ async function D(r, 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(i, n, g), [A] = i.moveCall({
|
|
364
372
|
target: "0x2::coin::from_balance",
|
|
365
373
|
arguments: [B],
|
|
366
374
|
typeArguments: [n.suiCoinType]
|
|
367
375
|
});
|
|
368
|
-
await x(
|
|
376
|
+
await x(i, n, A, {
|
|
369
377
|
amount: g
|
|
370
378
|
});
|
|
371
|
-
const j = await Y(
|
|
372
|
-
l,
|
|
379
|
+
const j = await Y(i, s, f), U = await $(
|
|
373
380
|
r,
|
|
381
|
+
i,
|
|
374
382
|
C,
|
|
375
383
|
j,
|
|
376
384
|
b
|
|
377
|
-
), _ =
|
|
385
|
+
), _ = i.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(i, n, v, _), [N] = i.moveCall({
|
|
382
390
|
target: "0x2::coin::from_balance",
|
|
383
391
|
arguments: [W],
|
|
384
392
|
typeArguments: [n.suiCoinType]
|
|
385
393
|
});
|
|
386
|
-
return await x(
|
|
394
|
+
return await x(i, n, N), i;
|
|
387
395
|
}
|
|
388
|
-
async function J(
|
|
396
|
+
async function J(i, e, a, t) {
|
|
389
397
|
var F, 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),
|
|
394
|
-
if (!
|
|
401
|
+
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);
|
|
402
|
+
if (!r || r.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(r.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
|
+
i,
|
|
401
409
|
K(o, {
|
|
402
|
-
lendingState:
|
|
410
|
+
lendingState: l,
|
|
403
411
|
pools: u
|
|
404
412
|
})
|
|
405
413
|
);
|
|
406
|
-
let d = (F = t == null ? void 0 : t.amount) != null ? F : Number(
|
|
407
|
-
if (Number(
|
|
414
|
+
let d = (F = t == null ? void 0 : t.amount) != null ? F : Number(r.borrowBalance);
|
|
415
|
+
if (Number(r.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()
|
|
411
419
|
);
|
|
412
420
|
}
|
|
413
|
-
console.log("migrateBetweenBorrowPTB", {
|
|
414
|
-
formAmount: d,
|
|
415
|
-
options: t,
|
|
416
|
-
fromPoolLending: l,
|
|
417
|
-
isMax: Number(l.borrowBalance) === d
|
|
418
|
-
});
|
|
419
421
|
const h = await V(n, {
|
|
420
422
|
env: this.config.env
|
|
421
423
|
});
|
|
@@ -439,32 +441,32 @@ async function J(r, e, a, t) {
|
|
|
439
441
|
n.suiCoinType,
|
|
440
442
|
B
|
|
441
443
|
);
|
|
442
|
-
const [A, j] = await X(
|
|
444
|
+
const [A, j] = await X(i, n, d), [U] = i.moveCall({
|
|
443
445
|
target: "0x2::coin::from_balance",
|
|
444
446
|
arguments: [A],
|
|
445
447
|
typeArguments: [n.suiCoinType]
|
|
446
448
|
});
|
|
447
|
-
await ee(
|
|
449
|
+
await ee(i, n, U, {
|
|
448
450
|
amount: d
|
|
449
451
|
});
|
|
450
|
-
const _ = await te(
|
|
452
|
+
const _ = await te(i, c, B), W = await $(
|
|
451
453
|
s,
|
|
452
|
-
|
|
454
|
+
i,
|
|
453
455
|
b,
|
|
454
456
|
_,
|
|
455
457
|
v
|
|
456
|
-
), N =
|
|
458
|
+
), N = i.moveCall({
|
|
457
459
|
target: "0x2::coin::into_balance",
|
|
458
460
|
arguments: [W],
|
|
459
461
|
typeArguments: [n.suiCoinType]
|
|
460
|
-
}), [S] = await Z(
|
|
462
|
+
}), [S] = await Z(i, n, j, N), [O] = i.moveCall({
|
|
461
463
|
target: "0x2::coin::from_balance",
|
|
462
464
|
arguments: [S],
|
|
463
465
|
typeArguments: [n.suiCoinType]
|
|
464
466
|
});
|
|
465
|
-
return
|
|
467
|
+
return i.transferObjects([O], s), i;
|
|
466
468
|
}
|
|
467
|
-
async function z(
|
|
469
|
+
async function z(i, e, a, t) {
|
|
468
470
|
var o, u;
|
|
469
471
|
if (!this.walletClient)
|
|
470
472
|
throw new Error("Wallet client not found");
|
|
@@ -474,21 +476,21 @@ async function z(r, e, a, t) {
|
|
|
474
476
|
throw new Error(`No balance of ${e}`);
|
|
475
477
|
if (t != null && t.amount && n.amount.lt(t.amount))
|
|
476
478
|
throw new Error("Amount is less than balance");
|
|
477
|
-
const c = (o = t == null ? void 0 : t.amount) != null ? o : n.amount.toNumber(),
|
|
478
|
-
let
|
|
479
|
+
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 r = await y(i, n.coins, {
|
|
479
481
|
balance: c,
|
|
480
482
|
useGasCoin: !0
|
|
481
483
|
});
|
|
482
484
|
if (T(e) !== T(s.suiCoinType)) {
|
|
483
485
|
const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
|
|
484
|
-
|
|
485
|
-
|
|
486
|
+
r = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
487
|
+
i,
|
|
486
488
|
d,
|
|
487
|
-
|
|
488
|
-
|
|
489
|
+
r,
|
|
490
|
+
l
|
|
489
491
|
);
|
|
490
492
|
}
|
|
491
|
-
return await x(
|
|
493
|
+
return await x(i, s, r), i;
|
|
492
494
|
}
|
|
493
495
|
class ve extends R {
|
|
494
496
|
constructor() {
|
|
@@ -537,23 +539,23 @@ class ve extends R {
|
|
|
537
539
|
env: this.config.env
|
|
538
540
|
});
|
|
539
541
|
await this.walletClient.module("balance").waitForUpdate();
|
|
540
|
-
const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType),
|
|
542
|
+
const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = y(n, c.coins, {
|
|
541
543
|
balance: a,
|
|
542
544
|
useGasCoin: !0
|
|
543
545
|
});
|
|
544
|
-
await x(n, s,
|
|
546
|
+
await x(n, s, l, {
|
|
545
547
|
env: this.config.env,
|
|
546
548
|
amount: a,
|
|
547
549
|
accountCap: t == null ? void 0 : t.accountCap
|
|
548
550
|
});
|
|
549
|
-
const
|
|
551
|
+
const r = await this.walletClient.signExecuteTransaction({
|
|
550
552
|
transaction: n,
|
|
551
553
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
552
554
|
});
|
|
553
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
555
|
+
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", {
|
|
554
556
|
identifier: e,
|
|
555
557
|
amount: a
|
|
556
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
558
|
+
}), this.walletClient.module("balance").updatePortfolio()), r;
|
|
557
559
|
}
|
|
558
560
|
/**
|
|
559
561
|
* Withdraws coins from a lending pool
|
|
@@ -564,7 +566,7 @@ class ve extends R {
|
|
|
564
566
|
* @returns Transaction response or dry run response
|
|
565
567
|
*/
|
|
566
568
|
async withdraw(e, a, t) {
|
|
567
|
-
var
|
|
569
|
+
var r, o, u;
|
|
568
570
|
if (!this.walletClient)
|
|
569
571
|
throw new Error("Wallet client not found");
|
|
570
572
|
const s = await P(e, {
|
|
@@ -576,14 +578,14 @@ class ve extends R {
|
|
|
576
578
|
accountCap: t == null ? void 0 : t.accountCap
|
|
577
579
|
});
|
|
578
580
|
n.transferObjects([c], this.walletClient.address);
|
|
579
|
-
const
|
|
581
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
580
582
|
transaction: n,
|
|
581
|
-
dryRun: (
|
|
583
|
+
dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
|
|
582
584
|
});
|
|
583
|
-
return !(t != null && t.dryRun) && ((u = (o =
|
|
585
|
+
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", {
|
|
584
586
|
identifier: e,
|
|
585
587
|
amount: a
|
|
586
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
588
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
587
589
|
}
|
|
588
590
|
/**
|
|
589
591
|
* Borrows coins from a lending pool
|
|
@@ -594,7 +596,7 @@ class ve extends R {
|
|
|
594
596
|
* @returns Transaction response or dry run response
|
|
595
597
|
*/
|
|
596
598
|
async borrow(e, a, t) {
|
|
597
|
-
var
|
|
599
|
+
var r, o, u;
|
|
598
600
|
if (!this.walletClient)
|
|
599
601
|
throw new Error("Wallet client not found");
|
|
600
602
|
const s = await P(e, {
|
|
@@ -606,14 +608,14 @@ class ve extends R {
|
|
|
606
608
|
accountCap: t == null ? void 0 : t.accountCap
|
|
607
609
|
});
|
|
608
610
|
n.transferObjects([c], this.walletClient.address);
|
|
609
|
-
const
|
|
611
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
610
612
|
transaction: n,
|
|
611
|
-
dryRun: (
|
|
613
|
+
dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
|
|
612
614
|
});
|
|
613
|
-
return !(t != null && t.dryRun) && ((u = (o =
|
|
615
|
+
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", {
|
|
614
616
|
identifier: e,
|
|
615
617
|
amount: a
|
|
616
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
618
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
617
619
|
}
|
|
618
620
|
/**
|
|
619
621
|
* Repays borrowed coins to a lending pool
|
|
@@ -630,23 +632,23 @@ class ve extends R {
|
|
|
630
632
|
await this.walletClient.module("balance").waitForUpdate();
|
|
631
633
|
const s = await P(e, {
|
|
632
634
|
env: this.config.env
|
|
633
|
-
}), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType),
|
|
635
|
+
}), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = y(n, c.coins, {
|
|
634
636
|
balance: a,
|
|
635
637
|
useGasCoin: !0
|
|
636
638
|
});
|
|
637
|
-
await ee(n, s,
|
|
639
|
+
await ee(n, s, l, {
|
|
638
640
|
env: this.config.env,
|
|
639
641
|
amount: a,
|
|
640
642
|
accountCap: t == null ? void 0 : t.accountCap
|
|
641
643
|
});
|
|
642
|
-
const
|
|
644
|
+
const r = await this.walletClient.signExecuteTransaction({
|
|
643
645
|
transaction: n,
|
|
644
646
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
645
647
|
});
|
|
646
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
648
|
+
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", {
|
|
647
649
|
identifier: e,
|
|
648
650
|
amount: a
|
|
649
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
651
|
+
}), this.walletClient.module("balance").updatePortfolio()), r;
|
|
650
652
|
}
|
|
651
653
|
/**
|
|
652
654
|
* Gets the current health factor for the user
|
|
@@ -678,32 +680,32 @@ class ve extends R {
|
|
|
678
680
|
throw new Error("Wallet client not found");
|
|
679
681
|
const c = await P(e, {
|
|
680
682
|
env: this.config.env
|
|
681
|
-
}),
|
|
683
|
+
}), l = await P(t, {
|
|
682
684
|
env: this.config.env
|
|
683
|
-
}),
|
|
685
|
+
}), r = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = y(r, o.coins, {
|
|
684
686
|
balance: a,
|
|
685
687
|
useGasCoin: !0
|
|
686
688
|
}), [d, h] = await we(
|
|
687
|
-
|
|
689
|
+
r,
|
|
688
690
|
c,
|
|
689
691
|
u,
|
|
690
|
-
|
|
692
|
+
l,
|
|
691
693
|
s,
|
|
692
694
|
{
|
|
693
695
|
env: this.config.env
|
|
694
696
|
}
|
|
695
|
-
), [f] =
|
|
697
|
+
), [f] = r.moveCall({
|
|
696
698
|
target: "0x2::coin::from_balance",
|
|
697
699
|
arguments: [d],
|
|
698
|
-
typeArguments: [
|
|
699
|
-
}), [b] =
|
|
700
|
+
typeArguments: [l.suiCoinType]
|
|
701
|
+
}), [b] = r.moveCall({
|
|
700
702
|
target: "0x2::coin::from_balance",
|
|
701
703
|
arguments: [h],
|
|
702
704
|
typeArguments: [c.suiCoinType]
|
|
703
705
|
});
|
|
704
|
-
|
|
706
|
+
r.transferObjects([f, b], this.walletClient.address);
|
|
705
707
|
const m = await this.walletClient.signExecuteTransaction({
|
|
706
|
-
transaction:
|
|
708
|
+
transaction: r,
|
|
707
709
|
dryRun: (C = n == null ? void 0 : n.dryRun) != null ? C : !1
|
|
708
710
|
});
|
|
709
711
|
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", {
|
|
@@ -749,7 +751,7 @@ class ve extends R {
|
|
|
749
751
|
* @returns Transaction response or dry run response
|
|
750
752
|
*/
|
|
751
753
|
async claimAllRewards(e) {
|
|
752
|
-
var n, c,
|
|
754
|
+
var n, c, l;
|
|
753
755
|
if (!this.walletClient)
|
|
754
756
|
throw new Error("Wallet client not found");
|
|
755
757
|
const a = new w(), t = await H(this.walletClient.address, {
|
|
@@ -763,7 +765,7 @@ class ve extends R {
|
|
|
763
765
|
transaction: a,
|
|
764
766
|
dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
|
|
765
767
|
});
|
|
766
|
-
return !(e != null && e.dryRun) && ((
|
|
768
|
+
return !(e != null && e.dryRun) && ((l = (c = s.effects) == null ? void 0 : c.status) == null ? void 0 : l.status) === "success" && (this.emit("lending:claim-rewards-success", {
|
|
767
769
|
rewards: t
|
|
768
770
|
}), this.walletClient.module("balance").updatePortfolio()), s;
|
|
769
771
|
}
|
|
@@ -890,7 +892,7 @@ class pe extends R {
|
|
|
890
892
|
* @throws Error if wallet client not found or stake amount is too low
|
|
891
893
|
*/
|
|
892
894
|
async stake(e, a) {
|
|
893
|
-
var
|
|
895
|
+
var r, o, u;
|
|
894
896
|
if (!this.walletClient)
|
|
895
897
|
throw new Error("Wallet client not found");
|
|
896
898
|
if (e < 1e9)
|
|
@@ -902,13 +904,13 @@ class pe extends R {
|
|
|
902
904
|
useGasCoin: !0
|
|
903
905
|
}), c = await this.stakePTB(t, n);
|
|
904
906
|
t.transferObjects([c], this.walletClient.address);
|
|
905
|
-
const
|
|
907
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
906
908
|
transaction: t,
|
|
907
|
-
dryRun: (
|
|
909
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
908
910
|
});
|
|
909
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
911
|
+
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", {
|
|
910
912
|
suiAmount: e
|
|
911
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
913
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
912
914
|
}
|
|
913
915
|
/**
|
|
914
916
|
* Unstake vSUI tokens to receive SUI tokens
|
|
@@ -919,7 +921,7 @@ class pe extends R {
|
|
|
919
921
|
* @throws Error if wallet client not found or unstake amount is too low
|
|
920
922
|
*/
|
|
921
923
|
async unstake(e, a) {
|
|
922
|
-
var
|
|
924
|
+
var r, o, u;
|
|
923
925
|
if (!this.walletClient)
|
|
924
926
|
throw new Error("Wallet client not found");
|
|
925
927
|
if (e < 1e9)
|
|
@@ -929,13 +931,13 @@ class pe extends R {
|
|
|
929
931
|
balance: e
|
|
930
932
|
}), c = await this.unstakePTB(t, n);
|
|
931
933
|
t.transferObjects([c], this.walletClient.address);
|
|
932
|
-
const
|
|
934
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
933
935
|
transaction: t,
|
|
934
|
-
dryRun: (
|
|
936
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
935
937
|
});
|
|
936
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
938
|
+
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", {
|
|
937
939
|
vSuiAmount: e
|
|
938
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
940
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
939
941
|
}
|
|
940
942
|
}
|
|
941
943
|
class Ee extends R {
|
|
@@ -1025,13 +1027,13 @@ class Ee extends R {
|
|
|
1025
1027
|
if (!this.walletClient)
|
|
1026
1028
|
throw new Error("Wallet client not found");
|
|
1027
1029
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1028
|
-
const c = this.walletClient.module("balance").portfolio.getBalance(e),
|
|
1030
|
+
const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(), r = y(l, c.coins, {
|
|
1029
1031
|
balance: t,
|
|
1030
1032
|
useGasCoin: !0
|
|
1031
|
-
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(
|
|
1032
|
-
|
|
1033
|
+
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o, r, s);
|
|
1034
|
+
l.transferObjects([u], this.walletClient.address);
|
|
1033
1035
|
const d = await this.walletClient.signExecuteTransaction({
|
|
1034
|
-
transaction:
|
|
1036
|
+
transaction: l,
|
|
1035
1037
|
dryRun: (h = n == null ? void 0 : n.dryRun) != null ? h : !1
|
|
1036
1038
|
});
|
|
1037
1039
|
if (!(n != null && n.dryRun) && ((b = (f = d.effects) == null ? void 0 : f.status) == null ? void 0 : b.status) === "success") {
|
|
@@ -1103,7 +1105,7 @@ class Re extends R {
|
|
|
1103
1105
|
* @param options Optional dry run
|
|
1104
1106
|
*/
|
|
1105
1107
|
async stake(e, a) {
|
|
1106
|
-
var
|
|
1108
|
+
var r, o, u;
|
|
1107
1109
|
if (!this.walletClient)
|
|
1108
1110
|
throw new Error("Wallet client not found");
|
|
1109
1111
|
const t = new w();
|
|
@@ -1113,11 +1115,11 @@ class Re extends R {
|
|
|
1113
1115
|
useGasCoin: !0
|
|
1114
1116
|
}), c = await this.stakePTB(t, n);
|
|
1115
1117
|
t.transferObjects([c], this.walletClient.address);
|
|
1116
|
-
const
|
|
1118
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
1117
1119
|
transaction: t,
|
|
1118
|
-
dryRun: (
|
|
1120
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
1119
1121
|
});
|
|
1120
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
1122
|
+
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;
|
|
1121
1123
|
}
|
|
1122
1124
|
/**
|
|
1123
1125
|
* Unstake haSUI for SUI
|
|
@@ -1126,7 +1128,7 @@ class Re extends R {
|
|
|
1126
1128
|
* @param options Optional dry run
|
|
1127
1129
|
*/
|
|
1128
1130
|
async unstake(e, a) {
|
|
1129
|
-
var
|
|
1131
|
+
var r, o, u;
|
|
1130
1132
|
if (!this.walletClient)
|
|
1131
1133
|
throw new Error("Wallet client not found");
|
|
1132
1134
|
await this.walletClient.module("balance").waitForUpdate();
|
|
@@ -1134,11 +1136,11 @@ class Re extends R {
|
|
|
1134
1136
|
balance: e
|
|
1135
1137
|
}), c = await this.unstakePTB(t, n);
|
|
1136
1138
|
t.transferObjects([c], this.walletClient.address);
|
|
1137
|
-
const
|
|
1139
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
1138
1140
|
transaction: t,
|
|
1139
|
-
dryRun: (
|
|
1141
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
1140
1142
|
});
|
|
1141
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
1143
|
+
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;
|
|
1142
1144
|
}
|
|
1143
1145
|
}
|
|
1144
1146
|
const Se = {
|