@naviprotocol/wallet-client 1.0.2-dev.0 → 1.0.2-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,8 +1,8 @@
|
|
|
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
|
|
5
|
-
import p, { BigNumber 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 x, 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 k } from "@naviprotocol/lending";
|
|
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";
|
|
8
8
|
import { buildSwapPTBFromQuote as $, generateRefId as Ce, getQuote as be } from "@naviprotocol/astros-aggregator-sdk";
|
|
@@ -120,7 +120,7 @@ class E {
|
|
|
120
120
|
let n = a[s];
|
|
121
121
|
n || (n = {
|
|
122
122
|
coinType: s,
|
|
123
|
-
amount:
|
|
123
|
+
amount: M(0),
|
|
124
124
|
coins: []
|
|
125
125
|
}, a[s] = n), n.coins.push(t), n.amount = n.amount.plus(t.balance);
|
|
126
126
|
}), this.balances = a;
|
|
@@ -133,7 +133,7 @@ class E {
|
|
|
133
133
|
* @returns UserCoinBalance object with coin type, total amount, and coin objects
|
|
134
134
|
*/
|
|
135
135
|
getBalance(e) {
|
|
136
|
-
return e = T(e), this.balances[e] || { coinType: e, amount:
|
|
136
|
+
return e = T(e), this.balances[e] || { coinType: e, amount: M(0), coins: [] };
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Gets all coin types in the portfolio
|
|
@@ -152,7 +152,7 @@ class E {
|
|
|
152
152
|
balanceOf(e) {
|
|
153
153
|
e = T(e);
|
|
154
154
|
const a = this.getBalance(e);
|
|
155
|
-
return (a == null ? void 0 : a.amount) ||
|
|
155
|
+
return (a == null ? void 0 : a.amount) || M(0);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Creates a deep copy of the portfolio
|
|
@@ -171,7 +171,7 @@ class Be extends R {
|
|
|
171
171
|
constructor() {
|
|
172
172
|
super(...arguments), this.name = "balance", this.defaultConfig = {
|
|
173
173
|
coinPollingInterval: 6e3
|
|
174
|
-
}, this.updatePortfolio =
|
|
174
|
+
}, this.updatePortfolio = L(async () => {
|
|
175
175
|
if (!this.walletClient)
|
|
176
176
|
throw new Error("Wallet client not found");
|
|
177
177
|
this._coins = await oe(this.walletClient.address, {
|
|
@@ -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 i = new w();
|
|
241
|
+
let l = i.gas;
|
|
242
|
+
T(e) !== T("0x2::sui::SUI") && (l = y(i, n.coins, {
|
|
243
243
|
balance: c.toNumber()
|
|
244
244
|
}));
|
|
245
|
-
const o =
|
|
245
|
+
const o = i.splitCoins(l, t);
|
|
246
246
|
return a.forEach((h, f) => {
|
|
247
|
-
|
|
247
|
+
i.transferObjects([o[f]], h);
|
|
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 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((i, l) => {
|
|
284
|
+
s.transferObjects([s.object(i)], a[l]);
|
|
285
285
|
}), await this.walletClient.signExecuteTransaction({
|
|
286
286
|
transaction: s,
|
|
287
287
|
dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
|
|
@@ -332,17 +332,10 @@ async function D(r, e, a, t) {
|
|
|
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 (
|
|
337
|
-
fromPoolLending: l,
|
|
338
|
-
lendingState: c,
|
|
339
|
-
address: i,
|
|
340
|
-
options: t,
|
|
341
|
-
from: e,
|
|
342
|
-
to: a
|
|
343
|
-
}), !l || l.supplyBalance === "0")
|
|
335
|
+
const s = await this.getPool(e), n = await this.getPool(a), c = await this.getLendingState(), i = c.find((F) => F.pool.id === s.id), l = this.walletClient.address;
|
|
336
|
+
if (!i || i.supplyBalance === "0")
|
|
344
337
|
throw new Error("No supply balance");
|
|
345
|
-
if (t != null && t.amount && t.amount > Number(
|
|
338
|
+
if (t != null && t.amount && t.amount > Number(i.supplyBalance))
|
|
346
339
|
throw new Error("Amount is less than supply balance");
|
|
347
340
|
const o = await Q(), u = await Promise.all([s, n]);
|
|
348
341
|
await q(
|
|
@@ -357,7 +350,7 @@ async function D(r, e, a, t) {
|
|
|
357
350
|
});
|
|
358
351
|
if (!(d != null && d.flashloanFee))
|
|
359
352
|
throw new Error(`${s.token.symbol} pool not support flashloan`);
|
|
360
|
-
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(i.supplyBalance), b = await this.walletClient.swap.getQuote(
|
|
361
354
|
s.suiCoinType,
|
|
362
355
|
n.suiCoinType,
|
|
363
356
|
f
|
|
@@ -376,7 +369,7 @@ async function D(r, e, a, t) {
|
|
|
376
369
|
amount: g
|
|
377
370
|
});
|
|
378
371
|
const j = await Y(r, s, f), U = await $(
|
|
379
|
-
|
|
372
|
+
l,
|
|
380
373
|
r,
|
|
381
374
|
C,
|
|
382
375
|
j,
|
|
@@ -397,26 +390,32 @@ async function J(r, e, a, t) {
|
|
|
397
390
|
if (!this.walletClient)
|
|
398
391
|
throw new Error("Wallet client not found");
|
|
399
392
|
await this.walletClient.balance.waitForUpdate();
|
|
400
|
-
const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a),
|
|
401
|
-
if (!
|
|
393
|
+
const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a), i = await this.getLendingState(), l = i.find((I) => I.pool.id === n.id);
|
|
394
|
+
if (!l || l.borrowBalance === "0")
|
|
402
395
|
throw new Error("No borrow balance");
|
|
403
|
-
if (t != null && t.amount && t.amount > Number(
|
|
396
|
+
if (t != null && t.amount && t.amount > Number(l.borrowBalance))
|
|
404
397
|
throw new Error("Amount is less than borrow balance");
|
|
405
398
|
const o = await Q(), u = await Promise.all([n, c]);
|
|
406
399
|
await q(
|
|
407
400
|
r,
|
|
408
401
|
K(o, {
|
|
409
|
-
lendingState:
|
|
402
|
+
lendingState: i,
|
|
410
403
|
pools: u
|
|
411
404
|
})
|
|
412
405
|
);
|
|
413
|
-
let d = (F = t == null ? void 0 : t.amount) != null ? F : Number(
|
|
414
|
-
if (Number(
|
|
406
|
+
let d = (F = t == null ? void 0 : t.amount) != null ? F : Number(l.borrowBalance);
|
|
407
|
+
if (Number(l.borrowBalance) === d) {
|
|
415
408
|
const I = parseFloat(Te(n.currentBorrowRate, 8)) / 100;
|
|
416
409
|
d = Math.ceil(
|
|
417
410
|
new p(d).multipliedBy(I * (60 * 3) / (365 * 24 * 3600)).plus(new p(1).shiftedBy(-n.token.decimals)).plus(d).toNumber()
|
|
418
411
|
);
|
|
419
412
|
}
|
|
413
|
+
console.log("migrateBetweenBorrowPTB", {
|
|
414
|
+
formAmount: d,
|
|
415
|
+
options: t,
|
|
416
|
+
fromPoolLending: l,
|
|
417
|
+
isMax: Number(l.borrowBalance) === d
|
|
418
|
+
});
|
|
420
419
|
const h = await V(n, {
|
|
421
420
|
env: this.config.env
|
|
422
421
|
});
|
|
@@ -475,27 +474,27 @@ async function z(r, e, a, t) {
|
|
|
475
474
|
throw new Error(`No balance of ${e}`);
|
|
476
475
|
if (t != null && t.amount && n.amount.lt(t.amount))
|
|
477
476
|
throw new Error("Amount is less than balance");
|
|
478
|
-
const c = (o = t == null ? void 0 : t.amount) != null ? o : n.amount.toNumber(),
|
|
479
|
-
let
|
|
477
|
+
const c = (o = t == null ? void 0 : t.amount) != null ? o : n.amount.toNumber(), i = (u = t == null ? void 0 : t.slippage) != null ? u : 5e-3;
|
|
478
|
+
let l = await y(r, n.coins, {
|
|
480
479
|
balance: c,
|
|
481
480
|
useGasCoin: !0
|
|
482
481
|
});
|
|
483
482
|
if (T(e) !== T(s.suiCoinType)) {
|
|
484
483
|
const d = await this.walletClient.swap.getQuote(e, s.suiCoinType, c);
|
|
485
|
-
|
|
484
|
+
l = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
486
485
|
r,
|
|
487
486
|
d,
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
l,
|
|
488
|
+
i
|
|
490
489
|
);
|
|
491
490
|
}
|
|
492
|
-
return await x(r, s,
|
|
491
|
+
return await x(r, s, l), r;
|
|
493
492
|
}
|
|
494
493
|
class ve extends R {
|
|
495
494
|
constructor() {
|
|
496
495
|
super(), this.name = "lending", this.defaultConfig = {
|
|
497
496
|
env: "prod"
|
|
498
|
-
}, this.migrateBetweenSupplyPTB = D, this.migrateBetweenBorrowPTB = J, this.migrateBalanceToSupplyPTB = z, this.migrateBetweenSupplyPTB = D.bind(this), this.
|
|
497
|
+
}, this.migrateBetweenSupplyPTB = D, this.migrateBetweenBorrowPTB = J, this.migrateBalanceToSupplyPTB = z, this.migrateBetweenSupplyPTB = D.bind(this), this.migrateBetweenBorrowPTB = J.bind(this), this.migrateBalanceToSupplyPTB = z.bind(this);
|
|
499
498
|
}
|
|
500
499
|
/**
|
|
501
500
|
* Gets all available lending pools
|
|
@@ -538,23 +537,23 @@ class ve extends R {
|
|
|
538
537
|
env: this.config.env
|
|
539
538
|
});
|
|
540
539
|
await this.walletClient.module("balance").waitForUpdate();
|
|
541
|
-
const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType),
|
|
540
|
+
const n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = y(n, c.coins, {
|
|
542
541
|
balance: a,
|
|
543
542
|
useGasCoin: !0
|
|
544
543
|
});
|
|
545
|
-
await x(n, s,
|
|
544
|
+
await x(n, s, i, {
|
|
546
545
|
env: this.config.env,
|
|
547
546
|
amount: a,
|
|
548
547
|
accountCap: t == null ? void 0 : t.accountCap
|
|
549
548
|
});
|
|
550
|
-
const
|
|
549
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
551
550
|
transaction: n,
|
|
552
551
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
553
552
|
});
|
|
554
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
553
|
+
return !(t != null && t.dryRun) && ((d = (u = l.effects) == null ? void 0 : u.status) == null ? void 0 : d.status) === "success" && (this.emit("lending:deposit-success", {
|
|
555
554
|
identifier: e,
|
|
556
555
|
amount: a
|
|
557
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
556
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
558
557
|
}
|
|
559
558
|
/**
|
|
560
559
|
* Withdraws coins from a lending pool
|
|
@@ -565,7 +564,7 @@ class ve extends R {
|
|
|
565
564
|
* @returns Transaction response or dry run response
|
|
566
565
|
*/
|
|
567
566
|
async withdraw(e, a, t) {
|
|
568
|
-
var
|
|
567
|
+
var l, o, u;
|
|
569
568
|
if (!this.walletClient)
|
|
570
569
|
throw new Error("Wallet client not found");
|
|
571
570
|
const s = await P(e, {
|
|
@@ -577,14 +576,14 @@ class ve extends R {
|
|
|
577
576
|
accountCap: t == null ? void 0 : t.accountCap
|
|
578
577
|
});
|
|
579
578
|
n.transferObjects([c], this.walletClient.address);
|
|
580
|
-
const
|
|
579
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
581
580
|
transaction: n,
|
|
582
|
-
dryRun: (
|
|
581
|
+
dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
|
|
583
582
|
});
|
|
584
|
-
return !(t != null && t.dryRun) && ((u = (o =
|
|
583
|
+
return !(t != null && t.dryRun) && ((u = (o = i.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:withdraw-success", {
|
|
585
584
|
identifier: e,
|
|
586
585
|
amount: a
|
|
587
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
586
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
588
587
|
}
|
|
589
588
|
/**
|
|
590
589
|
* Borrows coins from a lending pool
|
|
@@ -595,7 +594,7 @@ class ve extends R {
|
|
|
595
594
|
* @returns Transaction response or dry run response
|
|
596
595
|
*/
|
|
597
596
|
async borrow(e, a, t) {
|
|
598
|
-
var
|
|
597
|
+
var l, o, u;
|
|
599
598
|
if (!this.walletClient)
|
|
600
599
|
throw new Error("Wallet client not found");
|
|
601
600
|
const s = await P(e, {
|
|
@@ -607,14 +606,14 @@ class ve extends R {
|
|
|
607
606
|
accountCap: t == null ? void 0 : t.accountCap
|
|
608
607
|
});
|
|
609
608
|
n.transferObjects([c], this.walletClient.address);
|
|
610
|
-
const
|
|
609
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
611
610
|
transaction: n,
|
|
612
|
-
dryRun: (
|
|
611
|
+
dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
|
|
613
612
|
});
|
|
614
|
-
return !(t != null && t.dryRun) && ((u = (o =
|
|
613
|
+
return !(t != null && t.dryRun) && ((u = (o = i.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("lending:borrow-success", {
|
|
615
614
|
identifier: e,
|
|
616
615
|
amount: a
|
|
617
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
616
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
618
617
|
}
|
|
619
618
|
/**
|
|
620
619
|
* Repays borrowed coins to a lending pool
|
|
@@ -631,23 +630,23 @@ class ve extends R {
|
|
|
631
630
|
await this.walletClient.module("balance").waitForUpdate();
|
|
632
631
|
const s = await P(e, {
|
|
633
632
|
env: this.config.env
|
|
634
|
-
}), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType),
|
|
633
|
+
}), n = new w(), c = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = y(n, c.coins, {
|
|
635
634
|
balance: a,
|
|
636
635
|
useGasCoin: !0
|
|
637
636
|
});
|
|
638
|
-
await ee(n, s,
|
|
637
|
+
await ee(n, s, i, {
|
|
639
638
|
env: this.config.env,
|
|
640
639
|
amount: a,
|
|
641
640
|
accountCap: t == null ? void 0 : t.accountCap
|
|
642
641
|
});
|
|
643
|
-
const
|
|
642
|
+
const l = await this.walletClient.signExecuteTransaction({
|
|
644
643
|
transaction: n,
|
|
645
644
|
dryRun: (o = t == null ? void 0 : t.dryRun) != null ? o : !1
|
|
646
645
|
});
|
|
647
|
-
return !(t != null && t.dryRun) && ((d = (u =
|
|
646
|
+
return !(t != null && t.dryRun) && ((d = (u = l.effects) == null ? void 0 : u.status) == null ? void 0 : d.status) === "success" && (this.emit("lending:repay-success", {
|
|
648
647
|
identifier: e,
|
|
649
648
|
amount: a
|
|
650
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
649
|
+
}), this.walletClient.module("balance").updatePortfolio()), l;
|
|
651
650
|
}
|
|
652
651
|
/**
|
|
653
652
|
* Gets the current health factor for the user
|
|
@@ -679,32 +678,32 @@ class ve extends R {
|
|
|
679
678
|
throw new Error("Wallet client not found");
|
|
680
679
|
const c = await P(e, {
|
|
681
680
|
env: this.config.env
|
|
682
|
-
}),
|
|
681
|
+
}), i = await P(t, {
|
|
683
682
|
env: this.config.env
|
|
684
|
-
}),
|
|
683
|
+
}), l = new w(), o = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), u = y(l, o.coins, {
|
|
685
684
|
balance: a,
|
|
686
685
|
useGasCoin: !0
|
|
687
686
|
}), [d, h] = await we(
|
|
688
|
-
|
|
687
|
+
l,
|
|
689
688
|
c,
|
|
690
689
|
u,
|
|
691
|
-
|
|
690
|
+
i,
|
|
692
691
|
s,
|
|
693
692
|
{
|
|
694
693
|
env: this.config.env
|
|
695
694
|
}
|
|
696
|
-
), [f] =
|
|
695
|
+
), [f] = l.moveCall({
|
|
697
696
|
target: "0x2::coin::from_balance",
|
|
698
697
|
arguments: [d],
|
|
699
|
-
typeArguments: [
|
|
700
|
-
}), [b] =
|
|
698
|
+
typeArguments: [i.suiCoinType]
|
|
699
|
+
}), [b] = l.moveCall({
|
|
701
700
|
target: "0x2::coin::from_balance",
|
|
702
701
|
arguments: [h],
|
|
703
702
|
typeArguments: [c.suiCoinType]
|
|
704
703
|
});
|
|
705
|
-
|
|
704
|
+
l.transferObjects([f, b], this.walletClient.address);
|
|
706
705
|
const m = await this.walletClient.signExecuteTransaction({
|
|
707
|
-
transaction:
|
|
706
|
+
transaction: l,
|
|
708
707
|
dryRun: (C = n == null ? void 0 : n.dryRun) != null ? C : !1
|
|
709
708
|
});
|
|
710
709
|
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", {
|
|
@@ -750,7 +749,7 @@ class ve extends R {
|
|
|
750
749
|
* @returns Transaction response or dry run response
|
|
751
750
|
*/
|
|
752
751
|
async claimAllRewards(e) {
|
|
753
|
-
var n, c,
|
|
752
|
+
var n, c, i;
|
|
754
753
|
if (!this.walletClient)
|
|
755
754
|
throw new Error("Wallet client not found");
|
|
756
755
|
const a = new w(), t = await H(this.walletClient.address, {
|
|
@@ -764,7 +763,7 @@ class ve extends R {
|
|
|
764
763
|
transaction: a,
|
|
765
764
|
dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
|
|
766
765
|
});
|
|
767
|
-
return !(e != null && e.dryRun) && ((
|
|
766
|
+
return !(e != null && e.dryRun) && ((i = (c = s.effects) == null ? void 0 : c.status) == null ? void 0 : i.status) === "success" && (this.emit("lending:claim-rewards-success", {
|
|
768
767
|
rewards: t
|
|
769
768
|
}), this.walletClient.module("balance").updatePortfolio()), s;
|
|
770
769
|
}
|
|
@@ -839,7 +838,7 @@ class pe extends R {
|
|
|
839
838
|
metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
|
|
840
839
|
coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
|
|
841
840
|
}, this.getStats = ae(
|
|
842
|
-
|
|
841
|
+
L(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
|
|
843
842
|
);
|
|
844
843
|
}
|
|
845
844
|
/**
|
|
@@ -891,7 +890,7 @@ class pe extends R {
|
|
|
891
890
|
* @throws Error if wallet client not found or stake amount is too low
|
|
892
891
|
*/
|
|
893
892
|
async stake(e, a) {
|
|
894
|
-
var
|
|
893
|
+
var l, o, u;
|
|
895
894
|
if (!this.walletClient)
|
|
896
895
|
throw new Error("Wallet client not found");
|
|
897
896
|
if (e < 1e9)
|
|
@@ -903,13 +902,13 @@ class pe extends R {
|
|
|
903
902
|
useGasCoin: !0
|
|
904
903
|
}), c = await this.stakePTB(t, n);
|
|
905
904
|
t.transferObjects([c], this.walletClient.address);
|
|
906
|
-
const
|
|
905
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
907
906
|
transaction: t,
|
|
908
|
-
dryRun: (
|
|
907
|
+
dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
|
|
909
908
|
});
|
|
910
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
909
|
+
return !(a != null && a.dryRun) && ((u = (o = i.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:stake-success", {
|
|
911
910
|
suiAmount: e
|
|
912
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
911
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
913
912
|
}
|
|
914
913
|
/**
|
|
915
914
|
* Unstake vSUI tokens to receive SUI tokens
|
|
@@ -920,7 +919,7 @@ class pe extends R {
|
|
|
920
919
|
* @throws Error if wallet client not found or unstake amount is too low
|
|
921
920
|
*/
|
|
922
921
|
async unstake(e, a) {
|
|
923
|
-
var
|
|
922
|
+
var l, o, u;
|
|
924
923
|
if (!this.walletClient)
|
|
925
924
|
throw new Error("Wallet client not found");
|
|
926
925
|
if (e < 1e9)
|
|
@@ -930,13 +929,13 @@ class pe extends R {
|
|
|
930
929
|
balance: e
|
|
931
930
|
}), c = await this.unstakePTB(t, n);
|
|
932
931
|
t.transferObjects([c], this.walletClient.address);
|
|
933
|
-
const
|
|
932
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
934
933
|
transaction: t,
|
|
935
|
-
dryRun: (
|
|
934
|
+
dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
|
|
936
935
|
});
|
|
937
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
936
|
+
return !(a != null && a.dryRun) && ((u = (o = i.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("volo:unstake-success", {
|
|
938
937
|
vSuiAmount: e
|
|
939
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
938
|
+
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
940
939
|
}
|
|
941
940
|
}
|
|
942
941
|
class Ee extends R {
|
|
@@ -1026,13 +1025,13 @@ class Ee extends R {
|
|
|
1026
1025
|
if (!this.walletClient)
|
|
1027
1026
|
throw new Error("Wallet client not found");
|
|
1028
1027
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1029
|
-
const c = this.walletClient.module("balance").portfolio.getBalance(e),
|
|
1028
|
+
const c = this.walletClient.module("balance").portfolio.getBalance(e), i = new w(), l = y(i, c.coins, {
|
|
1030
1029
|
balance: t,
|
|
1031
1030
|
useGasCoin: !0
|
|
1032
|
-
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(
|
|
1033
|
-
|
|
1031
|
+
}), o = await this.getQuote(e, a, t), u = await this.buildSwapPTBFromQuote(i, o, l, s);
|
|
1032
|
+
i.transferObjects([u], this.walletClient.address);
|
|
1034
1033
|
const d = await this.walletClient.signExecuteTransaction({
|
|
1035
|
-
transaction:
|
|
1034
|
+
transaction: i,
|
|
1036
1035
|
dryRun: (h = n == null ? void 0 : n.dryRun) != null ? h : !1
|
|
1037
1036
|
});
|
|
1038
1037
|
if (!(n != null && n.dryRun) && ((b = (f = d.effects) == null ? void 0 : f.status) == null ? void 0 : b.status) === "success") {
|
|
@@ -1055,7 +1054,7 @@ class Re extends R {
|
|
|
1055
1054
|
configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
|
|
1056
1055
|
coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
1057
1056
|
}, this.getApy = ae(
|
|
1058
|
-
|
|
1057
|
+
L(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
|
|
1059
1058
|
);
|
|
1060
1059
|
}
|
|
1061
1060
|
/**
|
|
@@ -1104,7 +1103,7 @@ class Re extends R {
|
|
|
1104
1103
|
* @param options Optional dry run
|
|
1105
1104
|
*/
|
|
1106
1105
|
async stake(e, a) {
|
|
1107
|
-
var
|
|
1106
|
+
var l, o, u;
|
|
1108
1107
|
if (!this.walletClient)
|
|
1109
1108
|
throw new Error("Wallet client not found");
|
|
1110
1109
|
const t = new w();
|
|
@@ -1114,11 +1113,11 @@ class Re extends R {
|
|
|
1114
1113
|
useGasCoin: !0
|
|
1115
1114
|
}), c = await this.stakePTB(t, n);
|
|
1116
1115
|
t.transferObjects([c], this.walletClient.address);
|
|
1117
|
-
const
|
|
1116
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
1118
1117
|
transaction: t,
|
|
1119
|
-
dryRun: (
|
|
1118
|
+
dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
|
|
1120
1119
|
});
|
|
1121
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
1120
|
+
return !(a != null && a.dryRun) && ((u = (o = i.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1122
1121
|
}
|
|
1123
1122
|
/**
|
|
1124
1123
|
* Unstake haSUI for SUI
|
|
@@ -1127,7 +1126,7 @@ class Re extends R {
|
|
|
1127
1126
|
* @param options Optional dry run
|
|
1128
1127
|
*/
|
|
1129
1128
|
async unstake(e, a) {
|
|
1130
|
-
var
|
|
1129
|
+
var l, o, u;
|
|
1131
1130
|
if (!this.walletClient)
|
|
1132
1131
|
throw new Error("Wallet client not found");
|
|
1133
1132
|
await this.walletClient.module("balance").waitForUpdate();
|
|
@@ -1135,11 +1134,11 @@ class Re extends R {
|
|
|
1135
1134
|
balance: e
|
|
1136
1135
|
}), c = await this.unstakePTB(t, n);
|
|
1137
1136
|
t.transferObjects([c], this.walletClient.address);
|
|
1138
|
-
const
|
|
1137
|
+
const i = await this.walletClient.signExecuteTransaction({
|
|
1139
1138
|
transaction: t,
|
|
1140
|
-
dryRun: (
|
|
1139
|
+
dryRun: (l = a == null ? void 0 : a.dryRun) != null ? l : !1
|
|
1141
1140
|
});
|
|
1142
|
-
return !(a != null && a.dryRun) && ((u = (o =
|
|
1141
|
+
return !(a != null && a.dryRun) && ((u = (o = i.effects) == null ? void 0 : o.status) == null ? void 0 : u.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1143
1142
|
}
|
|
1144
1143
|
}
|
|
1145
1144
|
const Se = {
|
|
@@ -1243,7 +1242,7 @@ class Ie {
|
|
|
1243
1242
|
return e in this.modules;
|
|
1244
1243
|
}
|
|
1245
1244
|
}
|
|
1246
|
-
class
|
|
1245
|
+
class Me extends ne {
|
|
1247
1246
|
/**
|
|
1248
1247
|
* Creates a new watch-only signer
|
|
1249
1248
|
*
|
|
@@ -1307,7 +1306,7 @@ class Le extends ne {
|
|
|
1307
1306
|
return {};
|
|
1308
1307
|
}
|
|
1309
1308
|
}
|
|
1310
|
-
class
|
|
1309
|
+
class Le extends ne {
|
|
1311
1310
|
/**
|
|
1312
1311
|
* Creates a new watch-only signer
|
|
1313
1312
|
*
|
|
@@ -1361,7 +1360,7 @@ class Me extends ne {
|
|
|
1361
1360
|
}
|
|
1362
1361
|
export {
|
|
1363
1362
|
Ie as WalletClient,
|
|
1364
|
-
|
|
1365
|
-
|
|
1363
|
+
Me as WatchSigner,
|
|
1364
|
+
Le as WebSigner
|
|
1366
1365
|
};
|
|
1367
1366
|
//# sourceMappingURL=index.esm.js.map
|