@naviprotocol/lending 1.3.3 → 1.3.4-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/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +22 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/pool.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3,10 +3,10 @@ import { bcs as i, toHex as z, fromHex as W } from "@mysten/bcs";
|
|
|
3
3
|
import { SuiClient as J, getFullnodeUrl as K } from "@mysten/sui/client";
|
|
4
4
|
import Y from "lodash.camelcase";
|
|
5
5
|
import { normalizeStructTag as Q } from "@mysten/sui/utils";
|
|
6
|
-
import { SuiPriceServiceConnection as
|
|
6
|
+
import { SuiPriceServiceConnection as U, SuiPythClient as X } from "@pythnetwork/pyth-sui-js";
|
|
7
7
|
import T from "bignumber.js";
|
|
8
8
|
import { bcs as w } from "@mysten/sui/bcs";
|
|
9
|
-
const
|
|
9
|
+
const N = i.bytes(32).transform({
|
|
10
10
|
// To change the input type, you need to provide a type definition for the input
|
|
11
11
|
input: (e) => W(e),
|
|
12
12
|
output: (e) => z(e)
|
|
@@ -19,9 +19,9 @@ const R = i.bytes(32).transform({
|
|
|
19
19
|
coin_types: i.vector(i.string())
|
|
20
20
|
}), Z = i.struct("IncentivePoolInfo", {
|
|
21
21
|
/** Unique pool identifier */
|
|
22
|
-
pool_id:
|
|
22
|
+
pool_id: N,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
24
|
-
funds:
|
|
24
|
+
funds: N,
|
|
25
25
|
/** Current phase of the incentive program */
|
|
26
26
|
phase: i.u64(),
|
|
27
27
|
/** Timestamp when the incentive started */
|
|
@@ -129,9 +129,9 @@ const R = i.bytes(32).transform({
|
|
|
129
129
|
borrow_balance: i.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
131
|
supply_balance: i.u256()
|
|
132
|
-
}), ee = "1.3.
|
|
132
|
+
}), ee = "1.3.4-dev.2", F = {
|
|
133
133
|
version: ee
|
|
134
|
-
}, te =
|
|
134
|
+
}, te = F.version, re = () => {
|
|
135
135
|
if (typeof process != "undefined" && process.versions && process.versions.node)
|
|
136
136
|
try {
|
|
137
137
|
const e = require("os"), r = process.version, c = e.type(), t = e.arch();
|
|
@@ -143,7 +143,7 @@ const R = i.bytes(32).transform({
|
|
|
143
143
|
}, ae = () => {
|
|
144
144
|
let e = "";
|
|
145
145
|
return typeof process != "undefined" && process.versions && process.versions.node && (e = `lending/${te} (${re()})`), e;
|
|
146
|
-
},
|
|
146
|
+
}, E = ae(), A = new J({
|
|
147
147
|
url: K("mainnet")
|
|
148
148
|
});
|
|
149
149
|
function L(e) {
|
|
@@ -206,25 +206,25 @@ function M(e) {
|
|
|
206
206
|
const r = (e || 0) / Math.pow(10, 27);
|
|
207
207
|
return r > Math.pow(10, 5) ? 1 / 0 : r;
|
|
208
208
|
}
|
|
209
|
-
new
|
|
209
|
+
new U("https://hermes.pyth.network", {
|
|
210
210
|
timeout: 2e4
|
|
211
211
|
});
|
|
212
|
-
const ne = 27,
|
|
212
|
+
const ne = 27, D = (e, r) => {
|
|
213
213
|
if (!Number(e) || !Number(r)) return new T(0);
|
|
214
214
|
const c = new T(1).shiftedBy(1 * ne), t = c.multipliedBy(new T(0.5));
|
|
215
215
|
return new T(e).multipliedBy(new T(r)).plus(t).dividedBy(c).integerValue(T.ROUND_DOWN);
|
|
216
|
-
}, I =
|
|
217
|
-
"User-Agent":
|
|
216
|
+
}, I = E ? {
|
|
217
|
+
"User-Agent": E
|
|
218
218
|
} : {}, b = $(
|
|
219
219
|
j(async (e) => {
|
|
220
|
-
const r = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}&sdk=${
|
|
220
|
+
const r = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}&sdk=${F.version}`;
|
|
221
221
|
return (await fetch(r, { headers: I }).then((t) => t.json())).data;
|
|
222
222
|
})
|
|
223
223
|
), g = 1e3 * 60 * 5;
|
|
224
224
|
var k = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(k || {});
|
|
225
225
|
const S = $(
|
|
226
226
|
j(async (e) => {
|
|
227
|
-
const r = `https://open-api.naviprotocol.io/api/navi/pools?env=${(e == null ? void 0 : e.env) || "prod"}`;
|
|
227
|
+
const r = `https://open-api.naviprotocol.io/api/navi/pools?env=${(e == null ? void 0 : e.env) || "prod"}&sdk=${F.version}`;
|
|
228
228
|
return (await fetch(r, { headers: I }).then((t) => t.json())).data;
|
|
229
229
|
})
|
|
230
230
|
);
|
|
@@ -611,10 +611,10 @@ const Ve = $(
|
|
|
611
611
|
return V(
|
|
612
612
|
s[0].filter((p) => p.supply_balance !== "0" || p.borrow_balance !== "0")
|
|
613
613
|
).map((p) => {
|
|
614
|
-
const h = n.find((C) => C.id === p.assetId), f =
|
|
614
|
+
const h = n.find((C) => C.id === p.assetId), f = D(
|
|
615
615
|
p.supplyBalance,
|
|
616
616
|
h.currentSupplyIndex
|
|
617
|
-
).toString(), y =
|
|
617
|
+
).toString(), y = D(
|
|
618
618
|
p.borrowBalance,
|
|
619
619
|
h.currentBorrowIndex
|
|
620
620
|
).toString();
|
|
@@ -691,7 +691,7 @@ async function Ne(e, r) {
|
|
|
691
691
|
} while (c);
|
|
692
692
|
return t;
|
|
693
693
|
}
|
|
694
|
-
const q = new
|
|
694
|
+
const q = new U("https://hermes.pyth.network", {
|
|
695
695
|
timeout: 1e4
|
|
696
696
|
});
|
|
697
697
|
async function ie(e) {
|
|
@@ -775,7 +775,7 @@ async function le(e) {
|
|
|
775
775
|
function De(e, r) {
|
|
776
776
|
return e.filter((c) => !!(r != null && r.lendingState && r.lendingState.find((a) => a.assetId === c.assetId) || r != null && r.pools && r.pools.find((a) => a.id === c.assetId)));
|
|
777
777
|
}
|
|
778
|
-
const
|
|
778
|
+
const R = $(
|
|
779
779
|
j(async (e) => {
|
|
780
780
|
const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${(e == null ? void 0 : e.env) || "prod"}`, c = await fetch(r, { headers: I }).then((t) => t.json());
|
|
781
781
|
return Object.keys(c.data).map((t) => ({
|
|
@@ -785,14 +785,14 @@ const F = $(
|
|
|
785
785
|
})
|
|
786
786
|
);
|
|
787
787
|
async function Ue(e, r) {
|
|
788
|
-
return (await
|
|
788
|
+
return (await R(r)).find((t) => typeof e == "string" ? m(t.coinType) === m(e) : typeof e == "number" ? t.assetId === e : t.assetId === e.id) || null;
|
|
789
789
|
}
|
|
790
790
|
async function Le(e, r, c, t) {
|
|
791
791
|
const a = await b({
|
|
792
792
|
...t,
|
|
793
793
|
cacheTime: g
|
|
794
794
|
}), n = await v(r, t);
|
|
795
|
-
if (!(await
|
|
795
|
+
if (!(await R({
|
|
796
796
|
...t,
|
|
797
797
|
cacheTime: g
|
|
798
798
|
})).some(
|
|
@@ -829,7 +829,7 @@ async function Me(e, r, c, t, a) {
|
|
|
829
829
|
...a,
|
|
830
830
|
cacheTime: g
|
|
831
831
|
}), o = await v(r, a);
|
|
832
|
-
if (!(await
|
|
832
|
+
if (!(await R({
|
|
833
833
|
...a,
|
|
834
834
|
cacheTime: g
|
|
835
835
|
})).some(
|
|
@@ -1140,7 +1140,7 @@ async function Je(e, r) {
|
|
|
1140
1140
|
});
|
|
1141
1141
|
}
|
|
1142
1142
|
export {
|
|
1143
|
-
|
|
1143
|
+
N as Address,
|
|
1144
1144
|
g as DEFAULT_CACHE_TIME,
|
|
1145
1145
|
je as FlashLoanAssetConfig,
|
|
1146
1146
|
we as IncentiveAPYInfo,
|
|
@@ -1156,7 +1156,7 @@ export {
|
|
|
1156
1156
|
oe as depositCoinPTB,
|
|
1157
1157
|
De as filterPriceFeeds,
|
|
1158
1158
|
Le as flashloanPTB,
|
|
1159
|
-
|
|
1159
|
+
R as getAllFlashLoanAssets,
|
|
1160
1160
|
Be as getBorrowFee,
|
|
1161
1161
|
Ne as getCoins,
|
|
1162
1162
|
b as getConfig,
|