@naviprotocol/wallet-client 1.3.2-dev.1 → 1.3.2-dev.3
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 +87 -87
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { getFullnodeUrl as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { withSingleton as q, getCoins as
|
|
1
|
+
import { getFullnodeUrl as pe, SuiClient as Pe } from "@mysten/sui/client";
|
|
2
|
+
import Be from "mitt";
|
|
3
|
+
import Te from "axios";
|
|
4
|
+
import { withSingleton as q, getCoins as le, mergeCoinsPTB as P, getPriceFeeds as K, updateOraclePricesPTB as Q, filterPriceFeeds as G, getFlashLoanAsset as re, flashloanPTB as oe, depositCoinPTB as I, repayFlashLoanPTB as ce, borrowCoinPTB as ue, withdrawCoinPTB as de, repayCoinPTB as we, getPools as ve, getPool as B, getHealthFactor as Ee, liquidatePTB as Re, getUserAvailableLendingRewards as ee, getUserClaimedRewardHistory as Se, claimLendingRewardsPTB as Oe, getLendingState as Ae, createAccountCapPTB as xe, withCache as he, parseTxValue as U } from "@naviprotocol/lending";
|
|
5
5
|
import T, { BigNumber as $ } from "bignumber.js";
|
|
6
6
|
import { normalizeStructTag as C } from "@mysten/sui/utils";
|
|
7
7
|
import { Transaction as m } from "@mysten/sui/transactions";
|
|
8
|
-
import { buildSwapPTBFromQuote as z, generateRefId as
|
|
9
|
-
import { SuilendClient as
|
|
10
|
-
import { getCoinMetadataMap as
|
|
11
|
-
import { executeAuction as
|
|
12
|
-
import { Signer as
|
|
13
|
-
const
|
|
8
|
+
import { buildSwapPTBFromQuote as z, generateRefId as ke, getQuote as Fe } from "@naviprotocol/astros-aggregator-sdk";
|
|
9
|
+
import { SuilendClient as te, LENDING_MARKET_ID as je, LENDING_MARKET_TYPE as ae, parseReserve as Ne, parseObligation as _e } from "@suilend/sdk";
|
|
10
|
+
import { getCoinMetadataMap as Ie, MAX_U64 as Ue } from "@suilend/sui-fe";
|
|
11
|
+
import { executeAuction as We } from "shio-sdk";
|
|
12
|
+
import { Signer as fe } from "@mysten/sui/cryptography";
|
|
13
|
+
const ge = Te.create({
|
|
14
14
|
timeout: 2e4
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
ge.interceptors.response.use(
|
|
17
17
|
function(o) {
|
|
18
18
|
if (o.data.err)
|
|
19
19
|
throw new Error(o.data.err);
|
|
@@ -25,7 +25,7 @@ he.interceptors.response.use(
|
|
|
25
25
|
return Promise.reject(o);
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
|
-
class
|
|
28
|
+
class Me {
|
|
29
29
|
/**
|
|
30
30
|
* Creates a new custom transport instance
|
|
31
31
|
*
|
|
@@ -44,7 +44,7 @@ class Ue {
|
|
|
44
44
|
* @returns Promise<T> - The response data from the RPC call
|
|
45
45
|
*/
|
|
46
46
|
async request(e) {
|
|
47
|
-
return this.requestId += 1, (await
|
|
47
|
+
return this.requestId += 1, (await ge.post(this.rpcUrl, {
|
|
48
48
|
jsonrpc: "2.0",
|
|
49
49
|
id: this.requestId,
|
|
50
50
|
method: e.method,
|
|
@@ -64,7 +64,7 @@ class Ue {
|
|
|
64
64
|
throw new Error("subscribe not implemented.");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class O {
|
|
68
68
|
/**
|
|
69
69
|
* Gets the current configuration for this module
|
|
70
70
|
*
|
|
@@ -170,7 +170,7 @@ class E {
|
|
|
170
170
|
return a.balances = e, a;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
class
|
|
173
|
+
class Le extends O {
|
|
174
174
|
constructor() {
|
|
175
175
|
super(...arguments), this.name = "balance", this.defaultConfig = {
|
|
176
176
|
coinPollingInterval: 6e3,
|
|
@@ -178,7 +178,7 @@ class We extends A {
|
|
|
178
178
|
}, this.updatePortfolio = q(async () => {
|
|
179
179
|
if (!this.walletClient)
|
|
180
180
|
throw new Error("Wallet client not found");
|
|
181
|
-
this._coins = await
|
|
181
|
+
this._coins = await le(this.walletClient.address, {
|
|
182
182
|
client: this.walletClient.client
|
|
183
183
|
}), this._portfolio = new E(this._coins), this.emit("balance:portfolio-updated", {});
|
|
184
184
|
}), this._coins = [], this._portfolio = new E(), this.pollingTimer = null, this._updatePromise = null;
|
|
@@ -329,7 +329,7 @@ class We extends A {
|
|
|
329
329
|
super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
async function
|
|
332
|
+
async function ne(o, e, a, t) {
|
|
333
333
|
var F, j, N;
|
|
334
334
|
if (!this.walletClient)
|
|
335
335
|
throw new Error("Wallet client not found");
|
|
@@ -351,7 +351,7 @@ async function te(o, e, a, t) {
|
|
|
351
351
|
pools: f
|
|
352
352
|
})
|
|
353
353
|
);
|
|
354
|
-
const h = await
|
|
354
|
+
const h = await re(n, {
|
|
355
355
|
env: this.config.env
|
|
356
356
|
});
|
|
357
357
|
if (!h)
|
|
@@ -366,7 +366,7 @@ async function te(o, e, a, t) {
|
|
|
366
366
|
const p = Math.floor(g * (1 - y)), v = Math.floor(p / (1 + h.flashloanFee));
|
|
367
367
|
if (v <= 0)
|
|
368
368
|
throw new Error("The calculated borrow amount must be positive.");
|
|
369
|
-
const [R, W] = await
|
|
369
|
+
const [R, W] = await oe(o, n, v), [S] = o.moveCall({
|
|
370
370
|
target: "0x2::coin::from_balance",
|
|
371
371
|
arguments: [R],
|
|
372
372
|
typeArguments: [n.suiCoinType]
|
|
@@ -374,25 +374,25 @@ async function te(o, e, a, t) {
|
|
|
374
374
|
await I(o, n, S, {
|
|
375
375
|
amount: v
|
|
376
376
|
});
|
|
377
|
-
const
|
|
377
|
+
const A = await u.withdrawCoinPTB(o, s.suiCoinType, b), x = await z(
|
|
378
378
|
i,
|
|
379
379
|
o,
|
|
380
380
|
p,
|
|
381
|
-
|
|
381
|
+
A,
|
|
382
382
|
d
|
|
383
383
|
), k = o.moveCall({
|
|
384
384
|
target: "0x2::coin::into_balance",
|
|
385
385
|
arguments: [x],
|
|
386
386
|
typeArguments: [n.suiCoinType]
|
|
387
|
-
}), [M] = await
|
|
387
|
+
}), [M] = await ce(o, n, W, k), [L] = o.moveCall({
|
|
388
388
|
target: "0x2::coin::from_balance",
|
|
389
389
|
arguments: [M],
|
|
390
390
|
typeArguments: [n.suiCoinType]
|
|
391
391
|
});
|
|
392
392
|
return await I(o, n, L), o;
|
|
393
393
|
}
|
|
394
|
-
async function
|
|
395
|
-
var J, D, V, X;
|
|
394
|
+
async function se(o, e, a, t) {
|
|
395
|
+
var J, D, V, X, Y, Z;
|
|
396
396
|
if (!this.walletClient)
|
|
397
397
|
throw new Error("Wallet client not found");
|
|
398
398
|
const s = this.walletClient.address, n = await this.getPool(e), c = await this.getPool(a), i = await this.getLendingState(), l = (J = t == null ? void 0 : t.protocol) != null ? J : "navi", u = await this.getProtocol(l);
|
|
@@ -420,7 +420,7 @@ async function ae(o, e, a, t) {
|
|
|
420
420
|
new T(h).multipliedBy(_ * (60 * 3) / (365 * 24 * 3600)).plus(new T(1).shiftedBy(-n.token.decimals)).plus(h).toNumber()
|
|
421
421
|
);
|
|
422
422
|
}
|
|
423
|
-
const y = await
|
|
423
|
+
const y = await re(n, {
|
|
424
424
|
env: this.config.env
|
|
425
425
|
});
|
|
426
426
|
if (!y)
|
|
@@ -438,43 +438,43 @@ async function ae(o, e, a, t) {
|
|
|
438
438
|
W.forEach((_) => {
|
|
439
439
|
S[C(_.coinType)] = _;
|
|
440
440
|
});
|
|
441
|
-
const
|
|
442
|
-
if (!
|
|
441
|
+
const A = (Y = S[C(n.suiCoinType)]) == null ? void 0 : Y.price, x = (Z = S[C(c.suiCoinType)]) == null ? void 0 : Z.price;
|
|
442
|
+
if (!A || !x)
|
|
443
443
|
throw new Error("Fetch price failed");
|
|
444
444
|
const k = Number(
|
|
445
|
-
T(d).div(Math.pow(10,
|
|
446
|
-
), [M, L] = await
|
|
445
|
+
T(d).div(Math.pow(10, n.token.decimals)).multipliedBy(A).multipliedBy(1 + b).div(x).multipliedBy(Math.pow(10, c.token.decimals)).toFixed(0)
|
|
446
|
+
), [M, L] = await oe(o, n, h), [F] = o.moveCall({
|
|
447
447
|
target: "0x2::coin::from_balance",
|
|
448
448
|
arguments: [M],
|
|
449
449
|
typeArguments: [n.suiCoinType]
|
|
450
450
|
});
|
|
451
451
|
await u.repayCoinPTB(o, n.suiCoinType, F, h);
|
|
452
|
-
const j = await
|
|
452
|
+
const j = await ue(o, c, k), N = await this.walletClient.swap.getQuote(
|
|
453
453
|
c.suiCoinType,
|
|
454
454
|
n.suiCoinType,
|
|
455
455
|
k
|
|
456
|
-
),
|
|
456
|
+
), me = await z(
|
|
457
457
|
s,
|
|
458
458
|
o,
|
|
459
459
|
d,
|
|
460
460
|
j,
|
|
461
461
|
N
|
|
462
|
-
),
|
|
462
|
+
), Ce = o.moveCall({
|
|
463
463
|
target: "0x2::coin::into_balance",
|
|
464
|
-
arguments: [
|
|
464
|
+
arguments: [me],
|
|
465
465
|
typeArguments: [n.suiCoinType]
|
|
466
|
-
}), [
|
|
466
|
+
}), [ye] = await ce(o, n, L, Ce), [be] = o.moveCall({
|
|
467
467
|
target: "0x2::coin::from_balance",
|
|
468
|
-
arguments: [
|
|
468
|
+
arguments: [ye],
|
|
469
469
|
typeArguments: [n.suiCoinType]
|
|
470
470
|
});
|
|
471
|
-
return o.transferObjects([
|
|
471
|
+
return o.transferObjects([be], s), o;
|
|
472
472
|
}
|
|
473
|
-
async function
|
|
473
|
+
async function ie(o, e, a, t) {
|
|
474
474
|
var w, f;
|
|
475
475
|
if (!this.walletClient)
|
|
476
476
|
throw new Error("Wallet client not found");
|
|
477
|
-
const s = await
|
|
477
|
+
const s = await le(this.walletClient.address, {
|
|
478
478
|
client: this.walletClient.client,
|
|
479
479
|
coinType: e
|
|
480
480
|
}), n = await this.getPool(a), i = new E(s).getBalance(e);
|
|
@@ -500,7 +500,7 @@ async function ne(o, e, a, t) {
|
|
|
500
500
|
}
|
|
501
501
|
return await I(o, n, r), o;
|
|
502
502
|
}
|
|
503
|
-
class
|
|
503
|
+
class $e {
|
|
504
504
|
constructor(e) {
|
|
505
505
|
this.name = "navi", this.walletClient = e;
|
|
506
506
|
}
|
|
@@ -518,13 +518,13 @@ class Me {
|
|
|
518
518
|
throw new Error("Not implemented");
|
|
519
519
|
}
|
|
520
520
|
async withdrawCoinPTB(e, a, t) {
|
|
521
|
-
return
|
|
521
|
+
return de(e, a, t);
|
|
522
522
|
}
|
|
523
523
|
async borrowCoinPTB(e, a, t) {
|
|
524
524
|
throw new Error("Not implemented");
|
|
525
525
|
}
|
|
526
526
|
async repayCoinPTB(e, a, t, s) {
|
|
527
|
-
|
|
527
|
+
we(e, a, t, { amount: s });
|
|
528
528
|
}
|
|
529
529
|
}
|
|
530
530
|
class H {
|
|
@@ -533,10 +533,10 @@ class H {
|
|
|
533
533
|
}
|
|
534
534
|
static async create(e) {
|
|
535
535
|
const [a, t] = await Promise.all([
|
|
536
|
-
|
|
537
|
-
|
|
536
|
+
te.initialize(je, ae, e.client),
|
|
537
|
+
te.getObligationOwnerCaps(
|
|
538
538
|
e.address,
|
|
539
|
-
[
|
|
539
|
+
[ae],
|
|
540
540
|
e.client
|
|
541
541
|
)
|
|
542
542
|
]);
|
|
@@ -554,12 +554,12 @@ class H {
|
|
|
554
554
|
g && s.add(C(g.coinType.name));
|
|
555
555
|
});
|
|
556
556
|
});
|
|
557
|
-
const n = await
|
|
557
|
+
const n = await Ie(Array.from(s)), i = t.map((d) => Ne(d, n)).reduce(
|
|
558
558
|
(d, g) => (d[g.coinType] = g, d),
|
|
559
559
|
{}
|
|
560
560
|
), l = await this.suilendClient.getObligation(
|
|
561
561
|
this.obligationOwnerCap.obligationId
|
|
562
|
-
), u =
|
|
562
|
+
), u = _e(l, i), r = u.deposits.find((d) => d.coinType === a), w = u.borrows.find((d) => d.coinType === a), f = n[a].decimals;
|
|
563
563
|
return {
|
|
564
564
|
cTokenExchangeRate: i[a].cTokenExchangeRate.toNumber(),
|
|
565
565
|
supplyBalance: (y = r == null ? void 0 : r.depositedAmount.shiftedBy(f).decimalPlaces(0).toNumber()) != null ? y : 0,
|
|
@@ -576,7 +576,7 @@ class H {
|
|
|
576
576
|
this.obligationOwnerCap.id,
|
|
577
577
|
this.obligationOwnerCap.obligationId,
|
|
578
578
|
a,
|
|
579
|
-
n ?
|
|
579
|
+
n ? Ue.toString() : Math.ceil(t / s.cTokenExchangeRate).toString(),
|
|
580
580
|
e
|
|
581
581
|
);
|
|
582
582
|
}
|
|
@@ -587,13 +587,13 @@ class H {
|
|
|
587
587
|
this.suilendClient.repay(this.obligationOwnerCap.obligationId, a, t, e), e.transferObjects([t], e.pure.address(this.walletClient.address));
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
|
-
class
|
|
590
|
+
class qe extends O {
|
|
591
591
|
constructor() {
|
|
592
592
|
super(), this.name = "lending", this.defaultConfig = {
|
|
593
593
|
env: "prod",
|
|
594
594
|
protocols: [],
|
|
595
595
|
aggregatorBaseUrl: "https://aggregator-api.naviprotocol.io"
|
|
596
|
-
}, this._protocols = [], this.migrateBetweenSupplyPTB =
|
|
596
|
+
}, this._protocols = [], this.migrateBetweenSupplyPTB = ne, this.migrateBetweenBorrowPTB = se, this.migrateBalanceToSupplyPTB = ie, this.migrateBetweenSupplyPTB = ne.bind(this), this.migrateBetweenBorrowPTB = se.bind(this), this.migrateBalanceToSupplyPTB = ie.bind(this);
|
|
597
597
|
}
|
|
598
598
|
/** Get protocols (either from internal storage or config) */
|
|
599
599
|
get protocols() {
|
|
@@ -609,7 +609,7 @@ class Le extends A {
|
|
|
609
609
|
* @returns Array of pool information
|
|
610
610
|
*/
|
|
611
611
|
async getPools(e) {
|
|
612
|
-
return await
|
|
612
|
+
return await ve({
|
|
613
613
|
env: this.config.env,
|
|
614
614
|
...e
|
|
615
615
|
});
|
|
@@ -677,7 +677,7 @@ class Le extends A {
|
|
|
677
677
|
env: this.config.env
|
|
678
678
|
}), n = new m();
|
|
679
679
|
t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
|
|
680
|
-
const c = await
|
|
680
|
+
const c = await de(n, s, a, {
|
|
681
681
|
env: this.config.env,
|
|
682
682
|
accountCap: t == null ? void 0 : t.accountCap
|
|
683
683
|
});
|
|
@@ -707,7 +707,7 @@ class Le extends A {
|
|
|
707
707
|
env: this.config.env
|
|
708
708
|
}), n = new m();
|
|
709
709
|
t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
|
|
710
|
-
const c = await
|
|
710
|
+
const c = await ue(n, s, a, {
|
|
711
711
|
env: this.config.env,
|
|
712
712
|
accountCap: t == null ? void 0 : t.accountCap
|
|
713
713
|
});
|
|
@@ -740,7 +740,7 @@ class Le extends A {
|
|
|
740
740
|
balance: a,
|
|
741
741
|
useGasCoin: !0
|
|
742
742
|
});
|
|
743
|
-
await
|
|
743
|
+
await we(n, s, i, {
|
|
744
744
|
env: this.config.env,
|
|
745
745
|
amount: a,
|
|
746
746
|
accountCap: t == null ? void 0 : t.accountCap
|
|
@@ -763,7 +763,7 @@ class Le extends A {
|
|
|
763
763
|
if (!this.walletClient)
|
|
764
764
|
throw new Error("Wallet client not found");
|
|
765
765
|
const e = this.walletClient.address;
|
|
766
|
-
return await
|
|
766
|
+
return await Ee(e, {
|
|
767
767
|
env: this.config.env,
|
|
768
768
|
client: this.walletClient.client
|
|
769
769
|
});
|
|
@@ -789,7 +789,7 @@ class Le extends A {
|
|
|
789
789
|
}), l = new m(), u = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), r = P(l, u.coins, {
|
|
790
790
|
balance: a,
|
|
791
791
|
useGasCoin: !0
|
|
792
|
-
}), [w, f] = await
|
|
792
|
+
}), [w, f] = await Re(
|
|
793
793
|
l,
|
|
794
794
|
c,
|
|
795
795
|
r,
|
|
@@ -829,7 +829,7 @@ class Le extends A {
|
|
|
829
829
|
async getAvailableRewards(e) {
|
|
830
830
|
if (!this.walletClient)
|
|
831
831
|
throw new Error("Wallet client not found");
|
|
832
|
-
return
|
|
832
|
+
return ee(this.walletClient.address, {
|
|
833
833
|
...e,
|
|
834
834
|
env: this.config.env
|
|
835
835
|
});
|
|
@@ -844,7 +844,7 @@ class Le extends A {
|
|
|
844
844
|
async getClaimedRewardHistory(e) {
|
|
845
845
|
if (!this.walletClient)
|
|
846
846
|
throw new Error("Wallet client not found");
|
|
847
|
-
return
|
|
847
|
+
return Se(this.walletClient.address, {
|
|
848
848
|
...e
|
|
849
849
|
});
|
|
850
850
|
}
|
|
@@ -858,10 +858,10 @@ class Le extends A {
|
|
|
858
858
|
var n, c, i;
|
|
859
859
|
if (!this.walletClient)
|
|
860
860
|
throw new Error("Wallet client not found");
|
|
861
|
-
const a = new m(), t = await
|
|
861
|
+
const a = new m(), t = await ee(this.walletClient.address, {
|
|
862
862
|
env: this.config.env
|
|
863
863
|
});
|
|
864
|
-
await
|
|
864
|
+
await Oe(a, t, {
|
|
865
865
|
env: this.config.env,
|
|
866
866
|
accountCap: e == null ? void 0 : e.accountCap
|
|
867
867
|
});
|
|
@@ -913,7 +913,7 @@ class Le extends A {
|
|
|
913
913
|
async getLendingState(e) {
|
|
914
914
|
if (!this.walletClient)
|
|
915
915
|
throw new Error("Wallet client not found");
|
|
916
|
-
return await
|
|
916
|
+
return await Ae(this.walletClient.address, {
|
|
917
917
|
env: this.config.env,
|
|
918
918
|
...e,
|
|
919
919
|
client: this.walletClient.client
|
|
@@ -929,7 +929,7 @@ class Le extends A {
|
|
|
929
929
|
var n;
|
|
930
930
|
if (!this.walletClient)
|
|
931
931
|
throw new Error("Wallet client not found");
|
|
932
|
-
const a = new m(), t = await
|
|
932
|
+
const a = new m(), t = await xe(a);
|
|
933
933
|
return a.transferObjects([t], this.walletClient.address), await this.walletClient.signExecuteTransaction({
|
|
934
934
|
transaction: a,
|
|
935
935
|
dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
|
|
@@ -941,7 +941,7 @@ class Le extends A {
|
|
|
941
941
|
return;
|
|
942
942
|
}
|
|
943
943
|
const e = [];
|
|
944
|
-
e.push(new
|
|
944
|
+
e.push(new $e(this.walletClient));
|
|
945
945
|
try {
|
|
946
946
|
e.push(await H.create(this.walletClient));
|
|
947
947
|
} catch (a) {
|
|
@@ -950,14 +950,14 @@ class Le extends A {
|
|
|
950
950
|
this._protocols = e;
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
|
-
class
|
|
953
|
+
class Ke extends O {
|
|
954
954
|
constructor() {
|
|
955
955
|
super(...arguments), this.name = "volo", this.defaultConfig = {
|
|
956
956
|
packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
|
|
957
957
|
poolId: "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5",
|
|
958
958
|
metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
|
|
959
959
|
coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
|
|
960
|
-
}, this.getStats =
|
|
960
|
+
}, this.getStats = he(
|
|
961
961
|
q(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
|
|
962
962
|
);
|
|
963
963
|
}
|
|
@@ -1058,7 +1058,7 @@ class $e extends A {
|
|
|
1058
1058
|
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
|
-
class
|
|
1061
|
+
class Qe extends O {
|
|
1062
1062
|
constructor() {
|
|
1063
1063
|
super(...arguments), this.name = "swap", this.defaultConfig = {
|
|
1064
1064
|
apiKey: "",
|
|
@@ -1075,7 +1075,7 @@ class qe extends A {
|
|
|
1075
1075
|
* @returns Referral ID if API key is configured, otherwise 0
|
|
1076
1076
|
*/
|
|
1077
1077
|
get referral() {
|
|
1078
|
-
return this.config.apiKey ?
|
|
1078
|
+
return this.config.apiKey ? ke(this.config.apiKey) : 0;
|
|
1079
1079
|
}
|
|
1080
1080
|
/**
|
|
1081
1081
|
* Get the swap options
|
|
@@ -1097,7 +1097,7 @@ class qe extends A {
|
|
|
1097
1097
|
* @returns A promise that resolves with the quote
|
|
1098
1098
|
*/
|
|
1099
1099
|
async getQuote(e, a, t) {
|
|
1100
|
-
return
|
|
1100
|
+
return Fe(e, a, t, this.config.apiKey, this.swapOptions);
|
|
1101
1101
|
}
|
|
1102
1102
|
/**
|
|
1103
1103
|
* Builds a swap transaction from a quote
|
|
@@ -1158,7 +1158,7 @@ class qe extends A {
|
|
|
1158
1158
|
client: this.walletClient.client
|
|
1159
1159
|
}), f = await this.walletClient.signer.signTransaction(w), h = [f.signature];
|
|
1160
1160
|
try {
|
|
1161
|
-
await
|
|
1161
|
+
await We(f.bytes, h);
|
|
1162
1162
|
} catch (p) {
|
|
1163
1163
|
console.error(p);
|
|
1164
1164
|
}
|
|
@@ -1184,13 +1184,13 @@ class qe extends A {
|
|
|
1184
1184
|
return y;
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
1187
|
-
class
|
|
1187
|
+
class Ge extends O {
|
|
1188
1188
|
constructor() {
|
|
1189
1189
|
super(...arguments), this.name = "haedal", this.defaultConfig = {
|
|
1190
1190
|
packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2",
|
|
1191
1191
|
configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
|
|
1192
1192
|
coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
1193
|
-
}, this.getApy =
|
|
1193
|
+
}, this.getApy = he(
|
|
1194
1194
|
q(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
|
|
1195
1195
|
);
|
|
1196
1196
|
}
|
|
@@ -1278,32 +1278,32 @@ class Ke extends A {
|
|
|
1278
1278
|
return !(a != null && a.dryRun) && ((r = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : r.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1279
1279
|
}
|
|
1280
1280
|
}
|
|
1281
|
-
const
|
|
1281
|
+
const ze = {
|
|
1282
1282
|
/** Balance management module */
|
|
1283
|
-
balance: new
|
|
1283
|
+
balance: new Le(),
|
|
1284
1284
|
/** Lending protocol module */
|
|
1285
|
-
lending: new
|
|
1285
|
+
lending: new qe(),
|
|
1286
1286
|
/** Volo protocol module */
|
|
1287
|
-
volo: new
|
|
1287
|
+
volo: new Ke(),
|
|
1288
1288
|
/** DEX swapping module */
|
|
1289
|
-
swap: new
|
|
1289
|
+
swap: new Qe(),
|
|
1290
1290
|
/** Haedal protocol module */
|
|
1291
|
-
haedal: new
|
|
1292
|
-
},
|
|
1293
|
-
url:
|
|
1291
|
+
haedal: new Ge()
|
|
1292
|
+
}, He = {
|
|
1293
|
+
url: pe("mainnet")
|
|
1294
1294
|
};
|
|
1295
|
-
class
|
|
1295
|
+
class lt {
|
|
1296
1296
|
/**
|
|
1297
1297
|
* Creates a new wallet client instance
|
|
1298
1298
|
* @param options - Configuration options for the wallet client
|
|
1299
1299
|
*/
|
|
1300
1300
|
constructor(e) {
|
|
1301
|
-
this.modules =
|
|
1301
|
+
this.modules = ze, this.userConfigs = {}, this.events = Be();
|
|
1302
1302
|
const a = {
|
|
1303
|
-
...
|
|
1303
|
+
...He,
|
|
1304
1304
|
...e.client
|
|
1305
1305
|
};
|
|
1306
|
-
a.transport = a.transport || new
|
|
1306
|
+
a.transport = a.transport || new Me(a.url), this.client = new Pe(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, s]) => {
|
|
1307
1307
|
if (t !== s.name)
|
|
1308
1308
|
throw new Error(`Module name ${t} does not match module name ${s.name}`);
|
|
1309
1309
|
s.install(this);
|
|
@@ -1379,7 +1379,7 @@ class st {
|
|
|
1379
1379
|
return e in this.modules;
|
|
1380
1380
|
}
|
|
1381
1381
|
}
|
|
1382
|
-
class
|
|
1382
|
+
class rt extends fe {
|
|
1383
1383
|
/**
|
|
1384
1384
|
* Creates a new watch-only signer
|
|
1385
1385
|
*
|
|
@@ -1443,7 +1443,7 @@ class it extends we {
|
|
|
1443
1443
|
return {};
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
|
-
class
|
|
1446
|
+
class ot extends fe {
|
|
1447
1447
|
/**
|
|
1448
1448
|
* Creates a new watch-only signer
|
|
1449
1449
|
*
|
|
@@ -1496,8 +1496,8 @@ class lt extends we {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
}
|
|
1498
1498
|
export {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1499
|
+
lt as WalletClient,
|
|
1500
|
+
rt as WatchSigner,
|
|
1501
|
+
ot as WebSigner
|
|
1502
1502
|
};
|
|
1503
1503
|
//# sourceMappingURL=index.esm.js.map
|