@naviprotocol/lending 1.3.4-dev.2 → 1.3.4-dev.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 +24 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/pool.d.ts +2 -2
- package/dist/pool.d.ts.map +1 -1
- package/dist/types.d.ts +0 -1
- 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 D, 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 R = 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 N = 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: R,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
24
|
-
funds:
|
|
24
|
+
funds: R,
|
|
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 N = 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.4-dev.
|
|
132
|
+
}), ee = "1.3.4-dev.4", U = {
|
|
133
133
|
version: ee
|
|
134
|
-
}, te =
|
|
134
|
+
}, te = U.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 N = 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
|
+
}, N = 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 D("https://hermes.pyth.network", {
|
|
210
210
|
timeout: 2e4
|
|
211
211
|
});
|
|
212
|
-
const ne = 27,
|
|
212
|
+
const ne = 27, E = (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 = N ? {
|
|
217
|
+
"User-Agent": N
|
|
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=${U.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"}`;
|
|
228
228
|
return (await fetch(r, { headers: I }).then((t) => t.json())).data;
|
|
229
229
|
})
|
|
230
230
|
);
|
|
@@ -489,13 +489,12 @@ async function ke(e, r, c, t) {
|
|
|
489
489
|
e.object(n.contract.pool),
|
|
490
490
|
e.pure.u8(n.id),
|
|
491
491
|
d(c, e.object),
|
|
492
|
-
s,
|
|
493
492
|
e.object(a.incentiveV2),
|
|
494
493
|
e.object(a.incentiveV3),
|
|
495
494
|
d(t.accountCap, e.object)
|
|
496
495
|
],
|
|
497
496
|
typeArguments: [n.suiCoinType]
|
|
498
|
-
}) : e.moveCall({
|
|
497
|
+
}) : (e.moveCall({
|
|
499
498
|
target: `${a.package}::incentive_v3::entry_repay`,
|
|
500
499
|
arguments: [
|
|
501
500
|
e.object("0x06"),
|
|
@@ -509,7 +508,7 @@ async function ke(e, r, c, t) {
|
|
|
509
508
|
e.object(a.incentiveV3)
|
|
510
509
|
],
|
|
511
510
|
typeArguments: [n.suiCoinType]
|
|
512
|
-
}), e;
|
|
511
|
+
}), e);
|
|
513
512
|
}
|
|
514
513
|
const Be = $(
|
|
515
514
|
j(
|
|
@@ -611,10 +610,10 @@ const Ve = $(
|
|
|
611
610
|
return V(
|
|
612
611
|
s[0].filter((p) => p.supply_balance !== "0" || p.borrow_balance !== "0")
|
|
613
612
|
).map((p) => {
|
|
614
|
-
const h = n.find((C) => C.id === p.assetId), f =
|
|
613
|
+
const h = n.find((C) => C.id === p.assetId), f = E(
|
|
615
614
|
p.supplyBalance,
|
|
616
615
|
h.currentSupplyIndex
|
|
617
|
-
).toString(), y =
|
|
616
|
+
).toString(), y = E(
|
|
618
617
|
p.borrowBalance,
|
|
619
618
|
h.currentBorrowIndex
|
|
620
619
|
).toString();
|
|
@@ -691,7 +690,7 @@ async function Ne(e, r) {
|
|
|
691
690
|
} while (c);
|
|
692
691
|
return t;
|
|
693
692
|
}
|
|
694
|
-
const q = new
|
|
693
|
+
const q = new D("https://hermes.pyth.network", {
|
|
695
694
|
timeout: 1e4
|
|
696
695
|
});
|
|
697
696
|
async function ie(e) {
|
|
@@ -775,7 +774,7 @@ async function le(e) {
|
|
|
775
774
|
function De(e, r) {
|
|
776
775
|
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
776
|
}
|
|
778
|
-
const
|
|
777
|
+
const F = $(
|
|
779
778
|
j(async (e) => {
|
|
780
779
|
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
780
|
return Object.keys(c.data).map((t) => ({
|
|
@@ -785,14 +784,14 @@ const R = $(
|
|
|
785
784
|
})
|
|
786
785
|
);
|
|
787
786
|
async function Ue(e, r) {
|
|
788
|
-
return (await
|
|
787
|
+
return (await F(r)).find((t) => typeof e == "string" ? m(t.coinType) === m(e) : typeof e == "number" ? t.assetId === e : t.assetId === e.id) || null;
|
|
789
788
|
}
|
|
790
789
|
async function Le(e, r, c, t) {
|
|
791
790
|
const a = await b({
|
|
792
791
|
...t,
|
|
793
792
|
cacheTime: g
|
|
794
793
|
}), n = await v(r, t);
|
|
795
|
-
if (!(await
|
|
794
|
+
if (!(await F({
|
|
796
795
|
...t,
|
|
797
796
|
cacheTime: g
|
|
798
797
|
})).some(
|
|
@@ -829,7 +828,7 @@ async function Me(e, r, c, t, a) {
|
|
|
829
828
|
...a,
|
|
830
829
|
cacheTime: g
|
|
831
830
|
}), o = await v(r, a);
|
|
832
|
-
if (!(await
|
|
831
|
+
if (!(await F({
|
|
833
832
|
...a,
|
|
834
833
|
cacheTime: g
|
|
835
834
|
})).some(
|
|
@@ -1140,7 +1139,7 @@ async function Je(e, r) {
|
|
|
1140
1139
|
});
|
|
1141
1140
|
}
|
|
1142
1141
|
export {
|
|
1143
|
-
|
|
1142
|
+
R as Address,
|
|
1144
1143
|
g as DEFAULT_CACHE_TIME,
|
|
1145
1144
|
je as FlashLoanAssetConfig,
|
|
1146
1145
|
we as IncentiveAPYInfo,
|
|
@@ -1156,7 +1155,7 @@ export {
|
|
|
1156
1155
|
oe as depositCoinPTB,
|
|
1157
1156
|
De as filterPriceFeeds,
|
|
1158
1157
|
Le as flashloanPTB,
|
|
1159
|
-
|
|
1158
|
+
F as getAllFlashLoanAssets,
|
|
1160
1159
|
Be as getBorrowFee,
|
|
1161
1160
|
Ne as getCoins,
|
|
1162
1161
|
b as getConfig,
|