@naviprotocol/wallet-client 1.0.1-dev.0 → 1.0.1-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/LICENSE +21 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +88 -86
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/lendingModule/migrate.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getFullnodeUrl as ee, SuiClient as te } from "@mysten/sui/client";
|
|
2
2
|
import ae from "mitt";
|
|
3
3
|
import ne from "axios";
|
|
4
|
-
import { withSingleton as I, getCoins as se, mergeCoinsPTB as y, getFlashLoanAsset as G, flashloanPTB as H, depositCoinPTB as x, withdrawCoinPTB as D, repayFlashLoanPTB as J, repayCoinPTB as z, borrowCoinPTB as V, getPools as le, getPool as B, getHealthFactor as
|
|
4
|
+
import { withSingleton as I, getCoins as se, mergeCoinsPTB as y, getFlashLoanAsset as G, flashloanPTB as H, depositCoinPTB as x, withdrawCoinPTB as D, repayFlashLoanPTB as J, repayCoinPTB as z, borrowCoinPTB as V, getPools as le, getPool as B, getHealthFactor as ie, liquidatePTB as re, getUserAvailableLendingRewards as Q, getUserClaimedRewardHistory as ce, claimLendingRewardsPTB as oe, getPriceFeeds as ue, filterPriceFeeds as de, updateOraclePricesPTB as he, getLendingState as we, createAccountCapPTB as fe, withCache as X, parseTxValue as F } from "@naviprotocol/lending";
|
|
5
5
|
import P, { BigNumber as N } from "bignumber.js";
|
|
6
6
|
import { normalizeStructTag as T } from "@mysten/sui/utils";
|
|
7
7
|
import { Transaction as h } from "@mysten/sui/transactions";
|
|
@@ -11,15 +11,15 @@ const Z = ne.create({
|
|
|
11
11
|
timeout: 2e4
|
|
12
12
|
});
|
|
13
13
|
Z.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 Ce {
|
|
@@ -237,16 +237,16 @@ class be extends E {
|
|
|
237
237
|
const n = this.portfolio.getBalance(e), o = t.reduce((f, w) => f.plus(w), P(0));
|
|
238
238
|
if (n.amount.lt(o))
|
|
239
239
|
throw new Error("Insufficient balance");
|
|
240
|
-
const
|
|
241
|
-
let l =
|
|
242
|
-
T(e) !== T("0x2::sui::SUI") && (l = y(
|
|
240
|
+
const i = new h();
|
|
241
|
+
let l = i.gas;
|
|
242
|
+
T(e) !== T("0x2::sui::SUI") && (l = y(i, n.coins, {
|
|
243
243
|
balance: o.toNumber()
|
|
244
244
|
}));
|
|
245
|
-
const c =
|
|
245
|
+
const c = i.splitCoins(l, t);
|
|
246
246
|
return a.forEach((f, w) => {
|
|
247
|
-
|
|
247
|
+
i.transferObjects([c[w]], f);
|
|
248
248
|
}), await this.walletClient.signExecuteTransaction({
|
|
249
|
-
transaction:
|
|
249
|
+
transaction: i,
|
|
250
250
|
dryRun: (d = s == null ? void 0 : s.dryRun) != null ? d : !1
|
|
251
251
|
});
|
|
252
252
|
}
|
|
@@ -280,8 +280,8 @@ class be extends E {
|
|
|
280
280
|
throw new Error("Objects and recipients must have the same length");
|
|
281
281
|
await this.waitForUpdate();
|
|
282
282
|
const s = new h();
|
|
283
|
-
return e.forEach((
|
|
284
|
-
s.transferObjects([s.object(
|
|
283
|
+
return e.forEach((i, l) => {
|
|
284
|
+
s.transferObjects([s.object(i)], a[l]);
|
|
285
285
|
}), await this.walletClient.signExecuteTransaction({
|
|
286
286
|
transaction: s,
|
|
287
287
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
@@ -324,24 +324,25 @@ class be extends E {
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
const ye = 27;
|
|
327
|
-
function Be(
|
|
328
|
-
return
|
|
327
|
+
function Be(r, e = 2) {
|
|
328
|
+
return r ? new P(r.toString()).shiftedBy(-1 * ye).multipliedBy(100).decimalPlaces(e, P.ROUND_DOWN).toFixed(e) : "0.00";
|
|
329
329
|
}
|
|
330
|
-
async function q(
|
|
330
|
+
async function q(r, e, a, t) {
|
|
331
331
|
var R, S;
|
|
332
332
|
if (!this.walletClient)
|
|
333
333
|
throw new Error("Wallet client not found");
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
await this.walletClient.balance.waitForUpdate();
|
|
335
|
+
const s = await this.getPool(e), n = await this.getPool(a), i = (await this.getLendingState()).find((O) => O.pool.id === s.id), l = this.walletClient.address;
|
|
336
|
+
if (!i || i.supplyBalance === "0")
|
|
336
337
|
throw new Error("No supply balance");
|
|
337
|
-
if (t != null && t.amount && t.amount < Number(
|
|
338
|
+
if (t != null && t.amount && t.amount < Number(i.supplyBalance))
|
|
338
339
|
throw new Error("Amount is less than supply balance");
|
|
339
340
|
const c = await G(n, {
|
|
340
341
|
env: this.config.env
|
|
341
342
|
});
|
|
342
343
|
if (!(c != null && c.flashloanFee))
|
|
343
344
|
throw new Error(`${s.token.symbol} pool not support flashloan`);
|
|
344
|
-
const u = (R = t == null ? void 0 : t.slippage) != null ? R : 5e-3, d = (S = t == null ? void 0 : t.amount) != null ? S : Number(
|
|
345
|
+
const u = (R = t == null ? void 0 : t.slippage) != null ? R : 5e-3, d = (S = t == null ? void 0 : t.amount) != null ? S : Number(i.supplyBalance), f = await this.walletClient.swap.getQuote(
|
|
345
346
|
s.suiCoinType,
|
|
346
347
|
n.suiCoinType,
|
|
347
348
|
d
|
|
@@ -351,35 +352,36 @@ async function q(i, e, a, t) {
|
|
|
351
352
|
const b = Math.floor(w * (1 - u)), g = Math.floor(b / (1 + c.flashloanFee));
|
|
352
353
|
if (g <= 0)
|
|
353
354
|
throw new Error("The calculated borrow amount must be positive.");
|
|
354
|
-
const [m, C] = await H(
|
|
355
|
+
const [m, C] = await H(r, n, g), [v] = r.moveCall({
|
|
355
356
|
target: "0x2::coin::from_balance",
|
|
356
357
|
arguments: [m],
|
|
357
358
|
typeArguments: [n.suiCoinType]
|
|
358
359
|
});
|
|
359
|
-
await x(
|
|
360
|
+
await x(r, n, v, {
|
|
360
361
|
amount: g
|
|
361
362
|
});
|
|
362
|
-
const
|
|
363
|
+
const k = await D(r, s, d), A = await M(
|
|
363
364
|
l,
|
|
364
|
-
|
|
365
|
+
r,
|
|
365
366
|
b,
|
|
366
|
-
|
|
367
|
+
k,
|
|
367
368
|
f
|
|
368
|
-
),
|
|
369
|
+
), j = r.moveCall({
|
|
369
370
|
target: "0x2::coin::into_balance",
|
|
370
|
-
arguments: [
|
|
371
|
+
arguments: [A],
|
|
371
372
|
typeArguments: [n.suiCoinType]
|
|
372
|
-
}), [
|
|
373
|
+
}), [U] = await J(r, n, C, j), [_] = r.moveCall({
|
|
373
374
|
target: "0x2::coin::from_balance",
|
|
374
|
-
arguments: [
|
|
375
|
+
arguments: [U],
|
|
375
376
|
typeArguments: [n.suiCoinType]
|
|
376
377
|
});
|
|
377
|
-
return await x(
|
|
378
|
+
return await x(r, n, _), r;
|
|
378
379
|
}
|
|
379
|
-
async function K(
|
|
380
|
+
async function K(r, e, a, t) {
|
|
380
381
|
var O, L;
|
|
381
382
|
if (!this.walletClient)
|
|
382
383
|
throw new Error("Wallet client not found");
|
|
384
|
+
await this.walletClient.balance.waitForUpdate();
|
|
383
385
|
const s = this.walletClient.address, n = await this.getPool(e), o = await this.getPool(a), l = (await this.getLendingState()).find((W) => W.pool.id === n.id);
|
|
384
386
|
if (!l || l.borrowBalance === "0")
|
|
385
387
|
throw new Error("No borrow balance");
|
|
@@ -415,56 +417,56 @@ async function K(i, e, a, t) {
|
|
|
415
417
|
n.suiCoinType,
|
|
416
418
|
m
|
|
417
419
|
);
|
|
418
|
-
const [v,
|
|
420
|
+
const [v, k] = await H(r, n, c), [A] = r.moveCall({
|
|
419
421
|
target: "0x2::coin::from_balance",
|
|
420
422
|
arguments: [v],
|
|
421
423
|
typeArguments: [n.suiCoinType]
|
|
422
424
|
});
|
|
423
|
-
await z(
|
|
425
|
+
await z(r, n, A, {
|
|
424
426
|
amount: c
|
|
425
427
|
});
|
|
426
|
-
const
|
|
428
|
+
const j = await V(r, o, m), U = await M(
|
|
427
429
|
s,
|
|
428
|
-
|
|
430
|
+
r,
|
|
429
431
|
f,
|
|
430
|
-
|
|
432
|
+
j,
|
|
431
433
|
C
|
|
432
|
-
),
|
|
434
|
+
), _ = r.moveCall({
|
|
433
435
|
target: "0x2::coin::into_balance",
|
|
434
|
-
arguments: [
|
|
436
|
+
arguments: [U],
|
|
435
437
|
typeArguments: [n.suiCoinType]
|
|
436
|
-
}), [R] = await J(
|
|
438
|
+
}), [R] = await J(r, n, k, _), [S] = r.moveCall({
|
|
437
439
|
target: "0x2::coin::from_balance",
|
|
438
440
|
arguments: [R],
|
|
439
441
|
typeArguments: [n.suiCoinType]
|
|
440
442
|
});
|
|
441
|
-
return
|
|
443
|
+
return r.transferObjects([S], s), r;
|
|
442
444
|
}
|
|
443
|
-
async function $(
|
|
445
|
+
async function $(r, e, a, t) {
|
|
444
446
|
var c, u;
|
|
445
447
|
if (!this.walletClient)
|
|
446
448
|
throw new Error("Wallet client not found");
|
|
447
|
-
this.walletClient.address;
|
|
449
|
+
await this.walletClient.balance.waitForUpdate(), this.walletClient.address;
|
|
448
450
|
const s = await this.getPool(a), n = this.walletClient.balance.portfolio.getBalance(e);
|
|
449
451
|
if (n.amount.eq(0))
|
|
450
452
|
throw new Error(`No balance of ${e}`);
|
|
451
453
|
if (t != null && t.amount && n.amount.lt(t.amount))
|
|
452
454
|
throw new Error("Amount is less than balance");
|
|
453
|
-
const o = (c = t == null ? void 0 : t.amount) != null ? c : n.amount.toNumber(),
|
|
454
|
-
let l = await y(
|
|
455
|
+
const o = (c = t == null ? void 0 : t.amount) != null ? c : n.amount.toNumber(), i = (u = t == null ? void 0 : t.slippage) != null ? u : 5e-3;
|
|
456
|
+
let l = await y(r, n.coins, {
|
|
455
457
|
balance: o,
|
|
456
458
|
useGasCoin: !0
|
|
457
459
|
});
|
|
458
460
|
if (T(e) !== T(s.suiCoinType)) {
|
|
459
461
|
const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, o);
|
|
460
462
|
l = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
461
|
-
|
|
463
|
+
r,
|
|
462
464
|
d,
|
|
463
465
|
l,
|
|
464
|
-
|
|
466
|
+
i
|
|
465
467
|
);
|
|
466
468
|
}
|
|
467
|
-
return await x(
|
|
469
|
+
return await x(r, s, l), r;
|
|
468
470
|
}
|
|
469
471
|
class Te extends E {
|
|
470
472
|
constructor() {
|
|
@@ -513,11 +515,11 @@ class Te extends E {
|
|
|
513
515
|
env: this.config.env
|
|
514
516
|
});
|
|
515
517
|
await this.walletClient.module("balance").waitForUpdate();
|
|
516
|
-
const n = new h(), o = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType),
|
|
518
|
+
const n = new h(), o = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = y(n, o.coins, {
|
|
517
519
|
balance: a,
|
|
518
520
|
useGasCoin: !0
|
|
519
521
|
});
|
|
520
|
-
await x(n, s,
|
|
522
|
+
await x(n, s, i, {
|
|
521
523
|
env: this.config.env,
|
|
522
524
|
amount: a,
|
|
523
525
|
accountCap: t == null ? void 0 : t.accountCap
|
|
@@ -552,14 +554,14 @@ class Te extends E {
|
|
|
552
554
|
accountCap: t == null ? void 0 : t.accountCap
|
|
553
555
|
});
|
|
554
556
|
n.transferObjects([o], this.walletClient.address);
|
|
555
|
-
const
|
|
557
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
556
558
|
transaction: n,
|
|
557
559
|
dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
|
|
558
560
|
});
|
|
559
|
-
return !(t != null && t.dryRun) && ((u = (c =
|
|
561
|
+
return !(t != null && t.dryRun) && ((u = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:withdraw-success", {
|
|
560
562
|
identifier: e,
|
|
561
563
|
amount: a
|
|
562
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
564
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
563
565
|
}
|
|
564
566
|
/**
|
|
565
567
|
* Borrows coins from a lending pool
|
|
@@ -582,14 +584,14 @@ class Te extends E {
|
|
|
582
584
|
accountCap: t == null ? void 0 : t.accountCap
|
|
583
585
|
});
|
|
584
586
|
n.transferObjects([o], this.walletClient.address);
|
|
585
|
-
const
|
|
587
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
586
588
|
transaction: n,
|
|
587
589
|
dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
|
|
588
590
|
});
|
|
589
|
-
return !(t != null && t.dryRun) && ((u = (c =
|
|
591
|
+
return !(t != null && t.dryRun) && ((u = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:borrow-success", {
|
|
590
592
|
identifier: e,
|
|
591
593
|
amount: a
|
|
592
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
594
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
593
595
|
}
|
|
594
596
|
/**
|
|
595
597
|
* Repays borrowed coins to a lending pool
|
|
@@ -606,11 +608,11 @@ class Te extends E {
|
|
|
606
608
|
await this.walletClient.module("balance").waitForUpdate();
|
|
607
609
|
const s = await B(e, {
|
|
608
610
|
env: this.config.env
|
|
609
|
-
}), n = new h(), o = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType),
|
|
611
|
+
}), n = new h(), o = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = y(n, o.coins, {
|
|
610
612
|
balance: a,
|
|
611
613
|
useGasCoin: !0
|
|
612
614
|
});
|
|
613
|
-
await z(n, s,
|
|
615
|
+
await z(n, s, i, {
|
|
614
616
|
env: this.config.env,
|
|
615
617
|
amount: a,
|
|
616
618
|
accountCap: t == null ? void 0 : t.accountCap
|
|
@@ -633,7 +635,7 @@ class Te extends E {
|
|
|
633
635
|
if (!this.walletClient)
|
|
634
636
|
throw new Error("Wallet client not found");
|
|
635
637
|
const e = this.walletClient.address;
|
|
636
|
-
return await
|
|
638
|
+
return await ie(e, {
|
|
637
639
|
env: this.config.env,
|
|
638
640
|
client: this.walletClient.client
|
|
639
641
|
});
|
|
@@ -654,16 +656,16 @@ class Te extends E {
|
|
|
654
656
|
throw new Error("Wallet client not found");
|
|
655
657
|
const o = await B(e, {
|
|
656
658
|
env: this.config.env
|
|
657
|
-
}),
|
|
659
|
+
}), i = await B(t, {
|
|
658
660
|
env: this.config.env
|
|
659
661
|
}), l = new h(), c = this.walletClient.module("balance").portfolio.getBalance(o.suiCoinType), u = y(l, c.coins, {
|
|
660
662
|
balance: a,
|
|
661
663
|
useGasCoin: !0
|
|
662
|
-
}), [d, f] = await
|
|
664
|
+
}), [d, f] = await re(
|
|
663
665
|
l,
|
|
664
666
|
o,
|
|
665
667
|
u,
|
|
666
|
-
|
|
668
|
+
i,
|
|
667
669
|
s,
|
|
668
670
|
{
|
|
669
671
|
env: this.config.env
|
|
@@ -671,7 +673,7 @@ class Te extends E {
|
|
|
671
673
|
), [w] = l.moveCall({
|
|
672
674
|
target: "0x2::coin::from_balance",
|
|
673
675
|
arguments: [d],
|
|
674
|
-
typeArguments: [
|
|
676
|
+
typeArguments: [i.suiCoinType]
|
|
675
677
|
}), [b] = l.moveCall({
|
|
676
678
|
target: "0x2::coin::from_balance",
|
|
677
679
|
arguments: [f],
|
|
@@ -725,7 +727,7 @@ class Te extends E {
|
|
|
725
727
|
* @returns Transaction response or dry run response
|
|
726
728
|
*/
|
|
727
729
|
async claimAllRewards(e) {
|
|
728
|
-
var n, o,
|
|
730
|
+
var n, o, i;
|
|
729
731
|
if (!this.walletClient)
|
|
730
732
|
throw new Error("Wallet client not found");
|
|
731
733
|
const a = new h(), t = await Q(this.walletClient.address, {
|
|
@@ -739,7 +741,7 @@ class Te extends E {
|
|
|
739
741
|
transaction: a,
|
|
740
742
|
dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
|
|
741
743
|
});
|
|
742
|
-
return !(e != null && e.dryRun) && ((
|
|
744
|
+
return !(e != null && e.dryRun) && ((i = (o = s.effects) == null ? void 0 : o.status) == null ? void 0 : i.status) === "success" && (this.emit("lending:claim-rewards-success", {
|
|
743
745
|
rewards: t
|
|
744
746
|
}), this.walletClient.module("balance").updatePortfolio()), s;
|
|
745
747
|
}
|
|
@@ -831,7 +833,7 @@ class ve extends E {
|
|
|
831
833
|
e.object(this.config.poolId),
|
|
832
834
|
e.object(this.config.metadataId),
|
|
833
835
|
e.object("0x05"),
|
|
834
|
-
|
|
836
|
+
F(a, e.object)
|
|
835
837
|
],
|
|
836
838
|
typeArguments: []
|
|
837
839
|
});
|
|
@@ -851,7 +853,7 @@ class ve extends E {
|
|
|
851
853
|
e.object(this.config.poolId),
|
|
852
854
|
e.object(this.config.metadataId),
|
|
853
855
|
e.object("0x05"),
|
|
854
|
-
|
|
856
|
+
F(a, e.object)
|
|
855
857
|
],
|
|
856
858
|
typeArguments: []
|
|
857
859
|
});
|
|
@@ -878,13 +880,13 @@ class ve extends E {
|
|
|
878
880
|
useGasCoin: !0
|
|
879
881
|
}), o = await this.stakePTB(t, n);
|
|
880
882
|
t.transferObjects([o], this.walletClient.address);
|
|
881
|
-
const
|
|
883
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
882
884
|
transaction: t,
|
|
883
885
|
dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
|
|
884
886
|
});
|
|
885
|
-
return !(a != null && a.dryRun) && ((u = (c =
|
|
887
|
+
return !(a != null && a.dryRun) && ((u = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:stake-success", {
|
|
886
888
|
suiAmount: e
|
|
887
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
889
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
888
890
|
}
|
|
889
891
|
/**
|
|
890
892
|
* Unstake vSUI tokens to receive SUI tokens
|
|
@@ -905,13 +907,13 @@ class ve extends E {
|
|
|
905
907
|
balance: e
|
|
906
908
|
}), o = await this.unstakePTB(t, n);
|
|
907
909
|
t.transferObjects([o], this.walletClient.address);
|
|
908
|
-
const
|
|
910
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
909
911
|
transaction: t,
|
|
910
912
|
dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
|
|
911
913
|
});
|
|
912
|
-
return !(a != null && a.dryRun) && ((u = (c =
|
|
914
|
+
return !(a != null && a.dryRun) && ((u = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:unstake-success", {
|
|
913
915
|
vSuiAmount: e
|
|
914
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
916
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
915
917
|
}
|
|
916
918
|
}
|
|
917
919
|
class Pe extends E {
|
|
@@ -1001,13 +1003,13 @@ class Pe extends E {
|
|
|
1001
1003
|
if (!this.walletClient)
|
|
1002
1004
|
throw new Error("Wallet client not found");
|
|
1003
1005
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1004
|
-
const o = this.walletClient.module("balance").portfolio.getBalance(e),
|
|
1006
|
+
const o = this.walletClient.module("balance").portfolio.getBalance(e), i = new h(), l = y(i, o.coins, {
|
|
1005
1007
|
balance: t,
|
|
1006
1008
|
useGasCoin: !0
|
|
1007
|
-
}), c = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(
|
|
1008
|
-
|
|
1009
|
+
}), c = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(i, c, l, s);
|
|
1010
|
+
i.transferObjects([u], this.walletClient.address);
|
|
1009
1011
|
const d = await this.walletClient.signExecuteTransaction({
|
|
1010
|
-
transaction:
|
|
1012
|
+
transaction: i,
|
|
1011
1013
|
dryRun: (f = n == null ? void 0 : n.dryRun) != null ? f : !1
|
|
1012
1014
|
});
|
|
1013
1015
|
if (!(n != null && n.dryRun) && ((b = (w = d.effects) == null ? void 0 : w.status) == null ? void 0 : b.status) === "success") {
|
|
@@ -1046,7 +1048,7 @@ class pe extends E {
|
|
|
1046
1048
|
arguments: [
|
|
1047
1049
|
e.object("0x05"),
|
|
1048
1050
|
e.object(this.config.configId),
|
|
1049
|
-
|
|
1051
|
+
F(a, e.object),
|
|
1050
1052
|
e.pure.address("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1051
1053
|
],
|
|
1052
1054
|
typeArguments: []
|
|
@@ -1066,7 +1068,7 @@ class pe extends E {
|
|
|
1066
1068
|
arguments: [
|
|
1067
1069
|
e.object("0x05"),
|
|
1068
1070
|
e.object(this.config.configId),
|
|
1069
|
-
|
|
1071
|
+
F(a, e.object)
|
|
1070
1072
|
],
|
|
1071
1073
|
typeArguments: []
|
|
1072
1074
|
});
|
|
@@ -1089,11 +1091,11 @@ class pe extends E {
|
|
|
1089
1091
|
useGasCoin: !0
|
|
1090
1092
|
}), o = await this.stakePTB(t, n);
|
|
1091
1093
|
t.transferObjects([o], this.walletClient.address);
|
|
1092
|
-
const
|
|
1094
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
1093
1095
|
transaction: t,
|
|
1094
1096
|
dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
|
|
1095
1097
|
});
|
|
1096
|
-
return !(a != null && a.dryRun) && ((u = (c =
|
|
1098
|
+
return !(a != null && a.dryRun) && ((u = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1097
1099
|
}
|
|
1098
1100
|
/**
|
|
1099
1101
|
* Unstake haSUI for SUI
|
|
@@ -1110,11 +1112,11 @@ class pe extends E {
|
|
|
1110
1112
|
balance: e
|
|
1111
1113
|
}), o = await this.unstakePTB(t, n);
|
|
1112
1114
|
t.transferObjects([o], this.walletClient.address);
|
|
1113
|
-
const
|
|
1115
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
1114
1116
|
transaction: t,
|
|
1115
1117
|
dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
|
|
1116
1118
|
});
|
|
1117
|
-
return !(a != null && a.dryRun) && ((u = (c =
|
|
1119
|
+
return !(a != null && a.dryRun) && ((u = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1118
1120
|
}
|
|
1119
1121
|
}
|
|
1120
1122
|
const Ee = {
|