@naviprotocol/lending 1.4.2 → 1.4.4-beta.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 +36 -33
- 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/reward.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -129,7 +129,7 @@ const z = m.bytes(32).transform({
|
|
|
129
129
|
borrow_balance: m.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
131
|
supply_balance: m.u256()
|
|
132
|
-
}), ye = "1.4.
|
|
132
|
+
}), ye = "1.4.4-beta.1", S = {
|
|
133
133
|
version: ye
|
|
134
134
|
}, ge = S.version, he = () => {
|
|
135
135
|
if (typeof process < "u" && process.versions && process.versions.node)
|
|
@@ -143,7 +143,7 @@ const z = m.bytes(32).transform({
|
|
|
143
143
|
}, ve = () => {
|
|
144
144
|
let e = "";
|
|
145
145
|
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ge} (${he()})`), e;
|
|
146
|
-
}, K = ve(),
|
|
146
|
+
}, K = ve(), $ = new se({
|
|
147
147
|
url: ue("mainnet")
|
|
148
148
|
});
|
|
149
149
|
function Q(e) {
|
|
@@ -166,11 +166,11 @@ function B(e) {
|
|
|
166
166
|
})), n[r];
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function P(e) {
|
|
170
170
|
let n = {};
|
|
171
171
|
return (...o) => {
|
|
172
172
|
const r = o[o.length - 1], t = Q(o), a = n[t];
|
|
173
|
-
return !r?.disableCache && typeof a?.data < "u" && (typeof r?.cacheTime > "u" || r.cacheTime > Date.now() - a.cacheAt) ? a.data : e(...o).then((c) => (n[t] = {
|
|
173
|
+
return !r?.disableCache && typeof a?.data < "u" && (typeof r?.cacheTime > "u" || r.cacheTime > Date.now() - a.cacheAt) ? Promise.resolve(a.data) : e(...o).then((c) => (n[t] = {
|
|
174
174
|
data: c,
|
|
175
175
|
cacheAt: Date.now()
|
|
176
176
|
}, c));
|
|
@@ -253,7 +253,7 @@ function T() {
|
|
|
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 F = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(F || {});
|
|
256
|
-
const R =
|
|
256
|
+
const R = P(
|
|
257
257
|
B(
|
|
258
258
|
async (e) => {
|
|
259
259
|
const n = (e?.markets || [E.main]).map((t) => j(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${S.version}&market=${n.map(
|
|
@@ -292,12 +292,12 @@ async function A(e, n) {
|
|
|
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 Je =
|
|
295
|
+
const Je = P(
|
|
296
296
|
B(async (e) => {
|
|
297
297
|
const n = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${S.version}`;
|
|
298
298
|
return (await fetch(n, { headers: M }).then((r) => r.json())).data;
|
|
299
299
|
})
|
|
300
|
-
), Ze =
|
|
300
|
+
), Ze = P(
|
|
301
301
|
B(
|
|
302
302
|
async (e) => {
|
|
303
303
|
const n = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${S.version}`;
|
|
@@ -576,7 +576,7 @@ async function xe(e, n, o, r) {
|
|
|
576
576
|
typeArguments: [a.suiCoinType]
|
|
577
577
|
}), e;
|
|
578
578
|
}
|
|
579
|
-
const et =
|
|
579
|
+
const et = P(
|
|
580
580
|
B(
|
|
581
581
|
async (e) => {
|
|
582
582
|
const n = await _({
|
|
@@ -584,7 +584,7 @@ const et = $(
|
|
|
584
584
|
});
|
|
585
585
|
if (e?.address && typeof e?.asset < "u")
|
|
586
586
|
try {
|
|
587
|
-
const t = await A(e.asset, e), a = e?.client ??
|
|
587
|
+
const t = await A(e.asset, e), a = e?.client ?? $, c = new N();
|
|
588
588
|
c.moveCall({
|
|
589
589
|
target: `${n.package}::incentive_v3::get_borrow_fee_v2`,
|
|
590
590
|
arguments: [
|
|
@@ -603,7 +603,7 @@ const et = $(
|
|
|
603
603
|
} catch (t) {
|
|
604
604
|
console.error(t);
|
|
605
605
|
}
|
|
606
|
-
const r = (await
|
|
606
|
+
const r = (await $.getObject({
|
|
607
607
|
id: n.incentiveV3,
|
|
608
608
|
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
609
609
|
})).data.content.fields.borrow_fee_rate;
|
|
@@ -620,6 +620,11 @@ const et = $(
|
|
|
620
620
|
id: 1,
|
|
621
621
|
key: "ember",
|
|
622
622
|
name: "Ember Market"
|
|
623
|
+
},
|
|
624
|
+
suieco: {
|
|
625
|
+
id: 2,
|
|
626
|
+
key: "sui-eco",
|
|
627
|
+
name: "Sui Eco Market"
|
|
623
628
|
}
|
|
624
629
|
};
|
|
625
630
|
class Ce {
|
|
@@ -690,7 +695,7 @@ const j = (e) => {
|
|
|
690
695
|
if (!o)
|
|
691
696
|
throw new Error("Market not found");
|
|
692
697
|
return o;
|
|
693
|
-
}, je =
|
|
698
|
+
}, je = P(
|
|
694
699
|
B(
|
|
695
700
|
async (e, n) => {
|
|
696
701
|
const o = await R({
|
|
@@ -704,11 +709,11 @@ const j = (e) => {
|
|
|
704
709
|
});
|
|
705
710
|
}
|
|
706
711
|
)
|
|
707
|
-
), tt =
|
|
712
|
+
), tt = P(
|
|
708
713
|
B(
|
|
709
714
|
async (e, n) => (await je([e], n))[0]
|
|
710
715
|
)
|
|
711
|
-
), _ =
|
|
716
|
+
), _ = P(
|
|
712
717
|
B(
|
|
713
718
|
async (e) => {
|
|
714
719
|
const n = j(e?.market || D), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${S.version}&market=${n.key}`;
|
|
@@ -786,13 +791,13 @@ async function nt(e, n, o) {
|
|
|
786
791
|
]
|
|
787
792
|
}), t;
|
|
788
793
|
}
|
|
789
|
-
const x =
|
|
794
|
+
const x = P(
|
|
790
795
|
B(
|
|
791
796
|
async (e, n) => {
|
|
792
797
|
const o = await _({
|
|
793
798
|
cacheTime: b,
|
|
794
799
|
...n
|
|
795
|
-
}), r = new N(), t = n?.client ??
|
|
800
|
+
}), r = new N(), t = n?.client ?? $;
|
|
796
801
|
r.moveCall({
|
|
797
802
|
target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
|
|
798
803
|
arguments: [r.object(o.emode.contract.registryObject), r.pure.address(e)]
|
|
@@ -856,7 +861,7 @@ async function Ae(e, n, o) {
|
|
|
856
861
|
return ee(e, n, 0, 0, 0, !1, o);
|
|
857
862
|
}
|
|
858
863
|
async function te(e, n, o) {
|
|
859
|
-
const r = new N(), t = o?.client ??
|
|
864
|
+
const r = new N(), t = o?.client ?? $, a = await R({
|
|
860
865
|
...o,
|
|
861
866
|
markets: Object.values(E)
|
|
862
867
|
}), c = H(a);
|
|
@@ -901,7 +906,7 @@ async function te(e, n, o) {
|
|
|
901
906
|
});
|
|
902
907
|
}), u;
|
|
903
908
|
}
|
|
904
|
-
const it =
|
|
909
|
+
const it = P(
|
|
905
910
|
async (e, n) => {
|
|
906
911
|
const r = (n?.markets || Object.keys(E)).map((t) => j(t)).map((t) => ({
|
|
907
912
|
address: e,
|
|
@@ -911,7 +916,7 @@ const it = $(
|
|
|
911
916
|
}
|
|
912
917
|
);
|
|
913
918
|
async function ct(e, n) {
|
|
914
|
-
const o = n?.client ??
|
|
919
|
+
const o = n?.client ?? $, r = new N();
|
|
915
920
|
await Ae(r, e, n);
|
|
916
921
|
const t = await o.devInspectTransactionBlock({
|
|
917
922
|
transactionBlock: r,
|
|
@@ -920,7 +925,7 @@ async function ct(e, n) {
|
|
|
920
925
|
return X(Number(a[0]) || 0);
|
|
921
926
|
}
|
|
922
927
|
async function st(e, n, o, r) {
|
|
923
|
-
const t = r?.client ??
|
|
928
|
+
const t = r?.client ?? $, a = new N();
|
|
924
929
|
let c = 0, i = 0;
|
|
925
930
|
const s = await A(n, r);
|
|
926
931
|
if (o.forEach((v) => {
|
|
@@ -953,7 +958,7 @@ const ut = B(
|
|
|
953
958
|
);
|
|
954
959
|
async function lt(e, n) {
|
|
955
960
|
let o = null;
|
|
956
|
-
const r = [], t = n?.client ??
|
|
961
|
+
const r = [], t = n?.client ?? $;
|
|
957
962
|
do {
|
|
958
963
|
let a;
|
|
959
964
|
if (n?.coinType ? a = await t.getCoins({
|
|
@@ -971,7 +976,7 @@ async function lt(e, n) {
|
|
|
971
976
|
} while (o);
|
|
972
977
|
return r;
|
|
973
978
|
}
|
|
974
|
-
const
|
|
979
|
+
const Pe = P(
|
|
975
980
|
async (e, n) => {
|
|
976
981
|
const o = [], r = (n?.markets || Object.keys(E)).map((i) => j(i));
|
|
977
982
|
let t = [];
|
|
@@ -1357,9 +1362,9 @@ async function dt(e) {
|
|
|
1357
1362
|
throw new Error(`failed to get pyth stale price feed id, msg: ${n.message}`);
|
|
1358
1363
|
}
|
|
1359
1364
|
}
|
|
1360
|
-
async function
|
|
1365
|
+
async function $e(e, n) {
|
|
1361
1366
|
try {
|
|
1362
|
-
const o = [], r = n?.client ??
|
|
1367
|
+
const o = [], r = n?.client ?? $, t = e.map((c) => c.priceInfoObject), a = await r.multiGetObjects({
|
|
1363
1368
|
ids: Array.from(new Set(t)),
|
|
1364
1369
|
options: { showContent: !0 }
|
|
1365
1370
|
});
|
|
@@ -1392,7 +1397,7 @@ async function Pe(e, n) {
|
|
|
1392
1397
|
}
|
|
1393
1398
|
async function Se(e, n) {
|
|
1394
1399
|
try {
|
|
1395
|
-
const o = [], r = await
|
|
1400
|
+
const o = [], r = await $e(e, n);
|
|
1396
1401
|
if (!r) return o;
|
|
1397
1402
|
const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
1398
1403
|
for (const a of r) {
|
|
@@ -1413,7 +1418,7 @@ async function Se(e, n) {
|
|
|
1413
1418
|
}
|
|
1414
1419
|
}
|
|
1415
1420
|
async function Ve(e, n, o) {
|
|
1416
|
-
const r = o?.client ??
|
|
1421
|
+
const r = o?.client ?? $, t = await _({
|
|
1417
1422
|
...o,
|
|
1418
1423
|
cacheTime: b
|
|
1419
1424
|
});
|
|
@@ -1510,7 +1515,7 @@ async function mt(e, n, o, r) {
|
|
|
1510
1515
|
o.forEach((u) => {
|
|
1511
1516
|
a.includes(u.market) || a.push(u.market);
|
|
1512
1517
|
});
|
|
1513
|
-
const c = await
|
|
1518
|
+
const c = await Pe(n, {
|
|
1514
1519
|
...r,
|
|
1515
1520
|
markets: a
|
|
1516
1521
|
}), i = Ee(t, {
|
|
@@ -1527,7 +1532,7 @@ async function mt(e, n, o, r) {
|
|
|
1527
1532
|
return console.error(t), e;
|
|
1528
1533
|
}
|
|
1529
1534
|
}
|
|
1530
|
-
const G =
|
|
1535
|
+
const G = P(
|
|
1531
1536
|
B(
|
|
1532
1537
|
async (e) => {
|
|
1533
1538
|
const n = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${S.version}&market=${e?.market || D}`, o = await fetch(n, { headers: M }).then((r) => r.json());
|
|
@@ -1673,7 +1678,7 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1673
1678
|
}
|
|
1674
1679
|
}
|
|
1675
1680
|
async function De(e, n, o) {
|
|
1676
|
-
const r = o?.client ??
|
|
1681
|
+
const r = o?.client ?? $, t = new N(), a = await R({
|
|
1677
1682
|
...o,
|
|
1678
1683
|
markets: Object.values(E),
|
|
1679
1684
|
cacheTime: b
|
|
@@ -1848,9 +1853,7 @@ async function _t(e, n, o) {
|
|
|
1848
1853
|
...o,
|
|
1849
1854
|
cacheTime: b,
|
|
1850
1855
|
market: d
|
|
1851
|
-
}), f = c.split("___")[0], w = r.find(
|
|
1852
|
-
(V) => k(V.suiCoinType) === k(f)
|
|
1853
|
-
);
|
|
1856
|
+
}), f = c.split("___")[0], w = r.find((V) => k(V.suiCoinType) === k(f));
|
|
1854
1857
|
if (!w || !w.contract.rewardFundId)
|
|
1855
1858
|
throw new Error(`No matching rewardFund found for reward coin: ${f} ${d}`);
|
|
1856
1859
|
const I = w.contract.rewardFundId;
|
|
@@ -2025,7 +2028,7 @@ export {
|
|
|
2025
2028
|
ft as getFlashLoanAsset,
|
|
2026
2029
|
ct as getHealthFactor,
|
|
2027
2030
|
Ae as getHealthFactorPTB,
|
|
2028
|
-
|
|
2031
|
+
Pe as getLendingPositions,
|
|
2029
2032
|
it as getLendingState,
|
|
2030
2033
|
tt as getMarket,
|
|
2031
2034
|
j as getMarketConfig,
|
|
@@ -2055,7 +2058,7 @@ export {
|
|
|
2055
2058
|
Me as updateOraclePricesPTB,
|
|
2056
2059
|
Ve as updatePythPriceFeeds,
|
|
2057
2060
|
pt as verifyHealthFactorPTB,
|
|
2058
|
-
|
|
2061
|
+
P as withCache,
|
|
2059
2062
|
B as withSingleton,
|
|
2060
2063
|
Qe as withdrawCoinPTB
|
|
2061
2064
|
};
|