@naviprotocol/lending 1.2.2-dev.1 → 1.3.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flashloan.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +37 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/liquidate.d.ts.map +1 -1
- package/dist/pool.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction as
|
|
1
|
+
import { Transaction as B } from "@mysten/sui/transactions";
|
|
2
2
|
import { bcs as s, toHex as H, fromHex as q } from "@mysten/bcs";
|
|
3
3
|
import { SuiClient as z, getFullnodeUrl as O } from "@mysten/sui/client";
|
|
4
4
|
import W from "lodash.camelcase";
|
|
@@ -162,11 +162,11 @@ function A(e) {
|
|
|
162
162
|
}, o));
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
return Array.isArray(e) ? e.map((a) =>
|
|
165
|
+
function $(e) {
|
|
166
|
+
return Array.isArray(e) ? e.map((a) => $(a)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
167
167
|
(a, r) => ({
|
|
168
168
|
...a,
|
|
169
|
-
[W(r)]:
|
|
169
|
+
[W(r)]: $(e[r])
|
|
170
170
|
}),
|
|
171
171
|
{}
|
|
172
172
|
) : e;
|
|
@@ -201,7 +201,7 @@ const Z = 27, V = (e, a) => {
|
|
|
201
201
|
return new T(e).multipliedBy(new T(a)).plus(t).dividedBy(r).integerValue(T.ROUND_DOWN);
|
|
202
202
|
}, w = A(
|
|
203
203
|
_(async (e) => {
|
|
204
|
-
const a = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}`;
|
|
204
|
+
const a = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}&v=2`;
|
|
205
205
|
return (await fetch(a).then((t) => t.json())).data;
|
|
206
206
|
})
|
|
207
207
|
), g = 1e3 * 60 * 5;
|
|
@@ -272,6 +272,9 @@ async function x(e, a, r, t) {
|
|
|
272
272
|
e.object(c.incentiveV3)
|
|
273
273
|
],
|
|
274
274
|
typeArguments: [n.suiCoinType]
|
|
275
|
+
}), n.id === 0 && e.moveCall({
|
|
276
|
+
target: `${c.package}::pool::refresh_stake`,
|
|
277
|
+
arguments: [e.object(n.contract.pool), e.object("0x05")]
|
|
275
278
|
}), e;
|
|
276
279
|
}
|
|
277
280
|
async function be(e, a, r, t) {
|
|
@@ -282,7 +285,7 @@ async function be(e, a, r, t) {
|
|
|
282
285
|
let i;
|
|
283
286
|
if (t != null && t.accountCap) {
|
|
284
287
|
const [l] = e.moveCall({
|
|
285
|
-
target: `${c.package}::incentive_v3::
|
|
288
|
+
target: `${c.package}::incentive_v3::withdraw_with_account_cap_v2`,
|
|
286
289
|
arguments: [
|
|
287
290
|
e.object("0x06"),
|
|
288
291
|
e.object(c.priceOracle),
|
|
@@ -292,14 +295,15 @@ async function be(e, a, r, t) {
|
|
|
292
295
|
o,
|
|
293
296
|
e.object(c.incentiveV2),
|
|
294
297
|
e.object(c.incentiveV3),
|
|
295
|
-
f(t.accountCap, e.object)
|
|
298
|
+
f(t.accountCap, e.object),
|
|
299
|
+
e.object("0x05")
|
|
296
300
|
],
|
|
297
301
|
typeArguments: [n.suiCoinType]
|
|
298
302
|
});
|
|
299
303
|
i = l;
|
|
300
304
|
} else {
|
|
301
305
|
const [l] = e.moveCall({
|
|
302
|
-
target: `${c.package}::incentive_v3::
|
|
306
|
+
target: `${c.package}::incentive_v3::withdraw_v2`,
|
|
303
307
|
arguments: [
|
|
304
308
|
e.object("0x06"),
|
|
305
309
|
e.object(c.priceOracle),
|
|
@@ -308,7 +312,8 @@ async function be(e, a, r, t) {
|
|
|
308
312
|
e.pure.u8(n.id),
|
|
309
313
|
o,
|
|
310
314
|
e.object(c.incentiveV2),
|
|
311
|
-
e.object(c.incentiveV3)
|
|
315
|
+
e.object(c.incentiveV3),
|
|
316
|
+
e.object("0x05")
|
|
312
317
|
],
|
|
313
318
|
typeArguments: [n.suiCoinType]
|
|
314
319
|
});
|
|
@@ -328,7 +333,7 @@ async function ve(e, a, r, t) {
|
|
|
328
333
|
let i;
|
|
329
334
|
if (t != null && t.accountCap) {
|
|
330
335
|
const [l] = e.moveCall({
|
|
331
|
-
target: `${c.package}::incentive_v3::
|
|
336
|
+
target: `${c.package}::incentive_v3::borrow_with_account_cap_v2`,
|
|
332
337
|
arguments: [
|
|
333
338
|
e.object("0x06"),
|
|
334
339
|
e.object(c.priceOracle),
|
|
@@ -338,14 +343,15 @@ async function ve(e, a, r, t) {
|
|
|
338
343
|
o,
|
|
339
344
|
e.object(c.incentiveV2),
|
|
340
345
|
e.object(c.incentiveV3),
|
|
341
|
-
f(t.accountCap, e.object)
|
|
346
|
+
f(t.accountCap, e.object),
|
|
347
|
+
e.object("0x05")
|
|
342
348
|
],
|
|
343
349
|
typeArguments: [n.suiCoinType]
|
|
344
350
|
});
|
|
345
351
|
i = l;
|
|
346
352
|
} else {
|
|
347
353
|
const [l] = e.moveCall({
|
|
348
|
-
target: `${c.package}::incentive_v3::
|
|
354
|
+
target: `${c.package}::incentive_v3::borrow_v2`,
|
|
349
355
|
arguments: [
|
|
350
356
|
e.object("0x06"),
|
|
351
357
|
e.object(c.priceOracle),
|
|
@@ -354,7 +360,8 @@ async function ve(e, a, r, t) {
|
|
|
354
360
|
e.pure.u8(n.id),
|
|
355
361
|
o,
|
|
356
362
|
e.object(c.incentiveV2),
|
|
357
|
-
e.object(c.incentiveV3)
|
|
363
|
+
e.object(c.incentiveV3),
|
|
364
|
+
e.object("0x05")
|
|
358
365
|
],
|
|
359
366
|
typeArguments: [n.suiCoinType]
|
|
360
367
|
});
|
|
@@ -475,7 +482,7 @@ const Te = A(
|
|
|
475
482
|
const r = await w({
|
|
476
483
|
...a,
|
|
477
484
|
cacheTime: g
|
|
478
|
-
}), t = new
|
|
485
|
+
}), t = new B(), c = (l = a == null ? void 0 : a.client) != null ? l : I, n = await S(a);
|
|
479
486
|
t.moveCall({
|
|
480
487
|
target: `${r.uiGetter}::getter_unchecked::get_user_state`,
|
|
481
488
|
arguments: [t.object(r.storage), t.pure.address(e)]
|
|
@@ -484,7 +491,7 @@ const Te = A(
|
|
|
484
491
|
transactionBlock: t,
|
|
485
492
|
sender: e
|
|
486
493
|
}), i = k(o, [b.vector(Q)]);
|
|
487
|
-
return
|
|
494
|
+
return $(
|
|
488
495
|
i[0].filter((d) => d.supply_balance !== "0" || d.borrow_balance !== "0")
|
|
489
496
|
).map((d) => {
|
|
490
497
|
const h = n.find((v) => v.id === d.assetId), p = V(
|
|
@@ -505,7 +512,7 @@ const Te = A(
|
|
|
505
512
|
);
|
|
506
513
|
async function Ie(e, a) {
|
|
507
514
|
var o;
|
|
508
|
-
const r = (o = a == null ? void 0 : a.client) != null ? o : I, t = new
|
|
515
|
+
const r = (o = a == null ? void 0 : a.client) != null ? o : I, t = new B();
|
|
509
516
|
await ee(t, e, a);
|
|
510
517
|
const c = await r.devInspectTransactionBlock({
|
|
511
518
|
transactionBlock: t,
|
|
@@ -515,7 +522,7 @@ async function Ie(e, a) {
|
|
|
515
522
|
}
|
|
516
523
|
async function Ae(e, a, r, t) {
|
|
517
524
|
var p;
|
|
518
|
-
const c = (p = t == null ? void 0 : t.client) != null ? p : I, n = new
|
|
525
|
+
const c = (p = t == null ? void 0 : t.client) != null ? p : I, n = new B();
|
|
519
526
|
let o = 0, i = 0;
|
|
520
527
|
const u = await C(a, t);
|
|
521
528
|
if (r.forEach((y) => {
|
|
@@ -546,7 +553,7 @@ const Pe = _(
|
|
|
546
553
|
return (await fetch(t).then((n) => n.json())).data;
|
|
547
554
|
}
|
|
548
555
|
);
|
|
549
|
-
async function
|
|
556
|
+
async function $e(e, a) {
|
|
550
557
|
var n;
|
|
551
558
|
let r = null;
|
|
552
559
|
const t = [], c = (n = a == null ? void 0 : a.client) != null ? n : I;
|
|
@@ -609,7 +616,7 @@ async function ae(e, a, r) {
|
|
|
609
616
|
throw new Error(`failed to update pyth price feeds, msg: ${o.message}`);
|
|
610
617
|
}
|
|
611
618
|
}
|
|
612
|
-
async function
|
|
619
|
+
async function Be(e, a, r) {
|
|
613
620
|
const t = await w({
|
|
614
621
|
...r,
|
|
615
622
|
cacheTime: g
|
|
@@ -676,11 +683,12 @@ async function Fe(e, a, r, t) {
|
|
|
676
683
|
))
|
|
677
684
|
throw new Error("Pool does not support flashloan");
|
|
678
685
|
const [u, l] = e.moveCall({
|
|
679
|
-
target: `${c.package}::lending::
|
|
686
|
+
target: `${c.package}::lending::flash_loan_with_ctx_v2`,
|
|
680
687
|
arguments: [
|
|
681
688
|
e.object(c.flashloanConfig),
|
|
682
689
|
e.object(n.contract.pool),
|
|
683
|
-
f(r, e.pure.u64)
|
|
690
|
+
f(r, e.pure.u64),
|
|
691
|
+
e.object("0x05")
|
|
684
692
|
],
|
|
685
693
|
typeArguments: [n.suiCoinType]
|
|
686
694
|
});
|
|
@@ -716,7 +724,7 @@ async function Ve(e, a, r, t, c, n) {
|
|
|
716
724
|
...n,
|
|
717
725
|
cacheTime: g
|
|
718
726
|
}, i = await w(o), u = await C(a, o), l = await C(t, o), [d, h] = e.moveCall({
|
|
719
|
-
target: `${i.package}::incentive_v3::
|
|
727
|
+
target: `${i.package}::incentive_v3::liquidation_v2`,
|
|
720
728
|
arguments: [
|
|
721
729
|
e.object("0x06"),
|
|
722
730
|
// Clock object
|
|
@@ -738,8 +746,10 @@ async function Ve(e, a, r, t, c, n) {
|
|
|
738
746
|
// Borrower address
|
|
739
747
|
e.object(i.incentiveV2),
|
|
740
748
|
// Incentive V2 contract
|
|
741
|
-
e.object(i.incentiveV3)
|
|
749
|
+
e.object(i.incentiveV3),
|
|
742
750
|
// Incentive V3 contract
|
|
751
|
+
e.object("0x05")
|
|
752
|
+
// SuiSystemState object
|
|
743
753
|
],
|
|
744
754
|
typeArguments: [u.suiCoinType, l.suiCoinType]
|
|
745
755
|
});
|
|
@@ -753,7 +763,7 @@ async function Ee(e, a) {
|
|
|
753
763
|
}), c = (d = a == null ? void 0 : a.client) != null ? d : I, n = await w({
|
|
754
764
|
...a,
|
|
755
765
|
cacheTime: g
|
|
756
|
-
}), o = new
|
|
766
|
+
}), o = new B();
|
|
757
767
|
o.moveCall({
|
|
758
768
|
target: `${n.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
|
|
759
769
|
arguments: [
|
|
@@ -840,7 +850,7 @@ const Le = _(
|
|
|
840
850
|
), De = _(
|
|
841
851
|
async (e, a) => {
|
|
842
852
|
const r = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${(a == null ? void 0 : a.page) || 1}&pageSize=${(a == null ? void 0 : a.size) || 400}`, t = await fetch(r).then((c) => c.json());
|
|
843
|
-
return
|
|
853
|
+
return $({
|
|
844
854
|
data: t.data.rewards
|
|
845
855
|
});
|
|
846
856
|
}
|
|
@@ -985,7 +995,7 @@ export {
|
|
|
985
995
|
Fe as flashloanPTB,
|
|
986
996
|
F as getAllFlashLoanAssets,
|
|
987
997
|
_e as getBorrowFee,
|
|
988
|
-
|
|
998
|
+
$e as getCoins,
|
|
989
999
|
w as getConfig,
|
|
990
1000
|
he as getFees,
|
|
991
1001
|
Se as getFlashLoanAsset,
|
|
@@ -1010,7 +1020,7 @@ export {
|
|
|
1010
1020
|
Ce as repayCoinPTB,
|
|
1011
1021
|
Re as repayFlashLoanPTB,
|
|
1012
1022
|
Ne as summaryLendingRewards,
|
|
1013
|
-
|
|
1023
|
+
Be as updateOraclePricesPTB,
|
|
1014
1024
|
ae as updatePythPriceFeeds,
|
|
1015
1025
|
A as withCache,
|
|
1016
1026
|
_ as withSingleton,
|