@naviprotocol/wallet-client 1.3.2-dev.6 → 1.3.2-dev.7
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,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 L, getCoins as te, mergeCoinsPTB as P, getPriceFeeds as Q, updateOraclePricesPTB as K, filterPriceFeeds as $, getFlashLoanAsset as ae, flashloanPTB as ne, depositCoinPTB as N, 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 W } 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 q, 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";
|
|
@@ -64,7 +64,7 @@ class ke {
|
|
|
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
|
*
|
|
@@ -119,13 +119,13 @@ class S {
|
|
|
119
119
|
else {
|
|
120
120
|
const a = {};
|
|
121
121
|
e == null || e.forEach((t) => {
|
|
122
|
-
const
|
|
123
|
-
let
|
|
124
|
-
|
|
125
|
-
coinType:
|
|
126
|
-
amount:
|
|
122
|
+
const n = p(t.coinType);
|
|
123
|
+
let s = a[n];
|
|
124
|
+
s || (s = {
|
|
125
|
+
coinType: n,
|
|
126
|
+
amount: W(0),
|
|
127
127
|
coins: []
|
|
128
|
-
}, a[
|
|
128
|
+
}, a[n] = s), s.coins.push(t), s.amount = s.amount.plus(t.balance);
|
|
129
129
|
}), this.balances = a;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -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: W(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) || W(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 O {
|
|
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 = L(async () => {
|
|
179
179
|
if (!this.walletClient)
|
|
180
180
|
throw new Error("Wallet client not found");
|
|
181
181
|
this._coins = await te(this.walletClient.address, {
|
|
@@ -219,8 +219,8 @@ class Ne extends A {
|
|
|
219
219
|
* @param options - Optional parameters including dry run mode
|
|
220
220
|
* @returns Transaction response or dry run response
|
|
221
221
|
*/
|
|
222
|
-
async sendCoin(e, a, t,
|
|
223
|
-
return this.sendCoinBatch(e, [a], [t],
|
|
222
|
+
async sendCoin(e, a, t, n) {
|
|
223
|
+
return this.sendCoinBatch(e, [a], [t], n);
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
226
226
|
* Sends coins to multiple recipients in a single transaction
|
|
@@ -231,19 +231,19 @@ class Ne extends A {
|
|
|
231
231
|
* @param options - Optional parameters including dry run mode
|
|
232
232
|
* @returns Transaction response or dry run response
|
|
233
233
|
*/
|
|
234
|
-
async sendCoinBatch(e, a, t,
|
|
234
|
+
async sendCoinBatch(e, a, t, n) {
|
|
235
235
|
var w;
|
|
236
236
|
if (!this.walletClient)
|
|
237
237
|
throw new Error("Wallet client not found");
|
|
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
|
|
242
|
-
if (
|
|
241
|
+
const s = this.portfolio.getBalance(e), c = t.reduce((g, h) => g.plus(h), R(0));
|
|
242
|
+
if (s.amount.lt(c))
|
|
243
243
|
throw new Error("Insufficient balance");
|
|
244
244
|
const i = new m();
|
|
245
245
|
let l = i.gas;
|
|
246
|
-
p(e) !== p("0x2::sui::SUI") && (l =
|
|
246
|
+
p(e) !== p("0x2::sui::SUI") && (l = P(i, s.coins, {
|
|
247
247
|
balance: c.toNumber()
|
|
248
248
|
}));
|
|
249
249
|
const u = i.splitCoins(l, t);
|
|
@@ -251,7 +251,7 @@ class Ne extends A {
|
|
|
251
251
|
i.transferObjects([u[h]], g);
|
|
252
252
|
}), await this.walletClient.signExecuteTransaction({
|
|
253
253
|
transaction: i,
|
|
254
|
-
dryRun: (w =
|
|
254
|
+
dryRun: (w = n == null ? void 0 : n.dryRun) != null ? w : !1
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
@@ -283,11 +283,11 @@ class Ne extends A {
|
|
|
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
|
-
const
|
|
286
|
+
const n = new m();
|
|
287
287
|
return e.forEach((i, l) => {
|
|
288
|
-
|
|
288
|
+
n.transferObjects([n.object(i)], a[l]);
|
|
289
289
|
}), await this.walletClient.signExecuteTransaction({
|
|
290
|
-
transaction:
|
|
290
|
+
transaction: n,
|
|
291
291
|
dryRun: (c = t == null ? void 0 : t.dryRun) != null ? c : !1
|
|
292
292
|
});
|
|
293
293
|
}
|
|
@@ -330,85 +330,84 @@ class Ne extends A {
|
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
async function Y(o, e, a, t) {
|
|
333
|
-
var x, k
|
|
333
|
+
var A, x, k;
|
|
334
334
|
if (!this.walletClient)
|
|
335
335
|
throw new Error("Wallet client not found");
|
|
336
|
-
const
|
|
336
|
+
const n = await this.getPool(a), s = await this.getLendingState(), c = this.walletClient.address, i = (A = t == null ? void 0 : t.protocol) != null ? A : "navi";
|
|
337
|
+
let l;
|
|
338
|
+
i === "navi" && (l = await this.getPool(e));
|
|
339
|
+
const u = await this.getProtocol(i);
|
|
337
340
|
if (!u)
|
|
338
|
-
throw new Error(`Protocol ${
|
|
339
|
-
const r = await u.getPool(
|
|
341
|
+
throw new Error(`Protocol ${i} not found`);
|
|
342
|
+
const r = await u.getPool(e.toString());
|
|
340
343
|
if (console.log("migrateBetweenSupplyPTB", {
|
|
341
344
|
fromPoolLending: r
|
|
342
|
-
}),
|
|
345
|
+
}), i === "navi" && r.supplyBalance === 0)
|
|
343
346
|
throw new Error("No supply balance");
|
|
344
347
|
if (t != null && t.amount && t.amount > r.supplyBalance)
|
|
345
348
|
throw new Error("Amount is less than supply balance");
|
|
346
|
-
const w = await
|
|
347
|
-
await
|
|
349
|
+
const w = await Q();
|
|
350
|
+
await K(
|
|
348
351
|
o,
|
|
349
|
-
|
|
350
|
-
lendingState:
|
|
351
|
-
pools:
|
|
352
|
+
$(w, {
|
|
353
|
+
lendingState: s,
|
|
354
|
+
pools: l ? [l, n] : [n]
|
|
352
355
|
})
|
|
353
356
|
);
|
|
354
|
-
const
|
|
357
|
+
const g = await ae(n, {
|
|
355
358
|
env: this.config.env
|
|
356
359
|
});
|
|
357
|
-
if (!
|
|
360
|
+
if (!g)
|
|
358
361
|
throw new Error(`${n.token.symbol} pool not support flashloan`);
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
n.suiCoinType,
|
|
362
|
-
y
|
|
363
|
-
), f = Number(d.amount_out);
|
|
364
|
-
if (f <= 0)
|
|
362
|
+
const h = (x = t == null ? void 0 : t.slippage) != null ? x : 5e-3, b = (k = t == null ? void 0 : t.amount) != null ? k : Number(r.supplyBalance), y = await this.walletClient.swap.getQuote(e, n.suiCoinType, b), d = Number(y.amount_out);
|
|
363
|
+
if (d <= 0)
|
|
365
364
|
throw new Error("The amount of swapAmountOut must be greater than 0.");
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
365
|
+
const f = Math.floor(d * (1 - h)), C = Math.floor(f / (1 + g.flashloanFee));
|
|
366
|
+
if (C <= 0)
|
|
368
367
|
throw new Error("The calculated borrow amount must be positive.");
|
|
369
|
-
const [
|
|
368
|
+
const [B, v] = await ne(o, n, C), [E] = o.moveCall({
|
|
370
369
|
target: "0x2::coin::from_balance",
|
|
371
|
-
arguments: [
|
|
370
|
+
arguments: [B],
|
|
372
371
|
typeArguments: [n.suiCoinType]
|
|
373
372
|
});
|
|
374
|
-
await N(o, n,
|
|
375
|
-
amount:
|
|
373
|
+
await N(o, n, E, {
|
|
374
|
+
amount: C
|
|
376
375
|
});
|
|
377
|
-
const
|
|
378
|
-
|
|
376
|
+
const F = await u.withdrawCoinPTB(o, e, b), j = await q(
|
|
377
|
+
c,
|
|
379
378
|
o,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
),
|
|
379
|
+
f,
|
|
380
|
+
F,
|
|
381
|
+
y
|
|
382
|
+
), I = o.moveCall({
|
|
384
383
|
target: "0x2::coin::into_balance",
|
|
385
|
-
arguments: [
|
|
384
|
+
arguments: [j],
|
|
386
385
|
typeArguments: [n.suiCoinType]
|
|
387
|
-
}), [
|
|
386
|
+
}), [U] = await se(o, n, v, I), [M] = o.moveCall({
|
|
388
387
|
target: "0x2::coin::from_balance",
|
|
389
|
-
arguments: [
|
|
388
|
+
arguments: [U],
|
|
390
389
|
typeArguments: [n.suiCoinType]
|
|
391
390
|
});
|
|
392
|
-
return await N(o, n,
|
|
391
|
+
return await N(o, n, M), o;
|
|
393
392
|
}
|
|
394
393
|
async function Z(o, e, a, t) {
|
|
395
|
-
var
|
|
394
|
+
var z, H, D;
|
|
396
395
|
if (!this.walletClient)
|
|
397
396
|
throw new Error("Wallet client not found");
|
|
398
|
-
const
|
|
397
|
+
const n = this.walletClient.address, s = await this.getPool(e), c = await this.getPool(a), i = await this.getLendingState(), l = (z = t == null ? void 0 : t.protocol) != null ? z : "navi", u = await this.getProtocol(l);
|
|
399
398
|
if (!u)
|
|
400
399
|
throw new Error(`Protocol ${l} not found`);
|
|
401
|
-
const r = await u.getPool(
|
|
400
|
+
const r = await u.getPool(s.coinType);
|
|
402
401
|
if (console.log("migrateBetweenBorrowPTB", {
|
|
403
402
|
fromPoolLending: r
|
|
404
403
|
}), r.borrowBalance === 0)
|
|
405
404
|
throw new Error("No borrow balance");
|
|
406
405
|
if (t != null && t.amount && t.amount > r.borrowBalance)
|
|
407
406
|
throw new Error("Amount is more than borrow balance");
|
|
408
|
-
const w = await
|
|
409
|
-
await
|
|
407
|
+
const w = await Q(), g = await Promise.all([s, c]);
|
|
408
|
+
await K(
|
|
410
409
|
o,
|
|
411
|
-
|
|
410
|
+
$(w, {
|
|
412
411
|
lendingState: i,
|
|
413
412
|
pools: g
|
|
414
413
|
})
|
|
@@ -417,63 +416,63 @@ async function Z(o, e, a, t) {
|
|
|
417
416
|
if (Number(r.borrowBalance) === h) {
|
|
418
417
|
const de = r.borrowAPR / 100;
|
|
419
418
|
h = Math.ceil(
|
|
420
|
-
new R(h).multipliedBy(de * (60 * 3) / (365 * 24 * 3600)).plus(new R(1).shiftedBy(-
|
|
419
|
+
new R(h).multipliedBy(de * (60 * 3) / (365 * 24 * 3600)).plus(new R(1).shiftedBy(-s.token.decimals)).plus(h).toNumber()
|
|
421
420
|
);
|
|
422
421
|
}
|
|
423
|
-
const b = await ae(
|
|
422
|
+
const b = await ae(s, {
|
|
424
423
|
env: this.config.env
|
|
425
424
|
});
|
|
426
425
|
if (!b)
|
|
427
|
-
throw new Error(`${
|
|
426
|
+
throw new Error(`${s.token.symbol} pool not support flashloan`);
|
|
428
427
|
if (!this.walletClient)
|
|
429
428
|
throw new Error("Wallet client not found");
|
|
430
429
|
const y = (D = t == null ? void 0 : t.slippage) != null ? D : 5e-3, d = Math.ceil(h * (1 + b.flashloanFee)), f = d, C = await this.walletClient.swap.getQuote(
|
|
431
|
-
|
|
430
|
+
s.suiCoinType,
|
|
432
431
|
c.suiCoinType,
|
|
433
432
|
f
|
|
434
433
|
);
|
|
435
|
-
let
|
|
434
|
+
let B = 1 + y, v = Math.ceil(Number(C.amount_out) * B), E = await this.walletClient.swap.getQuote(
|
|
436
435
|
c.suiCoinType,
|
|
437
|
-
|
|
436
|
+
s.suiCoinType,
|
|
438
437
|
v
|
|
439
438
|
);
|
|
440
439
|
for (; Number(E.amount_out) < f; )
|
|
441
|
-
|
|
440
|
+
B = B * Math.max(f / Number(E.amount_out), 1.001), v = Math.ceil(Number(C.amount_out) * B), E = await this.walletClient.swap.getQuote(
|
|
442
441
|
c.suiCoinType,
|
|
443
|
-
|
|
442
|
+
s.suiCoinType,
|
|
444
443
|
v
|
|
445
444
|
);
|
|
446
|
-
const [F, j] = await ne(o,
|
|
445
|
+
const [F, j] = await ne(o, s, h), [I] = o.moveCall({
|
|
447
446
|
target: "0x2::coin::from_balance",
|
|
448
447
|
arguments: [F],
|
|
449
|
-
typeArguments: [
|
|
448
|
+
typeArguments: [s.suiCoinType]
|
|
450
449
|
});
|
|
451
|
-
await u.repayCoinPTB(o,
|
|
452
|
-
const U = await ie(o, c, v), M = await
|
|
453
|
-
|
|
450
|
+
await u.repayCoinPTB(o, s.suiCoinType, I, h);
|
|
451
|
+
const U = await ie(o, c, v), M = await q(
|
|
452
|
+
n,
|
|
454
453
|
o,
|
|
455
454
|
d,
|
|
456
455
|
U,
|
|
457
456
|
E
|
|
458
|
-
),
|
|
457
|
+
), A = o.moveCall({
|
|
459
458
|
target: "0x2::coin::into_balance",
|
|
460
459
|
arguments: [M],
|
|
461
|
-
typeArguments: [
|
|
462
|
-
}), [x] = await se(o,
|
|
460
|
+
typeArguments: [s.suiCoinType]
|
|
461
|
+
}), [x] = await se(o, s, j, A), [k] = o.moveCall({
|
|
463
462
|
target: "0x2::coin::from_balance",
|
|
464
463
|
arguments: [x],
|
|
465
|
-
typeArguments: [
|
|
464
|
+
typeArguments: [s.suiCoinType]
|
|
466
465
|
});
|
|
467
|
-
return o.transferObjects([k],
|
|
466
|
+
return o.transferObjects([k], n), o;
|
|
468
467
|
}
|
|
469
468
|
async function ee(o, e, a, t) {
|
|
470
469
|
var w, g;
|
|
471
470
|
if (!this.walletClient)
|
|
472
471
|
throw new Error("Wallet client not found");
|
|
473
|
-
const
|
|
472
|
+
const n = await te(this.walletClient.address, {
|
|
474
473
|
client: this.walletClient.client,
|
|
475
474
|
coinType: e
|
|
476
|
-
}),
|
|
475
|
+
}), s = await this.getPool(a), i = new S(n).getBalance(e);
|
|
477
476
|
if (i.amount.eq(0))
|
|
478
477
|
throw new Error(`No balance of ${e}`);
|
|
479
478
|
if (console.log("migrateBalanceToSupplyPTB", {
|
|
@@ -481,12 +480,12 @@ async function ee(o, e, a, t) {
|
|
|
481
480
|
}), t != null && t.amount && i.amount.lt(t.amount))
|
|
482
481
|
throw new Error("Amount is greater than balance");
|
|
483
482
|
const l = (w = t == null ? void 0 : t.amount) != null ? w : i.amount.toNumber(), u = (g = t == null ? void 0 : t.slippage) != null ? g : 5e-3;
|
|
484
|
-
let r = await
|
|
483
|
+
let r = await P(o, i.coins, {
|
|
485
484
|
balance: l,
|
|
486
485
|
useGasCoin: !0
|
|
487
486
|
});
|
|
488
|
-
if (p(e) !== p(
|
|
489
|
-
const h = await this.walletClient.swap.getQuote(e,
|
|
487
|
+
if (p(e) !== p(s.suiCoinType)) {
|
|
488
|
+
const h = await this.walletClient.swap.getQuote(e, s.suiCoinType, l);
|
|
490
489
|
r = await this.walletClient.swap.buildSwapPTBFromQuote(
|
|
491
490
|
o,
|
|
492
491
|
h,
|
|
@@ -494,23 +493,23 @@ async function ee(o, e, a, t) {
|
|
|
494
493
|
u
|
|
495
494
|
);
|
|
496
495
|
}
|
|
497
|
-
return await N(o,
|
|
496
|
+
return await N(o, s, r), o;
|
|
498
497
|
}
|
|
499
498
|
class _e {
|
|
500
499
|
constructor(e) {
|
|
501
500
|
this.name = "navi", this.walletClient = e;
|
|
502
501
|
}
|
|
503
502
|
async getPool(e) {
|
|
504
|
-
const a = await this.walletClient.lending.getPool(e),
|
|
503
|
+
const a = await this.walletClient.lending.getPool(e), n = (await this.walletClient.lending.getLendingState()).find(
|
|
505
504
|
(i) => i.pool.suiCoinType === p(e)
|
|
506
|
-
),
|
|
505
|
+
), s = n ? new R(n.supplyBalance).toNumber() : 0, c = n ? new R(n.borrowBalance).toNumber() : 0;
|
|
507
506
|
return {
|
|
508
|
-
supplyBalance:
|
|
507
|
+
supplyBalance: s,
|
|
509
508
|
borrowBalance: c,
|
|
510
509
|
borrowAPR: parseFloat(a.borrowIncentiveApyInfo.apy)
|
|
511
510
|
};
|
|
512
511
|
}
|
|
513
|
-
async depositCoinPTB(e, a, t,
|
|
512
|
+
async depositCoinPTB(e, a, t, n) {
|
|
514
513
|
throw new Error("Not implemented");
|
|
515
514
|
}
|
|
516
515
|
async withdrawCoinPTB(e, a, t) {
|
|
@@ -519,11 +518,11 @@ class _e {
|
|
|
519
518
|
async borrowCoinPTB(e, a, t) {
|
|
520
519
|
throw new Error("Not implemented");
|
|
521
520
|
}
|
|
522
|
-
async repayCoinPTB(e, a, t,
|
|
523
|
-
re(e, a, t, { amount:
|
|
521
|
+
async repayCoinPTB(e, a, t, n) {
|
|
522
|
+
re(e, a, t, { amount: n });
|
|
524
523
|
}
|
|
525
524
|
}
|
|
526
|
-
class
|
|
525
|
+
class G {
|
|
527
526
|
constructor(e, a, t) {
|
|
528
527
|
this.name = "suilend", this.walletClient = e, this.obligationOwnerCap = a, this.suilendClient = t;
|
|
529
528
|
}
|
|
@@ -538,24 +537,24 @@ class z {
|
|
|
538
537
|
]);
|
|
539
538
|
if (t.length === 0)
|
|
540
539
|
throw new Error("No existing obligations found for wallet address: " + e.address);
|
|
541
|
-
return new
|
|
540
|
+
return new G(e, t[0], a);
|
|
542
541
|
}
|
|
543
542
|
async getPool(e) {
|
|
544
543
|
var b, y;
|
|
545
|
-
const a = p(e), t = this.suilendClient.lendingMarket.reserves,
|
|
544
|
+
const a = p(e), t = this.suilendClient.lendingMarket.reserves, n = /* @__PURE__ */ new Set();
|
|
546
545
|
t.forEach((d) => {
|
|
547
|
-
|
|
548
|
-
f &&
|
|
546
|
+
n.add(p(d.coinType.name)), d.depositsPoolRewardManager.poolRewards.forEach((f) => {
|
|
547
|
+
f && n.add(p(f.coinType.name));
|
|
549
548
|
}), d.borrowsPoolRewardManager.poolRewards.forEach((f) => {
|
|
550
|
-
f &&
|
|
549
|
+
f && n.add(p(f.coinType.name));
|
|
551
550
|
});
|
|
552
551
|
});
|
|
553
|
-
const
|
|
552
|
+
const s = await Oe(Array.from(n)), i = t.map((d) => Re(d, s)).reduce(
|
|
554
553
|
(d, f) => (d[f.coinType] = f, d),
|
|
555
554
|
{}
|
|
556
555
|
), l = await this.suilendClient.getObligation(
|
|
557
556
|
this.obligationOwnerCap.obligationId
|
|
558
|
-
), u = Se(l, i), r = u.deposits.find((d) => d.coinType === a), w = u.borrows.find((d) => d.coinType === a), g =
|
|
557
|
+
), u = Se(l, i), r = u.deposits.find((d) => d.coinType === a), w = u.borrows.find((d) => d.coinType === a), g = s[a].decimals;
|
|
559
558
|
return {
|
|
560
559
|
cTokenExchangeRate: i[a].cTokenExchangeRate.toNumber(),
|
|
561
560
|
supplyBalance: (b = r == null ? void 0 : r.depositedAmount.shiftedBy(g).decimalPlaces(0).toNumber()) != null ? b : 0,
|
|
@@ -563,27 +562,27 @@ class z {
|
|
|
563
562
|
borrowAPR: i[a].borrowAprPercent.toNumber()
|
|
564
563
|
};
|
|
565
564
|
}
|
|
566
|
-
async depositCoinPTB(e, a, t,
|
|
565
|
+
async depositCoinPTB(e, a, t, n) {
|
|
567
566
|
throw new Error("Not implemented");
|
|
568
567
|
}
|
|
569
568
|
async withdrawCoinPTB(e, a, t) {
|
|
570
|
-
const
|
|
569
|
+
const n = await this.getPool(a), s = t === n.supplyBalance;
|
|
571
570
|
return await this.suilendClient.withdraw(
|
|
572
571
|
this.obligationOwnerCap.id,
|
|
573
572
|
this.obligationOwnerCap.obligationId,
|
|
574
573
|
a,
|
|
575
|
-
|
|
574
|
+
s ? Ae.toString() : Math.ceil(t / n.cTokenExchangeRate).toString(),
|
|
576
575
|
e
|
|
577
576
|
);
|
|
578
577
|
}
|
|
579
578
|
async borrowCoinPTB(e, a, t) {
|
|
580
579
|
throw new Error("Not implemented");
|
|
581
580
|
}
|
|
582
|
-
async repayCoinPTB(e, a, t,
|
|
581
|
+
async repayCoinPTB(e, a, t, n) {
|
|
583
582
|
this.suilendClient.repay(this.obligationOwnerCap.obligationId, a, t, e), e.transferObjects([t], e.pure.address(this.walletClient.address));
|
|
584
583
|
}
|
|
585
584
|
}
|
|
586
|
-
class Fe extends
|
|
585
|
+
class Fe extends O {
|
|
587
586
|
constructor() {
|
|
588
587
|
super(), this.name = "lending", this.defaultConfig = {
|
|
589
588
|
env: "prod",
|
|
@@ -634,21 +633,21 @@ class Fe extends A {
|
|
|
634
633
|
var u, r, w;
|
|
635
634
|
if (!this.walletClient)
|
|
636
635
|
throw new Error("Wallet client not found");
|
|
637
|
-
const
|
|
636
|
+
const n = await T(e, {
|
|
638
637
|
env: this.config.env
|
|
639
638
|
});
|
|
640
639
|
await this.walletClient.module("balance").waitForUpdate();
|
|
641
|
-
const
|
|
640
|
+
const s = new m(), c = this.walletClient.module("balance").portfolio.getBalance(n.suiCoinType), i = P(s, c.coins, {
|
|
642
641
|
balance: a,
|
|
643
642
|
useGasCoin: !0
|
|
644
643
|
});
|
|
645
|
-
await N(
|
|
644
|
+
await N(s, n, i, {
|
|
646
645
|
env: this.config.env,
|
|
647
646
|
amount: a,
|
|
648
647
|
accountCap: t == null ? void 0 : t.accountCap
|
|
649
648
|
});
|
|
650
649
|
const l = await this.walletClient.signExecuteTransaction({
|
|
651
|
-
transaction:
|
|
650
|
+
transaction: s,
|
|
652
651
|
dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
|
|
653
652
|
});
|
|
654
653
|
return !(t != null && t.dryRun) && ((w = (r = l.effects) == null ? void 0 : r.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:deposit-success", {
|
|
@@ -668,17 +667,17 @@ class Fe extends A {
|
|
|
668
667
|
var l, u, r;
|
|
669
668
|
if (!this.walletClient)
|
|
670
669
|
throw new Error("Wallet client not found");
|
|
671
|
-
const
|
|
670
|
+
const n = await T(e, {
|
|
672
671
|
env: this.config.env
|
|
673
|
-
}),
|
|
674
|
-
t != null && t.disableUpdateOracle || await this.updateOraclePTB(
|
|
675
|
-
const c = await le(
|
|
672
|
+
}), s = new m();
|
|
673
|
+
t != null && t.disableUpdateOracle || await this.updateOraclePTB(s, [n]);
|
|
674
|
+
const c = await le(s, n, a, {
|
|
676
675
|
env: this.config.env,
|
|
677
676
|
accountCap: t == null ? void 0 : t.accountCap
|
|
678
677
|
});
|
|
679
|
-
|
|
678
|
+
s.transferObjects([c], this.walletClient.address);
|
|
680
679
|
const i = await this.walletClient.signExecuteTransaction({
|
|
681
|
-
transaction:
|
|
680
|
+
transaction: s,
|
|
682
681
|
dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
|
|
683
682
|
});
|
|
684
683
|
return !(t != null && t.dryRun) && ((r = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : r.status) === "success" && (this.emit("lending:withdraw-success", {
|
|
@@ -698,17 +697,17 @@ class Fe extends A {
|
|
|
698
697
|
var l, u, r;
|
|
699
698
|
if (!this.walletClient)
|
|
700
699
|
throw new Error("Wallet client not found");
|
|
701
|
-
const
|
|
700
|
+
const n = await T(e, {
|
|
702
701
|
env: this.config.env
|
|
703
|
-
}),
|
|
704
|
-
t != null && t.disableUpdateOracle || await this.updateOraclePTB(
|
|
705
|
-
const c = await ie(
|
|
702
|
+
}), s = new m();
|
|
703
|
+
t != null && t.disableUpdateOracle || await this.updateOraclePTB(s, [n]);
|
|
704
|
+
const c = await ie(s, n, a, {
|
|
706
705
|
env: this.config.env,
|
|
707
706
|
accountCap: t == null ? void 0 : t.accountCap
|
|
708
707
|
});
|
|
709
|
-
|
|
708
|
+
s.transferObjects([c], this.walletClient.address);
|
|
710
709
|
const i = await this.walletClient.signExecuteTransaction({
|
|
711
|
-
transaction:
|
|
710
|
+
transaction: s,
|
|
712
711
|
dryRun: (l = t == null ? void 0 : t.dryRun) != null ? l : !1
|
|
713
712
|
});
|
|
714
713
|
return !(t != null && t.dryRun) && ((r = (u = i.effects) == null ? void 0 : u.status) == null ? void 0 : r.status) === "success" && (this.emit("lending:borrow-success", {
|
|
@@ -729,19 +728,19 @@ class Fe extends A {
|
|
|
729
728
|
if (!this.walletClient)
|
|
730
729
|
throw new Error("Wallet client not found");
|
|
731
730
|
await this.walletClient.module("balance").waitForUpdate();
|
|
732
|
-
const
|
|
731
|
+
const n = await T(e, {
|
|
733
732
|
env: this.config.env
|
|
734
|
-
}),
|
|
733
|
+
}), s = new m(), c = this.walletClient.module("balance").portfolio.getBalance(n.suiCoinType), i = P(s, c.coins, {
|
|
735
734
|
balance: a,
|
|
736
735
|
useGasCoin: !0
|
|
737
736
|
});
|
|
738
|
-
await re(
|
|
737
|
+
await re(s, n, i, {
|
|
739
738
|
env: this.config.env,
|
|
740
739
|
amount: a,
|
|
741
740
|
accountCap: t == null ? void 0 : t.accountCap
|
|
742
741
|
});
|
|
743
742
|
const l = await this.walletClient.signExecuteTransaction({
|
|
744
|
-
transaction:
|
|
743
|
+
transaction: s,
|
|
745
744
|
dryRun: (u = t == null ? void 0 : t.dryRun) != null ? u : !1
|
|
746
745
|
});
|
|
747
746
|
return !(t != null && t.dryRun) && ((w = (r = l.effects) == null ? void 0 : r.status) == null ? void 0 : w.status) === "success" && (this.emit("lending:repay-success", {
|
|
@@ -773,7 +772,7 @@ class Fe extends A {
|
|
|
773
772
|
* @param options - Optional parameters including dry run mode
|
|
774
773
|
* @returns Transaction response or dry run response
|
|
775
774
|
*/
|
|
776
|
-
async liquidate(e, a, t,
|
|
775
|
+
async liquidate(e, a, t, n, s) {
|
|
777
776
|
var d, f, C;
|
|
778
777
|
if (!this.walletClient)
|
|
779
778
|
throw new Error("Wallet client not found");
|
|
@@ -781,7 +780,7 @@ class Fe extends A {
|
|
|
781
780
|
env: this.config.env
|
|
782
781
|
}), i = await T(t, {
|
|
783
782
|
env: this.config.env
|
|
784
|
-
}), l = new m(), u = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), r =
|
|
783
|
+
}), l = new m(), u = this.walletClient.module("balance").portfolio.getBalance(c.suiCoinType), r = P(l, u.coins, {
|
|
785
784
|
balance: a,
|
|
786
785
|
useGasCoin: !0
|
|
787
786
|
}), [w, g] = await be(
|
|
@@ -789,7 +788,7 @@ class Fe extends A {
|
|
|
789
788
|
c,
|
|
790
789
|
r,
|
|
791
790
|
i,
|
|
792
|
-
|
|
791
|
+
n,
|
|
793
792
|
{
|
|
794
793
|
env: this.config.env
|
|
795
794
|
}
|
|
@@ -805,13 +804,13 @@ class Fe extends A {
|
|
|
805
804
|
l.transferObjects([h, b], this.walletClient.address);
|
|
806
805
|
const y = await this.walletClient.signExecuteTransaction({
|
|
807
806
|
transaction: l,
|
|
808
|
-
dryRun: (d =
|
|
807
|
+
dryRun: (d = s == null ? void 0 : s.dryRun) != null ? d : !1
|
|
809
808
|
});
|
|
810
|
-
return !(
|
|
809
|
+
return !(s != null && s.dryRun) && ((C = (f = y.effects) == null ? void 0 : f.status) == null ? void 0 : C.status) === "success" && (this.emit("lending:liquidate-success", {
|
|
811
810
|
payIdentifier: e,
|
|
812
811
|
payAmount: a,
|
|
813
812
|
collateralIdentifier: t,
|
|
814
|
-
liquidationAddress:
|
|
813
|
+
liquidationAddress: n
|
|
815
814
|
}), this.walletClient.module("balance").updatePortfolio()), y;
|
|
816
815
|
}
|
|
817
816
|
/**
|
|
@@ -850,7 +849,7 @@ class Fe extends A {
|
|
|
850
849
|
* @returns Transaction response or dry run response
|
|
851
850
|
*/
|
|
852
851
|
async claimAllRewards(e) {
|
|
853
|
-
var
|
|
852
|
+
var s, c, i;
|
|
854
853
|
if (!this.walletClient)
|
|
855
854
|
throw new Error("Wallet client not found");
|
|
856
855
|
const a = new m(), t = await J(this.walletClient.address, {
|
|
@@ -860,24 +859,24 @@ class Fe extends A {
|
|
|
860
859
|
env: this.config.env,
|
|
861
860
|
accountCap: e == null ? void 0 : e.accountCap
|
|
862
861
|
});
|
|
863
|
-
const
|
|
862
|
+
const n = await this.walletClient.signExecuteTransaction({
|
|
864
863
|
transaction: a,
|
|
865
|
-
dryRun: (
|
|
864
|
+
dryRun: (s = e == null ? void 0 : e.dryRun) != null ? s : !1
|
|
866
865
|
});
|
|
867
|
-
return !(e != null && e.dryRun) && ((i = (c =
|
|
866
|
+
return !(e != null && e.dryRun) && ((i = (c = n.effects) == null ? void 0 : c.status) == null ? void 0 : i.status) === "success" && (this.emit("lending:claim-rewards-success", {
|
|
868
867
|
rewards: t
|
|
869
|
-
}), this.walletClient.module("balance").updatePortfolio()),
|
|
868
|
+
}), this.walletClient.module("balance").updatePortfolio()), n;
|
|
870
869
|
}
|
|
871
870
|
async updateOraclePTB(e, a) {
|
|
872
|
-
const t = await
|
|
871
|
+
const t = await Q({
|
|
873
872
|
env: this.config.env
|
|
874
|
-
}),
|
|
873
|
+
}), n = await this.getLendingState({
|
|
875
874
|
cacheTime: 60 * 1e3
|
|
876
|
-
}),
|
|
877
|
-
lendingState:
|
|
875
|
+
}), s = $(t, {
|
|
876
|
+
lendingState: n,
|
|
878
877
|
pools: a
|
|
879
878
|
});
|
|
880
|
-
await
|
|
879
|
+
await K(e, s, {
|
|
881
880
|
env: this.config.env,
|
|
882
881
|
updatePythPriceFeeds: !0
|
|
883
882
|
});
|
|
@@ -890,13 +889,13 @@ class Fe extends A {
|
|
|
890
889
|
* @returns Transaction response or dry run response
|
|
891
890
|
*/
|
|
892
891
|
async updateOracle(e) {
|
|
893
|
-
var
|
|
892
|
+
var n;
|
|
894
893
|
if (!this.walletClient)
|
|
895
894
|
throw new Error("Wallet client not found");
|
|
896
895
|
const a = new m();
|
|
897
896
|
return await this.updateOraclePTB(a, e == null ? void 0 : e.pools), await this.walletClient.signExecuteTransaction({
|
|
898
897
|
transaction: a,
|
|
899
|
-
dryRun: (
|
|
898
|
+
dryRun: (n = e == null ? void 0 : e.dryRun) != null ? n : !1
|
|
900
899
|
});
|
|
901
900
|
}
|
|
902
901
|
/**
|
|
@@ -921,13 +920,13 @@ class Fe extends A {
|
|
|
921
920
|
* @returns Transaction response or dry run response
|
|
922
921
|
*/
|
|
923
922
|
async createAccountCap(e) {
|
|
924
|
-
var
|
|
923
|
+
var s;
|
|
925
924
|
if (!this.walletClient)
|
|
926
925
|
throw new Error("Wallet client not found");
|
|
927
926
|
const a = new m(), t = await Be(a);
|
|
928
927
|
return a.transferObjects([t], this.walletClient.address), await this.walletClient.signExecuteTransaction({
|
|
929
928
|
transaction: a,
|
|
930
|
-
dryRun: (
|
|
929
|
+
dryRun: (s = e == null ? void 0 : e.dryRun) != null ? s : !1
|
|
931
930
|
});
|
|
932
931
|
}
|
|
933
932
|
async initializeProtocols() {
|
|
@@ -938,14 +937,14 @@ class Fe extends A {
|
|
|
938
937
|
const e = [];
|
|
939
938
|
e.push(new _e(this.walletClient));
|
|
940
939
|
try {
|
|
941
|
-
e.push(await
|
|
940
|
+
e.push(await G.create(this.walletClient));
|
|
942
941
|
} catch (a) {
|
|
943
942
|
console.warn("Failed to initialize SuilendProtocol:", a);
|
|
944
943
|
}
|
|
945
944
|
this._protocols = e;
|
|
946
945
|
}
|
|
947
946
|
}
|
|
948
|
-
class je extends
|
|
947
|
+
class je extends O {
|
|
949
948
|
constructor() {
|
|
950
949
|
super(...arguments), this.name = "volo", this.defaultConfig = {
|
|
951
950
|
packageId: "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20",
|
|
@@ -953,7 +952,7 @@ class je extends A {
|
|
|
953
952
|
metadataId: "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60",
|
|
954
953
|
coinType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
|
|
955
954
|
}, this.getStats = oe(
|
|
956
|
-
|
|
955
|
+
L(async () => (await fetch("https://open-api.naviprotocol.io/api/volo/stats").then((a) => a.json())).data)
|
|
957
956
|
);
|
|
958
957
|
}
|
|
959
958
|
/**
|
|
@@ -1012,10 +1011,10 @@ class je extends A {
|
|
|
1012
1011
|
throw new Error("Stake amount should be greater than 1Sui");
|
|
1013
1012
|
const t = new m();
|
|
1014
1013
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1015
|
-
const
|
|
1014
|
+
const n = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), s = P(t, n.coins, {
|
|
1016
1015
|
balance: e,
|
|
1017
1016
|
useGasCoin: !0
|
|
1018
|
-
}), c = await this.stakePTB(t,
|
|
1017
|
+
}), c = await this.stakePTB(t, s);
|
|
1019
1018
|
t.transferObjects([c], this.walletClient.address);
|
|
1020
1019
|
const i = await this.walletClient.signExecuteTransaction({
|
|
1021
1020
|
transaction: t,
|
|
@@ -1040,9 +1039,9 @@ class je extends A {
|
|
|
1040
1039
|
if (e < 1e9)
|
|
1041
1040
|
throw new Error("Unstake amount should >= 1vSui");
|
|
1042
1041
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1043
|
-
const t = new m(),
|
|
1042
|
+
const t = new m(), n = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), s = P(t, n.coins, {
|
|
1044
1043
|
balance: e
|
|
1045
|
-
}), c = await this.unstakePTB(t,
|
|
1044
|
+
}), c = await this.unstakePTB(t, s);
|
|
1046
1045
|
t.transferObjects([c], this.walletClient.address);
|
|
1047
1046
|
const i = await this.walletClient.signExecuteTransaction({
|
|
1048
1047
|
transaction: t,
|
|
@@ -1053,7 +1052,7 @@ class je extends A {
|
|
|
1053
1052
|
}), this.walletClient.module("balance").updatePortfolio()), i;
|
|
1054
1053
|
}
|
|
1055
1054
|
}
|
|
1056
|
-
class Ie extends
|
|
1055
|
+
class Ie extends O {
|
|
1057
1056
|
constructor() {
|
|
1058
1057
|
super(...arguments), this.name = "swap", this.defaultConfig = {
|
|
1059
1058
|
apiKey: "",
|
|
@@ -1102,14 +1101,14 @@ class Ie extends A {
|
|
|
1102
1101
|
* @param slippage - The slippage tolerance
|
|
1103
1102
|
* @returns The swap transaction
|
|
1104
1103
|
*/
|
|
1105
|
-
async buildSwapPTBFromQuote(e, a, t,
|
|
1104
|
+
async buildSwapPTBFromQuote(e, a, t, n) {
|
|
1106
1105
|
if (!this.walletClient)
|
|
1107
1106
|
throw new Error("Wallet client not found");
|
|
1108
|
-
const
|
|
1109
|
-
return await
|
|
1107
|
+
const s = new R(a.amount_out).multipliedBy(1 - n).toFixed(0);
|
|
1108
|
+
return await q(
|
|
1110
1109
|
this.walletClient.address,
|
|
1111
1110
|
e,
|
|
1112
|
-
Number(
|
|
1111
|
+
Number(s),
|
|
1113
1112
|
t,
|
|
1114
1113
|
a,
|
|
1115
1114
|
this.referral,
|
|
@@ -1135,16 +1134,16 @@ class Ie extends A {
|
|
|
1135
1134
|
* @param options - Optional parameters including dry run mode
|
|
1136
1135
|
* @returns Transaction response or dry run response
|
|
1137
1136
|
*/
|
|
1138
|
-
async swap(e, a, t,
|
|
1137
|
+
async swap(e, a, t, n, s) {
|
|
1139
1138
|
var y, d, f;
|
|
1140
1139
|
if (!this.walletClient)
|
|
1141
1140
|
throw new Error("Wallet client not found");
|
|
1142
1141
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1143
|
-
const c = this.walletClient.module("balance").portfolio.getBalance(e), i = new m(), l =
|
|
1142
|
+
const c = this.walletClient.module("balance").portfolio.getBalance(e), i = new m(), l = P(i, c.coins, {
|
|
1144
1143
|
balance: t,
|
|
1145
1144
|
useGasCoin: !0
|
|
1146
|
-
}), u = await this.getQuote(e, a, t), r = await this.buildSwapPTBFromQuote(i, u, l,
|
|
1147
|
-
if (i.transferObjects([r], this.walletClient.address), i.setSender(this.walletClient.address),
|
|
1145
|
+
}), u = await this.getQuote(e, a, t), r = await this.buildSwapPTBFromQuote(i, u, l, n);
|
|
1146
|
+
if (i.transferObjects([r], this.walletClient.address), i.setSender(this.walletClient.address), s != null && s.dryRun)
|
|
1148
1147
|
return await this.walletClient.signExecuteTransaction({
|
|
1149
1148
|
transaction: i,
|
|
1150
1149
|
dryRun: !0
|
|
@@ -1167,26 +1166,26 @@ class Ie extends A {
|
|
|
1167
1166
|
}
|
|
1168
1167
|
});
|
|
1169
1168
|
if (((d = (y = b.effects) == null ? void 0 : y.status) == null ? void 0 : d.status) === "success") {
|
|
1170
|
-
const C = (f = b.events) == null ? void 0 : f.find((
|
|
1169
|
+
const C = (f = b.events) == null ? void 0 : f.find((B) => B.type.includes("::slippage::SwapEvent"));
|
|
1171
1170
|
C && this.emit("swap:swap-success", {
|
|
1172
1171
|
fromCoinType: e,
|
|
1173
1172
|
toCoinType: a,
|
|
1174
1173
|
fromAmount: t,
|
|
1175
|
-
slippage:
|
|
1174
|
+
slippage: n,
|
|
1176
1175
|
toAmount: Number(C.parsedJson.amount_out)
|
|
1177
1176
|
}), this.walletClient.module("balance").updatePortfolio();
|
|
1178
1177
|
}
|
|
1179
1178
|
return b;
|
|
1180
1179
|
}
|
|
1181
1180
|
}
|
|
1182
|
-
class Ue extends
|
|
1181
|
+
class Ue extends O {
|
|
1183
1182
|
constructor() {
|
|
1184
1183
|
super(...arguments), this.name = "haedal", this.defaultConfig = {
|
|
1185
1184
|
packageId: "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2",
|
|
1186
1185
|
configId: "0x47b224762220393057ebf4f70501b6e657c3e56684737568439a04f80849b2ca",
|
|
1187
1186
|
coinType: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
1188
1187
|
}, this.getApy = oe(
|
|
1189
|
-
|
|
1188
|
+
L(async () => (await fetch("https://open-api.naviprotocol.io/api/haedal/stats").then((a) => a.json())).data.apy)
|
|
1190
1189
|
);
|
|
1191
1190
|
}
|
|
1192
1191
|
/**
|
|
@@ -1240,10 +1239,10 @@ class Ue extends A {
|
|
|
1240
1239
|
throw new Error("Wallet client not found");
|
|
1241
1240
|
const t = new m();
|
|
1242
1241
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1243
|
-
const
|
|
1242
|
+
const n = this.walletClient.module("balance").portfolio.getBalance("0x2::sui::SUI"), s = P(t, n.coins, {
|
|
1244
1243
|
balance: e,
|
|
1245
1244
|
useGasCoin: !0
|
|
1246
|
-
}), c = await this.stakePTB(t,
|
|
1245
|
+
}), c = await this.stakePTB(t, s);
|
|
1247
1246
|
t.transferObjects([c], this.walletClient.address);
|
|
1248
1247
|
const i = await this.walletClient.signExecuteTransaction({
|
|
1249
1248
|
transaction: t,
|
|
@@ -1262,9 +1261,9 @@ class Ue extends A {
|
|
|
1262
1261
|
if (!this.walletClient)
|
|
1263
1262
|
throw new Error("Wallet client not found");
|
|
1264
1263
|
await this.walletClient.module("balance").waitForUpdate();
|
|
1265
|
-
const t = new m(),
|
|
1264
|
+
const t = new m(), n = this.walletClient.module("balance").portfolio.getBalance(this.config.coinType), s = P(t, n.coins, {
|
|
1266
1265
|
balance: e
|
|
1267
|
-
}), c = await this.unstakePTB(t,
|
|
1266
|
+
}), c = await this.unstakePTB(t, s);
|
|
1268
1267
|
t.transferObjects([c], this.walletClient.address);
|
|
1269
1268
|
const i = await this.walletClient.signExecuteTransaction({
|
|
1270
1269
|
transaction: t,
|
|
@@ -1298,10 +1297,10 @@ class Ye {
|
|
|
1298
1297
|
...We,
|
|
1299
1298
|
...e.client
|
|
1300
1299
|
};
|
|
1301
|
-
a.transport = a.transport || new ke(a.url), this.client = new he(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t,
|
|
1302
|
-
if (t !==
|
|
1303
|
-
throw new Error(`Module name ${t} does not match module name ${
|
|
1304
|
-
|
|
1300
|
+
a.transport = a.transport || new ke(a.url), this.client = new he(a), this.signer = e.signer, this.userConfigs = e.configs || {}, Object.entries(this.modules).forEach(([t, n]) => {
|
|
1301
|
+
if (t !== n.name)
|
|
1302
|
+
throw new Error(`Module name ${t} does not match module name ${n.name}`);
|
|
1303
|
+
n.install(this);
|
|
1305
1304
|
});
|
|
1306
1305
|
}
|
|
1307
1306
|
get lending() {
|
|
@@ -1327,11 +1326,11 @@ class Ye {
|
|
|
1327
1326
|
async signExecuteTransaction(e) {
|
|
1328
1327
|
const { dryRun: a = !1, ...t } = e;
|
|
1329
1328
|
if (a) {
|
|
1330
|
-
let
|
|
1331
|
-
return e.transaction instanceof m ? (e.transaction.setSenderIfNotSet(this.address),
|
|
1329
|
+
let n;
|
|
1330
|
+
return e.transaction instanceof m ? (e.transaction.setSenderIfNotSet(this.address), n = await e.transaction.build({
|
|
1332
1331
|
client: this.client
|
|
1333
|
-
})) :
|
|
1334
|
-
transactionBlock:
|
|
1332
|
+
})) : n = e.transaction, this.client.dryRunTransactionBlock({
|
|
1333
|
+
transactionBlock: n
|
|
1335
1334
|
});
|
|
1336
1335
|
}
|
|
1337
1336
|
return this.client.signAndExecuteTransaction({
|