@naviprotocol/lending 2.0.5-beta.0 → 2.0.5-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.esm.js +214 -184
- package/dist/index.esm.js.map +1 -1
- package/dist/market.d.ts +54 -0
- package/dist/market.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Transaction as q } from "@mysten/sui/transactions";
|
|
2
2
|
import { bcs as l } from "@mysten/sui/bcs";
|
|
3
|
-
import { toHex as
|
|
3
|
+
import { toHex as Ue, fromHex as Me, normalizeStructTag as Y, SUI_CLOCK_OBJECT_ID as x, fromBase64 as De } from "@mysten/sui/utils";
|
|
4
4
|
import Fe from "lodash.camelcase";
|
|
5
5
|
import p from "bignumber.js";
|
|
6
6
|
import { SuiJsonRpcClient as Ne } from "@mysten/sui/jsonRpc";
|
|
7
7
|
import { SuiGraphQLClient as Re } from "@mysten/sui/graphql";
|
|
8
|
-
import { SuiGrpcClient as he, GrpcWebFetchTransport as
|
|
8
|
+
import { SuiGrpcClient as he, GrpcWebFetchTransport as be } from "@mysten/sui/grpc";
|
|
9
9
|
const ie = l.bytes(32).transform({
|
|
10
10
|
// To change the input type, you need to provide a type definition for the input
|
|
11
|
-
input: (e) =>
|
|
12
|
-
output: (e) =>
|
|
11
|
+
input: (e) => Me(e),
|
|
12
|
+
output: (e) => Ue(e)
|
|
13
13
|
}), qt = l.struct("IncentiveAPYInfo", {
|
|
14
14
|
/** Asset identifier */
|
|
15
15
|
asset_id: l.u8(),
|
|
@@ -129,7 +129,7 @@ const ie = l.bytes(32).transform({
|
|
|
129
129
|
borrow_balance: l.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
131
|
supply_balance: l.u256()
|
|
132
|
-
}), Ge = "2.0.5-beta.
|
|
132
|
+
}), Ge = "2.0.5-beta.1", V = {
|
|
133
133
|
version: Ge
|
|
134
134
|
}, We = V.version, He = () => {
|
|
135
135
|
if (typeof process < "u" && process.versions && process.versions.node) {
|
|
@@ -140,7 +140,7 @@ const ie = l.bytes(32).transform({
|
|
|
140
140
|
}, Je = () => {
|
|
141
141
|
let e = "";
|
|
142
142
|
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${We} (${He()})`), e;
|
|
143
|
-
}, ce = Je(),
|
|
143
|
+
}, ce = Je(), we = "0x2::sui::SUI";
|
|
144
144
|
class Ke extends Error {
|
|
145
145
|
constructor(t) {
|
|
146
146
|
super(
|
|
@@ -163,7 +163,7 @@ function ve(e) {
|
|
|
163
163
|
throw new Error("NAVI Sui balance helpers require a v2 Core API client");
|
|
164
164
|
return t;
|
|
165
165
|
}
|
|
166
|
-
function Ce(e, t =
|
|
166
|
+
function Ce(e, t = we) {
|
|
167
167
|
const r = ee(e.addressBalance ?? e.fundsInAddressBalance) ?? "0";
|
|
168
168
|
let o = ee(e.balance ?? e.totalBalance), n = ee(e.coinBalance);
|
|
169
169
|
return !n && o && (n = Ye(o, r)), !o && n && (o = Qe(n, r)), {
|
|
@@ -174,7 +174,7 @@ function Ce(e, t = be) {
|
|
|
174
174
|
...e.coinObjectCount === null || e.coinObjectCount === void 0 ? {} : { coinObjectCount: e.coinObjectCount }
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function Ht(e, t =
|
|
177
|
+
function Ht(e, t = we) {
|
|
178
178
|
const r = Y(t);
|
|
179
179
|
return e.filter((o) => Y(o.coinType) === r).reduce((o, n) => o + BigInt(n.balance), 0n).toString();
|
|
180
180
|
}
|
|
@@ -192,7 +192,7 @@ async function Kt(e, t) {
|
|
|
192
192
|
function Ze(e, t) {
|
|
193
193
|
if ("client" in t)
|
|
194
194
|
return t.client;
|
|
195
|
-
const r = new
|
|
195
|
+
const r = new be({
|
|
196
196
|
baseUrl: t.url,
|
|
197
197
|
meta: t.headers,
|
|
198
198
|
fetchInit: t.fetchInit,
|
|
@@ -211,7 +211,7 @@ function Xe(e, t) {
|
|
|
211
211
|
fetch: t.fetch
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function ke(e, t) {
|
|
215
215
|
return "client" in t ? t.client : new Ne({
|
|
216
216
|
network: e,
|
|
217
217
|
url: t.url
|
|
@@ -224,7 +224,7 @@ function xe(e) {
|
|
|
224
224
|
coreClient: t,
|
|
225
225
|
grpc: t,
|
|
226
226
|
graphql: e.graphql ? Xe(e.network, e.graphql) : void 0,
|
|
227
|
-
legacyJsonRpc: e.legacyJsonRpc ?
|
|
227
|
+
legacyJsonRpc: e.legacyJsonRpc ? ke(e.network, e.legacyJsonRpc) : void 0,
|
|
228
228
|
services: e.services
|
|
229
229
|
};
|
|
230
230
|
}
|
|
@@ -238,11 +238,11 @@ let te;
|
|
|
238
238
|
function tt() {
|
|
239
239
|
return te || (te = new he({
|
|
240
240
|
network: "mainnet",
|
|
241
|
-
transport: new
|
|
241
|
+
transport: new be({ baseUrl: et })
|
|
242
242
|
})), te;
|
|
243
243
|
}
|
|
244
244
|
function rt(e, t = "mainnet") {
|
|
245
|
-
return e ? typeof e == "string" ?
|
|
245
|
+
return e ? typeof e == "string" ? ke(t, { url: e }) : xe(e) : tt();
|
|
246
246
|
}
|
|
247
247
|
const nt = 16 * 1024;
|
|
248
248
|
function oe(e) {
|
|
@@ -543,7 +543,7 @@ class lt {
|
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
545
|
const dt = "https://open-api.naviprotocol.io/api";
|
|
546
|
-
let Q = {},
|
|
546
|
+
let Q = {}, je = 0;
|
|
547
547
|
function pt(e) {
|
|
548
548
|
return e.replace(/\/+$/, "");
|
|
549
549
|
}
|
|
@@ -555,12 +555,12 @@ function Yt(e) {
|
|
|
555
555
|
...Q.services,
|
|
556
556
|
...e.services
|
|
557
557
|
}
|
|
558
|
-
},
|
|
558
|
+
}, je += 1;
|
|
559
559
|
}
|
|
560
560
|
function de() {
|
|
561
|
-
return
|
|
561
|
+
return je;
|
|
562
562
|
}
|
|
563
|
-
function
|
|
563
|
+
function U(e) {
|
|
564
564
|
const t = e?.services?.naviOpenApi ?? Q.services?.naviOpenApi;
|
|
565
565
|
return {
|
|
566
566
|
baseUrl: pt(t?.baseUrl ?? dt),
|
|
@@ -568,7 +568,7 @@ function M(e) {
|
|
|
568
568
|
};
|
|
569
569
|
}
|
|
570
570
|
function F(e, t) {
|
|
571
|
-
const r =
|
|
571
|
+
const r = U(t), o = e.startsWith("/") ? e : `/${e}`;
|
|
572
572
|
return `${r.baseUrl}${o}`;
|
|
573
573
|
}
|
|
574
574
|
function mt(e) {
|
|
@@ -586,7 +586,7 @@ function N(e, t) {
|
|
|
586
586
|
...t?.headers ?? {}
|
|
587
587
|
};
|
|
588
588
|
}
|
|
589
|
-
const
|
|
589
|
+
const M = rt();
|
|
590
590
|
function pe(e) {
|
|
591
591
|
return e ? e instanceof Uint8Array ? Array.from(e) : Array.isArray(e) ? e : Array.from(De(e)) : [];
|
|
592
592
|
}
|
|
@@ -685,7 +685,7 @@ function Be(e) {
|
|
|
685
685
|
__naviSdkServiceConfigVersion: de()
|
|
686
686
|
}), JSON.stringify(t);
|
|
687
687
|
}
|
|
688
|
-
function
|
|
688
|
+
function A(e) {
|
|
689
689
|
const t = {};
|
|
690
690
|
return (...r) => {
|
|
691
691
|
const o = Be(r);
|
|
@@ -739,9 +739,9 @@ function Pe(e) {
|
|
|
739
739
|
new Ie("https://hermes.pyth.network", {
|
|
740
740
|
timeout: 2e4
|
|
741
741
|
});
|
|
742
|
-
const
|
|
742
|
+
const bt = 27, me = (e, t) => {
|
|
743
743
|
if (!Number(e) || !Number(t)) return new p(0);
|
|
744
|
-
const r = new p(1).shiftedBy(1 *
|
|
744
|
+
const r = new p(1).shiftedBy(1 * bt), o = r.multipliedBy(new p(0.5));
|
|
745
745
|
return new p(e).multipliedBy(new p(t)).plus(o).dividedBy(r).integerValue(p.ROUND_DOWN);
|
|
746
746
|
}, R = ce ? {
|
|
747
747
|
"User-Agent": ce
|
|
@@ -772,21 +772,21 @@ function K(e, t) {
|
|
|
772
772
|
isEMode: !0
|
|
773
773
|
};
|
|
774
774
|
}
|
|
775
|
-
function
|
|
775
|
+
function wt(e) {
|
|
776
776
|
const [t, r] = e.split("-");
|
|
777
777
|
return !t || !r ? null : {
|
|
778
778
|
marketKey: t,
|
|
779
779
|
poolId: parseInt(r)
|
|
780
780
|
};
|
|
781
781
|
}
|
|
782
|
-
function
|
|
782
|
+
function S() {
|
|
783
783
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
784
784
|
}
|
|
785
785
|
var H = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(H || {});
|
|
786
786
|
const J = O(
|
|
787
|
-
|
|
787
|
+
A(
|
|
788
788
|
async (e) => {
|
|
789
|
-
const t = (e?.markets || [L.main]).map((a) => P(a)), r =
|
|
789
|
+
const t = (e?.markets || [L.main]).map((a) => P(a)), r = U(e), o = F(
|
|
790
790
|
`/navi/pools?env=${e?.env || "prod"}&sdk=${V.version}&market=${t.map(
|
|
791
791
|
(a) => a.key
|
|
792
792
|
)}`,
|
|
@@ -795,16 +795,16 @@ const J = O(
|
|
|
795
795
|
(a) => a.json()
|
|
796
796
|
);
|
|
797
797
|
return n.data.forEach((a) => {
|
|
798
|
-
const i = n.meta.emodes.filter((
|
|
799
|
-
const
|
|
800
|
-
return a.market ===
|
|
801
|
-
}).filter((
|
|
798
|
+
const i = n.meta.emodes.filter((w) => {
|
|
799
|
+
const k = P(w.marketId);
|
|
800
|
+
return a.market === k.key && w.isActive;
|
|
801
|
+
}).filter((w) => !!w.assets.find((k) => k.assetId === a.id));
|
|
802
802
|
a.emodes = i;
|
|
803
|
-
const s = p(a.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), u = p(a.borrowedAmount).shiftedBy(-9).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), m = p(s).multipliedBy(a.oracle.price).toString(),
|
|
803
|
+
const s = p(a.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), u = p(a.borrowedAmount).shiftedBy(-9).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), m = p(s).multipliedBy(a.oracle.price).toString(), b = p(u).multipliedBy(a.oracle.price).toString(), g = p(a.supplyCapCeiling).shiftedBy(-27).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), y = p.max(
|
|
804
804
|
p(a.borrowedAmount),
|
|
805
805
|
p(a.validBorrowAmount)
|
|
806
806
|
).shiftedBy(-9).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), d = p(g).multipliedBy(a.oracle.price).toString(), f = p(y).multipliedBy(a.oracle.price).toString();
|
|
807
|
-
a.poolSupplyAmount = s, a.poolBorrowAmount = u, a.poolSupplyValue = m, a.poolBorrowValue =
|
|
807
|
+
a.poolSupplyAmount = s, a.poolBorrowAmount = u, a.poolSupplyValue = m, a.poolBorrowValue = b, a.poolSupplyCapAmount = g, a.poolBorrowCapAmount = y, a.poolSupplyCapValue = d, a.poolBorrowCapValue = f;
|
|
808
808
|
}), n.data;
|
|
809
809
|
}
|
|
810
810
|
)
|
|
@@ -812,7 +812,7 @@ const J = O(
|
|
|
812
812
|
async function E(e, t) {
|
|
813
813
|
let r = t?.market;
|
|
814
814
|
if (typeof e == "string") {
|
|
815
|
-
const a =
|
|
815
|
+
const a = wt(e);
|
|
816
816
|
a && (r = a.marketKey, e = a.poolId);
|
|
817
817
|
}
|
|
818
818
|
const o = await J({
|
|
@@ -828,16 +828,16 @@ async function E(e, t) {
|
|
|
828
828
|
return n.isDeprecated && console.log(`The lending pool for coinType ${n.suiCoinType} is going to be deprecated.`), n;
|
|
829
829
|
}
|
|
830
830
|
const Zt = O(
|
|
831
|
-
|
|
832
|
-
const t =
|
|
831
|
+
A(async (e) => {
|
|
832
|
+
const t = U(e), r = F(`/navi/stats?sdk=${V.version}`, e);
|
|
833
833
|
return (await fetch(r, {
|
|
834
834
|
headers: N(R, t)
|
|
835
835
|
}).then((n) => n.json())).data;
|
|
836
836
|
})
|
|
837
837
|
), Xt = O(
|
|
838
|
-
|
|
838
|
+
A(
|
|
839
839
|
async (e) => {
|
|
840
|
-
const t =
|
|
840
|
+
const t = U(e), r = F(`/navi/fee?sdk=${V.version}`, e);
|
|
841
841
|
return await fetch(r, {
|
|
842
842
|
headers: N(R, t)
|
|
843
843
|
}).then((n) => n.json());
|
|
@@ -1115,11 +1115,11 @@ async function tr(e, t, r, o) {
|
|
|
1115
1115
|
}), e;
|
|
1116
1116
|
}
|
|
1117
1117
|
const rr = O(
|
|
1118
|
-
|
|
1118
|
+
A(
|
|
1119
1119
|
async (e) => {
|
|
1120
1120
|
const t = await I({
|
|
1121
1121
|
...e
|
|
1122
|
-
}), r = e?.client ??
|
|
1122
|
+
}), r = e?.client ?? M;
|
|
1123
1123
|
if (e?.address && typeof e?.asset < "u")
|
|
1124
1124
|
try {
|
|
1125
1125
|
const a = await E(e.asset, e), c = new q();
|
|
@@ -1171,6 +1171,36 @@ const rr = O(
|
|
|
1171
1171
|
id: 3,
|
|
1172
1172
|
key: "sui-eco",
|
|
1173
1173
|
name: "Sui Eco Market"
|
|
1174
|
+
},
|
|
1175
|
+
"sui-usdc": {
|
|
1176
|
+
id: 4,
|
|
1177
|
+
key: "sui-usdc",
|
|
1178
|
+
name: "SUI/USDC Market"
|
|
1179
|
+
},
|
|
1180
|
+
"wbtc-usdc": {
|
|
1181
|
+
id: 5,
|
|
1182
|
+
key: "wbtc-usdc",
|
|
1183
|
+
name: "WBTC/USDC Market"
|
|
1184
|
+
},
|
|
1185
|
+
"xbtc-usdc": {
|
|
1186
|
+
id: 6,
|
|
1187
|
+
key: "xbtc-usdc",
|
|
1188
|
+
name: "xBTC/USDC Market"
|
|
1189
|
+
},
|
|
1190
|
+
"vsui-usdc": {
|
|
1191
|
+
id: 7,
|
|
1192
|
+
key: "vsui-usdc",
|
|
1193
|
+
name: "vSUI/USDC Market"
|
|
1194
|
+
},
|
|
1195
|
+
"vsui-sui": {
|
|
1196
|
+
id: 8,
|
|
1197
|
+
key: "vsui-sui",
|
|
1198
|
+
name: "vSUI/SUI Market"
|
|
1199
|
+
},
|
|
1200
|
+
"hasui-sui": {
|
|
1201
|
+
id: 9,
|
|
1202
|
+
key: "hasui-sui",
|
|
1203
|
+
name: "hasSUI/SUI Market"
|
|
1174
1204
|
}
|
|
1175
1205
|
};
|
|
1176
1206
|
class Ct {
|
|
@@ -1192,10 +1222,10 @@ class Ct {
|
|
|
1192
1222
|
return;
|
|
1193
1223
|
}
|
|
1194
1224
|
r[s.uniqueId] || this.pools.push(s), s?.emodes?.forEach((m) => {
|
|
1195
|
-
o[m.uniqueId] || this.emodes.push(m), m.assets.forEach((
|
|
1196
|
-
|
|
1225
|
+
o[m.uniqueId] || this.emodes.push(m), m.assets.forEach((b) => {
|
|
1226
|
+
b.isDebt && m.assets.find(
|
|
1197
1227
|
(y) => y.isCollateral && y.ltv > 0 && y.assetId !== s.id
|
|
1198
|
-
) && n.add(s.uniqueId),
|
|
1228
|
+
) && n.add(s.uniqueId), b.isCollateral && m.assets.find((y) => y.isDebt && y.assetId !== s.id) && a.add(s.uniqueId);
|
|
1199
1229
|
});
|
|
1200
1230
|
}), i = i.plus(s.poolBorrowValue), c = c.plus(s.poolSupplyValue);
|
|
1201
1231
|
}), this.poolMap = ne(this.pools, "id"), this.emodeMap = fe(this.emodes, "emodeId"), this.emodes.forEach((s) => {
|
|
@@ -1241,8 +1271,8 @@ const P = (e) => {
|
|
|
1241
1271
|
if (!r)
|
|
1242
1272
|
throw new Error("Market not found");
|
|
1243
1273
|
return r;
|
|
1244
|
-
},
|
|
1245
|
-
|
|
1274
|
+
}, kt = O(
|
|
1275
|
+
A(
|
|
1246
1276
|
async (e, t) => {
|
|
1247
1277
|
const r = await J({
|
|
1248
1278
|
cacheTime: 6e4,
|
|
@@ -1256,13 +1286,13 @@ const P = (e) => {
|
|
|
1256
1286
|
}
|
|
1257
1287
|
)
|
|
1258
1288
|
), nr = O(
|
|
1259
|
-
|
|
1260
|
-
async (e, t) => (await
|
|
1289
|
+
A(
|
|
1290
|
+
async (e, t) => (await kt([e], t))[0]
|
|
1261
1291
|
)
|
|
1262
1292
|
), I = O(
|
|
1263
|
-
|
|
1293
|
+
A(
|
|
1264
1294
|
async (e) => {
|
|
1265
|
-
const t = P(e?.market || z), r =
|
|
1295
|
+
const t = P(e?.market || z), r = U(e), o = F(
|
|
1266
1296
|
`/navi/config?env=${e?.env || "prod"}&sdk=${V.version}&market=${t.key}`,
|
|
1267
1297
|
e
|
|
1268
1298
|
);
|
|
@@ -1282,7 +1312,7 @@ async function It(e, t) {
|
|
|
1282
1312
|
arguments: []
|
|
1283
1313
|
});
|
|
1284
1314
|
}
|
|
1285
|
-
async function
|
|
1315
|
+
async function jt(e, t, r) {
|
|
1286
1316
|
const o = await I({
|
|
1287
1317
|
cacheTime: v,
|
|
1288
1318
|
...r
|
|
@@ -1331,7 +1361,7 @@ async function ar(e, t, r) {
|
|
|
1331
1361
|
...r,
|
|
1332
1362
|
accountCap: n
|
|
1333
1363
|
});
|
|
1334
|
-
const a = await P(r?.market || z), c = await
|
|
1364
|
+
const a = await P(r?.market || z), c = await jt(e, n, r);
|
|
1335
1365
|
return e.moveCall({
|
|
1336
1366
|
target: `${o.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
|
|
1337
1367
|
arguments: [
|
|
@@ -1342,13 +1372,13 @@ async function ar(e, t, r) {
|
|
|
1342
1372
|
]
|
|
1343
1373
|
}), n;
|
|
1344
1374
|
}
|
|
1345
|
-
const
|
|
1346
|
-
|
|
1375
|
+
const Se = O(
|
|
1376
|
+
A(
|
|
1347
1377
|
async (e, t) => {
|
|
1348
1378
|
const r = await I({
|
|
1349
1379
|
cacheTime: v,
|
|
1350
1380
|
...t
|
|
1351
|
-
}), o = new q(), n = t?.client ??
|
|
1381
|
+
}), o = new q(), n = t?.client ?? M;
|
|
1352
1382
|
o.moveCall({
|
|
1353
1383
|
target: `${r.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
|
|
1354
1384
|
arguments: [o.object(r.emode.contract.registryObject), o.pure.address(e)]
|
|
@@ -1357,10 +1387,10 @@ const Ae = O(
|
|
|
1357
1387
|
transactionBlock: o,
|
|
1358
1388
|
sender: e
|
|
1359
1389
|
})).results[0].returnValues, i = l.vector(l.u64()).parse(Uint8Array.from(c[0][0])), s = l.vector(l.u64()).parse(Uint8Array.from(c[1][0])), u = l.vector(l.Address).parse(Uint8Array.from(c[2][0]));
|
|
1360
|
-
return i.map((m,
|
|
1390
|
+
return i.map((m, b) => ({
|
|
1361
1391
|
marketId: Number(m),
|
|
1362
|
-
emodeId: Number(s[
|
|
1363
|
-
accountCap: u[
|
|
1392
|
+
emodeId: Number(s[b]),
|
|
1393
|
+
accountCap: u[b].toString()
|
|
1364
1394
|
}));
|
|
1365
1395
|
}
|
|
1366
1396
|
)
|
|
@@ -1399,14 +1429,14 @@ function cr(e, t, r) {
|
|
|
1399
1429
|
} catch {
|
|
1400
1430
|
return !1;
|
|
1401
1431
|
}
|
|
1402
|
-
})(s || m || "") && !!r?.useGasCoin, d = BigInt(n), f = !y && !!m,
|
|
1403
|
-
if (o &&
|
|
1404
|
-
throw new Error(`Balance is less than the specified balance: ${
|
|
1405
|
-
if (i.length === 0 && !
|
|
1432
|
+
})(s || m || "") && !!r?.useGasCoin, d = BigInt(n), f = !y && !!m, w = f ? a : 0n, k = u + w, _ = !o || u >= d ? 0n : d - u, j = f && _ > 0n && w >= _;
|
|
1433
|
+
if (o && k < d)
|
|
1434
|
+
throw new Error(`Balance is less than the specified balance: ${k} < ${d}`);
|
|
1435
|
+
if (i.length === 0 && !j)
|
|
1406
1436
|
throw new Error("No coins to merge");
|
|
1407
1437
|
if (y)
|
|
1408
1438
|
return o ? e.splitCoins(e.gas, [e.pure.u64(n)]) : e.gas;
|
|
1409
|
-
if (!
|
|
1439
|
+
if (!j)
|
|
1410
1440
|
return i.length === 1 ? e.object(i[0]) : e.mergeCoins(i[0], i.slice(1)), o ? e.splitCoins(i[0], [e.pure.u64(n)]) : i[0];
|
|
1411
1441
|
const T = e.moveCall({
|
|
1412
1442
|
target: "0x2::coin::redeem_funds",
|
|
@@ -1424,7 +1454,7 @@ function cr(e, t, r) {
|
|
|
1424
1454
|
$ = T;
|
|
1425
1455
|
return D.length > 0 && e.mergeCoins($, D), i.length === 0 ? $ : o ? e.splitCoins($, [e.pure.u64(n)]) : $;
|
|
1426
1456
|
}
|
|
1427
|
-
async function
|
|
1457
|
+
async function Ae(e, t, r, o, n, a, c) {
|
|
1428
1458
|
const i = await I({
|
|
1429
1459
|
...c,
|
|
1430
1460
|
cacheTime: v
|
|
@@ -1446,10 +1476,10 @@ async function Se(e, t, r, o, n, a, c) {
|
|
|
1446
1476
|
});
|
|
1447
1477
|
}
|
|
1448
1478
|
async function Bt(e, t, r) {
|
|
1449
|
-
return
|
|
1479
|
+
return Ae(e, t, 0, 0, 0, !1, r);
|
|
1450
1480
|
}
|
|
1451
1481
|
async function $e(e, t, r) {
|
|
1452
|
-
const o = new q(), n = r?.client ??
|
|
1482
|
+
const o = new q(), n = r?.client ?? M, a = await J({
|
|
1453
1483
|
...r,
|
|
1454
1484
|
markets: Object.values(L)
|
|
1455
1485
|
}), c = ne(a), s = Array.from(new Set(t.map((d) => d.market))).map((d) => P(d));
|
|
@@ -1478,40 +1508,40 @@ async function $e(e, t, r) {
|
|
|
1478
1508
|
const m = (await W(n, {
|
|
1479
1509
|
transactionBlock: o,
|
|
1480
1510
|
sender: e
|
|
1481
|
-
})).results || [],
|
|
1511
|
+
})).results || [], b = {};
|
|
1482
1512
|
s.forEach((d, f) => {
|
|
1483
1513
|
try {
|
|
1484
|
-
const
|
|
1485
|
-
for (const _ of
|
|
1486
|
-
|
|
1514
|
+
const w = m[f]?.returnValues?.map((_) => l.vector(qe).parse(Uint8Array.from(_[0])))[0] || [], k = {};
|
|
1515
|
+
for (const _ of w)
|
|
1516
|
+
k[_.id] = {
|
|
1487
1517
|
supplyIndex: _.supply_index,
|
|
1488
1518
|
borrowIndex: _.borrow_index
|
|
1489
1519
|
};
|
|
1490
|
-
|
|
1491
|
-
} catch (
|
|
1520
|
+
b[d.key] = k;
|
|
1521
|
+
} catch (w) {
|
|
1492
1522
|
console.warn(
|
|
1493
1523
|
`[@naviprotocol/lending] Failed to decode reserve data for market "${d.key}", falling back to open-api pool indices`,
|
|
1494
|
-
|
|
1524
|
+
w
|
|
1495
1525
|
);
|
|
1496
1526
|
}
|
|
1497
1527
|
});
|
|
1498
1528
|
const g = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(ze).parse(Uint8Array.from(f[0])))[0] || []), y = [];
|
|
1499
1529
|
return g.forEach((d, f) => {
|
|
1500
|
-
const
|
|
1501
|
-
d.forEach((
|
|
1502
|
-
if (
|
|
1530
|
+
const w = t[f], k = P(w.market), _ = b[k.key] || {};
|
|
1531
|
+
d.forEach((j) => {
|
|
1532
|
+
if (j.supply_balance === "0" && j.borrow_balance === "0" && (w.emodeId === void 0 || !r?.includeZeroBalanceEmodePositions))
|
|
1503
1533
|
return;
|
|
1504
|
-
const T = c[`${
|
|
1534
|
+
const T = c[`${k.key}-${j.asset_id}`];
|
|
1505
1535
|
if (!T)
|
|
1506
1536
|
return;
|
|
1507
|
-
const $ = _[
|
|
1537
|
+
const $ = _[j.asset_id], D = $?.supplyIndex ?? T.currentSupplyIndex, B = $?.borrowIndex ?? T.currentBorrowIndex, X = me(j.supply_balance, D).toString(), Ve = me(j.borrow_balance, B).toString();
|
|
1508
1538
|
y.push({
|
|
1509
1539
|
supplyBalance: X,
|
|
1510
1540
|
borrowBalance: Ve,
|
|
1511
|
-
assetId:
|
|
1512
|
-
market:
|
|
1541
|
+
assetId: j.asset_id,
|
|
1542
|
+
market: k.key,
|
|
1513
1543
|
pool: T,
|
|
1514
|
-
emodeId:
|
|
1544
|
+
emodeId: w.emodeId
|
|
1515
1545
|
});
|
|
1516
1546
|
});
|
|
1517
1547
|
}), y;
|
|
@@ -1526,7 +1556,7 @@ const sr = O(
|
|
|
1526
1556
|
}
|
|
1527
1557
|
);
|
|
1528
1558
|
async function ur(e, t) {
|
|
1529
|
-
const r = t?.client ??
|
|
1559
|
+
const r = t?.client ?? M, o = new q();
|
|
1530
1560
|
await Bt(o, e, t);
|
|
1531
1561
|
const n = await W(r, {
|
|
1532
1562
|
transactionBlock: o,
|
|
@@ -1535,7 +1565,7 @@ async function ur(e, t) {
|
|
|
1535
1565
|
return Pe(Number(a[0]) || 0);
|
|
1536
1566
|
}
|
|
1537
1567
|
async function lr(e, t, r, o) {
|
|
1538
|
-
const n = o?.client ??
|
|
1568
|
+
const n = o?.client ?? M, a = new q();
|
|
1539
1569
|
let c = 0, i = 0;
|
|
1540
1570
|
const s = await E(t, o);
|
|
1541
1571
|
if (r.forEach((g) => {
|
|
@@ -1543,7 +1573,7 @@ async function lr(e, t, r, o) {
|
|
|
1543
1573
|
}), c * i < 0)
|
|
1544
1574
|
throw new Error("Invalid operations");
|
|
1545
1575
|
const u = c > 0 || i > 0;
|
|
1546
|
-
await
|
|
1576
|
+
await Ae(
|
|
1547
1577
|
a,
|
|
1548
1578
|
e,
|
|
1549
1579
|
s,
|
|
@@ -1555,14 +1585,14 @@ async function lr(e, t, r, o) {
|
|
|
1555
1585
|
const m = await W(n, {
|
|
1556
1586
|
transactionBlock: a,
|
|
1557
1587
|
sender: e
|
|
1558
|
-
}),
|
|
1559
|
-
return Pe(Number(
|
|
1588
|
+
}), b = Z(m, [l.u256()]);
|
|
1589
|
+
return Pe(Number(b[0]) || 0);
|
|
1560
1590
|
}
|
|
1561
|
-
const dr =
|
|
1591
|
+
const dr = A(
|
|
1562
1592
|
async (e, t) => {
|
|
1563
1593
|
const r = new URLSearchParams();
|
|
1564
1594
|
t?.cursor && r.set("cursor", t.cursor), r.set("userAddress", e);
|
|
1565
|
-
const o =
|
|
1595
|
+
const o = U(t), n = F(
|
|
1566
1596
|
`/navi/user/transactions?${r.toString()}&sdk=${V.version}`,
|
|
1567
1597
|
t
|
|
1568
1598
|
);
|
|
@@ -1573,7 +1603,7 @@ const dr = S(
|
|
|
1573
1603
|
);
|
|
1574
1604
|
async function pr(e, t) {
|
|
1575
1605
|
let r = null;
|
|
1576
|
-
const o = [], n = t?.client ??
|
|
1606
|
+
const o = [], n = t?.client ?? M, a = n.core;
|
|
1577
1607
|
do {
|
|
1578
1608
|
let c;
|
|
1579
1609
|
if (t?.coinType)
|
|
@@ -1615,15 +1645,15 @@ async function pr(e, t) {
|
|
|
1615
1645
|
for (const u of i) {
|
|
1616
1646
|
let m = null;
|
|
1617
1647
|
do {
|
|
1618
|
-
const
|
|
1648
|
+
const b = await a.listCoins({
|
|
1619
1649
|
owner: e,
|
|
1620
1650
|
coinType: u,
|
|
1621
1651
|
cursor: m,
|
|
1622
1652
|
limit: 100
|
|
1623
1653
|
});
|
|
1624
1654
|
o.push(
|
|
1625
|
-
...(
|
|
1626
|
-
), m =
|
|
1655
|
+
...(b.objects ?? b.data ?? []).map((g) => ye(g, u)).filter(Boolean)
|
|
1656
|
+
), m = b.cursor ?? b.nextCursor ?? null;
|
|
1627
1657
|
} while (m);
|
|
1628
1658
|
}
|
|
1629
1659
|
break;
|
|
@@ -1646,7 +1676,7 @@ async function pr(e, t) {
|
|
|
1646
1676
|
}
|
|
1647
1677
|
const Pt = O(
|
|
1648
1678
|
async (e, t) => {
|
|
1649
|
-
const r = [], o = (t?.markets || Object.keys(L)).map((i) => P(i)), n = await
|
|
1679
|
+
const r = [], o = (t?.markets || Object.keys(L)).map((i) => P(i)), n = await Se(e, t), a = o.map((i) => ({
|
|
1650
1680
|
address: e,
|
|
1651
1681
|
market: i.key
|
|
1652
1682
|
})).concat(
|
|
@@ -1665,11 +1695,11 @@ const Pt = O(
|
|
|
1665
1695
|
if (!i.pool.emodes.find((m) => m.emodeId === s.emodeId))
|
|
1666
1696
|
return;
|
|
1667
1697
|
if (p(i.supplyBalance).gte(0)) {
|
|
1668
|
-
const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN),
|
|
1669
|
-
if (m.gt(0) ||
|
|
1698
|
+
const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), b = K(i.pool, s);
|
|
1699
|
+
if (m.gt(0) || b.emode.isCollateral)
|
|
1670
1700
|
try {
|
|
1671
1701
|
r.push({
|
|
1672
|
-
id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${
|
|
1702
|
+
id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${S()}`,
|
|
1673
1703
|
wallet: e,
|
|
1674
1704
|
protocol: "navi",
|
|
1675
1705
|
market: i.market,
|
|
@@ -1687,11 +1717,11 @@ const Pt = O(
|
|
|
1687
1717
|
}
|
|
1688
1718
|
}
|
|
1689
1719
|
if (p(i.borrowBalance).gte(0)) {
|
|
1690
|
-
const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN),
|
|
1691
|
-
if (m.gt(0) ||
|
|
1720
|
+
const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), b = K(i.pool, s);
|
|
1721
|
+
if (m.gt(0) || b.emode.isDebt)
|
|
1692
1722
|
try {
|
|
1693
1723
|
r.push({
|
|
1694
|
-
id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${
|
|
1724
|
+
id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${S()}`,
|
|
1695
1725
|
wallet: e,
|
|
1696
1726
|
protocol: "navi",
|
|
1697
1727
|
market: i.market,
|
|
@@ -1712,7 +1742,7 @@ const Pt = O(
|
|
|
1712
1742
|
if (p(i.supplyBalance).gt(0)) {
|
|
1713
1743
|
const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
|
|
1714
1744
|
r.push({
|
|
1715
|
-
id: `${i.pool.uniqueId}_navi-lending-supply-${
|
|
1745
|
+
id: `${i.pool.uniqueId}_navi-lending-supply-${S()}`,
|
|
1716
1746
|
wallet: e,
|
|
1717
1747
|
protocol: "navi",
|
|
1718
1748
|
type: "navi-lending-supply",
|
|
@@ -1728,7 +1758,7 @@ const Pt = O(
|
|
|
1728
1758
|
if (p(i.borrowBalance).gt(0)) {
|
|
1729
1759
|
const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
|
|
1730
1760
|
r.push({
|
|
1731
|
-
id: `${i.pool.uniqueId}_navi-lending-borrow-${
|
|
1761
|
+
id: `${i.pool.uniqueId}_navi-lending-borrow-${S()}`,
|
|
1732
1762
|
wallet: e,
|
|
1733
1763
|
protocol: "navi",
|
|
1734
1764
|
market: i.market,
|
|
@@ -1797,7 +1827,7 @@ class G {
|
|
|
1797
1827
|
const o = !!t.isEMode, n = this.getPrice(t);
|
|
1798
1828
|
let a;
|
|
1799
1829
|
return o ? a = {
|
|
1800
|
-
id:
|
|
1830
|
+
id: S(),
|
|
1801
1831
|
wallet: "",
|
|
1802
1832
|
protocol: "navi",
|
|
1803
1833
|
market: "",
|
|
@@ -1810,7 +1840,7 @@ class G {
|
|
|
1810
1840
|
emodeCap: {}
|
|
1811
1841
|
}
|
|
1812
1842
|
} : a = {
|
|
1813
|
-
id:
|
|
1843
|
+
id: S(),
|
|
1814
1844
|
wallet: "",
|
|
1815
1845
|
protocol: "navi",
|
|
1816
1846
|
market: "",
|
|
@@ -1827,7 +1857,7 @@ class G {
|
|
|
1827
1857
|
const o = !!t.isEMode, n = this.getPrice(t);
|
|
1828
1858
|
let a;
|
|
1829
1859
|
return o ? a = {
|
|
1830
|
-
id:
|
|
1860
|
+
id: S(),
|
|
1831
1861
|
wallet: "",
|
|
1832
1862
|
protocol: "navi",
|
|
1833
1863
|
market: "",
|
|
@@ -1840,7 +1870,7 @@ class G {
|
|
|
1840
1870
|
emodeCap: {}
|
|
1841
1871
|
}
|
|
1842
1872
|
} : a = {
|
|
1843
|
-
id:
|
|
1873
|
+
id: S(),
|
|
1844
1874
|
wallet: "",
|
|
1845
1875
|
protocol: "navi",
|
|
1846
1876
|
market: "",
|
|
@@ -1857,7 +1887,7 @@ class G {
|
|
|
1857
1887
|
const o = !!t.isEMode, n = this.getPrice(t);
|
|
1858
1888
|
let a;
|
|
1859
1889
|
return o ? a = {
|
|
1860
|
-
id:
|
|
1890
|
+
id: S(),
|
|
1861
1891
|
wallet: "",
|
|
1862
1892
|
protocol: "navi",
|
|
1863
1893
|
market: "",
|
|
@@ -1870,7 +1900,7 @@ class G {
|
|
|
1870
1900
|
emodeCap: {}
|
|
1871
1901
|
}
|
|
1872
1902
|
} : a = {
|
|
1873
|
-
id:
|
|
1903
|
+
id: S(),
|
|
1874
1904
|
wallet: "",
|
|
1875
1905
|
protocol: "navi",
|
|
1876
1906
|
market: "",
|
|
@@ -1887,7 +1917,7 @@ class G {
|
|
|
1887
1917
|
const o = !!t.isEMode, n = this.getPrice(t);
|
|
1888
1918
|
let a;
|
|
1889
1919
|
return o ? a = {
|
|
1890
|
-
id:
|
|
1920
|
+
id: S(),
|
|
1891
1921
|
wallet: "",
|
|
1892
1922
|
protocol: "navi",
|
|
1893
1923
|
market: "",
|
|
@@ -1900,7 +1930,7 @@ class G {
|
|
|
1900
1930
|
emodeCap: {}
|
|
1901
1931
|
}
|
|
1902
1932
|
} : a = {
|
|
1903
|
-
id:
|
|
1933
|
+
id: S(),
|
|
1904
1934
|
wallet: "",
|
|
1905
1935
|
protocol: "navi",
|
|
1906
1936
|
market: "",
|
|
@@ -1933,11 +1963,11 @@ class G {
|
|
|
1933
1963
|
} else if (y.type === "navi-lending-emode-supply") {
|
|
1934
1964
|
const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d);
|
|
1935
1965
|
n = n.plus(f);
|
|
1936
|
-
const
|
|
1966
|
+
const w = d.pool.emode;
|
|
1937
1967
|
s = s.plus(
|
|
1938
|
-
new p(f).multipliedBy(
|
|
1968
|
+
new p(f).multipliedBy(w.lt)
|
|
1939
1969
|
), u = u.plus(
|
|
1940
|
-
new p(f).multipliedBy(
|
|
1970
|
+
new p(f).multipliedBy(w.ltv)
|
|
1941
1971
|
);
|
|
1942
1972
|
} else if (y.type === "navi-lending-emode-borrow") {
|
|
1943
1973
|
const d = y["navi-lending-emode-borrow"];
|
|
@@ -1945,32 +1975,32 @@ class G {
|
|
|
1945
1975
|
}
|
|
1946
1976
|
}), a = p.max(a, 0), n = p.max(n, 0), s = p.max(s, 0), u = p.max(u, 0), t.forEach((y) => {
|
|
1947
1977
|
if (y.type === "navi-lending-supply") {
|
|
1948
|
-
const d = y["navi-lending-supply"], f = this.resolveValueUSD(d),
|
|
1978
|
+
const d = y["navi-lending-supply"], f = this.resolveValueUSD(d), w = d.pool.supplyIncentiveApyInfo.apy;
|
|
1949
1979
|
n.gt(0) && (c = c.plus(
|
|
1950
|
-
new p(f).dividedBy(n).multipliedBy(new p(
|
|
1980
|
+
new p(f).dividedBy(n).multipliedBy(new p(w).dividedBy(100))
|
|
1951
1981
|
)), r[d.pool.suiCoinType] = p(r[d.pool.suiCoinType] || 0).plus(d.amount).toString();
|
|
1952
1982
|
} else if (y.type === "navi-lending-borrow") {
|
|
1953
|
-
const d = y["navi-lending-borrow"], f = this.resolveValueUSD(d),
|
|
1983
|
+
const d = y["navi-lending-borrow"], f = this.resolveValueUSD(d), w = d.pool.borrowIncentiveApyInfo.apy;
|
|
1954
1984
|
a.gt(0) && (i = i.plus(
|
|
1955
|
-
new p(f).dividedBy(a).multipliedBy(new p(
|
|
1985
|
+
new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
|
|
1956
1986
|
)), o[d.pool.suiCoinType] = p(o[d.pool.suiCoinType] || 0).plus(d.amount).toString();
|
|
1957
1987
|
} else if (y.type === "navi-lending-emode-supply") {
|
|
1958
|
-
const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d),
|
|
1988
|
+
const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d), w = d.pool.supplyIncentiveApyInfo.apy;
|
|
1959
1989
|
n.gt(0) && (c = c.plus(
|
|
1960
|
-
new p(f).dividedBy(n).multipliedBy(new p(
|
|
1990
|
+
new p(f).dividedBy(n).multipliedBy(new p(w).dividedBy(100))
|
|
1961
1991
|
)), r[d.pool.suiCoinType] = p(r[d.pool.suiCoinType] || 0).plus(d.amount).toString();
|
|
1962
1992
|
} else if (y.type === "navi-lending-emode-borrow") {
|
|
1963
|
-
const d = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(d),
|
|
1993
|
+
const d = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(d), w = d.pool.borrowIncentiveApyInfo.apy;
|
|
1964
1994
|
a.gt(0) && (i = i.plus(
|
|
1965
|
-
new p(f).dividedBy(a).multipliedBy(new p(
|
|
1995
|
+
new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
|
|
1966
1996
|
)), o[d.pool.suiCoinType] = p(o[d.pool.suiCoinType] || 0).plus(d.amount).toString();
|
|
1967
1997
|
}
|
|
1968
1998
|
});
|
|
1969
|
-
const m = n.minus(a),
|
|
1999
|
+
const m = n.minus(a), b = n.minus(a).eq(0) ? new p(0) : n.multipliedBy(c).minus(a.multipliedBy(i)).div(n.minus(a));
|
|
1970
2000
|
return {
|
|
1971
2001
|
hf: a.toNumber() !== 0 ? s.dividedBy(a).toNumber() : 1 / 0,
|
|
1972
2002
|
netVaule: m.toString(),
|
|
1973
|
-
netWorthApr:
|
|
2003
|
+
netWorthApr: b.toString(),
|
|
1974
2004
|
totalSupplyValue: n.toString(),
|
|
1975
2005
|
totalBorrowValue: a.toString(),
|
|
1976
2006
|
totalsupplyApy: c.toString(),
|
|
@@ -2023,8 +2053,8 @@ async function fr(e) {
|
|
|
2023
2053
|
throw new Error(`failed to get pyth stale price feed id, msg: ${t.message}`);
|
|
2024
2054
|
}
|
|
2025
2055
|
}
|
|
2026
|
-
async function
|
|
2027
|
-
const r = [], o = t?.client ??
|
|
2056
|
+
async function St(e, t) {
|
|
2057
|
+
const r = [], o = t?.client ?? M, n = e.map((c) => c.priceInfoObject), a = await gt(o, {
|
|
2028
2058
|
ids: Array.from(new Set(n)),
|
|
2029
2059
|
options: { showContent: !0 }
|
|
2030
2060
|
});
|
|
@@ -2044,11 +2074,11 @@ async function At(e, t) {
|
|
|
2044
2074
|
console.warn(`unexpected pyth price struct, priceInfoObject: ${i.objectId}`);
|
|
2045
2075
|
continue;
|
|
2046
2076
|
}
|
|
2047
|
-
const { magnitude:
|
|
2077
|
+
const { magnitude: b, negative: g } = m, y = u.conf, d = u.timestamp;
|
|
2048
2078
|
r.push({
|
|
2049
2079
|
priceFeedId: s.priceFeedId,
|
|
2050
2080
|
priceInfoObject: s.priceInfoObject,
|
|
2051
|
-
price: g ? "-" +
|
|
2081
|
+
price: g ? "-" + b : b,
|
|
2052
2082
|
conf: y,
|
|
2053
2083
|
publishTime: Number(d),
|
|
2054
2084
|
expiration: s.expiration
|
|
@@ -2056,9 +2086,9 @@ async function At(e, t) {
|
|
|
2056
2086
|
}
|
|
2057
2087
|
return r;
|
|
2058
2088
|
}
|
|
2059
|
-
async function
|
|
2089
|
+
async function At(e, t) {
|
|
2060
2090
|
try {
|
|
2061
|
-
const r = [], o = await
|
|
2091
|
+
const r = [], o = await St(e, t);
|
|
2062
2092
|
if (!o) return r;
|
|
2063
2093
|
const n = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
2064
2094
|
for (const a of o) {
|
|
@@ -2079,7 +2109,7 @@ async function St(e, t) {
|
|
|
2079
2109
|
}
|
|
2080
2110
|
}
|
|
2081
2111
|
async function $t(e, t, r) {
|
|
2082
|
-
const o = r?.client ??
|
|
2112
|
+
const o = r?.client ?? M, n = await I({
|
|
2083
2113
|
...r,
|
|
2084
2114
|
cacheTime: v
|
|
2085
2115
|
});
|
|
@@ -2104,7 +2134,7 @@ async function ge(e, t, r) {
|
|
|
2104
2134
|
priceFeedId: c.pythPriceFeedId,
|
|
2105
2135
|
priceInfoObject: c.pythPriceInfoObject,
|
|
2106
2136
|
expiration: 30
|
|
2107
|
-
})), a = await
|
|
2137
|
+
})), a = await At(n, r);
|
|
2108
2138
|
a.length > 0 && await $t(e, a, r);
|
|
2109
2139
|
}
|
|
2110
2140
|
for (const n of t)
|
|
@@ -2183,9 +2213,9 @@ async function yr(e, t, r, o) {
|
|
|
2183
2213
|
}
|
|
2184
2214
|
}
|
|
2185
2215
|
const ae = O(
|
|
2186
|
-
|
|
2216
|
+
A(
|
|
2187
2217
|
async (e) => {
|
|
2188
|
-
const t =
|
|
2218
|
+
const t = U(e), r = F(
|
|
2189
2219
|
`/navi/flashloan?env=${e?.env || "prod"}&sdk=${V.version}&market=${e?.market || z}`,
|
|
2190
2220
|
e
|
|
2191
2221
|
), o = await fetch(r, {
|
|
@@ -2238,7 +2268,7 @@ async function hr(e, t, r, o) {
|
|
|
2238
2268
|
return [s, u];
|
|
2239
2269
|
}
|
|
2240
2270
|
}
|
|
2241
|
-
async function
|
|
2271
|
+
async function br(e, t, r, o, n) {
|
|
2242
2272
|
const a = await I({
|
|
2243
2273
|
...n,
|
|
2244
2274
|
cacheTime: v
|
|
@@ -2263,13 +2293,13 @@ async function wr(e, t, r, o, n) {
|
|
|
2263
2293
|
});
|
|
2264
2294
|
return [u];
|
|
2265
2295
|
}
|
|
2266
|
-
async function
|
|
2296
|
+
async function wr(e, t, r, o, n, a) {
|
|
2267
2297
|
const c = {
|
|
2268
2298
|
...a,
|
|
2269
2299
|
cacheTime: v
|
|
2270
2300
|
}, i = await I(c), s = await E(t, c), u = await E(o, c);
|
|
2271
2301
|
if (i.version === 1) {
|
|
2272
|
-
const [m,
|
|
2302
|
+
const [m, b] = e.moveCall({
|
|
2273
2303
|
target: `${i.package}::incentive_v3::liquidation`,
|
|
2274
2304
|
arguments: [
|
|
2275
2305
|
e.object("0x06"),
|
|
@@ -2297,9 +2327,9 @@ async function br(e, t, r, o, n, a) {
|
|
|
2297
2327
|
],
|
|
2298
2328
|
typeArguments: [s.suiCoinType, u.suiCoinType]
|
|
2299
2329
|
});
|
|
2300
|
-
return [m,
|
|
2330
|
+
return [m, b];
|
|
2301
2331
|
} else {
|
|
2302
|
-
const [m,
|
|
2332
|
+
const [m, b] = e.moveCall({
|
|
2303
2333
|
target: `${i.package}::incentive_v3::liquidation_v2`,
|
|
2304
2334
|
arguments: [
|
|
2305
2335
|
e.object("0x06"),
|
|
@@ -2329,11 +2359,11 @@ async function br(e, t, r, o, n, a) {
|
|
|
2329
2359
|
],
|
|
2330
2360
|
typeArguments: [s.suiCoinType, u.suiCoinType]
|
|
2331
2361
|
});
|
|
2332
|
-
return [m,
|
|
2362
|
+
return [m, b];
|
|
2333
2363
|
}
|
|
2334
2364
|
}
|
|
2335
2365
|
async function Ot(e, t, r) {
|
|
2336
|
-
const o = r?.client ??
|
|
2366
|
+
const o = r?.client ?? M, n = await J({
|
|
2337
2367
|
...r,
|
|
2338
2368
|
markets: Object.values(L),
|
|
2339
2369
|
cacheTime: v
|
|
@@ -2359,13 +2389,13 @@ async function Ot(e, t, r) {
|
|
|
2359
2389
|
// User address
|
|
2360
2390
|
]
|
|
2361
2391
|
});
|
|
2362
|
-
const
|
|
2392
|
+
const b = (await W(o, {
|
|
2363
2393
|
transactionBlock: u,
|
|
2364
2394
|
sender: e
|
|
2365
2395
|
}))?.results?.[0];
|
|
2366
|
-
if (!
|
|
2396
|
+
if (!b)
|
|
2367
2397
|
return;
|
|
2368
|
-
const g = Z({ results: [
|
|
2398
|
+
const g = Z({ results: [b] }, [
|
|
2369
2399
|
l.vector(l.string()),
|
|
2370
2400
|
// Asset coin types
|
|
2371
2401
|
l.vector(l.string()),
|
|
@@ -2381,12 +2411,12 @@ async function Ot(e, t, r) {
|
|
|
2381
2411
|
const y = g[0].length;
|
|
2382
2412
|
for (let d = 0; d < y; d++) {
|
|
2383
2413
|
const f = a.find(
|
|
2384
|
-
(
|
|
2385
|
-
),
|
|
2386
|
-
(
|
|
2414
|
+
(k) => C(k.coinType) === C(g[1][d])
|
|
2415
|
+
), w = n.find(
|
|
2416
|
+
(k) => C(k.coinType) === C(g[0][d]) && k.market === i.market
|
|
2387
2417
|
);
|
|
2388
|
-
!f || !
|
|
2389
|
-
assetId:
|
|
2418
|
+
!f || !w || c.push({
|
|
2419
|
+
assetId: w.id,
|
|
2390
2420
|
assetCoinType: C(g[0][d]),
|
|
2391
2421
|
rewardCoinType: C(g[1][d]),
|
|
2392
2422
|
option: Number(g[2][d]),
|
|
@@ -2409,7 +2439,7 @@ async function Ot(e, t, r) {
|
|
|
2409
2439
|
), c;
|
|
2410
2440
|
}
|
|
2411
2441
|
async function vr(e, t) {
|
|
2412
|
-
const r = (t?.markets || [L.main]).map((a) => P(a)), o = await
|
|
2442
|
+
const r = (t?.markets || [L.main]).map((a) => P(a)), o = await Se(e, t), n = r.map((a) => ({
|
|
2413
2443
|
address: e,
|
|
2414
2444
|
owner: e,
|
|
2415
2445
|
market: a.key
|
|
@@ -2455,9 +2485,9 @@ function Cr(e) {
|
|
|
2455
2485
|
}))
|
|
2456
2486
|
}));
|
|
2457
2487
|
}
|
|
2458
|
-
const
|
|
2488
|
+
const kr = A(
|
|
2459
2489
|
async (e, t) => {
|
|
2460
|
-
const r =
|
|
2490
|
+
const r = U(t), o = F(
|
|
2461
2491
|
`/navi/user/total_claimed_reward?userAddress=${e}&sdk=${V.version}&market=${t?.market || z}`,
|
|
2462
2492
|
t
|
|
2463
2493
|
);
|
|
@@ -2465,9 +2495,9 @@ const jr = S(
|
|
|
2465
2495
|
headers: N(R, r)
|
|
2466
2496
|
}).then((a) => a.json())).data;
|
|
2467
2497
|
}
|
|
2468
|
-
), Ir =
|
|
2498
|
+
), Ir = A(
|
|
2469
2499
|
async (e, t) => {
|
|
2470
|
-
const r =
|
|
2500
|
+
const r = U(t), o = F(
|
|
2471
2501
|
`/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${V.version}&market=${t?.market || z}`,
|
|
2472
2502
|
t
|
|
2473
2503
|
), n = await fetch(o, {
|
|
@@ -2478,14 +2508,14 @@ const jr = S(
|
|
|
2478
2508
|
});
|
|
2479
2509
|
}
|
|
2480
2510
|
);
|
|
2481
|
-
async function
|
|
2511
|
+
async function jr(e, t, r) {
|
|
2482
2512
|
const o = await J({
|
|
2483
2513
|
...r,
|
|
2484
2514
|
markets: Object.values(L),
|
|
2485
2515
|
cacheTime: v
|
|
2486
2516
|
}), n = /* @__PURE__ */ new Map();
|
|
2487
2517
|
for (const c of t) {
|
|
2488
|
-
const { rewardCoinType: i, ruleIds: s, market: u, owner: m, address:
|
|
2518
|
+
const { rewardCoinType: i, ruleIds: s, market: u, owner: m, address: b, emodeId: g } = c, y = `${i}___${b}__${u}`;
|
|
2489
2519
|
for (const d of s) {
|
|
2490
2520
|
n.has(y) || n.set(y, {
|
|
2491
2521
|
assetIds: [],
|
|
@@ -2493,7 +2523,7 @@ async function kr(e, t, r) {
|
|
|
2493
2523
|
amount: 0,
|
|
2494
2524
|
market: u,
|
|
2495
2525
|
owner: m,
|
|
2496
|
-
address:
|
|
2526
|
+
address: b,
|
|
2497
2527
|
isEMode: typeof g < "u"
|
|
2498
2528
|
});
|
|
2499
2529
|
const f = n.get(y);
|
|
@@ -2503,24 +2533,24 @@ async function kr(e, t, r) {
|
|
|
2503
2533
|
const a = [];
|
|
2504
2534
|
for (const [
|
|
2505
2535
|
c,
|
|
2506
|
-
{ assetIds: i, ruleIds: s, amount: u, market: m, owner:
|
|
2536
|
+
{ assetIds: i, ruleIds: s, amount: u, market: m, owner: b, address: g, isEMode: y }
|
|
2507
2537
|
] of n) {
|
|
2508
2538
|
const d = await I({
|
|
2509
2539
|
...r,
|
|
2510
2540
|
cacheTime: v,
|
|
2511
2541
|
market: m
|
|
2512
|
-
}), f = c.split("___")[0],
|
|
2513
|
-
(
|
|
2542
|
+
}), f = c.split("___")[0], w = o.filter(
|
|
2543
|
+
(j) => C(j.suiCoinType) === C(f)
|
|
2514
2544
|
);
|
|
2515
|
-
|
|
2516
|
-
const
|
|
2545
|
+
w.sort((j, T) => j.market === m ? -1 : 1);
|
|
2546
|
+
const k = w[0], _ = d.rewardFunds[C(f)];
|
|
2517
2547
|
if (!_)
|
|
2518
2548
|
throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
|
|
2519
2549
|
if (r?.accountCap && !r.customCoinReceive)
|
|
2520
2550
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
2521
2551
|
if (r?.customCoinReceive) {
|
|
2522
|
-
let
|
|
2523
|
-
r.accountCap ?
|
|
2552
|
+
let j;
|
|
2553
|
+
r.accountCap ? j = e.moveCall({
|
|
2524
2554
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2525
2555
|
arguments: [
|
|
2526
2556
|
e.object("0x06"),
|
|
@@ -2539,7 +2569,7 @@ async function kr(e, t, r) {
|
|
|
2539
2569
|
// Account capability
|
|
2540
2570
|
],
|
|
2541
2571
|
typeArguments: [f]
|
|
2542
|
-
}) : y ?
|
|
2572
|
+
}) : y ? j = e.moveCall({
|
|
2543
2573
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2544
2574
|
arguments: [
|
|
2545
2575
|
e.object("0x06"),
|
|
@@ -2558,7 +2588,7 @@ async function kr(e, t, r) {
|
|
|
2558
2588
|
// Account capability
|
|
2559
2589
|
],
|
|
2560
2590
|
typeArguments: [f]
|
|
2561
|
-
}) :
|
|
2591
|
+
}) : j = e.moveCall({
|
|
2562
2592
|
target: `${d.package}::incentive_v3::claim_reward`,
|
|
2563
2593
|
arguments: [
|
|
2564
2594
|
e.object("0x06"),
|
|
@@ -2578,7 +2608,7 @@ async function kr(e, t, r) {
|
|
|
2578
2608
|
});
|
|
2579
2609
|
const [T] = e.moveCall({
|
|
2580
2610
|
target: "0x2::coin::from_balance",
|
|
2581
|
-
arguments: [
|
|
2611
|
+
arguments: [j],
|
|
2582
2612
|
typeArguments: [f]
|
|
2583
2613
|
});
|
|
2584
2614
|
if (r?.customCoinReceive.type === "transfer") {
|
|
@@ -2590,23 +2620,23 @@ async function kr(e, t, r) {
|
|
|
2590
2620
|
);
|
|
2591
2621
|
}
|
|
2592
2622
|
if (r?.customCoinReceive.type === "depositNAVI") {
|
|
2593
|
-
const $ = p(
|
|
2623
|
+
const $ = p(k.totalSupplyAmount).shiftedBy(-9), D = p(k.supplyCapCeiling).shiftedBy(-27);
|
|
2594
2624
|
$.plus(u).isGreaterThan(D) && r?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
|
|
2595
2625
|
[T],
|
|
2596
2626
|
e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
2597
|
-
) : await vt(e,
|
|
2627
|
+
) : await vt(e, k, T, {
|
|
2598
2628
|
...r,
|
|
2599
|
-
market:
|
|
2629
|
+
market: k.market
|
|
2600
2630
|
});
|
|
2601
2631
|
} else
|
|
2602
2632
|
a.push({
|
|
2603
2633
|
coin: T,
|
|
2604
|
-
identifier:
|
|
2605
|
-
owner:
|
|
2634
|
+
identifier: k,
|
|
2635
|
+
owner: b,
|
|
2606
2636
|
isEMode: y
|
|
2607
2637
|
});
|
|
2608
2638
|
} else if (r?.accountCap || y) {
|
|
2609
|
-
const
|
|
2639
|
+
const j = e.moveCall({
|
|
2610
2640
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2611
2641
|
arguments: [
|
|
2612
2642
|
e.object("0x06"),
|
|
@@ -2627,12 +2657,12 @@ async function kr(e, t, r) {
|
|
|
2627
2657
|
typeArguments: [f]
|
|
2628
2658
|
}), [T] = e.moveCall({
|
|
2629
2659
|
target: "0x2::coin::from_balance",
|
|
2630
|
-
arguments: [
|
|
2660
|
+
arguments: [j],
|
|
2631
2661
|
typeArguments: [f]
|
|
2632
2662
|
});
|
|
2633
2663
|
e.transferObjects(
|
|
2634
2664
|
[T],
|
|
2635
|
-
h(r?.accountCap ||
|
|
2665
|
+
h(r?.accountCap || b, e.pure.address)
|
|
2636
2666
|
);
|
|
2637
2667
|
} else
|
|
2638
2668
|
e.moveCall({
|
|
@@ -2677,11 +2707,11 @@ export {
|
|
|
2677
2707
|
ze as UserStateInfo,
|
|
2678
2708
|
er as borrowCoinPTB,
|
|
2679
2709
|
F as buildNaviOpenApiUrl,
|
|
2680
|
-
|
|
2710
|
+
jr as claimLendingRewardsPTB,
|
|
2681
2711
|
Yt as configureNaviSdk,
|
|
2682
2712
|
It as createAccountCapPTB,
|
|
2683
2713
|
ar as createEModeCapPTB,
|
|
2684
|
-
|
|
2714
|
+
ke as createNaviLegacyJsonRpcClient,
|
|
2685
2715
|
rt as createNaviSuiClient,
|
|
2686
2716
|
xe as createNaviSuiClientBundle,
|
|
2687
2717
|
vt as depositCoinPTB,
|
|
@@ -2690,7 +2720,7 @@ export {
|
|
|
2690
2720
|
or as exitEModePTB,
|
|
2691
2721
|
Et as filterPriceFeeds,
|
|
2692
2722
|
hr as flashloanPTB,
|
|
2693
|
-
|
|
2723
|
+
jt as getAccountCapOwnerPTB,
|
|
2694
2724
|
Jt as getAddressBalance,
|
|
2695
2725
|
ae as getAllFlashLoanAssets,
|
|
2696
2726
|
rr as getBorrowFee,
|
|
@@ -2705,39 +2735,39 @@ export {
|
|
|
2705
2735
|
sr as getLendingState,
|
|
2706
2736
|
nr as getMarket,
|
|
2707
2737
|
P as getMarketConfig,
|
|
2708
|
-
|
|
2738
|
+
kt as getMarkets,
|
|
2709
2739
|
E as getPool,
|
|
2710
2740
|
J as getPools,
|
|
2711
2741
|
Oe as getPriceFeeds,
|
|
2712
2742
|
fr as getPythStalePriceFeedId,
|
|
2713
|
-
|
|
2743
|
+
At as getPythStalePriceFeedIdV2,
|
|
2714
2744
|
lr as getSimulatedHealthFactor,
|
|
2715
|
-
|
|
2745
|
+
Ae as getSimulatedHealthFactorPTB,
|
|
2716
2746
|
Zt as getStats,
|
|
2717
2747
|
dr as getTransactions,
|
|
2718
2748
|
vr as getUserAvailableLendingRewards,
|
|
2719
2749
|
Ir as getUserClaimedRewardHistory,
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2750
|
+
Se as getUserEModeCaps,
|
|
2751
|
+
kr as getUserTotalClaimedReward,
|
|
2752
|
+
wr as liquidatePTB,
|
|
2723
2753
|
Kt as listAddressBalances,
|
|
2724
2754
|
cr as mergeCoinsPTB,
|
|
2725
2755
|
N as mergeServiceHeaders,
|
|
2726
2756
|
Ce as normalizeAddressBalance,
|
|
2727
2757
|
C as normalizeCoinType,
|
|
2728
|
-
|
|
2758
|
+
wt as parsePoolUID,
|
|
2729
2759
|
h as parseTxValue,
|
|
2730
2760
|
tr as repayCoinPTB,
|
|
2731
|
-
|
|
2761
|
+
br as repayFlashLoanPTB,
|
|
2732
2762
|
Qt as requireNaviGraphQLClient,
|
|
2733
|
-
|
|
2763
|
+
U as resolveNaviOpenApiEndpoint,
|
|
2734
2764
|
Cr as summaryLendingRewards,
|
|
2735
2765
|
yr as updateOraclePriceBeforeUserOperationPTB,
|
|
2736
2766
|
ge as updateOraclePricesPTB,
|
|
2737
2767
|
$t as updatePythPriceFeeds,
|
|
2738
2768
|
mr as verifyHealthFactorPTB,
|
|
2739
2769
|
O as withCache,
|
|
2740
|
-
|
|
2770
|
+
A as withSingleton,
|
|
2741
2771
|
xt as withdrawCoinPTB
|
|
2742
2772
|
};
|
|
2743
2773
|
//# sourceMappingURL=index.esm.js.map
|