@naviprotocol/wallet-client 1.4.1 → 1.4.3-dev.1
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 +213 -204
- package/dist/index.esm.js.map +1 -1
- package/dist/modules/lendingModule/migrate.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getFullnodeUrl as we, SuiClient as he } from "@mysten/sui/client";
|
|
2
2
|
import fe from "mitt";
|
|
3
3
|
import ge from "axios";
|
|
4
|
-
import { withSingleton as
|
|
5
|
-
import R, { BigNumber as
|
|
4
|
+
import { withSingleton as K, getCoins as te, mergeCoinsPTB as B, getPriceFeeds as $, updateOraclePricesPTB as q, filterPriceFeeds as G, depositCoinPTB as A, getFlashLoanAsset as ae, flashloanPTB as ne, repayFlashLoanPTB as se, borrowCoinPTB as ie, withdrawCoinPTB as le, repayCoinPTB as re, getPools as me, getPool as T, getHealthFactor as Ce, liquidatePTB as be, getUserAvailableLendingRewards as J, getUserClaimedRewardHistory as ye, claimLendingRewardsPTB as pe, getLendingState as Pe, createAccountCapPTB as Be, withCache as oe, parseTxValue as _ } from "@naviprotocol/lending";
|
|
5
|
+
import R, { BigNumber as Q } from "bignumber.js";
|
|
6
6
|
import { normalizeStructTag as p } from "@mysten/sui/utils";
|
|
7
7
|
import { Transaction as m } from "@mysten/sui/transactions";
|
|
8
|
-
import { buildSwapPTBFromQuote as
|
|
8
|
+
import { buildSwapPTBFromQuote as z, generateRefId as Te, getQuote as ve } from "@naviprotocol/astros-aggregator-sdk";
|
|
9
9
|
import { SuilendClient as V, LENDING_MARKET_ID as Ee, LENDING_MARKET_TYPE as X, parseReserve as Re, parseObligation as Se } from "@suilend/sdk";
|
|
10
10
|
import { getCoinMetadataMap as Oe, MAX_U64 as Ae } from "@suilend/sui-fe";
|
|
11
11
|
import { executeAuction as xe } from "shio-sdk";
|
|
@@ -14,15 +14,15 @@ const ue = ge.create({
|
|
|
14
14
|
timeout: 2e4
|
|
15
15
|
});
|
|
16
16
|
ue.interceptors.response.use(
|
|
17
|
-
function(
|
|
18
|
-
if (
|
|
19
|
-
throw new Error(
|
|
20
|
-
if (
|
|
21
|
-
throw new Error(
|
|
22
|
-
return
|
|
17
|
+
function(l) {
|
|
18
|
+
if (l.data.err)
|
|
19
|
+
throw new Error(l.data.err);
|
|
20
|
+
if (l.data.error)
|
|
21
|
+
throw new Error(l.data.error.message);
|
|
22
|
+
return l;
|
|
23
23
|
},
|
|
24
|
-
function(
|
|
25
|
-
return Promise.reject(
|
|
24
|
+
function(l) {
|
|
25
|
+
return Promise.reject(l);
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
28
|
class ke {
|
|
@@ -64,7 +64,7 @@ class ke {
|
|
|
64
64
|
throw new Error("subscribe not implemented.");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class x {
|
|
68
68
|
/**
|
|
69
69
|
* Gets the current configuration for this module
|
|
70
70
|
*
|
|
@@ -123,7 +123,7 @@ class S {
|
|
|
123
123
|
let n = a[s];
|
|
124
124
|
n || (n = {
|
|
125
125
|
coinType: s,
|
|
126
|
-
amount:
|
|
126
|
+
amount: Q(0),
|
|
127
127
|
coins: []
|
|
128
128
|
}, a[s] = n), n.coins.push(t), n.amount = n.amount.plus(t.balance);
|
|
129
129
|
}), this.balances = a;
|
|
@@ -136,7 +136,7 @@ class S {
|
|
|
136
136
|
* @returns UserCoinBalance object with coin type, total amount, and coin objects
|
|
137
137
|
*/
|
|
138
138
|
getBalance(e) {
|
|
139
|
-
return e = p(e), this.balances[e] || { coinType: e, amount:
|
|
139
|
+
return e = p(e), this.balances[e] || { coinType: e, amount: Q(0), coins: [] };
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Gets all coin types in the portfolio
|
|
@@ -155,7 +155,7 @@ class S {
|
|
|
155
155
|
balanceOf(e) {
|
|
156
156
|
e = p(e);
|
|
157
157
|
const a = this.getBalance(e);
|
|
158
|
-
return (a == null ? void 0 : a.amount) ||
|
|
158
|
+
return (a == null ? void 0 : a.amount) || Q(0);
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* Creates a deep copy of the portfolio
|
|
@@ -170,12 +170,12 @@ class S {
|
|
|
170
170
|
return a.balances = e, a;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
class Ne extends
|
|
173
|
+
class Ne extends x {
|
|
174
174
|
constructor() {
|
|
175
175
|
super(...arguments), this.name = "balance", this.defaultConfig = {
|
|
176
176
|
coinPollingInterval: 6e3,
|
|
177
177
|
disableCoinPolling: !1
|
|
178
|
-
}, this.updatePortfolio =
|
|
178
|
+
}, this.updatePortfolio = K(async () => {
|
|
179
179
|
if (!this.walletClient)
|
|
180
180
|
throw new Error("Wallet client not found");
|
|
181
181
|
this._coins = await te(this.walletClient.address, {
|
|
@@ -238,17 +238,17 @@ class Ne extends A {
|
|
|
238
238
|
if (a.length !== t.length)
|
|
239
239
|
throw new Error("Recipients and amounts must have the same length");
|
|
240
240
|
await this.waitForUpdate();
|
|
241
|
-
const n = this.portfolio.getBalance(e),
|
|
242
|
-
if (n.amount.lt(
|
|
241
|
+
const n = this.portfolio.getBalance(e), u = t.reduce((h, f) => h.plus(f), R(0));
|
|
242
|
+
if (n.amount.lt(u))
|
|
243
243
|
throw new Error("Insufficient balance");
|
|
244
244
|
const i = new m();
|
|
245
|
-
let
|
|
246
|
-
p(e) !== p("0x2::sui::SUI") && (
|
|
247
|
-
balance:
|
|
245
|
+
let r = i.gas;
|
|
246
|
+
p(e) !== p("0x2::sui::SUI") && (r = B(i, n.coins, {
|
|
247
|
+
balance: u.toNumber()
|
|
248
248
|
}));
|
|
249
|
-
const
|
|
250
|
-
return a.forEach((
|
|
251
|
-
i.transferObjects([
|
|
249
|
+
const c = i.splitCoins(r, t);
|
|
250
|
+
return a.forEach((h, f) => {
|
|
251
|
+
i.transferObjects([c[f]], h);
|
|
252
252
|
}), await this.walletClient.signExecuteTransaction({
|
|
253
253
|
transaction: i,
|
|
254
254
|
dryRun: (w = s == null ? void 0 : s.dryRun) != null ? w : !1
|
|
@@ -277,18 +277,18 @@ class Ne extends A {
|
|
|
277
277
|
* @returns Transaction response or dry run response
|
|
278
278
|
*/
|
|
279
279
|
async transferObjectBatch(e, a, t) {
|
|
280
|
-
var
|
|
280
|
+
var u;
|
|
281
281
|
if (!this.walletClient)
|
|
282
282
|
throw new Error("Wallet client not found");
|
|
283
283
|
if (e.length !== a.length)
|
|
284
284
|
throw new Error("Objects and recipients must have the same length");
|
|
285
285
|
await this.waitForUpdate();
|
|
286
286
|
const s = new m();
|
|
287
|
-
return e.forEach((i,
|
|
288
|
-
s.transferObjects([s.object(i)], a[
|
|
287
|
+
return e.forEach((i, r) => {
|
|
288
|
+
s.transferObjects([s.object(i)], a[r]);
|
|
289
289
|
}), await this.walletClient.signExecuteTransaction({
|
|
290
290
|
transaction: s,
|
|
291
|
-
dryRun: (
|
|
291
|
+
dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
294
|
/**
|
|
@@ -329,95 +329,104 @@ class Ne extends A {
|
|
|
329
329
|
super.uninstall(), this.pollingTimer && (clearTimeout(this.pollingTimer), this.pollingTimer = null);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
async function Y(
|
|
333
|
-
var
|
|
332
|
+
async function Y(l, e, a, t) {
|
|
333
|
+
var k, N, O;
|
|
334
334
|
if (!this.walletClient)
|
|
335
335
|
throw new Error("Wallet client not found");
|
|
336
|
-
const s = await this.getPool(e), n = await this.getPool(a),
|
|
337
|
-
if (!
|
|
338
|
-
throw new Error(`Protocol ${
|
|
339
|
-
const
|
|
336
|
+
const s = await this.getPool(e), n = await this.getPool(a), u = await this.getLendingState(), i = this.walletClient.address, r = (k = t == null ? void 0 : t.protocol) != null ? k : "navi", c = await this.getProtocol(r);
|
|
337
|
+
if (!c)
|
|
338
|
+
throw new Error(`Protocol ${r} not found`);
|
|
339
|
+
const o = await c.getPool(s.coinType);
|
|
340
340
|
if (console.log("migrateBetweenSupplyPTB", {
|
|
341
|
-
fromPoolLending:
|
|
342
|
-
}),
|
|
341
|
+
fromPoolLending: o
|
|
342
|
+
}), r === "navi" && o.supplyBalance === 0)
|
|
343
343
|
throw new Error("No supply balance");
|
|
344
|
-
if (t != null && t.amount && t.amount >
|
|
344
|
+
if (t != null && t.amount && t.amount > o.supplyBalance)
|
|
345
345
|
throw new Error("Amount is less than supply balance");
|
|
346
|
-
const w = await
|
|
347
|
-
await
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
lendingState:
|
|
351
|
-
pools:
|
|
346
|
+
const w = (N = t == null ? void 0 : t.slippage) != null ? N : 5e-3, h = (O = t == null ? void 0 : t.amount) != null ? O : Number(o.supplyBalance), f = await $(), b = await Promise.all([s, n]);
|
|
347
|
+
if (await q(
|
|
348
|
+
l,
|
|
349
|
+
G(f, {
|
|
350
|
+
lendingState: u,
|
|
351
|
+
pools: b
|
|
352
352
|
})
|
|
353
|
-
)
|
|
354
|
-
|
|
353
|
+
), r !== "navi" && s.id === n.id) {
|
|
354
|
+
const F = await c.withdrawCoinPTB(
|
|
355
|
+
l,
|
|
356
|
+
s.suiCoinType,
|
|
357
|
+
h
|
|
358
|
+
);
|
|
359
|
+
return await A(l, n, F, {
|
|
360
|
+
amount: h
|
|
361
|
+
}), l;
|
|
362
|
+
}
|
|
363
|
+
const y = await ae(n, {
|
|
355
364
|
env: this.config.env
|
|
356
365
|
});
|
|
357
|
-
if (!
|
|
366
|
+
if (!y)
|
|
358
367
|
throw new Error(`${n.token.symbol} pool not support flashloan`);
|
|
359
|
-
const
|
|
368
|
+
const d = await this.walletClient.swap.getQuote(
|
|
360
369
|
s.suiCoinType,
|
|
361
370
|
n.suiCoinType,
|
|
362
|
-
|
|
363
|
-
),
|
|
364
|
-
if (
|
|
371
|
+
h
|
|
372
|
+
), g = Number(d.amount_out);
|
|
373
|
+
if (g <= 0)
|
|
365
374
|
throw new Error("The amount of swapAmountOut must be greater than 0.");
|
|
366
|
-
const C = Math.floor(
|
|
375
|
+
const C = Math.floor(g * (1 - w)), P = Math.floor(C / (1 + y.flashloanFee));
|
|
367
376
|
if (P <= 0)
|
|
368
377
|
throw new Error("The calculated borrow amount must be positive.");
|
|
369
|
-
const [v, E] = await ne(
|
|
378
|
+
const [v, E] = await ne(l, n, P), [j] = l.moveCall({
|
|
370
379
|
target: "0x2::coin::from_balance",
|
|
371
380
|
arguments: [v],
|
|
372
381
|
typeArguments: [n.suiCoinType]
|
|
373
382
|
});
|
|
374
|
-
await
|
|
383
|
+
await A(l, n, j, {
|
|
375
384
|
amount: P
|
|
376
385
|
});
|
|
377
|
-
const
|
|
386
|
+
const I = await c.withdrawCoinPTB(l, s.suiCoinType, h), U = await z(
|
|
378
387
|
i,
|
|
379
|
-
|
|
388
|
+
l,
|
|
380
389
|
C,
|
|
381
|
-
|
|
390
|
+
I,
|
|
382
391
|
d
|
|
383
|
-
),
|
|
392
|
+
), M = l.moveCall({
|
|
384
393
|
target: "0x2::coin::into_balance",
|
|
385
|
-
arguments: [
|
|
394
|
+
arguments: [U],
|
|
386
395
|
typeArguments: [n.suiCoinType]
|
|
387
|
-
}), [
|
|
396
|
+
}), [W] = await se(l, n, E, M), [L] = l.moveCall({
|
|
388
397
|
target: "0x2::coin::from_balance",
|
|
389
|
-
arguments: [
|
|
398
|
+
arguments: [W],
|
|
390
399
|
typeArguments: [n.suiCoinType]
|
|
391
400
|
});
|
|
392
|
-
return await
|
|
401
|
+
return await A(l, n, L), l;
|
|
393
402
|
}
|
|
394
|
-
async function Z(
|
|
395
|
-
var O,
|
|
403
|
+
async function Z(l, e, a, t) {
|
|
404
|
+
var O, F, D;
|
|
396
405
|
if (!this.walletClient)
|
|
397
406
|
throw new Error("Wallet client not found");
|
|
398
|
-
const s = this.walletClient.address, n = await this.getPool(e),
|
|
399
|
-
if (!
|
|
400
|
-
throw new Error(`Protocol ${
|
|
401
|
-
const
|
|
407
|
+
const s = this.walletClient.address, n = await this.getPool(e), u = await this.getPool(a), i = await this.getLendingState(), r = (O = t == null ? void 0 : t.protocol) != null ? O : "navi", c = await this.getProtocol(r);
|
|
408
|
+
if (!c)
|
|
409
|
+
throw new Error(`Protocol ${r} not found`);
|
|
410
|
+
const o = await c.getPool(n.coinType);
|
|
402
411
|
if (console.log("migrateBetweenBorrowPTB", {
|
|
403
|
-
fromPoolLending:
|
|
404
|
-
}),
|
|
412
|
+
fromPoolLending: o
|
|
413
|
+
}), o.borrowBalance === 0)
|
|
405
414
|
throw new Error("No borrow balance");
|
|
406
|
-
if (t != null && t.amount && t.amount >
|
|
415
|
+
if (t != null && t.amount && t.amount > o.borrowBalance)
|
|
407
416
|
throw new Error("Amount is more than borrow balance");
|
|
408
|
-
const w = await
|
|
409
|
-
await
|
|
410
|
-
|
|
411
|
-
|
|
417
|
+
const w = await $(), h = await Promise.all([n, u]);
|
|
418
|
+
await q(
|
|
419
|
+
l,
|
|
420
|
+
G(w, {
|
|
412
421
|
lendingState: i,
|
|
413
|
-
pools:
|
|
422
|
+
pools: h
|
|
414
423
|
})
|
|
415
424
|
);
|
|
416
|
-
let
|
|
417
|
-
if (Number(
|
|
418
|
-
const de =
|
|
419
|
-
|
|
420
|
-
new R(
|
|
425
|
+
let f = (F = t == null ? void 0 : t.amount) != null ? F : Number(o.borrowBalance);
|
|
426
|
+
if (Number(o.borrowBalance) === f) {
|
|
427
|
+
const de = o.borrowAPR / 100;
|
|
428
|
+
f = Math.ceil(
|
|
429
|
+
new R(f).multipliedBy(de * (60 * 3) / (365 * 24 * 3600)).plus(new R(1).shiftedBy(-n.token.decimals)).plus(f).toNumber()
|
|
421
430
|
);
|
|
422
431
|
}
|
|
423
432
|
const b = await ae(n, {
|
|
@@ -427,47 +436,47 @@ async function Z(o, e, a, t) {
|
|
|
427
436
|
throw new Error(`${n.token.symbol} pool not support flashloan`);
|
|
428
437
|
if (!this.walletClient)
|
|
429
438
|
throw new Error("Wallet client not found");
|
|
430
|
-
const y = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, d = Math.ceil(
|
|
439
|
+
const y = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, d = Math.ceil(f * (1 + b.flashloanFee)), g = d, C = await this.walletClient.swap.getQuote(
|
|
431
440
|
n.suiCoinType,
|
|
432
|
-
|
|
433
|
-
|
|
441
|
+
u.suiCoinType,
|
|
442
|
+
g
|
|
434
443
|
);
|
|
435
444
|
let P = 1 + y, v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
|
|
436
|
-
|
|
445
|
+
u.suiCoinType,
|
|
437
446
|
n.suiCoinType,
|
|
438
447
|
v
|
|
439
448
|
);
|
|
440
|
-
for (; Number(E.amount_out) <
|
|
441
|
-
P = P * Math.max(
|
|
442
|
-
|
|
449
|
+
for (; Number(E.amount_out) < g; )
|
|
450
|
+
P = P * Math.max(g / Number(E.amount_out), 1.001), v = Math.ceil(Number(C.amount_out) * P), E = await this.walletClient.swap.getQuote(
|
|
451
|
+
u.suiCoinType,
|
|
443
452
|
n.suiCoinType,
|
|
444
453
|
v
|
|
445
454
|
);
|
|
446
|
-
const [
|
|
455
|
+
const [j, I] = await ne(l, n, f), [U] = l.moveCall({
|
|
447
456
|
target: "0x2::coin::from_balance",
|
|
448
|
-
arguments: [
|
|
457
|
+
arguments: [j],
|
|
449
458
|
typeArguments: [n.suiCoinType]
|
|
450
459
|
});
|
|
451
|
-
await
|
|
452
|
-
const
|
|
460
|
+
await c.repayCoinPTB(l, n.suiCoinType, U, f);
|
|
461
|
+
const M = await ie(l, u, v), W = await z(
|
|
453
462
|
s,
|
|
454
|
-
|
|
463
|
+
l,
|
|
455
464
|
d,
|
|
456
|
-
|
|
465
|
+
M,
|
|
457
466
|
E
|
|
458
|
-
),
|
|
467
|
+
), L = l.moveCall({
|
|
459
468
|
target: "0x2::coin::into_balance",
|
|
460
|
-
arguments: [
|
|
469
|
+
arguments: [W],
|
|
461
470
|
typeArguments: [n.suiCoinType]
|
|
462
|
-
}), [
|
|
471
|
+
}), [k] = await se(l, n, I, L), [N] = l.moveCall({
|
|
463
472
|
target: "0x2::coin::from_balance",
|
|
464
|
-
arguments: [
|
|
473
|
+
arguments: [k],
|
|
465
474
|
typeArguments: [n.suiCoinType]
|
|
466
475
|
});
|
|
467
|
-
return
|
|
476
|
+
return l.transferObjects([N], s), l;
|
|
468
477
|
}
|
|
469
|
-
async function ee(
|
|
470
|
-
var w,
|
|
478
|
+
async function ee(l, e, a, t) {
|
|
479
|
+
var w, h;
|
|
471
480
|
if (!this.walletClient)
|
|
472
481
|
throw new Error("Wallet client not found");
|
|
473
482
|
const s = await te(this.walletClient.address, {
|
|
@@ -480,33 +489,33 @@ async function ee(o, e, a, t) {
|
|
|
480
489
|
balance: i.amount.toNumber()
|
|
481
490
|
}), t != null && t.amount && i.amount.lt(t.amount))
|
|
482
491
|
throw new Error("Amount is greater than balance");
|
|
483
|
-
const
|
|
484
|
-
let
|
|
485
|
-
balance:
|
|
492
|
+
const r = (w = t == null ? void 0 : t.amount) != null ? w : i.amount.toNumber(), c = (h = t == null ? void 0 : t.slippage) != null ? h : 5e-3;
|
|
493
|
+
let o = await B(l, i.coins, {
|
|
494
|
+
balance: r,
|
|
486
495
|
useGasCoin: !0
|
|
487
496
|
});
|
|
488
497
|
if (p(e) !== p(n.suiCoinType)) {
|
|
489
|
-
const
|
|
490
|
-
|
|
498
|
+
const f = await this.walletClient.swap.getQuote(e, n.suiCoinType, r);
|
|
499
|
+
o = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
500
|
+
l,
|
|
501
|
+
f,
|
|
491
502
|
o,
|
|
492
|
-
|
|
493
|
-
r,
|
|
494
|
-
u
|
|
503
|
+
c
|
|
495
504
|
);
|
|
496
505
|
}
|
|
497
|
-
return await
|
|
506
|
+
return await A(l, n, o), l;
|
|
498
507
|
}
|
|
499
|
-
class
|
|
508
|
+
class Fe {
|
|
500
509
|
constructor(e) {
|
|
501
510
|
this.name = "navi", this.walletClient = e;
|
|
502
511
|
}
|
|
503
512
|
async getPool(e) {
|
|
504
513
|
const a = await this.walletClient.lending.getPool(e), s = (await this.walletClient.lending.getLendingState()).find(
|
|
505
514
|
(i) => i.pool.suiCoinType === p(e)
|
|
506
|
-
), n = s ? new R(s.supplyBalance).toNumber() : 0,
|
|
515
|
+
), n = s ? new R(s.supplyBalance).toNumber() : 0, u = s ? new R(s.borrowBalance).toNumber() : 0;
|
|
507
516
|
return {
|
|
508
517
|
supplyBalance: n,
|
|
509
|
-
borrowBalance:
|
|
518
|
+
borrowBalance: u,
|
|
510
519
|
borrowAPR: parseFloat(a.borrowIncentiveApyInfo.apy)
|
|
511
520
|
};
|
|
512
521
|
}
|
|
@@ -523,7 +532,7 @@ class _e {
|
|
|
523
532
|
re(e, a, t, { amount: s });
|
|
524
533
|
}
|
|
525
534
|
}
|
|
526
|
-
class
|
|
535
|
+
class H {
|
|
527
536
|
constructor(e, a, t) {
|
|
528
537
|
this.name = "suilend", this.walletClient = e, this.obligationOwnerCap = a, this.suilendClient = t;
|
|
529
538
|
}
|
|
@@ -538,28 +547,28 @@ class z {
|
|
|
538
547
|
]);
|
|
539
548
|
if (t.length === 0)
|
|
540
549
|
throw new Error("No existing obligations found for wallet address: " + e.address);
|
|
541
|
-
return new
|
|
550
|
+
return new H(e, t[0], a);
|
|
542
551
|
}
|
|
543
552
|
async getPool(e) {
|
|
544
553
|
var b, y;
|
|
545
554
|
const a = p(e), t = this.suilendClient.lendingMarket.reserves, s = /* @__PURE__ */ new Set();
|
|
546
555
|
t.forEach((d) => {
|
|
547
|
-
s.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((
|
|
548
|
-
|
|
549
|
-
}), d.borrowsPoolRewardManager.poolRewards.forEach((
|
|
550
|
-
|
|
556
|
+
s.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((g) => {
|
|
557
|
+
g && s.add(p(g.coinType.name));
|
|
558
|
+
}), d.borrowsPoolRewardManager.poolRewards.forEach((g) => {
|
|
559
|
+
g && s.add(p(g.coinType.name));
|
|
551
560
|
});
|
|
552
561
|
});
|
|
553
562
|
const n = await Oe(Array.from(s)), i = t.map((d) => Re(d, n)).reduce(
|
|
554
|
-
(d,
|
|
563
|
+
(d, g) => (d[g.coinType] = g, d),
|
|
555
564
|
{}
|
|
556
|
-
),
|
|
565
|
+
), r = await this.suilendClient.getObligation(
|
|
557
566
|
this.obligationOwnerCap.obligationId
|
|
558
|
-
),
|
|
567
|
+
), c = Se(r, i), o = c.deposits.find((d) => d.coinType === a), w = c.borrows.find((d) => d.coinType === a), h = n[a].decimals;
|
|
559
568
|
return {
|
|
560
569
|
cTokenExchangeRate: i[a].cTokenExchangeRate.toNumber(),
|
|
561
|
-
supplyBalance: (b =
|
|
562
|
-
borrowBalance: (y = w == null ? void 0 : w.borrowedAmount.shiftedBy(
|
|
570
|
+
supplyBalance: (b = o == null ? void 0 : o.depositedAmount.shiftedBy(h).decimalPlaces(0).toNumber()) != null ? b : 0,
|
|
571
|
+
borrowBalance: (y = w == null ? void 0 : w.borrowedAmount.shiftedBy(h).decimalPlaces(0).toNumber()) != null ? y : 0,
|
|
563
572
|
borrowAPR: i[a].borrowAprPercent.toNumber()
|
|
564
573
|
};
|
|
565
574
|
}
|
|
@@ -583,7 +592,7 @@ class z {
|
|
|
583
592
|
this.suilendClient.repay(this.obligationOwnerCap.obligationId, a, t, e), e.transferObjects([t], e.pure.address(this.walletClient.address));
|
|
584
593
|
}
|
|
585
594
|
}
|
|
586
|
-
class
|
|
595
|
+
class _e extends x {
|
|
587
596
|
constructor() {
|
|
588
597
|
super(), this.name = "lending", this.defaultConfig = {
|
|
589
598
|
env: "prod",
|
|
@@ -631,30 +640,30 @@ class Fe extends A {
|
|
|
631
640
|
* @returns Transaction response or dry run response
|
|
632
641
|
*/
|
|
633
642
|
async deposit(e, a, t) {
|
|
634
|
-
var
|
|
643
|
+
var c, o, w;
|
|
635
644
|
if (!this.walletClient)
|
|
636
645
|
throw new Error("Wallet client not found");
|
|
637
646
|
const s = await T(e, {
|
|
638
647
|
env: this.config.env
|
|
639
648
|
});
|
|
640
649
|
await this.walletClient.module("balance").waitForUpdate();
|
|
641
|
-
const n = new m(),
|
|
650
|
+
const n = new m(), u = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, u.coins, {
|
|
642
651
|
balance: a,
|
|
643
652
|
useGasCoin: !0
|
|
644
653
|
});
|
|
645
|
-
await
|
|
654
|
+
await A(n, s, i, {
|
|
646
655
|
env: this.config.env,
|
|
647
656
|
amount: a,
|
|
648
657
|
accountCap: t == null ? void 0 : t.accountCap
|
|
649
658
|
});
|
|
650
|
-
const
|
|
659
|
+
const r = await this.walletClient.signExecuteTransaction({
|
|
651
660
|
transaction: n,
|
|
652
|
-
dryRun: (
|
|
661
|
+
dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
|
|
653
662
|
});
|
|
654
|
-
return !(t != null && t.dryRun) && ((w = (
|
|
663
|
+
return !(t != null && t.dryRun) && ((w = (o = r.effects) == null ? void 0 : o.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:deposit-success", {
|
|
655
664
|
identifier: e,
|
|
656
665
|
amount: a
|
|
657
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
666
|
+
}), this.walletClient.module("balance").updatePortfolio()), r;
|
|
658
667
|
}
|
|
659
668
|
/**
|
|
660
669
|
* Withdraws coins from a lending pool
|
|
@@ -665,23 +674,23 @@ class Fe extends A {
|
|
|
665
674
|
* @returns Transaction response or dry run response
|
|
666
675
|
*/
|
|
667
676
|
async withdraw(e, a, t) {
|
|
668
|
-
var
|
|
677
|
+
var r, c, o;
|
|
669
678
|
if (!this.walletClient)
|
|
670
679
|
throw new Error("Wallet client not found");
|
|
671
680
|
const s = await T(e, {
|
|
672
681
|
env: this.config.env
|
|
673
682
|
}), n = new m();
|
|
674
683
|
t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
|
|
675
|
-
const
|
|
684
|
+
const u = await le(n, s, a, {
|
|
676
685
|
env: this.config.env,
|
|
677
686
|
accountCap: t == null ? void 0 : t.accountCap
|
|
678
687
|
});
|
|
679
|
-
n.transferObjects([
|
|
688
|
+
n.transferObjects([u], this.walletClient.address);
|
|
680
689
|
const i = await this.walletClient.signExecuteTransaction({
|
|
681
690
|
transaction: n,
|
|
682
|
-
dryRun: (
|
|
691
|
+
dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
|
|
683
692
|
});
|
|
684
|
-
return !(t != null && t.dryRun) && ((
|
|
693
|
+
return !(t != null && t.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:withdraw-success", {
|
|
685
694
|
identifier: e,
|
|
686
695
|
amount: a
|
|
687
696
|
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
@@ -695,23 +704,23 @@ class Fe extends A {
|
|
|
695
704
|
* @returns Transaction response or dry run response
|
|
696
705
|
*/
|
|
697
706
|
async borrow(e, a, t) {
|
|
698
|
-
var
|
|
707
|
+
var r, c, o;
|
|
699
708
|
if (!this.walletClient)
|
|
700
709
|
throw new Error("Wallet client not found");
|
|
701
710
|
const s = await T(e, {
|
|
702
711
|
env: this.config.env
|
|
703
712
|
}), n = new m();
|
|
704
713
|
t != null && t.disableUpdateOracle || await this.updateOraclePTB(n, [s]);
|
|
705
|
-
const
|
|
714
|
+
const u = await ie(n, s, a, {
|
|
706
715
|
env: this.config.env,
|
|
707
716
|
accountCap: t == null ? void 0 : t.accountCap
|
|
708
717
|
});
|
|
709
|
-
n.transferObjects([
|
|
718
|
+
n.transferObjects([u], this.walletClient.address);
|
|
710
719
|
const i = await this.walletClient.signExecuteTransaction({
|
|
711
720
|
transaction: n,
|
|
712
|
-
dryRun: (
|
|
721
|
+
dryRun: (r = t == null ? void 0 : t.dryRun) != null ? r : !1
|
|
713
722
|
});
|
|
714
|
-
return !(t != null && t.dryRun) && ((
|
|
723
|
+
return !(t != null && t.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("lending:borrow-success", {
|
|
715
724
|
identifier: e,
|
|
716
725
|
amount: a
|
|
717
726
|
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
@@ -725,13 +734,13 @@ class Fe extends A {
|
|
|
725
734
|
* @returns Transaction response or dry run response
|
|
726
735
|
*/
|
|
727
736
|
async repay(e, a, t) {
|
|
728
|
-
var
|
|
737
|
+
var c, o, w;
|
|
729
738
|
if (!this.walletClient)
|
|
730
739
|
throw new Error("Wallet client not found");
|
|
731
740
|
await this.walletClient.module("balance").waitForUpdate();
|
|
732
741
|
const s = await T(e, {
|
|
733
742
|
env: this.config.env
|
|
734
|
-
}), n = new m(),
|
|
743
|
+
}), n = new m(), u = this.walletClient.module("balance").portfolio.getBalance(s.suiCoinType), i = B(n, u.coins, {
|
|
735
744
|
balance: a,
|
|
736
745
|
useGasCoin: !0
|
|
737
746
|
});
|
|
@@ -740,14 +749,14 @@ class Fe extends A {
|
|
|
740
749
|
amount: a,
|
|
741
750
|
accountCap: t == null ? void 0 : t.accountCap
|
|
742
751
|
});
|
|
743
|
-
const
|
|
752
|
+
const r = await this.walletClient.signExecuteTransaction({
|
|
744
753
|
transaction: n,
|
|
745
|
-
dryRun: (
|
|
754
|
+
dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
|
|
746
755
|
});
|
|
747
|
-
return !(t != null && t.dryRun) && ((w = (
|
|
756
|
+
return !(t != null && t.dryRun) && ((w = (o = r.effects) == null ? void 0 : o.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:repay-success", {
|
|
748
757
|
identifier: e,
|
|
749
758
|
amount: a
|
|
750
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
759
|
+
}), this.walletClient.module("balance").updatePortfolio()), r;
|
|
751
760
|
}
|
|
752
761
|
/**
|
|
753
762
|
* Gets the current health factor for the user
|
|
@@ -774,40 +783,40 @@ class Fe extends A {
|
|
|
774
783
|
* @returns Transaction response or dry run response
|
|
775
784
|
*/
|
|
776
785
|
async liquidate(e, a, t, s, n) {
|
|
777
|
-
var d,
|
|
786
|
+
var d, g, C;
|
|
778
787
|
if (!this.walletClient)
|
|
779
788
|
throw new Error("Wallet client not found");
|
|
780
|
-
const
|
|
789
|
+
const u = await T(e, {
|
|
781
790
|
env: this.config.env
|
|
782
791
|
}), i = await T(t, {
|
|
783
792
|
env: this.config.env
|
|
784
|
-
}),
|
|
793
|
+
}), r = new m(), c = this.walletClient.module("balance").portfolio.getBalance(u.suiCoinType), o = B(r, c.coins, {
|
|
785
794
|
balance: a,
|
|
786
795
|
useGasCoin: !0
|
|
787
|
-
}), [w,
|
|
788
|
-
l,
|
|
789
|
-
c,
|
|
796
|
+
}), [w, h] = await be(
|
|
790
797
|
r,
|
|
798
|
+
u,
|
|
799
|
+
o,
|
|
791
800
|
i,
|
|
792
801
|
s,
|
|
793
802
|
{
|
|
794
803
|
env: this.config.env
|
|
795
804
|
}
|
|
796
|
-
), [
|
|
805
|
+
), [f] = r.moveCall({
|
|
797
806
|
target: "0x2::coin::from_balance",
|
|
798
807
|
arguments: [w],
|
|
799
808
|
typeArguments: [i.suiCoinType]
|
|
800
|
-
}), [b] =
|
|
809
|
+
}), [b] = r.moveCall({
|
|
801
810
|
target: "0x2::coin::from_balance",
|
|
802
|
-
arguments: [
|
|
803
|
-
typeArguments: [
|
|
811
|
+
arguments: [h],
|
|
812
|
+
typeArguments: [u.suiCoinType]
|
|
804
813
|
});
|
|
805
|
-
|
|
814
|
+
r.transferObjects([f, b], this.walletClient.address);
|
|
806
815
|
const y = await this.walletClient.signExecuteTransaction({
|
|
807
|
-
transaction:
|
|
816
|
+
transaction: r,
|
|
808
817
|
dryRun: (d = n == null ? void 0 : n.dryRun) != null ? d : !1
|
|
809
818
|
});
|
|
810
|
-
return !(n != null && n.dryRun) && ((C = (
|
|
819
|
+
return !(n != null && n.dryRun) && ((C = (g = y.effects) == null ? void 0 : g.status) == null ? void 0 : C.status) === "success" && (this.emit("lending:liquidate-success", {
|
|
811
820
|
payIdentifier: e,
|
|
812
821
|
payAmount: a,
|
|
813
822
|
collateralIdentifier: t,
|
|
@@ -850,7 +859,7 @@ class Fe extends A {
|
|
|
850
859
|
* @returns Transaction response or dry run response
|
|
851
860
|
*/
|
|
852
861
|
async claimAllRewards(e) {
|
|
853
|
-
var n,
|
|
862
|
+
var n, u, i;
|
|
854
863
|
if (!this.walletClient)
|
|
855
864
|
throw new Error("Wallet client not found");
|
|
856
865
|
const a = new m(), t = await J(this.walletClient.address, {
|
|
@@ -864,20 +873,20 @@ class Fe extends A {
|
|
|
864
873
|
transaction: a,
|
|
865
874
|
dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
|
|
866
875
|
});
|
|
867
|
-
return !(e != null && e.dryRun) && ((i = (
|
|
876
|
+
return !(e != null && e.dryRun) && ((i = (u = s.effects) == null ? void 0 : u.status) == null ? void 0 : i.status) === "success" && (this.emit("lending:claim-rewards-success", {
|
|
868
877
|
rewards: t
|
|
869
878
|
}), this.walletClient.module("balance").updatePortfolio()), s;
|
|
870
879
|
}
|
|
871
880
|
async updateOraclePTB(e, a) {
|
|
872
|
-
const t = await
|
|
881
|
+
const t = await $({
|
|
873
882
|
env: this.config.env
|
|
874
883
|
}), s = await this.getLendingState({
|
|
875
884
|
cacheTime: 60 * 1e3
|
|
876
|
-
}), n =
|
|
885
|
+
}), n = G(t, {
|
|
877
886
|
lendingState: s,
|
|
878
887
|
pools: a
|
|
879
888
|
});
|
|
880
|
-
await
|
|
889
|
+
await q(e, n, {
|
|
881
890
|
env: this.config.env,
|
|
882
891
|
updatePythPriceFeeds: !0
|
|
883
892
|
});
|
|
@@ -936,16 +945,16 @@ class Fe extends A {
|
|
|
936
945
|
return;
|
|
937
946
|
}
|
|
938
947
|
const e = [];
|
|
939
|
-
e.push(new
|
|
948
|
+
e.push(new Fe(this.walletClient));
|
|
940
949
|
try {
|
|
941
|
-
e.push(await
|
|
950
|
+
e.push(await H.create(this.walletClient));
|
|
942
951
|
} catch (a) {
|
|
943
952
|
console.warn("Failed to initialize SuilendProtocol:", a);
|
|
944
953
|
}
|
|
945
954
|
this._protocols = e;
|
|
946
955
|
}
|
|
947
956
|
}
|
|
948
|
-
class je extends
|
|
957
|
+
class je extends x {
|
|
949
958
|
constructor() {
|
|
950
959
|
super(...arguments), this.name = "volo", this.defaultConfig = {
|
|
951
960
|
packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
|
|
@@ -953,7 +962,7 @@ class je extends A {
|
|
|
953
962
|
metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
|
|
954
963
|
coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
|
|
955
964
|
}, this.getStats = oe(
|
|
956
|
-
|
|
965
|
+
K(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
|
|
957
966
|
);
|
|
958
967
|
}
|
|
959
968
|
/**
|
|
@@ -1005,7 +1014,7 @@ class je extends A {
|
|
|
1005
1014
|
* @throws Error if wallet client not found or stake amount is too low
|
|
1006
1015
|
*/
|
|
1007
1016
|
async stake(e, a) {
|
|
1008
|
-
var
|
|
1017
|
+
var r, c, o;
|
|
1009
1018
|
if (!this.walletClient)
|
|
1010
1019
|
throw new Error("Wallet client not found");
|
|
1011
1020
|
if (e < 1e9)
|
|
@@ -1015,13 +1024,13 @@ class je extends A {
|
|
|
1015
1024
|
const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
|
|
1016
1025
|
balance: e,
|
|
1017
1026
|
useGasCoin: !0
|
|
1018
|
-
}),
|
|
1019
|
-
t.transferObjects([
|
|
1027
|
+
}), u = await this.stakePTB(t, n);
|
|
1028
|
+
t.transferObjects([u], this.walletClient.address);
|
|
1020
1029
|
const i = await this.walletClient.signExecuteTransaction({
|
|
1021
1030
|
transaction: t,
|
|
1022
|
-
dryRun: (
|
|
1031
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
1023
1032
|
});
|
|
1024
|
-
return !(a != null && a.dryRun) && ((
|
|
1033
|
+
return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:stake-success", {
|
|
1025
1034
|
suiAmount: e
|
|
1026
1035
|
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1027
1036
|
}
|
|
@@ -1034,7 +1043,7 @@ class je extends A {
|
|
|
1034
1043
|
* @throws Error if wallet client not found or unstake amount is too low
|
|
1035
1044
|
*/
|
|
1036
1045
|
async unstake(e, a) {
|
|
1037
|
-
var
|
|
1046
|
+
var r, c, o;
|
|
1038
1047
|
if (!this.walletClient)
|
|
1039
1048
|
throw new Error("Wallet client not found");
|
|
1040
1049
|
if (e < 1e9)
|
|
@@ -1042,18 +1051,18 @@ class je extends A {
|
|
|
1042
1051
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1043
1052
|
const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
|
|
1044
1053
|
balance: e
|
|
1045
|
-
}),
|
|
1046
|
-
t.transferObjects([
|
|
1054
|
+
}), u = await this.unstakePTB(t, n);
|
|
1055
|
+
t.transferObjects([u], this.walletClient.address);
|
|
1047
1056
|
const i = await this.walletClient.signExecuteTransaction({
|
|
1048
1057
|
transaction: t,
|
|
1049
|
-
dryRun: (
|
|
1058
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
1050
1059
|
});
|
|
1051
|
-
return !(a != null && a.dryRun) && ((
|
|
1060
|
+
return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("volo:unstake-success", {
|
|
1052
1061
|
vSuiAmount: e
|
|
1053
1062
|
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1054
1063
|
}
|
|
1055
1064
|
}
|
|
1056
|
-
class Ie extends
|
|
1065
|
+
class Ie extends x {
|
|
1057
1066
|
constructor() {
|
|
1058
1067
|
super(...arguments), this.name = "swap", this.defaultConfig = {
|
|
1059
1068
|
apiKey: "",
|
|
@@ -1106,7 +1115,7 @@ class Ie extends A {
|
|
|
1106
1115
|
if (!this.walletClient)
|
|
1107
1116
|
throw new Error("Wallet client not found");
|
|
1108
1117
|
const n = new R(a.amount_out).multipliedBy(1 - s).toFixed(0);
|
|
1109
|
-
return await
|
|
1118
|
+
return await z(
|
|
1110
1119
|
this.walletClient.address,
|
|
1111
1120
|
e,
|
|
1112
1121
|
Number(n),
|
|
@@ -1136,30 +1145,30 @@ class Ie extends A {
|
|
|
1136
1145
|
* @returns Transaction response or dry run response
|
|
1137
1146
|
*/
|
|
1138
1147
|
async swap(e, a, t, s, n) {
|
|
1139
|
-
var y, d,
|
|
1148
|
+
var y, d, g;
|
|
1140
1149
|
if (!this.walletClient)
|
|
1141
1150
|
throw new Error("Wallet client not found");
|
|
1142
1151
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1143
|
-
const
|
|
1152
|
+
const u = this.walletClient.module("balance").portfolio.getBalance(e), i = new m(), r = B(i, u.coins, {
|
|
1144
1153
|
balance: t,
|
|
1145
1154
|
useGasCoin: !0
|
|
1146
|
-
}),
|
|
1147
|
-
if (i.transferObjects([
|
|
1155
|
+
}), c = await this.getQuote(e, a, t), o = await this.buildSwapPTBFromQuote(i, c, r, s);
|
|
1156
|
+
if (i.transferObjects([o], this.walletClient.address), i.setSender(this.walletClient.address), n != null && n.dryRun)
|
|
1148
1157
|
return await this.walletClient.signExecuteTransaction({
|
|
1149
1158
|
transaction: i,
|
|
1150
1159
|
dryRun: !0
|
|
1151
1160
|
});
|
|
1152
1161
|
const w = await i.build({
|
|
1153
1162
|
client: this.walletClient.client
|
|
1154
|
-
}),
|
|
1163
|
+
}), h = await this.walletClient.signer.signTransaction(w), f = [h.signature];
|
|
1155
1164
|
try {
|
|
1156
|
-
await xe(
|
|
1165
|
+
await xe(h.bytes, f);
|
|
1157
1166
|
} catch (C) {
|
|
1158
1167
|
console.error(C);
|
|
1159
1168
|
}
|
|
1160
1169
|
const b = await this.walletClient.client.executeTransactionBlock({
|
|
1161
|
-
transactionBlock:
|
|
1162
|
-
signature:
|
|
1170
|
+
transactionBlock: h.bytes,
|
|
1171
|
+
signature: f,
|
|
1163
1172
|
options: {
|
|
1164
1173
|
showEffects: !0,
|
|
1165
1174
|
showEvents: !0,
|
|
@@ -1167,7 +1176,7 @@ class Ie extends A {
|
|
|
1167
1176
|
}
|
|
1168
1177
|
});
|
|
1169
1178
|
if (((d = (y = b.effects) == null ? void 0 : y.status) == null ? void 0 : d.status) === "success") {
|
|
1170
|
-
const C = (
|
|
1179
|
+
const C = (g = b.events) == null ? void 0 : g.find((P) => P.type.includes("::slippage::SwapEvent"));
|
|
1171
1180
|
C && this.emit("swap:swap-success", {
|
|
1172
1181
|
fromCoinType: e,
|
|
1173
1182
|
toCoinType: a,
|
|
@@ -1179,14 +1188,14 @@ class Ie extends A {
|
|
|
1179
1188
|
return b;
|
|
1180
1189
|
}
|
|
1181
1190
|
}
|
|
1182
|
-
class Ue extends
|
|
1191
|
+
class Ue extends x {
|
|
1183
1192
|
constructor() {
|
|
1184
1193
|
super(...arguments), this.name = "haedal", this.defaultConfig = {
|
|
1185
1194
|
packageId: "0x19e6ea7f5ced4f090e20da794cc80349a03e638940ddb95155a4e301f5f4967c",
|
|
1186
1195
|
configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
|
|
1187
1196
|
coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
1188
1197
|
}, this.getApy = oe(
|
|
1189
|
-
|
|
1198
|
+
K(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
|
|
1190
1199
|
);
|
|
1191
1200
|
}
|
|
1192
1201
|
/**
|
|
@@ -1235,7 +1244,7 @@ class Ue extends A {
|
|
|
1235
1244
|
* @param options Optional dry run
|
|
1236
1245
|
*/
|
|
1237
1246
|
async stake(e, a) {
|
|
1238
|
-
var
|
|
1247
|
+
var r, c, o;
|
|
1239
1248
|
if (!this.walletClient)
|
|
1240
1249
|
throw new Error("Wallet client not found");
|
|
1241
1250
|
const t = new m();
|
|
@@ -1243,13 +1252,13 @@ class Ue extends A {
|
|
|
1243
1252
|
const s = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), n = B(t, s.coins, {
|
|
1244
1253
|
balance: e,
|
|
1245
1254
|
useGasCoin: !0
|
|
1246
|
-
}),
|
|
1247
|
-
t.transferObjects([
|
|
1255
|
+
}), u = await this.stakePTB(t, n);
|
|
1256
|
+
t.transferObjects([u], this.walletClient.address);
|
|
1248
1257
|
const i = await this.walletClient.signExecuteTransaction({
|
|
1249
1258
|
transaction: t,
|
|
1250
|
-
dryRun: (
|
|
1259
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
1251
1260
|
});
|
|
1252
|
-
return !(a != null && a.dryRun) && ((
|
|
1261
|
+
return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:stake-success", { suiAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1253
1262
|
}
|
|
1254
1263
|
/**
|
|
1255
1264
|
* Unstake haSUI for SUI
|
|
@@ -1258,26 +1267,26 @@ class Ue extends A {
|
|
|
1258
1267
|
* @param options Optional dry run
|
|
1259
1268
|
*/
|
|
1260
1269
|
async unstake(e, a) {
|
|
1261
|
-
var
|
|
1270
|
+
var r, c, o;
|
|
1262
1271
|
if (!this.walletClient)
|
|
1263
1272
|
throw new Error("Wallet client not found");
|
|
1264
1273
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1265
1274
|
const t = new m(), s = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), n = B(t, s.coins, {
|
|
1266
1275
|
balance: e
|
|
1267
|
-
}),
|
|
1268
|
-
t.transferObjects([
|
|
1276
|
+
}), u = await this.unstakePTB(t, n);
|
|
1277
|
+
t.transferObjects([u], this.walletClient.address);
|
|
1269
1278
|
const i = await this.walletClient.signExecuteTransaction({
|
|
1270
1279
|
transaction: t,
|
|
1271
|
-
dryRun: (
|
|
1280
|
+
dryRun: (r = a == null ? void 0 : a.dryRun) != null ? r : !1
|
|
1272
1281
|
});
|
|
1273
|
-
return !(a != null && a.dryRun) && ((
|
|
1282
|
+
return !(a != null && a.dryRun) && ((o = (c = i.effects) == null ? void 0 : c.status) == null ? void 0 : o.status) === "success" && (this.emit("haedal:unstake-success", { haSUIAmount: e }), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1274
1283
|
}
|
|
1275
1284
|
}
|
|
1276
1285
|
const Me = {
|
|
1277
1286
|
/** Balance management module */
|
|
1278
1287
|
balance: new Ne(),
|
|
1279
1288
|
/** Lending protocol module */
|
|
1280
|
-
lending: new
|
|
1289
|
+
lending: new _e(),
|
|
1281
1290
|
/** Volo protocol module */
|
|
1282
1291
|
volo: new je(),
|
|
1283
1292
|
/** DEX swapping module */
|