@naviprotocol/wallet-client 1.0.2-dev.2 → 1.0.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.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +107 -113
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/lendingModule/migrate.d.ts.map +1 -1
- package/package.json +4 -4
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
|
|
@@ -350,7 +350,7 @@ async function D(r, e, a, t) {
|
|
|
350
350
|
});
|
|
351
351
|
if (!(d != null && d.flashloanFee))
|
|
352
352
|
throw new Error(`${s.token.symbol} pool not support flashloan`);
|
|
353
|
-
const h = (S = t == null ? void 0 : t.slippage) != null ? S : 5e-3, f = (O = t == null ? void 0 : t.amount) != null ? O : Number(
|
|
353
|
+
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
354
|
s.suiCoinType,
|
|
355
355
|
n.suiCoinType,
|
|
356
356
|
f
|
|
@@ -360,62 +360,56 @@ async function D(r, e, a, t) {
|
|
|
360
360
|
const C = Math.floor(m * (1 - h)), g = Math.floor(C / (1 + d.flashloanFee));
|
|
361
361
|
if (g <= 0)
|
|
362
362
|
throw new Error("The calculated borrow amount must be positive.");
|
|
363
|
-
const [B, v] = await X(
|
|
363
|
+
const [B, v] = await X(i, n, g), [A] = i.moveCall({
|
|
364
364
|
target: "0x2::coin::from_balance",
|
|
365
365
|
arguments: [B],
|
|
366
366
|
typeArguments: [n.suiCoinType]
|
|
367
367
|
});
|
|
368
|
-
await x(
|
|
368
|
+
await x(i, n, A, {
|
|
369
369
|
amount: g
|
|
370
370
|
});
|
|
371
|
-
const j = await Y(
|
|
372
|
-
l,
|
|
371
|
+
const j = await Y(i, s, f), U = await $(
|
|
373
372
|
r,
|
|
373
|
+
i,
|
|
374
374
|
C,
|
|
375
375
|
j,
|
|
376
376
|
b
|
|
377
|
-
), _ =
|
|
377
|
+
), _ = i.moveCall({
|
|
378
378
|
target: "0x2::coin::into_balance",
|
|
379
379
|
arguments: [U],
|
|
380
380
|
typeArguments: [n.suiCoinType]
|
|
381
|
-
}), [W] = await Z(
|
|
381
|
+
}), [W] = await Z(i, n, v, _), [N] = i.moveCall({
|
|
382
382
|
target: "0x2::coin::from_balance",
|
|
383
383
|
arguments: [W],
|
|
384
384
|
typeArguments: [n.suiCoinType]
|
|
385
385
|
});
|
|
386
|
-
return await x(
|
|
386
|
+
return await x(i, n, N), i;
|
|
387
387
|
}
|
|
388
|
-
async function J(
|
|
388
|
+
async function J(i, e, a, t) {
|
|
389
389
|
var F, G;
|
|
390
390
|
if (!this.walletClient)
|
|
391
391
|
throw new Error("Wallet client not found");
|
|
392
392
|
await this.walletClient.balance.waitForUpdate();
|
|
393
|
-
const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a),
|
|
394
|
-
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")
|
|
395
395
|
throw new Error("No borrow balance");
|
|
396
|
-
if (t != null && t.amount && t.amount > Number(
|
|
396
|
+
if (t != null && t.amount && t.amount > Number(r.borrowBalance))
|
|
397
397
|
throw new Error("Amount is less than borrow balance");
|
|
398
398
|
const o = await Q(), u = await Promise.all([n, c]);
|
|
399
399
|
await q(
|
|
400
|
-
|
|
400
|
+
i,
|
|
401
401
|
K(o, {
|
|
402
|
-
lendingState:
|
|
402
|
+
lendingState: l,
|
|
403
403
|
pools: u
|
|
404
404
|
})
|
|
405
405
|
);
|
|
406
|
-
let d = (F = t == null ? void 0 : t.amount) != null ? F : Number(
|
|
407
|
-
if (Number(
|
|
406
|
+
let d = (F = t == null ? void 0 : t.amount) != null ? F : Number(r.borrowBalance);
|
|
407
|
+
if (Number(r.borrowBalance) === d) {
|
|
408
408
|
const I = parseFloat(Te(n.currentBorrowRate, 8)) / 100;
|
|
409
409
|
d = Math.ceil(
|
|
410
410
|
new p(d).multipliedBy(I * (60 * 3) / (365 * 24 * 3600)).plus(new p(1).shiftedBy(-n.token.decimals)).plus(d).toNumber()
|
|
411
411
|
);
|
|
412
412
|
}
|
|
413
|
-
console.log("migrateBetweenBorrowPTB", {
|
|
414
|
-
formAmount: d,
|
|
415
|
-
options: t,
|
|
416
|
-
fromPoolLending: l,
|
|
417
|
-
isMax: Number(l.borrowBalance) === d
|
|
418
|
-
});
|
|
419
413
|
const h = await V(n, {
|
|
420
414
|
env: this.config.env
|
|
421
415
|
});
|
|
@@ -439,32 +433,32 @@ async function J(r, e, a, t) {
|
|
|
439
433
|
n.suiCoinType,
|
|
440
434
|
B
|
|
441
435
|
);
|
|
442
|
-
const [A, j] = await X(
|
|
436
|
+
const [A, j] = await X(i, n, d), [U] = i.moveCall({
|
|
443
437
|
target: "0x2::coin::from_balance",
|
|
444
438
|
arguments: [A],
|
|
445
439
|
typeArguments: [n.suiCoinType]
|
|
446
440
|
});
|
|
447
|
-
await ee(
|
|
441
|
+
await ee(i, n, U, {
|
|
448
442
|
amount: d
|
|
449
443
|
});
|
|
450
|
-
const _ = await te(
|
|
444
|
+
const _ = await te(i, c, B), W = await $(
|
|
451
445
|
s,
|
|
452
|
-
|
|
446
|
+
i,
|
|
453
447
|
b,
|
|
454
448
|
_,
|
|
455
449
|
v
|
|
456
|
-
), N =
|
|
450
|
+
), N = i.moveCall({
|
|
457
451
|
target: "0x2::coin::into_balance",
|
|
458
452
|
arguments: [W],
|
|
459
453
|
typeArguments: [n.suiCoinType]
|
|
460
|
-
}), [S] = await Z(
|
|
454
|
+
}), [S] = await Z(i, n, j, N), [O] = i.moveCall({
|
|
461
455
|
target: "0x2::coin::from_balance",
|
|
462
456
|
arguments: [S],
|
|
463
457
|
typeArguments: [n.suiCoinType]
|
|
464
458
|
});
|
|
465
|
-
return
|
|
459
|
+
return i.transferObjects([O], s), i;
|
|
466
460
|
}
|
|
467
|
-
async function z(
|
|
461
|
+
async function z(i, e, a, t) {
|
|
468
462
|
var o, u;
|
|
469
463
|
if (!this.walletClient)
|
|
470
464
|
throw new Error("Wallet client not found");
|
|
@@ -474,21 +468,21 @@ async function z(r, e, a, t) {
|
|
|
474
468
|
throw new Error(`No balance of ${e}`);
|
|
475
469
|
if (t != null && t.amount && n.amount.lt(t.amount))
|
|
476
470
|
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
|
|
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;
|
|
472
|
+
let r = await y(i, n.coins, {
|
|
479
473
|
balance: c,
|
|
480
474
|
useGasCoin: !0
|
|
481
475
|
});
|
|
482
476
|
if (T(e) !== T(s.suiCoinType)) {
|
|
483
477
|
const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
|
|
484
|
-
|
|
485
|
-
|
|
478
|
+
r = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
479
|
+
i,
|
|
486
480
|
d,
|
|
487
|
-
|
|
488
|
-
|
|
481
|
+
r,
|
|
482
|
+
l
|
|
489
483
|
);
|
|
490
484
|
}
|
|
491
|
-
return await x(
|
|
485
|
+
return await x(i, s, r), i;
|
|
492
486
|
}
|
|
493
487
|
class ve extends R {
|
|
494
488
|
constructor() {
|
|
@@ -537,23 +531,23 @@ class ve extends R {
|
|
|
537
531
|
env: this.config.env
|
|
538
532
|
});
|
|
539
533
|
await this.walletClient.module("balance").waitForUpdate();
|
|
540
|
-
const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType),
|
|
534
|
+
const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = y(n, c.coins, {
|
|
541
535
|
balance: a,
|
|
542
536
|
useGasCoin: !0
|
|
543
537
|
});
|
|
544
|
-
await x(n, s,
|
|
538
|
+
await x(n, s, l, {
|
|
545
539
|
env: this.config.env,
|
|
546
540
|
amount: a,
|
|
547
541
|
accountCap: t == null ? void 0 : t.accountCap
|
|
548
542
|
});
|
|
549
|
-
const
|
|
543
|
+
const r = await this.walletClient.signExecuteTransaction({
|
|
550
544
|
transaction: n,
|
|
551
545
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
552
546
|
});
|
|
553
|
-
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", {
|
|
554
548
|
identifier: e,
|
|
555
549
|
amount: a
|
|
556
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
550
|
+
}), this.walletClient.module("balance").updatePortfolio()), r;
|
|
557
551
|
}
|
|
558
552
|
/**
|
|
559
553
|
* Withdraws coins from a lending pool
|
|
@@ -564,7 +558,7 @@ class ve extends R {
|
|
|
564
558
|
* @returns Transaction response or dry run response
|
|
565
559
|
*/
|
|
566
560
|
async withdraw(e, a, t) {
|
|
567
|
-
var
|
|
561
|
+
var r, o, u;
|
|
568
562
|
if (!this.walletClient)
|
|
569
563
|
throw new Error("Wallet client not found");
|
|
570
564
|
const s = await P(e, {
|
|
@@ -576,14 +570,14 @@ class ve extends R {
|
|
|
576
570
|
accountCap: t == null ? void 0 : t.accountCap
|
|
577
571
|
});
|
|
578
572
|
n.transferObjects([c], this.walletClient.address);
|
|
579
|
-
const
|
|
573
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
580
574
|
transaction: n,
|
|
581
|
-
dryRun: (
|
|
575
|
+
dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
|
|
582
576
|
});
|
|
583
|
-
return !(t != null && t.dryRun) && ((u = (o =
|
|
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", {
|
|
584
578
|
identifier: e,
|
|
585
579
|
amount: a
|
|
586
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
580
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
587
581
|
}
|
|
588
582
|
/**
|
|
589
583
|
* Borrows coins from a lending pool
|
|
@@ -594,7 +588,7 @@ class ve extends R {
|
|
|
594
588
|
* @returns Transaction response or dry run response
|
|
595
589
|
*/
|
|
596
590
|
async borrow(e, a, t) {
|
|
597
|
-
var
|
|
591
|
+
var r, o, u;
|
|
598
592
|
if (!this.walletClient)
|
|
599
593
|
throw new Error("Wallet client not found");
|
|
600
594
|
const s = await P(e, {
|
|
@@ -606,14 +600,14 @@ class ve extends R {
|
|
|
606
600
|
accountCap: t == null ? void 0 : t.accountCap
|
|
607
601
|
});
|
|
608
602
|
n.transferObjects([c], this.walletClient.address);
|
|
609
|
-
const
|
|
603
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
610
604
|
transaction: n,
|
|
611
|
-
dryRun: (
|
|
605
|
+
dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
|
|
612
606
|
});
|
|
613
|
-
return !(t != null && t.dryRun) && ((u = (o =
|
|
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", {
|
|
614
608
|
identifier: e,
|
|
615
609
|
amount: a
|
|
616
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
610
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
617
611
|
}
|
|
618
612
|
/**
|
|
619
613
|
* Repays borrowed coins to a lending pool
|
|
@@ -630,23 +624,23 @@ class ve extends R {
|
|
|
630
624
|
await this.walletClient.module("balance").waitForUpdate();
|
|
631
625
|
const s = await P(e, {
|
|
632
626
|
env: this.config.env
|
|
633
|
-
}), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType),
|
|
627
|
+
}), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), l = y(n, c.coins, {
|
|
634
628
|
balance: a,
|
|
635
629
|
useGasCoin: !0
|
|
636
630
|
});
|
|
637
|
-
await ee(n, s,
|
|
631
|
+
await ee(n, s, l, {
|
|
638
632
|
env: this.config.env,
|
|
639
633
|
amount: a,
|
|
640
634
|
accountCap: t == null ? void 0 : t.accountCap
|
|
641
635
|
});
|
|
642
|
-
const
|
|
636
|
+
const r = await this.walletClient.signExecuteTransaction({
|
|
643
637
|
transaction: n,
|
|
644
638
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
645
639
|
});
|
|
646
|
-
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", {
|
|
647
641
|
identifier: e,
|
|
648
642
|
amount: a
|
|
649
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
643
|
+
}), this.walletClient.module("balance").updatePortfolio()), r;
|
|
650
644
|
}
|
|
651
645
|
/**
|
|
652
646
|
* Gets the current health factor for the user
|
|
@@ -678,32 +672,32 @@ class ve extends R {
|
|
|
678
672
|
throw new Error("Wallet client not found");
|
|
679
673
|
const c = await P(e, {
|
|
680
674
|
env: this.config.env
|
|
681
|
-
}),
|
|
675
|
+
}), l = await P(t, {
|
|
682
676
|
env: this.config.env
|
|
683
|
-
}),
|
|
677
|
+
}), r = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = y(r, o.coins, {
|
|
684
678
|
balance: a,
|
|
685
679
|
useGasCoin: !0
|
|
686
680
|
}), [d, h] = await we(
|
|
687
|
-
|
|
681
|
+
r,
|
|
688
682
|
c,
|
|
689
683
|
u,
|
|
690
|
-
|
|
684
|
+
l,
|
|
691
685
|
s,
|
|
692
686
|
{
|
|
693
687
|
env: this.config.env
|
|
694
688
|
}
|
|
695
|
-
), [f] =
|
|
689
|
+
), [f] = r.moveCall({
|
|
696
690
|
target: "0x2::coin::from_balance",
|
|
697
691
|
arguments: [d],
|
|
698
|
-
typeArguments: [
|
|
699
|
-
}), [b] =
|
|
692
|
+
typeArguments: [l.suiCoinType]
|
|
693
|
+
}), [b] = r.moveCall({
|
|
700
694
|
target: "0x2::coin::from_balance",
|
|
701
695
|
arguments: [h],
|
|
702
696
|
typeArguments: [c.suiCoinType]
|
|
703
697
|
});
|
|
704
|
-
|
|
698
|
+
r.transferObjects([f, b], this.walletClient.address);
|
|
705
699
|
const m = await this.walletClient.signExecuteTransaction({
|
|
706
|
-
transaction:
|
|
700
|
+
transaction: r,
|
|
707
701
|
dryRun: (C = n == null ? void 0 : n.dryRun) != null ? C : !1
|
|
708
702
|
});
|
|
709
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", {
|
|
@@ -749,7 +743,7 @@ class ve extends R {
|
|
|
749
743
|
* @returns Transaction response or dry run response
|
|
750
744
|
*/
|
|
751
745
|
async claimAllRewards(e) {
|
|
752
|
-
var n, c,
|
|
746
|
+
var n, c, l;
|
|
753
747
|
if (!this.walletClient)
|
|
754
748
|
throw new Error("Wallet client not found");
|
|
755
749
|
const a = new w(), t = await H(this.walletClient.address, {
|
|
@@ -763,7 +757,7 @@ class ve extends R {
|
|
|
763
757
|
transaction: a,
|
|
764
758
|
dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
|
|
765
759
|
});
|
|
766
|
-
return !(e != null && e.dryRun) && ((
|
|
760
|
+
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
761
|
rewards: t
|
|
768
762
|
}), this.walletClient.module("balance").updatePortfolio()), s;
|
|
769
763
|
}
|
|
@@ -890,7 +884,7 @@ class pe extends R {
|
|
|
890
884
|
* @throws Error if wallet client not found or stake amount is too low
|
|
891
885
|
*/
|
|
892
886
|
async stake(e, a) {
|
|
893
|
-
var
|
|
887
|
+
var r, o, u;
|
|
894
888
|
if (!this.walletClient)
|
|
895
889
|
throw new Error("Wallet client not found");
|
|
896
890
|
if (e < 1e9)
|
|
@@ -902,13 +896,13 @@ class pe extends R {
|
|
|
902
896
|
useGasCoin: !0
|
|
903
897
|
}), c = await this.stakePTB(t, n);
|
|
904
898
|
t.transferObjects([c], this.walletClient.address);
|
|
905
|
-
const
|
|
899
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
906
900
|
transaction: t,
|
|
907
|
-
dryRun: (
|
|
901
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
908
902
|
});
|
|
909
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
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", {
|
|
910
904
|
suiAmount: e
|
|
911
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
905
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
912
906
|
}
|
|
913
907
|
/**
|
|
914
908
|
* Unstake vSUI tokens to receive SUI tokens
|
|
@@ -919,7 +913,7 @@ class pe extends R {
|
|
|
919
913
|
* @throws Error if wallet client not found or unstake amount is too low
|
|
920
914
|
*/
|
|
921
915
|
async unstake(e, a) {
|
|
922
|
-
var
|
|
916
|
+
var r, o, u;
|
|
923
917
|
if (!this.walletClient)
|
|
924
918
|
throw new Error("Wallet client not found");
|
|
925
919
|
if (e < 1e9)
|
|
@@ -929,13 +923,13 @@ class pe extends R {
|
|
|
929
923
|
balance: e
|
|
930
924
|
}), c = await this.unstakePTB(t, n);
|
|
931
925
|
t.transferObjects([c], this.walletClient.address);
|
|
932
|
-
const
|
|
926
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
933
927
|
transaction: t,
|
|
934
|
-
dryRun: (
|
|
928
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
935
929
|
});
|
|
936
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
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", {
|
|
937
931
|
vSuiAmount: e
|
|
938
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
932
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
939
933
|
}
|
|
940
934
|
}
|
|
941
935
|
class Ee extends R {
|
|
@@ -1025,13 +1019,13 @@ class Ee extends R {
|
|
|
1025
1019
|
if (!this.walletClient)
|
|
1026
1020
|
throw new Error("Wallet client not found");
|
|
1027
1021
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1028
|
-
const c = this.walletClient.module("balance").portfolio.getBalance(e),
|
|
1022
|
+
const c = this.walletClient.module("balance").portfolio.getBalance(e), l = new w(), r = y(l, c.coins, {
|
|
1029
1023
|
balance: t,
|
|
1030
1024
|
useGasCoin: !0
|
|
1031
|
-
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(
|
|
1032
|
-
|
|
1025
|
+
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(l, o, r, s);
|
|
1026
|
+
l.transferObjects([u], this.walletClient.address);
|
|
1033
1027
|
const d = await this.walletClient.signExecuteTransaction({
|
|
1034
|
-
transaction:
|
|
1028
|
+
transaction: l,
|
|
1035
1029
|
dryRun: (h = n == null ? void 0 : n.dryRun) != null ? h : !1
|
|
1036
1030
|
});
|
|
1037
1031
|
if (!(n != null && n.dryRun) && ((b = (f = d.effects) == null ? void 0 : f.status) == null ? void 0 : b.status) === "success") {
|
|
@@ -1103,7 +1097,7 @@ class Re extends R {
|
|
|
1103
1097
|
* @param options Optional dry run
|
|
1104
1098
|
*/
|
|
1105
1099
|
async stake(e, a) {
|
|
1106
|
-
var
|
|
1100
|
+
var r, o, u;
|
|
1107
1101
|
if (!this.walletClient)
|
|
1108
1102
|
throw new Error("Wallet client not found");
|
|
1109
1103
|
const t = new w();
|
|
@@ -1113,11 +1107,11 @@ class Re extends R {
|
|
|
1113
1107
|
useGasCoin: !0
|
|
1114
1108
|
}), c = await this.stakePTB(t, n);
|
|
1115
1109
|
t.transferObjects([c], this.walletClient.address);
|
|
1116
|
-
const
|
|
1110
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
1117
1111
|
transaction: t,
|
|
1118
|
-
dryRun: (
|
|
1112
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
1119
1113
|
});
|
|
1120
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
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;
|
|
1121
1115
|
}
|
|
1122
1116
|
/**
|
|
1123
1117
|
* Unstake haSUI for SUI
|
|
@@ -1126,7 +1120,7 @@ class Re extends R {
|
|
|
1126
1120
|
* @param options Optional dry run
|
|
1127
1121
|
*/
|
|
1128
1122
|
async unstake(e, a) {
|
|
1129
|
-
var
|
|
1123
|
+
var r, o, u;
|
|
1130
1124
|
if (!this.walletClient)
|
|
1131
1125
|
throw new Error("Wallet client not found");
|
|
1132
1126
|
await this.walletClient.module("balance").waitForUpdate();
|
|
@@ -1134,11 +1128,11 @@ class Re extends R {
|
|
|
1134
1128
|
balance: e
|
|
1135
1129
|
}), c = await this.unstakePTB(t, n);
|
|
1136
1130
|
t.transferObjects([c], this.walletClient.address);
|
|
1137
|
-
const
|
|
1131
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
1138
1132
|
transaction: t,
|
|
1139
|
-
dryRun: (
|
|
1133
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
1140
1134
|
});
|
|
1141
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
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;
|
|
1142
1136
|
}
|
|
1143
1137
|
}
|
|
1144
1138
|
const Se = {
|