@naviprotocol/lending 1.4.5-beta.2 → 1.4.5-beta.4
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 +43 -45
- package/dist/index.esm.js.map +1 -1
- package/dist/market.d.ts +9 -0
- package/dist/market.d.ts.map +1 -1
- package/dist/pool.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -129,7 +129,7 @@ const J = d.bytes(32).transform({
|
|
|
129
129
|
borrow_balance: d.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
131
|
supply_balance: d.u256()
|
|
132
|
-
}), be = "1.4.5-beta.
|
|
132
|
+
}), be = "1.4.5-beta.4", E = {
|
|
133
133
|
version: be
|
|
134
134
|
}, ke = E.version, _e = () => {
|
|
135
135
|
if (typeof process < "u" && process.versions && process.versions.node)
|
|
@@ -143,7 +143,7 @@ const J = d.bytes(32).transform({
|
|
|
143
143
|
}, Ce = () => {
|
|
144
144
|
let e = "";
|
|
145
145
|
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ke} (${_e()})`), e;
|
|
146
|
-
}, Z = Ce(),
|
|
146
|
+
}, Z = Ce(), V = new de({
|
|
147
147
|
url: me("mainnet")
|
|
148
148
|
});
|
|
149
149
|
function ee(e) {
|
|
@@ -166,7 +166,7 @@ function P(e) {
|
|
|
166
166
|
})), r[n];
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function M(e) {
|
|
170
170
|
let r = {};
|
|
171
171
|
return (...o) => {
|
|
172
172
|
const n = o[o.length - 1], t = ee(o), a = r[t];
|
|
@@ -253,7 +253,7 @@ function $() {
|
|
|
253
253
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
254
254
|
}
|
|
255
255
|
var R = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(R || {});
|
|
256
|
-
const q =
|
|
256
|
+
const q = M(
|
|
257
257
|
P(
|
|
258
258
|
async (e) => {
|
|
259
259
|
const r = (e?.markets || [U.main]).map((t) => T(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.map(
|
|
@@ -292,12 +292,12 @@ async function S(e, r) {
|
|
|
292
292
|
throw new Error("Pool not found");
|
|
293
293
|
return t.isDeprecated && console.log(`The lending pool for coinType ${t.suiCoinType} is going to be deprecated.`), t;
|
|
294
294
|
}
|
|
295
|
-
const xe =
|
|
295
|
+
const xe = M(
|
|
296
296
|
P(async (e) => {
|
|
297
297
|
const r = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${E.version}`;
|
|
298
298
|
return (await fetch(r, { headers: D }).then((n) => n.json())).data;
|
|
299
299
|
})
|
|
300
|
-
), et =
|
|
300
|
+
), et = M(
|
|
301
301
|
P(
|
|
302
302
|
async (e) => {
|
|
303
303
|
const r = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${E.version}`;
|
|
@@ -309,19 +309,17 @@ async function Be(e, r, o, n) {
|
|
|
309
309
|
const t = await _({
|
|
310
310
|
...n,
|
|
311
311
|
cacheTime: b
|
|
312
|
-
}), a = await S(r, n);
|
|
313
|
-
n?.market;
|
|
314
|
-
const s = n?.env || "prod";
|
|
312
|
+
}), a = await S(r, n), s = n?.market || O, i = n?.env || "prod";
|
|
315
313
|
if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
|
|
316
314
|
throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
|
|
317
|
-
const
|
|
318
|
-
if (k(a.suiCoinType) === k("0x2::sui::SUI") &&
|
|
315
|
+
const c = typeof o == "object" && o.$kind === "GasCoin";
|
|
316
|
+
if (k(a.suiCoinType) === k("0x2::sui::SUI") && c) {
|
|
319
317
|
if (!n?.amount)
|
|
320
318
|
throw new Error("Amount is required for sui coin");
|
|
321
319
|
o = e.splitCoins(o, [n.amount]);
|
|
322
320
|
}
|
|
323
|
-
let
|
|
324
|
-
return typeof n?.amount < "u" ?
|
|
321
|
+
let u;
|
|
322
|
+
return typeof n?.amount < "u" ? u = g(n.amount, e.pure.u64) : u = e.moveCall({
|
|
325
323
|
target: "0x2::coin::value",
|
|
326
324
|
arguments: [g(o, e.object)],
|
|
327
325
|
typeArguments: [a.suiCoinType]
|
|
@@ -346,12 +344,12 @@ async function Be(e, r, o, n) {
|
|
|
346
344
|
e.object(a.contract.pool),
|
|
347
345
|
e.pure.u8(a.id),
|
|
348
346
|
g(o, e.object),
|
|
349
|
-
|
|
347
|
+
u,
|
|
350
348
|
e.object(t.incentiveV2),
|
|
351
349
|
e.object(t.incentiveV3)
|
|
352
350
|
],
|
|
353
351
|
typeArguments: [a.suiCoinType]
|
|
354
|
-
}), t.version === 2 && a.token.symbol === "SUI" &&
|
|
352
|
+
}), t.version === 2 && a.token.symbol === "SUI" && i === "prod" && s === "main" && e.moveCall({
|
|
355
353
|
target: `${t.package}::pool::refresh_stake`,
|
|
356
354
|
arguments: [e.object(a.contract.pool), e.object("0x05")]
|
|
357
355
|
}), e;
|
|
@@ -578,7 +576,7 @@ async function rt(e, r, o, n) {
|
|
|
578
576
|
typeArguments: [a.suiCoinType]
|
|
579
577
|
}), e;
|
|
580
578
|
}
|
|
581
|
-
const nt =
|
|
579
|
+
const nt = M(
|
|
582
580
|
P(
|
|
583
581
|
async (e) => {
|
|
584
582
|
const r = await _({
|
|
@@ -586,7 +584,7 @@ const nt = V(
|
|
|
586
584
|
});
|
|
587
585
|
if (e?.address && typeof e?.asset < "u")
|
|
588
586
|
try {
|
|
589
|
-
const t = await S(e.asset, e), a = e?.client ??
|
|
587
|
+
const t = await S(e.asset, e), a = e?.client ?? V, s = new F();
|
|
590
588
|
s.moveCall({
|
|
591
589
|
target: `${r.package}::incentive_v3::get_borrow_fee_v2`,
|
|
592
590
|
arguments: [
|
|
@@ -605,7 +603,7 @@ const nt = V(
|
|
|
605
603
|
} catch (t) {
|
|
606
604
|
console.error(t);
|
|
607
605
|
}
|
|
608
|
-
const n = (await
|
|
606
|
+
const n = (await V.getObject({
|
|
609
607
|
id: r.incentiveV3,
|
|
610
608
|
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
611
609
|
})).data.content.fields.borrow_fee_rate;
|
|
@@ -623,15 +621,15 @@ const nt = V(
|
|
|
623
621
|
key: "ember",
|
|
624
622
|
name: "Ember Market"
|
|
625
623
|
},
|
|
626
|
-
// 'sui-eco': {
|
|
627
|
-
// id: 2,
|
|
628
|
-
// key: 'sui-eco',
|
|
629
|
-
// name: 'Sui Eco Market'
|
|
630
|
-
// },
|
|
631
624
|
rwa: {
|
|
632
625
|
id: 2,
|
|
633
626
|
key: "rwa",
|
|
634
627
|
name: "Matrixdock Market"
|
|
628
|
+
},
|
|
629
|
+
"sui-eco": {
|
|
630
|
+
id: 3,
|
|
631
|
+
key: "sui-eco",
|
|
632
|
+
name: "Sui Eco Market"
|
|
635
633
|
}
|
|
636
634
|
};
|
|
637
635
|
class Ae {
|
|
@@ -702,7 +700,7 @@ const T = (e) => {
|
|
|
702
700
|
if (!o)
|
|
703
701
|
throw new Error("Market not found");
|
|
704
702
|
return o;
|
|
705
|
-
}, $e =
|
|
703
|
+
}, $e = M(
|
|
706
704
|
P(
|
|
707
705
|
async (e, r) => {
|
|
708
706
|
const o = await q({
|
|
@@ -716,11 +714,11 @@ const T = (e) => {
|
|
|
716
714
|
});
|
|
717
715
|
}
|
|
718
716
|
)
|
|
719
|
-
), at =
|
|
717
|
+
), at = M(
|
|
720
718
|
P(
|
|
721
719
|
async (e, r) => (await $e([e], r))[0]
|
|
722
720
|
)
|
|
723
|
-
), _ =
|
|
721
|
+
), _ = M(
|
|
724
722
|
P(
|
|
725
723
|
async (e) => {
|
|
726
724
|
const r = T(e?.market || O), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.key}`;
|
|
@@ -748,7 +746,7 @@ async function Se(e, r, o) {
|
|
|
748
746
|
arguments: [r]
|
|
749
747
|
});
|
|
750
748
|
}
|
|
751
|
-
async function
|
|
749
|
+
async function Me(e, r, o) {
|
|
752
750
|
const n = await _({
|
|
753
751
|
...o,
|
|
754
752
|
cacheTime: b
|
|
@@ -783,7 +781,7 @@ async function ct(e, r, o) {
|
|
|
783
781
|
cacheTime: b,
|
|
784
782
|
...o
|
|
785
783
|
}), t = await Pe(e, o);
|
|
786
|
-
await
|
|
784
|
+
await Me(e, r, {
|
|
787
785
|
...o,
|
|
788
786
|
accountCap: t
|
|
789
787
|
});
|
|
@@ -798,13 +796,13 @@ async function ct(e, r, o) {
|
|
|
798
796
|
]
|
|
799
797
|
}), t;
|
|
800
798
|
}
|
|
801
|
-
const oe =
|
|
799
|
+
const oe = M(
|
|
802
800
|
P(
|
|
803
801
|
async (e, r) => {
|
|
804
802
|
const o = await _({
|
|
805
803
|
cacheTime: b,
|
|
806
804
|
...r
|
|
807
|
-
}), n = new F(), t = r?.client ??
|
|
805
|
+
}), n = new F(), t = r?.client ?? V;
|
|
808
806
|
n.moveCall({
|
|
809
807
|
target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
|
|
810
808
|
arguments: [n.object(o.emode.contract.registryObject), n.pure.address(e)]
|
|
@@ -864,11 +862,11 @@ async function re(e, r, o, n, t, a, s) {
|
|
|
864
862
|
typeArguments: [c.suiCoinType]
|
|
865
863
|
});
|
|
866
864
|
}
|
|
867
|
-
async function
|
|
865
|
+
async function Ve(e, r, o) {
|
|
868
866
|
return re(e, r, 0, 0, 0, !1, o);
|
|
869
867
|
}
|
|
870
868
|
async function ne(e, r, o) {
|
|
871
|
-
const n = new F(), t = o?.client ??
|
|
869
|
+
const n = new F(), t = o?.client ?? V, a = await q({
|
|
872
870
|
...o,
|
|
873
871
|
markets: Object.values(U)
|
|
874
872
|
}), s = z(a), c = Array.from(new Set(r.map((l) => l.market))).map((l) => T(l));
|
|
@@ -935,7 +933,7 @@ async function ne(e, r, o) {
|
|
|
935
933
|
});
|
|
936
934
|
}), y;
|
|
937
935
|
}
|
|
938
|
-
const ut =
|
|
936
|
+
const ut = M(
|
|
939
937
|
async (e, r) => {
|
|
940
938
|
const n = (r?.markets || Object.keys(U)).map((t) => T(t)).map((t) => ({
|
|
941
939
|
address: e,
|
|
@@ -945,8 +943,8 @@ const ut = V(
|
|
|
945
943
|
}
|
|
946
944
|
);
|
|
947
945
|
async function pt(e, r) {
|
|
948
|
-
const o = r?.client ??
|
|
949
|
-
await
|
|
946
|
+
const o = r?.client ?? V, n = new F();
|
|
947
|
+
await Ve(n, e, r);
|
|
950
948
|
const t = await o.devInspectTransactionBlock({
|
|
951
949
|
transactionBlock: n,
|
|
952
950
|
sender: e
|
|
@@ -954,7 +952,7 @@ async function pt(e, r) {
|
|
|
954
952
|
return te(Number(a[0]) || 0);
|
|
955
953
|
}
|
|
956
954
|
async function dt(e, r, o, n) {
|
|
957
|
-
const t = n?.client ??
|
|
955
|
+
const t = n?.client ?? V, a = new F();
|
|
958
956
|
let s = 0, i = 0;
|
|
959
957
|
const c = await S(r, n);
|
|
960
958
|
if (o.forEach((v) => {
|
|
@@ -987,7 +985,7 @@ const mt = P(
|
|
|
987
985
|
);
|
|
988
986
|
async function ft(e, r) {
|
|
989
987
|
let o = null;
|
|
990
|
-
const n = [], t = r?.client ??
|
|
988
|
+
const n = [], t = r?.client ?? V;
|
|
991
989
|
do {
|
|
992
990
|
let a;
|
|
993
991
|
if (r?.coinType ? a = await t.getCoins({
|
|
@@ -1005,7 +1003,7 @@ async function ft(e, r) {
|
|
|
1005
1003
|
} while (o);
|
|
1006
1004
|
return n;
|
|
1007
1005
|
}
|
|
1008
|
-
const Ee =
|
|
1006
|
+
const Ee = M(
|
|
1009
1007
|
async (e, r) => {
|
|
1010
1008
|
const o = [], n = (r?.markets || Object.keys(U)).map((i) => T(i));
|
|
1011
1009
|
let t = [];
|
|
@@ -1393,7 +1391,7 @@ async function gt(e) {
|
|
|
1393
1391
|
}
|
|
1394
1392
|
async function De(e, r) {
|
|
1395
1393
|
try {
|
|
1396
|
-
const o = [], n = r?.client ??
|
|
1394
|
+
const o = [], n = r?.client ?? V, t = e.map((s) => s.priceInfoObject), a = await n.multiGetObjects({
|
|
1397
1395
|
ids: Array.from(new Set(t)),
|
|
1398
1396
|
options: { showContent: !0 }
|
|
1399
1397
|
});
|
|
@@ -1447,7 +1445,7 @@ async function Ue(e, r) {
|
|
|
1447
1445
|
}
|
|
1448
1446
|
}
|
|
1449
1447
|
async function Oe(e, r, o) {
|
|
1450
|
-
const n = o?.client ??
|
|
1448
|
+
const n = o?.client ?? V, t = await _({
|
|
1451
1449
|
...o,
|
|
1452
1450
|
cacheTime: b
|
|
1453
1451
|
});
|
|
@@ -1561,7 +1559,7 @@ async function ht(e, r, o, n) {
|
|
|
1561
1559
|
return console.error(t), e;
|
|
1562
1560
|
}
|
|
1563
1561
|
}
|
|
1564
|
-
const Y =
|
|
1562
|
+
const Y = M(
|
|
1565
1563
|
P(
|
|
1566
1564
|
async (e) => {
|
|
1567
1565
|
const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${E.version}&market=${e?.market || O}`, o = await fetch(r, { headers: D }).then((n) => n.json());
|
|
@@ -1707,7 +1705,7 @@ async function kt(e, r, o, n, t, a) {
|
|
|
1707
1705
|
}
|
|
1708
1706
|
}
|
|
1709
1707
|
async function Re(e, r, o) {
|
|
1710
|
-
const n = o?.client ??
|
|
1708
|
+
const n = o?.client ?? V, t = new F(), a = await q({
|
|
1711
1709
|
...o,
|
|
1712
1710
|
markets: Object.values(U),
|
|
1713
1711
|
cacheTime: b
|
|
@@ -2050,7 +2048,7 @@ export {
|
|
|
2050
2048
|
ct as createEModeCapPTB,
|
|
2051
2049
|
Be as depositCoinPTB,
|
|
2052
2050
|
st as emodeIdentityId,
|
|
2053
|
-
|
|
2051
|
+
Me as enterEModePTB,
|
|
2054
2052
|
it as exitEModePTB,
|
|
2055
2053
|
Fe as filterPriceFeeds,
|
|
2056
2054
|
wt as flashloanPTB,
|
|
@@ -2062,7 +2060,7 @@ export {
|
|
|
2062
2060
|
et as getFees,
|
|
2063
2061
|
vt as getFlashLoanAsset,
|
|
2064
2062
|
pt as getHealthFactor,
|
|
2065
|
-
|
|
2063
|
+
Ve as getHealthFactorPTB,
|
|
2066
2064
|
Ee as getLendingPositions,
|
|
2067
2065
|
ut as getLendingState,
|
|
2068
2066
|
at as getMarket,
|
|
@@ -2093,7 +2091,7 @@ export {
|
|
|
2093
2091
|
Ne as updateOraclePricesPTB,
|
|
2094
2092
|
Oe as updatePythPriceFeeds,
|
|
2095
2093
|
yt as verifyHealthFactorPTB,
|
|
2096
|
-
|
|
2094
|
+
M as withCache,
|
|
2097
2095
|
P as withSingleton,
|
|
2098
2096
|
tt as withdrawCoinPTB
|
|
2099
2097
|
};
|