@naviprotocol/lending 2.0.5-beta.1 → 2.0.5-beta.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.esm.js +327 -321
- package/dist/index.esm.js.map +1 -1
- package/dist/oracle.d.ts +1 -1
- package/dist/oracle.d.ts.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { Transaction as q } from "@mysten/sui/transactions";
|
|
2
2
|
import { bcs as l } from "@mysten/sui/bcs";
|
|
3
|
-
import { toHex as
|
|
4
|
-
import
|
|
3
|
+
import { toHex as Me, fromHex as De, normalizeStructTag as Y, SUI_CLOCK_OBJECT_ID as x, fromBase64 as Fe } from "@mysten/sui/utils";
|
|
4
|
+
import Ne from "lodash.camelcase";
|
|
5
5
|
import p from "bignumber.js";
|
|
6
|
-
import { SuiJsonRpcClient as
|
|
7
|
-
import { SuiGraphQLClient as
|
|
8
|
-
import { SuiGrpcClient as
|
|
6
|
+
import { SuiJsonRpcClient as Re } from "@mysten/sui/jsonRpc";
|
|
7
|
+
import { SuiGraphQLClient as Le } from "@mysten/sui/graphql";
|
|
8
|
+
import { SuiGrpcClient as we, 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) =>
|
|
13
|
-
}),
|
|
11
|
+
input: (e) => De(e),
|
|
12
|
+
output: (e) => Me(e)
|
|
13
|
+
}), zt = l.struct("IncentiveAPYInfo", {
|
|
14
14
|
/** Asset identifier */
|
|
15
15
|
asset_id: l.u8(),
|
|
16
16
|
/** Annual Percentage Yield as a 256-bit integer */
|
|
17
17
|
apy: l.u256(),
|
|
18
18
|
/** List of supported coin types for this incentive */
|
|
19
19
|
coin_types: l.vector(l.string())
|
|
20
|
-
}),
|
|
20
|
+
}), qe = l.struct("IncentivePoolInfo", {
|
|
21
21
|
/** Unique pool identifier */
|
|
22
22
|
pool_id: ie,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
@@ -44,12 +44,12 @@ const ie = l.bytes(32).transform({
|
|
|
44
44
|
available: l.u256(),
|
|
45
45
|
/** Total amount of incentives */
|
|
46
46
|
total: l.u256()
|
|
47
|
-
}),
|
|
47
|
+
}), Gt = l.struct("IncentivePoolInfoByPhase", {
|
|
48
48
|
/** Phase number */
|
|
49
49
|
phase: l.u64(),
|
|
50
50
|
/** List of incentive pools in this phase */
|
|
51
|
-
pools: l.vector(
|
|
52
|
-
}),
|
|
51
|
+
pools: l.vector(qe)
|
|
52
|
+
}), Wt = l.struct("OracleInfo", {
|
|
53
53
|
/** Oracle identifier */
|
|
54
54
|
oracle_id: l.u8(),
|
|
55
55
|
/** Current price as a 256-bit integer */
|
|
@@ -58,7 +58,7 @@ const ie = l.bytes(32).transform({
|
|
|
58
58
|
decimals: l.u8(),
|
|
59
59
|
/** Whether the oracle data is valid */
|
|
60
60
|
valid: l.bool()
|
|
61
|
-
}),
|
|
61
|
+
}), Ht = l.struct("FlashLoanAssetConfig", {
|
|
62
62
|
/** Unique identifier for the flash loan asset */
|
|
63
63
|
id: l.string(),
|
|
64
64
|
/** Asset identifier */
|
|
@@ -75,7 +75,7 @@ const ie = l.bytes(32).transform({
|
|
|
75
75
|
max: l.u64(),
|
|
76
76
|
/** Minimum flash loan amount */
|
|
77
77
|
min: l.u64()
|
|
78
|
-
}),
|
|
78
|
+
}), ze = l.struct("ReserveDataInfo", {
|
|
79
79
|
/** Reserve identifier */
|
|
80
80
|
id: l.u8(),
|
|
81
81
|
/** Oracle identifier for price feeds */
|
|
@@ -122,26 +122,26 @@ const ie = l.bytes(32).transform({
|
|
|
122
122
|
liquidation_bonus: l.u256(),
|
|
123
123
|
/** Liquidation threshold */
|
|
124
124
|
liquidation_threshold: l.u256()
|
|
125
|
-
}),
|
|
125
|
+
}), Ge = l.struct("UserStateInfo", {
|
|
126
126
|
/** Asset identifier */
|
|
127
127
|
asset_id: l.u8(),
|
|
128
128
|
/** User's current borrow balance */
|
|
129
129
|
borrow_balance: l.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
131
|
supply_balance: l.u256()
|
|
132
|
-
}),
|
|
133
|
-
version:
|
|
134
|
-
},
|
|
132
|
+
}), We = "2.0.5-beta.2", V = {
|
|
133
|
+
version: We
|
|
134
|
+
}, He = V.version, Je = () => {
|
|
135
135
|
if (typeof process < "u" && process.versions && process.versions.node) {
|
|
136
136
|
const e = process.version;
|
|
137
137
|
return `Node.js ${e.startsWith("v") ? e.substring(1) : e}`;
|
|
138
138
|
}
|
|
139
139
|
return "Node/Unknown";
|
|
140
|
-
},
|
|
140
|
+
}, Ke = () => {
|
|
141
141
|
let e = "";
|
|
142
|
-
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${
|
|
143
|
-
}, ce =
|
|
144
|
-
class
|
|
142
|
+
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${He} (${Je()})`), e;
|
|
143
|
+
}, ce = Ke(), ve = "0x2::sui::SUI";
|
|
144
|
+
class Qe extends Error {
|
|
145
145
|
constructor(t) {
|
|
146
146
|
super(
|
|
147
147
|
`NAVI Sui SDK capability "${t}" requires an explicit graphql client; no public GraphQL fallback is configured`
|
|
@@ -151,22 +151,22 @@ class Ke extends Error {
|
|
|
151
151
|
function ee(e) {
|
|
152
152
|
return e == null ? void 0 : String(e);
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Ye(e, t) {
|
|
155
155
|
return (BigInt(e) + BigInt(t)).toString();
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Ze(e, t) {
|
|
158
158
|
return (BigInt(e) - BigInt(t)).toString();
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function Ce(e) {
|
|
161
161
|
const t = e.core;
|
|
162
162
|
if (typeof t?.getBalance != "function" || typeof t?.listBalances != "function")
|
|
163
163
|
throw new Error("NAVI Sui balance helpers require a v2 Core API client");
|
|
164
164
|
return t;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function ke(e, t = ve) {
|
|
167
167
|
const r = ee(e.addressBalance ?? e.fundsInAddressBalance) ?? "0";
|
|
168
168
|
let o = ee(e.balance ?? e.totalBalance), n = ee(e.coinBalance);
|
|
169
|
-
return !n && o && (n =
|
|
169
|
+
return !n && o && (n = Ze(o, r)), !o && n && (o = Ye(n, r)), {
|
|
170
170
|
coinType: Y(e.coinType ?? t),
|
|
171
171
|
totalBalance: o ?? "0",
|
|
172
172
|
coinBalance: n ?? "0",
|
|
@@ -174,22 +174,22 @@ function Ce(e, t = we) {
|
|
|
174
174
|
...e.coinObjectCount === null || e.coinObjectCount === void 0 ? {} : { coinObjectCount: e.coinObjectCount }
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function Jt(e, t = ve) {
|
|
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
|
}
|
|
181
|
-
async function Jt(e, t) {
|
|
182
|
-
const r = await ve(e).getBalance(t), o = r.balance;
|
|
183
|
-
return Ce((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
|
|
184
|
-
}
|
|
185
181
|
async function Kt(e, t) {
|
|
186
|
-
const r = await
|
|
182
|
+
const r = await Ce(e).getBalance(t), o = r.balance;
|
|
183
|
+
return ke((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
|
|
184
|
+
}
|
|
185
|
+
async function Qt(e, t) {
|
|
186
|
+
const r = await Ce(e).listBalances(t), { balances: o = [] } = r;
|
|
187
187
|
return {
|
|
188
|
-
balances: o.map((n) =>
|
|
188
|
+
balances: o.map((n) => ke(n)),
|
|
189
189
|
nextCursor: r.nextCursor ?? r.cursor ?? null
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function Xe(e, t) {
|
|
193
193
|
if ("client" in t)
|
|
194
194
|
return t.client;
|
|
195
195
|
const r = new be({
|
|
@@ -198,53 +198,53 @@ function Ze(e, t) {
|
|
|
198
198
|
fetchInit: t.fetchInit,
|
|
199
199
|
fetch: t.fetch
|
|
200
200
|
});
|
|
201
|
-
return new
|
|
201
|
+
return new we({
|
|
202
202
|
network: e,
|
|
203
203
|
transport: r
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
-
function
|
|
207
|
-
return "client" in t ? t.client : new
|
|
206
|
+
function xe(e, t) {
|
|
207
|
+
return "client" in t ? t.client : new Le({
|
|
208
208
|
network: e,
|
|
209
209
|
url: t.url,
|
|
210
210
|
headers: t.headers,
|
|
211
211
|
fetch: t.fetch
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
-
function
|
|
215
|
-
return "client" in t ? t.client : new
|
|
214
|
+
function Ie(e, t) {
|
|
215
|
+
return "client" in t ? t.client : new Re({
|
|
216
216
|
network: e,
|
|
217
217
|
url: t.url
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
-
function
|
|
221
|
-
const t =
|
|
220
|
+
function et(e) {
|
|
221
|
+
const t = Xe(e.network, e.grpc);
|
|
222
222
|
return {
|
|
223
223
|
network: e.network,
|
|
224
224
|
coreClient: t,
|
|
225
225
|
grpc: t,
|
|
226
|
-
graphql: e.graphql ?
|
|
227
|
-
legacyJsonRpc: e.legacyJsonRpc ?
|
|
226
|
+
graphql: e.graphql ? xe(e.network, e.graphql) : void 0,
|
|
227
|
+
legacyJsonRpc: e.legacyJsonRpc ? Ie(e.network, e.legacyJsonRpc) : void 0,
|
|
228
228
|
services: e.services
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function Yt(e, t) {
|
|
232
232
|
if (!e.graphql)
|
|
233
|
-
throw new
|
|
233
|
+
throw new Qe(t);
|
|
234
234
|
return e.graphql;
|
|
235
235
|
}
|
|
236
|
-
const
|
|
236
|
+
const tt = "https://fullnode.mainnet.sui.io:443";
|
|
237
237
|
let te;
|
|
238
|
-
function
|
|
239
|
-
return te || (te = new
|
|
238
|
+
function rt() {
|
|
239
|
+
return te || (te = new we({
|
|
240
240
|
network: "mainnet",
|
|
241
|
-
transport: new be({ baseUrl:
|
|
241
|
+
transport: new be({ baseUrl: tt })
|
|
242
242
|
})), te;
|
|
243
243
|
}
|
|
244
|
-
function
|
|
245
|
-
return e ? typeof e == "string" ?
|
|
244
|
+
function nt(e, t = "mainnet") {
|
|
245
|
+
return e ? typeof e == "string" ? Ie(t, { url: e }) : et(e) : rt();
|
|
246
246
|
}
|
|
247
|
-
const
|
|
247
|
+
const ot = 16 * 1024;
|
|
248
248
|
function oe(e) {
|
|
249
249
|
return e.replace(/^0x/i, "");
|
|
250
250
|
}
|
|
@@ -254,12 +254,12 @@ function se(e) {
|
|
|
254
254
|
r[o] = parseInt(t.slice(o * 2, o * 2 + 2), 16);
|
|
255
255
|
return r;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function at(e, t) {
|
|
258
258
|
return (e[t] << 8) + e[t + 1];
|
|
259
259
|
}
|
|
260
260
|
function ue(e) {
|
|
261
261
|
return l.vector(l.U8).serialize(Array.from(e), {
|
|
262
|
-
maxSize:
|
|
262
|
+
maxSize: ot
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
265
|
function le(e, t) {
|
|
@@ -268,17 +268,17 @@ function le(e, t) {
|
|
|
268
268
|
bcs: t
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function it(e) {
|
|
272
272
|
return l.vector(l.U8).serialize(Array.from(new TextEncoder().encode(e))).toBytes();
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function ct(e) {
|
|
275
275
|
return l.struct("PriceIdentifier", {
|
|
276
276
|
bytes: l.vector(l.U8)
|
|
277
277
|
}).serialize({
|
|
278
278
|
bytes: Array.from(e)
|
|
279
279
|
}).toBytes();
|
|
280
280
|
}
|
|
281
|
-
function
|
|
281
|
+
function st(e) {
|
|
282
282
|
const t = [];
|
|
283
283
|
let r = 0, o = 0;
|
|
284
284
|
for (let n = 0; n < e.length; n += 1) {
|
|
@@ -287,19 +287,19 @@ function ct(e) {
|
|
|
287
287
|
}
|
|
288
288
|
return t.push(e.slice(o).trim()), t;
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function ut(e) {
|
|
291
291
|
const r = e.indexOf("::table::Table"), o = e.indexOf("<", r), n = e.lastIndexOf(">"), a = "::price_identifier::PriceIdentifier";
|
|
292
292
|
if (r < 0 || o < 0 || n <= o)
|
|
293
293
|
throw new Error(`Unexpected Pyth price table type: ${e}`);
|
|
294
|
-
const [c, i] =
|
|
294
|
+
const [c, i] = st(e.slice(o + 1, n));
|
|
295
295
|
if (!c?.endsWith(a) || !i?.endsWith("::object::ID"))
|
|
296
296
|
throw new Error(`Unexpected Pyth price table type arguments: ${e}`);
|
|
297
297
|
return c.slice(0, -a.length);
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function lt(e) {
|
|
300
300
|
return Uint8Array.from(atob(e), (t) => t.charCodeAt(0));
|
|
301
301
|
}
|
|
302
|
-
class
|
|
302
|
+
class je {
|
|
303
303
|
constructor(t, r) {
|
|
304
304
|
this.endpoint = t.replace(/\/$/, ""), this.timeout = r?.timeout ?? 1e4;
|
|
305
305
|
}
|
|
@@ -327,7 +327,7 @@ class Ie {
|
|
|
327
327
|
throw new Error(`Unsupported Hermes price update encoding: ${o}`);
|
|
328
328
|
if (n.length === 0)
|
|
329
329
|
throw new Error("Hermes price update response did not include binary update data");
|
|
330
|
-
return n.map(
|
|
330
|
+
return n.map(lt);
|
|
331
331
|
}
|
|
332
332
|
async get(t, r, o) {
|
|
333
333
|
const n = new AbortController(), a = setTimeout(() => n.abort(), this.timeout), c = new URL(`${this.endpoint}${t}`);
|
|
@@ -347,7 +347,7 @@ class Ie {
|
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
class
|
|
350
|
+
class dt {
|
|
351
351
|
constructor(t, r, o) {
|
|
352
352
|
this.provider = t, this.pythStateId = r, this.wormholeStateId = o, this.priceFeedObjectIdCache = /* @__PURE__ */ new Map();
|
|
353
353
|
}
|
|
@@ -504,7 +504,7 @@ class lt {
|
|
|
504
504
|
if (c) {
|
|
505
505
|
const { dynamicField: i } = await c.getDynamicField({
|
|
506
506
|
parentId: o,
|
|
507
|
-
name: le(a,
|
|
507
|
+
name: le(a, ct(se(r)))
|
|
508
508
|
}), s = i?.value?.bcs;
|
|
509
509
|
this.priceFeedObjectIdCache.set(
|
|
510
510
|
r,
|
|
@@ -524,7 +524,7 @@ class lt {
|
|
|
524
524
|
}
|
|
525
525
|
async getPriceTableInfo() {
|
|
526
526
|
if (!this.priceTableInfo) {
|
|
527
|
-
const t = this.getCoreProvider() ? le("vector<u8>",
|
|
527
|
+
const t = this.getCoreProvider() ? le("vector<u8>", it("price_info")) : {
|
|
528
528
|
type: "vector<u8>",
|
|
529
529
|
value: "price_info"
|
|
530
530
|
}, r = await this.getDynamicMoveObjectJson(this.pythStateId, t);
|
|
@@ -532,22 +532,22 @@ class lt {
|
|
|
532
532
|
throw new Error("Price Table not found, contract may not be initialized");
|
|
533
533
|
this.priceTableInfo = {
|
|
534
534
|
id: r.objectId,
|
|
535
|
-
fieldType:
|
|
535
|
+
fieldType: ut(r.type)
|
|
536
536
|
};
|
|
537
537
|
}
|
|
538
538
|
return this.priceTableInfo;
|
|
539
539
|
}
|
|
540
540
|
extractVaaBytesFromAccumulatorMessage(t) {
|
|
541
|
-
const o = 7 + t[6] + 1, n =
|
|
541
|
+
const o = 7 + t[6] + 1, n = at(t, o), a = o + 2;
|
|
542
542
|
return t.subarray(a, a + n);
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
|
-
const
|
|
546
|
-
let Q = {},
|
|
547
|
-
function
|
|
545
|
+
const pt = "https://open-api.naviprotocol.io/api";
|
|
546
|
+
let Q = {}, _e = 0;
|
|
547
|
+
function mt(e) {
|
|
548
548
|
return e.replace(/\/+$/, "");
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function Zt(e) {
|
|
551
551
|
Q = {
|
|
552
552
|
...Q,
|
|
553
553
|
...e,
|
|
@@ -555,15 +555,15 @@ function Yt(e) {
|
|
|
555
555
|
...Q.services,
|
|
556
556
|
...e.services
|
|
557
557
|
}
|
|
558
|
-
},
|
|
558
|
+
}, _e += 1;
|
|
559
559
|
}
|
|
560
560
|
function de() {
|
|
561
|
-
return
|
|
561
|
+
return _e;
|
|
562
562
|
}
|
|
563
563
|
function U(e) {
|
|
564
564
|
const t = e?.services?.naviOpenApi ?? Q.services?.naviOpenApi;
|
|
565
565
|
return {
|
|
566
|
-
baseUrl:
|
|
566
|
+
baseUrl: mt(t?.baseUrl ?? pt),
|
|
567
567
|
headers: t?.headers
|
|
568
568
|
};
|
|
569
569
|
}
|
|
@@ -571,7 +571,7 @@ function F(e, t) {
|
|
|
571
571
|
const r = U(t), o = e.startsWith("/") ? e : `/${e}`;
|
|
572
572
|
return `${r.baseUrl}${o}`;
|
|
573
573
|
}
|
|
574
|
-
function
|
|
574
|
+
function ft(e) {
|
|
575
575
|
if (e instanceof Headers) {
|
|
576
576
|
const t = {};
|
|
577
577
|
return e.forEach((r, o) => {
|
|
@@ -582,15 +582,15 @@ function mt(e) {
|
|
|
582
582
|
}
|
|
583
583
|
function N(e, t) {
|
|
584
584
|
return {
|
|
585
|
-
...
|
|
585
|
+
...ft(e),
|
|
586
586
|
...t?.headers ?? {}
|
|
587
587
|
};
|
|
588
588
|
}
|
|
589
|
-
const M =
|
|
589
|
+
const M = nt();
|
|
590
590
|
function pe(e) {
|
|
591
|
-
return e ? e instanceof Uint8Array ? Array.from(e) : Array.isArray(e) ? e : Array.from(
|
|
591
|
+
return e ? e instanceof Uint8Array ? Array.from(e) : Array.isArray(e) ? e : Array.from(Fe(e)) : [];
|
|
592
592
|
}
|
|
593
|
-
function
|
|
593
|
+
function yt(e) {
|
|
594
594
|
const t = e?.commandResults ?? [], r = e?.Transaction ?? e?.FailedTransaction ?? {}, o = r.effects?.errors?.[0] ?? r.effects?.status?.error ?? r.status?.error ?? r.status?.errors?.[0];
|
|
595
595
|
return o && console.warn("[lending] devInspect(core simulate) returned error:", o), {
|
|
596
596
|
effects: r.effects,
|
|
@@ -621,9 +621,9 @@ async function W(e, t) {
|
|
|
621
621
|
commandResults: !0
|
|
622
622
|
}
|
|
623
623
|
});
|
|
624
|
-
return
|
|
624
|
+
return yt(n);
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function Te(e) {
|
|
627
627
|
return {
|
|
628
628
|
json: !!e?.showContent,
|
|
629
629
|
display: !!e?.showDisplay,
|
|
@@ -631,7 +631,7 @@ function _e(e) {
|
|
|
631
631
|
objectBcs: !!e?.showBcs
|
|
632
632
|
};
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function Be(e) {
|
|
635
635
|
return !e || e instanceof Error ? {
|
|
636
636
|
error: e instanceof Error ? { code: "notFound", error: e.message } : void 0
|
|
637
637
|
} : {
|
|
@@ -651,27 +651,27 @@ function Te(e) {
|
|
|
651
651
|
}
|
|
652
652
|
};
|
|
653
653
|
}
|
|
654
|
-
async function
|
|
654
|
+
async function gt(e, t) {
|
|
655
655
|
const r = e?.core;
|
|
656
656
|
if (typeof r?.getObject != "function")
|
|
657
657
|
throw new Error("getSuiObject requires a Sui v2 Core-capable client");
|
|
658
658
|
const { object: o } = await r.getObject({
|
|
659
659
|
objectId: t.id,
|
|
660
|
-
include:
|
|
660
|
+
include: Te(t.options)
|
|
661
661
|
});
|
|
662
|
-
return
|
|
662
|
+
return Be(o);
|
|
663
663
|
}
|
|
664
|
-
async function
|
|
664
|
+
async function ht(e, t) {
|
|
665
665
|
const r = e?.core;
|
|
666
666
|
if (typeof r?.getObjects != "function")
|
|
667
667
|
throw new Error("multiGetSuiObjects requires a Sui v2 Core-capable client");
|
|
668
668
|
const { objects: o } = await r.getObjects({
|
|
669
669
|
objectIds: t.ids,
|
|
670
|
-
include:
|
|
670
|
+
include: Te(t.options)
|
|
671
671
|
});
|
|
672
|
-
return o.map(
|
|
672
|
+
return o.map(Be);
|
|
673
673
|
}
|
|
674
|
-
function
|
|
674
|
+
function Pe(e) {
|
|
675
675
|
const t = [];
|
|
676
676
|
let r = !1;
|
|
677
677
|
return e.forEach((o, n) => {
|
|
@@ -688,7 +688,7 @@ function Be(e) {
|
|
|
688
688
|
function A(e) {
|
|
689
689
|
const t = {};
|
|
690
690
|
return (...r) => {
|
|
691
|
-
const o =
|
|
691
|
+
const o = Pe(r);
|
|
692
692
|
return t[o] || (t[o] = e(...r).finally(() => {
|
|
693
693
|
delete t[o];
|
|
694
694
|
})), t[o];
|
|
@@ -697,7 +697,7 @@ function A(e) {
|
|
|
697
697
|
function O(e) {
|
|
698
698
|
let t = {};
|
|
699
699
|
return (...r) => {
|
|
700
|
-
const o = r[r.length - 1], n =
|
|
700
|
+
const o = r[r.length - 1], n = Pe(r), a = t[n];
|
|
701
701
|
return !o?.disableCache && typeof a?.data < "u" && (typeof o?.cacheTime > "u" || o.cacheTime > Date.now() - a.cacheAt) ? Promise.resolve(a.data) : e(...r).then((c) => (t[n] = {
|
|
702
702
|
data: c,
|
|
703
703
|
cacheAt: Date.now()
|
|
@@ -708,7 +708,7 @@ function re(e) {
|
|
|
708
708
|
return Array.isArray(e) ? e.map((t) => re(t)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
709
709
|
(t, r) => ({
|
|
710
710
|
...t,
|
|
711
|
-
[
|
|
711
|
+
[Ne(r)]: re(e[r])
|
|
712
712
|
}),
|
|
713
713
|
{}
|
|
714
714
|
) : e;
|
|
@@ -718,7 +718,7 @@ function h(e, t) {
|
|
|
718
718
|
throw new Error("Transaction value is required");
|
|
719
719
|
return typeof e == "object" ? e : t(e);
|
|
720
720
|
}
|
|
721
|
-
function
|
|
721
|
+
function wt(e, t) {
|
|
722
722
|
return typeof t == "string" ? e.object(t) : typeof t == "object" && t.$kind ? t : e.object(t.contract.pool);
|
|
723
723
|
}
|
|
724
724
|
function Z(e, t, r) {
|
|
@@ -732,11 +732,11 @@ function Z(e, t, r) {
|
|
|
732
732
|
function C(e) {
|
|
733
733
|
return Y(e);
|
|
734
734
|
}
|
|
735
|
-
function
|
|
735
|
+
function Se(e) {
|
|
736
736
|
const t = (e || 0) / Math.pow(10, 27);
|
|
737
737
|
return t > Math.pow(10, 5) ? 1 / 0 : t;
|
|
738
738
|
}
|
|
739
|
-
new
|
|
739
|
+
new je("https://hermes.pyth.network", {
|
|
740
740
|
timeout: 2e4
|
|
741
741
|
});
|
|
742
742
|
const bt = 27, me = (e, t) => {
|
|
@@ -772,7 +772,7 @@ function K(e, t) {
|
|
|
772
772
|
isEMode: !0
|
|
773
773
|
};
|
|
774
774
|
}
|
|
775
|
-
function
|
|
775
|
+
function vt(e) {
|
|
776
776
|
const [t, r] = e.split("-");
|
|
777
777
|
return !t || !r ? null : {
|
|
778
778
|
marketKey: t,
|
|
@@ -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 k = P(
|
|
800
|
-
return a.market === k.key &&
|
|
801
|
-
}).filter((
|
|
798
|
+
const i = n.meta.emodes.filter((b) => {
|
|
799
|
+
const k = P(b.marketId);
|
|
800
|
+
return a.market === k.key && b.isActive;
|
|
801
|
+
}).filter((b) => !!b.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(), w = 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 = w, 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 = vt(e);
|
|
816
816
|
a && (r = a.marketKey, e = a.poolId);
|
|
817
817
|
}
|
|
818
818
|
const o = await J({
|
|
@@ -827,14 +827,14 @@ async function E(e, t) {
|
|
|
827
827
|
throw new Error("Pool not found");
|
|
828
828
|
return n.isDeprecated && console.log(`The lending pool for coinType ${n.suiCoinType} is going to be deprecated.`), n;
|
|
829
829
|
}
|
|
830
|
-
const
|
|
830
|
+
const Xt = O(
|
|
831
831
|
A(async (e) => {
|
|
832
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
840
|
const t = U(e), r = F(`/navi/fee?sdk=${V.version}`, e);
|
|
@@ -844,7 +844,7 @@ const Zt = O(
|
|
|
844
844
|
}
|
|
845
845
|
)
|
|
846
846
|
);
|
|
847
|
-
async function
|
|
847
|
+
async function Ct(e, t, r, o) {
|
|
848
848
|
const n = await I({
|
|
849
849
|
...o,
|
|
850
850
|
cacheTime: v
|
|
@@ -892,7 +892,7 @@ async function vt(e, t, r, o) {
|
|
|
892
892
|
arguments: [e.object(a.contract.pool), e.object("0x05")]
|
|
893
893
|
}), e;
|
|
894
894
|
}
|
|
895
|
-
async function
|
|
895
|
+
async function er(e, t, r, o) {
|
|
896
896
|
const n = await I({
|
|
897
897
|
...o,
|
|
898
898
|
cacheTime: v
|
|
@@ -975,7 +975,7 @@ async function xt(e, t, r, o) {
|
|
|
975
975
|
typeArguments: [a.suiCoinType]
|
|
976
976
|
});
|
|
977
977
|
}
|
|
978
|
-
async function
|
|
978
|
+
async function tr(e, t, r, o) {
|
|
979
979
|
const n = await I({
|
|
980
980
|
...o,
|
|
981
981
|
cacheTime: v
|
|
@@ -1061,7 +1061,7 @@ async function er(e, t, r, o) {
|
|
|
1061
1061
|
typeArguments: [a.suiCoinType]
|
|
1062
1062
|
});
|
|
1063
1063
|
}
|
|
1064
|
-
async function
|
|
1064
|
+
async function rr(e, t, r, o) {
|
|
1065
1065
|
const n = await I({
|
|
1066
1066
|
...o,
|
|
1067
1067
|
cacheTime: v
|
|
@@ -1114,7 +1114,7 @@ async function tr(e, t, r, o) {
|
|
|
1114
1114
|
typeArguments: [a.suiCoinType]
|
|
1115
1115
|
}), e;
|
|
1116
1116
|
}
|
|
1117
|
-
const
|
|
1117
|
+
const nr = O(
|
|
1118
1118
|
A(
|
|
1119
1119
|
async (e) => {
|
|
1120
1120
|
const t = await I({
|
|
@@ -1144,7 +1144,7 @@ const rr = O(
|
|
|
1144
1144
|
a
|
|
1145
1145
|
);
|
|
1146
1146
|
}
|
|
1147
|
-
const n = (await
|
|
1147
|
+
const n = (await gt(r, {
|
|
1148
1148
|
id: t.incentiveV3,
|
|
1149
1149
|
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
1150
1150
|
})).data.content.fields.borrow_fee_rate;
|
|
@@ -1203,7 +1203,7 @@ const rr = O(
|
|
|
1203
1203
|
name: "hasSUI/SUI Market"
|
|
1204
1204
|
}
|
|
1205
1205
|
};
|
|
1206
|
-
class
|
|
1206
|
+
class kt {
|
|
1207
1207
|
constructor(t, r) {
|
|
1208
1208
|
this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
|
|
1209
1209
|
marketTotalSupplyValue: "0",
|
|
@@ -1222,10 +1222,10 @@ class Ct {
|
|
|
1222
1222
|
return;
|
|
1223
1223
|
}
|
|
1224
1224
|
r[s.uniqueId] || this.pools.push(s), s?.emodes?.forEach((m) => {
|
|
1225
|
-
o[m.uniqueId] || this.emodes.push(m), m.assets.forEach((
|
|
1226
|
-
|
|
1225
|
+
o[m.uniqueId] || this.emodes.push(m), m.assets.forEach((w) => {
|
|
1226
|
+
w.isDebt && m.assets.find(
|
|
1227
1227
|
(y) => y.isCollateral && y.ltv > 0 && y.assetId !== s.id
|
|
1228
|
-
) && n.add(s.uniqueId),
|
|
1228
|
+
) && n.add(s.uniqueId), w.isCollateral && m.assets.find((y) => y.isDebt && y.assetId !== s.id) && a.add(s.uniqueId);
|
|
1229
1229
|
});
|
|
1230
1230
|
}), i = i.plus(s.poolBorrowValue), c = c.plus(s.poolSupplyValue);
|
|
1231
1231
|
}), this.poolMap = ne(this.pools, "id"), this.emodeMap = fe(this.emodes, "emodeId"), this.emodes.forEach((s) => {
|
|
@@ -1271,7 +1271,7 @@ const P = (e) => {
|
|
|
1271
1271
|
if (!r)
|
|
1272
1272
|
throw new Error("Market not found");
|
|
1273
1273
|
return r;
|
|
1274
|
-
},
|
|
1274
|
+
}, It = O(
|
|
1275
1275
|
A(
|
|
1276
1276
|
async (e, t) => {
|
|
1277
1277
|
const r = await J({
|
|
@@ -1281,13 +1281,13 @@ const P = (e) => {
|
|
|
1281
1281
|
});
|
|
1282
1282
|
return e.map((o) => {
|
|
1283
1283
|
const n = P(o), a = r.filter((c) => c.market === n.key);
|
|
1284
|
-
return new
|
|
1284
|
+
return new kt(o, a);
|
|
1285
1285
|
});
|
|
1286
1286
|
}
|
|
1287
1287
|
)
|
|
1288
|
-
),
|
|
1288
|
+
), or = O(
|
|
1289
1289
|
A(
|
|
1290
|
-
async (e, t) => (await
|
|
1290
|
+
async (e, t) => (await It([e], t))[0]
|
|
1291
1291
|
)
|
|
1292
1292
|
), I = O(
|
|
1293
1293
|
A(
|
|
@@ -1302,7 +1302,7 @@ const P = (e) => {
|
|
|
1302
1302
|
}
|
|
1303
1303
|
)
|
|
1304
1304
|
), v = 1e3 * 60 * 5;
|
|
1305
|
-
async function
|
|
1305
|
+
async function jt(e, t) {
|
|
1306
1306
|
const r = await I({
|
|
1307
1307
|
cacheTime: v,
|
|
1308
1308
|
...t
|
|
@@ -1312,7 +1312,7 @@ async function It(e, t) {
|
|
|
1312
1312
|
arguments: []
|
|
1313
1313
|
});
|
|
1314
1314
|
}
|
|
1315
|
-
async function
|
|
1315
|
+
async function _t(e, t, r) {
|
|
1316
1316
|
const o = await I({
|
|
1317
1317
|
cacheTime: v,
|
|
1318
1318
|
...r
|
|
@@ -1322,7 +1322,7 @@ async function jt(e, t, r) {
|
|
|
1322
1322
|
arguments: [t]
|
|
1323
1323
|
});
|
|
1324
1324
|
}
|
|
1325
|
-
async function
|
|
1325
|
+
async function Tt(e, t, r) {
|
|
1326
1326
|
const o = await I({
|
|
1327
1327
|
...r,
|
|
1328
1328
|
cacheTime: v
|
|
@@ -1339,7 +1339,7 @@ async function _t(e, t, r) {
|
|
|
1339
1339
|
arguments: [e.object(o.storage), h(t, e.pure.u64)]
|
|
1340
1340
|
}), e;
|
|
1341
1341
|
}
|
|
1342
|
-
async function
|
|
1342
|
+
async function ar(e, t) {
|
|
1343
1343
|
const r = await I({
|
|
1344
1344
|
...t,
|
|
1345
1345
|
cacheTime: v
|
|
@@ -1352,16 +1352,16 @@ async function or(e, t) {
|
|
|
1352
1352
|
arguments: [e.object(r.storage)]
|
|
1353
1353
|
}), e;
|
|
1354
1354
|
}
|
|
1355
|
-
async function
|
|
1355
|
+
async function ir(e, t, r) {
|
|
1356
1356
|
const o = await I({
|
|
1357
1357
|
cacheTime: v,
|
|
1358
1358
|
...r
|
|
1359
|
-
}), n = await
|
|
1360
|
-
await
|
|
1359
|
+
}), n = await jt(e, r);
|
|
1360
|
+
await Tt(e, t, {
|
|
1361
1361
|
...r,
|
|
1362
1362
|
accountCap: n
|
|
1363
1363
|
});
|
|
1364
|
-
const a = await P(r?.market || z), c = await
|
|
1364
|
+
const a = await P(r?.market || z), c = await _t(e, n, r);
|
|
1365
1365
|
return e.moveCall({
|
|
1366
1366
|
target: `${o.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
|
|
1367
1367
|
arguments: [
|
|
@@ -1372,7 +1372,7 @@ async function ar(e, t, r) {
|
|
|
1372
1372
|
]
|
|
1373
1373
|
}), n;
|
|
1374
1374
|
}
|
|
1375
|
-
const
|
|
1375
|
+
const Ae = O(
|
|
1376
1376
|
A(
|
|
1377
1377
|
async (e, t) => {
|
|
1378
1378
|
const r = await I({
|
|
@@ -1387,29 +1387,29 @@ const Se = O(
|
|
|
1387
1387
|
transactionBlock: o,
|
|
1388
1388
|
sender: e
|
|
1389
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]));
|
|
1390
|
-
return i.map((m,
|
|
1390
|
+
return i.map((m, w) => ({
|
|
1391
1391
|
marketId: Number(m),
|
|
1392
|
-
emodeId: Number(s[
|
|
1393
|
-
accountCap: u[
|
|
1392
|
+
emodeId: Number(s[w]),
|
|
1393
|
+
accountCap: u[w].toString()
|
|
1394
1394
|
}));
|
|
1395
1395
|
}
|
|
1396
1396
|
)
|
|
1397
1397
|
);
|
|
1398
|
-
function
|
|
1398
|
+
function cr(e) {
|
|
1399
1399
|
return `${P(e.marketId).key}-${e.emodeId}`;
|
|
1400
1400
|
}
|
|
1401
|
-
function
|
|
1401
|
+
function Bt(e, t) {
|
|
1402
1402
|
return e.coinType ? e.coinType : t || (typeof e.type == "string" ? e.type.match(/::coin::Coin<(.+)>$/) : null)?.[1];
|
|
1403
1403
|
}
|
|
1404
1404
|
function ye(e, t) {
|
|
1405
|
-
const r =
|
|
1405
|
+
const r = Bt(e, t), o = e.coinObjectId ?? e.objectId;
|
|
1406
1406
|
return !r || !o || e.balance === void 0 || e.balance === null ? null : {
|
|
1407
1407
|
...e,
|
|
1408
1408
|
coinType: C(r),
|
|
1409
1409
|
coinObjectId: o
|
|
1410
1410
|
};
|
|
1411
1411
|
}
|
|
1412
|
-
function
|
|
1412
|
+
function sr(e, t, r) {
|
|
1413
1413
|
const o = typeof r?.balance == "number", n = o ? r.balance : 0, a = BigInt(r?.addressBalance ?? 0);
|
|
1414
1414
|
let c = 0;
|
|
1415
1415
|
const i = [];
|
|
@@ -1429,7 +1429,7 @@ function cr(e, t, r) {
|
|
|
1429
1429
|
} catch {
|
|
1430
1430
|
return !1;
|
|
1431
1431
|
}
|
|
1432
|
-
})(s || m || "") && !!r?.useGasCoin, d = BigInt(n), f = !y && !!m,
|
|
1432
|
+
})(s || m || "") && !!r?.useGasCoin, d = BigInt(n), f = !y && !!m, b = f ? a : 0n, k = u + b, _ = !o || u >= d ? 0n : d - u, j = f && _ > 0n && b >= _;
|
|
1433
1433
|
if (o && k < d)
|
|
1434
1434
|
throw new Error(`Balance is less than the specified balance: ${k} < ${d}`);
|
|
1435
1435
|
if (i.length === 0 && !j)
|
|
@@ -1454,7 +1454,7 @@ function cr(e, t, r) {
|
|
|
1454
1454
|
$ = T;
|
|
1455
1455
|
return D.length > 0 && e.mergeCoins($, D), i.length === 0 ? $ : o ? e.splitCoins($, [e.pure.u64(n)]) : $;
|
|
1456
1456
|
}
|
|
1457
|
-
async function
|
|
1457
|
+
async function $e(e, t, r, o, n, a, c) {
|
|
1458
1458
|
const i = await I({
|
|
1459
1459
|
...c,
|
|
1460
1460
|
cacheTime: v
|
|
@@ -1465,7 +1465,7 @@ async function Ae(e, t, r, o, n, a, c) {
|
|
|
1465
1465
|
e.object("0x06"),
|
|
1466
1466
|
e.object(i.storage),
|
|
1467
1467
|
e.object(i.oracle.priceOracle),
|
|
1468
|
-
|
|
1468
|
+
wt(e, s),
|
|
1469
1469
|
h(t, e.pure.address),
|
|
1470
1470
|
h(s.id, e.pure.u8),
|
|
1471
1471
|
h(o, e.pure.u64),
|
|
@@ -1475,10 +1475,10 @@ async function Ae(e, t, r, o, n, a, c) {
|
|
|
1475
1475
|
typeArguments: [s.suiCoinType]
|
|
1476
1476
|
});
|
|
1477
1477
|
}
|
|
1478
|
-
async function
|
|
1479
|
-
return
|
|
1478
|
+
async function Pt(e, t, r) {
|
|
1479
|
+
return $e(e, t, 0, 0, 0, !1, r);
|
|
1480
1480
|
}
|
|
1481
|
-
async function
|
|
1481
|
+
async function Ee(e, t, r) {
|
|
1482
1482
|
const o = new q(), n = r?.client ?? M, a = await J({
|
|
1483
1483
|
...r,
|
|
1484
1484
|
markets: Object.values(L)
|
|
@@ -1508,63 +1508,63 @@ async function $e(e, t, r) {
|
|
|
1508
1508
|
const m = (await W(n, {
|
|
1509
1509
|
transactionBlock: o,
|
|
1510
1510
|
sender: e
|
|
1511
|
-
})).results || [],
|
|
1511
|
+
})).results || [], w = {};
|
|
1512
1512
|
s.forEach((d, f) => {
|
|
1513
1513
|
try {
|
|
1514
|
-
const
|
|
1515
|
-
for (const _ of
|
|
1514
|
+
const b = m[f]?.returnValues?.map((_) => l.vector(ze).parse(Uint8Array.from(_[0])))[0] || [], k = {};
|
|
1515
|
+
for (const _ of b)
|
|
1516
1516
|
k[_.id] = {
|
|
1517
1517
|
supplyIndex: _.supply_index,
|
|
1518
1518
|
borrowIndex: _.borrow_index
|
|
1519
1519
|
};
|
|
1520
|
-
|
|
1521
|
-
} catch (
|
|
1520
|
+
w[d.key] = k;
|
|
1521
|
+
} catch (b) {
|
|
1522
1522
|
console.warn(
|
|
1523
1523
|
`[@naviprotocol/lending] Failed to decode reserve data for market "${d.key}", falling back to open-api pool indices`,
|
|
1524
|
-
|
|
1524
|
+
b
|
|
1525
1525
|
);
|
|
1526
1526
|
}
|
|
1527
1527
|
});
|
|
1528
|
-
const g = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(
|
|
1528
|
+
const g = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(Ge).parse(Uint8Array.from(f[0])))[0] || []), y = [];
|
|
1529
1529
|
return g.forEach((d, f) => {
|
|
1530
|
-
const
|
|
1530
|
+
const b = t[f], k = P(b.market), _ = w[k.key] || {};
|
|
1531
1531
|
d.forEach((j) => {
|
|
1532
|
-
if (j.supply_balance === "0" && j.borrow_balance === "0" && (
|
|
1532
|
+
if (j.supply_balance === "0" && j.borrow_balance === "0" && (b.emodeId === void 0 || !r?.includeZeroBalanceEmodePositions))
|
|
1533
1533
|
return;
|
|
1534
1534
|
const T = c[`${k.key}-${j.asset_id}`];
|
|
1535
1535
|
if (!T)
|
|
1536
1536
|
return;
|
|
1537
|
-
const $ = _[j.asset_id], D = $?.supplyIndex ?? T.currentSupplyIndex, B = $?.borrowIndex ?? T.currentBorrowIndex, X = me(j.supply_balance, D).toString(),
|
|
1537
|
+
const $ = _[j.asset_id], D = $?.supplyIndex ?? T.currentSupplyIndex, B = $?.borrowIndex ?? T.currentBorrowIndex, X = me(j.supply_balance, D).toString(), Ue = me(j.borrow_balance, B).toString();
|
|
1538
1538
|
y.push({
|
|
1539
1539
|
supplyBalance: X,
|
|
1540
|
-
borrowBalance:
|
|
1540
|
+
borrowBalance: Ue,
|
|
1541
1541
|
assetId: j.asset_id,
|
|
1542
1542
|
market: k.key,
|
|
1543
1543
|
pool: T,
|
|
1544
|
-
emodeId:
|
|
1544
|
+
emodeId: b.emodeId
|
|
1545
1545
|
});
|
|
1546
1546
|
});
|
|
1547
1547
|
}), y;
|
|
1548
1548
|
}
|
|
1549
|
-
const
|
|
1549
|
+
const ur = O(
|
|
1550
1550
|
async (e, t) => {
|
|
1551
1551
|
const o = (t?.markets || Object.keys(L)).map((n) => P(n)).map((n) => ({
|
|
1552
1552
|
address: e,
|
|
1553
1553
|
market: n.key
|
|
1554
1554
|
}));
|
|
1555
|
-
return await
|
|
1555
|
+
return await Ee(e, o, t);
|
|
1556
1556
|
}
|
|
1557
1557
|
);
|
|
1558
|
-
async function
|
|
1558
|
+
async function lr(e, t) {
|
|
1559
1559
|
const r = t?.client ?? M, o = new q();
|
|
1560
|
-
await
|
|
1560
|
+
await Pt(o, e, t);
|
|
1561
1561
|
const n = await W(r, {
|
|
1562
1562
|
transactionBlock: o,
|
|
1563
1563
|
sender: e
|
|
1564
1564
|
}), a = Z(n, [l.u256()]);
|
|
1565
|
-
return
|
|
1565
|
+
return Se(Number(a[0]) || 0);
|
|
1566
1566
|
}
|
|
1567
|
-
async function
|
|
1567
|
+
async function dr(e, t, r, o) {
|
|
1568
1568
|
const n = o?.client ?? M, a = new q();
|
|
1569
1569
|
let c = 0, i = 0;
|
|
1570
1570
|
const s = await E(t, o);
|
|
@@ -1573,7 +1573,7 @@ async function lr(e, t, r, o) {
|
|
|
1573
1573
|
}), c * i < 0)
|
|
1574
1574
|
throw new Error("Invalid operations");
|
|
1575
1575
|
const u = c > 0 || i > 0;
|
|
1576
|
-
await
|
|
1576
|
+
await $e(
|
|
1577
1577
|
a,
|
|
1578
1578
|
e,
|
|
1579
1579
|
s,
|
|
@@ -1585,10 +1585,10 @@ async function lr(e, t, r, o) {
|
|
|
1585
1585
|
const m = await W(n, {
|
|
1586
1586
|
transactionBlock: a,
|
|
1587
1587
|
sender: e
|
|
1588
|
-
}),
|
|
1589
|
-
return
|
|
1588
|
+
}), w = Z(m, [l.u256()]);
|
|
1589
|
+
return Se(Number(w[0]) || 0);
|
|
1590
1590
|
}
|
|
1591
|
-
const
|
|
1591
|
+
const pr = A(
|
|
1592
1592
|
async (e, t) => {
|
|
1593
1593
|
const r = new URLSearchParams();
|
|
1594
1594
|
t?.cursor && r.set("cursor", t.cursor), r.set("userAddress", e);
|
|
@@ -1601,7 +1601,7 @@ const dr = A(
|
|
|
1601
1601
|
}).then((c) => c.json())).data;
|
|
1602
1602
|
}
|
|
1603
1603
|
);
|
|
1604
|
-
async function
|
|
1604
|
+
async function mr(e, t) {
|
|
1605
1605
|
let r = null;
|
|
1606
1606
|
const o = [], n = t?.client ?? M, a = n.core;
|
|
1607
1607
|
do {
|
|
@@ -1645,15 +1645,15 @@ async function pr(e, t) {
|
|
|
1645
1645
|
for (const u of i) {
|
|
1646
1646
|
let m = null;
|
|
1647
1647
|
do {
|
|
1648
|
-
const
|
|
1648
|
+
const w = await a.listCoins({
|
|
1649
1649
|
owner: e,
|
|
1650
1650
|
coinType: u,
|
|
1651
1651
|
cursor: m,
|
|
1652
1652
|
limit: 100
|
|
1653
1653
|
});
|
|
1654
1654
|
o.push(
|
|
1655
|
-
...(
|
|
1656
|
-
), m =
|
|
1655
|
+
...(w.objects ?? w.data ?? []).map((g) => ye(g, u)).filter(Boolean)
|
|
1656
|
+
), m = w.cursor ?? w.nextCursor ?? null;
|
|
1657
1657
|
} while (m);
|
|
1658
1658
|
}
|
|
1659
1659
|
break;
|
|
@@ -1674,9 +1674,9 @@ async function pr(e, t) {
|
|
|
1674
1674
|
} while (r);
|
|
1675
1675
|
return o;
|
|
1676
1676
|
}
|
|
1677
|
-
const
|
|
1677
|
+
const St = O(
|
|
1678
1678
|
async (e, t) => {
|
|
1679
|
-
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 Ae(e, t), a = o.map((i) => ({
|
|
1680
1680
|
address: e,
|
|
1681
1681
|
market: i.key
|
|
1682
1682
|
})).concat(
|
|
@@ -1686,7 +1686,7 @@ const Pt = O(
|
|
|
1686
1686
|
emodeId: i.emodeId
|
|
1687
1687
|
}))
|
|
1688
1688
|
);
|
|
1689
|
-
return (await
|
|
1689
|
+
return (await Ee(e, a, t)).forEach((i) => {
|
|
1690
1690
|
const s = typeof i.emodeId == "number" ? n.find((u) => {
|
|
1691
1691
|
const m = P(i.market);
|
|
1692
1692
|
return u.emodeId === i.emodeId && u.marketId === m.id;
|
|
@@ -1695,8 +1695,8 @@ const Pt = O(
|
|
|
1695
1695
|
if (!i.pool.emodes.find((m) => m.emodeId === s.emodeId))
|
|
1696
1696
|
return;
|
|
1697
1697
|
if (p(i.supplyBalance).gte(0)) {
|
|
1698
|
-
const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN),
|
|
1699
|
-
if (m.gt(0) ||
|
|
1698
|
+
const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), w = K(i.pool, s);
|
|
1699
|
+
if (m.gt(0) || w.emode.isCollateral)
|
|
1700
1700
|
try {
|
|
1701
1701
|
r.push({
|
|
1702
1702
|
id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${S()}`,
|
|
@@ -1717,8 +1717,8 @@ const Pt = O(
|
|
|
1717
1717
|
}
|
|
1718
1718
|
}
|
|
1719
1719
|
if (p(i.borrowBalance).gte(0)) {
|
|
1720
|
-
const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN),
|
|
1721
|
-
if (m.gt(0) ||
|
|
1720
|
+
const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), w = K(i.pool, s);
|
|
1721
|
+
if (m.gt(0) || w.emode.isDebt)
|
|
1722
1722
|
try {
|
|
1723
1723
|
r.push({
|
|
1724
1724
|
id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${S()}`,
|
|
@@ -1963,11 +1963,11 @@ class G {
|
|
|
1963
1963
|
} else if (y.type === "navi-lending-emode-supply") {
|
|
1964
1964
|
const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d);
|
|
1965
1965
|
n = n.plus(f);
|
|
1966
|
-
const
|
|
1966
|
+
const b = d.pool.emode;
|
|
1967
1967
|
s = s.plus(
|
|
1968
|
-
new p(f).multipliedBy(
|
|
1968
|
+
new p(f).multipliedBy(b.lt)
|
|
1969
1969
|
), u = u.plus(
|
|
1970
|
-
new p(f).multipliedBy(
|
|
1970
|
+
new p(f).multipliedBy(b.ltv)
|
|
1971
1971
|
);
|
|
1972
1972
|
} else if (y.type === "navi-lending-emode-borrow") {
|
|
1973
1973
|
const d = y["navi-lending-emode-borrow"];
|
|
@@ -1975,32 +1975,32 @@ class G {
|
|
|
1975
1975
|
}
|
|
1976
1976
|
}), a = p.max(a, 0), n = p.max(n, 0), s = p.max(s, 0), u = p.max(u, 0), t.forEach((y) => {
|
|
1977
1977
|
if (y.type === "navi-lending-supply") {
|
|
1978
|
-
const d = y["navi-lending-supply"], f = this.resolveValueUSD(d),
|
|
1978
|
+
const d = y["navi-lending-supply"], f = this.resolveValueUSD(d), b = d.pool.supplyIncentiveApyInfo.apy;
|
|
1979
1979
|
n.gt(0) && (c = c.plus(
|
|
1980
|
-
new p(f).dividedBy(n).multipliedBy(new p(
|
|
1980
|
+
new p(f).dividedBy(n).multipliedBy(new p(b).dividedBy(100))
|
|
1981
1981
|
)), r[d.pool.suiCoinType] = p(r[d.pool.suiCoinType] || 0).plus(d.amount).toString();
|
|
1982
1982
|
} else if (y.type === "navi-lending-borrow") {
|
|
1983
|
-
const d = y["navi-lending-borrow"], f = this.resolveValueUSD(d),
|
|
1983
|
+
const d = y["navi-lending-borrow"], f = this.resolveValueUSD(d), b = d.pool.borrowIncentiveApyInfo.apy;
|
|
1984
1984
|
a.gt(0) && (i = i.plus(
|
|
1985
|
-
new p(f).dividedBy(a).multipliedBy(new p(
|
|
1985
|
+
new p(f).dividedBy(a).multipliedBy(new p(b).dividedBy(100))
|
|
1986
1986
|
)), o[d.pool.suiCoinType] = p(o[d.pool.suiCoinType] || 0).plus(d.amount).toString();
|
|
1987
1987
|
} else if (y.type === "navi-lending-emode-supply") {
|
|
1988
|
-
const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d),
|
|
1988
|
+
const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d), b = d.pool.supplyIncentiveApyInfo.apy;
|
|
1989
1989
|
n.gt(0) && (c = c.plus(
|
|
1990
|
-
new p(f).dividedBy(n).multipliedBy(new p(
|
|
1990
|
+
new p(f).dividedBy(n).multipliedBy(new p(b).dividedBy(100))
|
|
1991
1991
|
)), r[d.pool.suiCoinType] = p(r[d.pool.suiCoinType] || 0).plus(d.amount).toString();
|
|
1992
1992
|
} else if (y.type === "navi-lending-emode-borrow") {
|
|
1993
|
-
const d = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(d),
|
|
1993
|
+
const d = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(d), b = d.pool.borrowIncentiveApyInfo.apy;
|
|
1994
1994
|
a.gt(0) && (i = i.plus(
|
|
1995
|
-
new p(f).dividedBy(a).multipliedBy(new p(
|
|
1995
|
+
new p(f).dividedBy(a).multipliedBy(new p(b).dividedBy(100))
|
|
1996
1996
|
)), o[d.pool.suiCoinType] = p(o[d.pool.suiCoinType] || 0).plus(d.amount).toString();
|
|
1997
1997
|
}
|
|
1998
1998
|
});
|
|
1999
|
-
const m = n.minus(a),
|
|
1999
|
+
const m = n.minus(a), w = n.minus(a).eq(0) ? new p(0) : n.multipliedBy(c).minus(a.multipliedBy(i)).div(n.minus(a));
|
|
2000
2000
|
return {
|
|
2001
2001
|
hf: a.toNumber() !== 0 ? s.dividedBy(a).toNumber() : 1 / 0,
|
|
2002
2002
|
netVaule: m.toString(),
|
|
2003
|
-
netWorthApr:
|
|
2003
|
+
netWorthApr: w.toString(),
|
|
2004
2004
|
totalSupplyValue: n.toString(),
|
|
2005
2005
|
totalBorrowValue: a.toString(),
|
|
2006
2006
|
totalsupplyApy: c.toString(),
|
|
@@ -2012,7 +2012,7 @@ class G {
|
|
|
2012
2012
|
};
|
|
2013
2013
|
}
|
|
2014
2014
|
}
|
|
2015
|
-
async function
|
|
2015
|
+
async function fr(e, t, r, o) {
|
|
2016
2016
|
const n = await I({
|
|
2017
2017
|
...o,
|
|
2018
2018
|
cacheTime: v
|
|
@@ -2028,33 +2028,37 @@ async function mr(e, t, r, o) {
|
|
|
2028
2028
|
]
|
|
2029
2029
|
});
|
|
2030
2030
|
}
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2031
|
+
const ge = /* @__PURE__ */ new Map(), Oe = (e) => {
|
|
2032
|
+
const t = e ?? "https://hermes.pyth.network";
|
|
2033
|
+
let r = ge.get(t);
|
|
2034
|
+
return r || (r = new je(t, { timeout: 1e4 }), ge.set(t, r)), r;
|
|
2035
|
+
};
|
|
2036
|
+
async function yr(e, t) {
|
|
2035
2037
|
try {
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2038
|
+
const r = [], o = await I({ ...t, cacheTime: v }), n = await Oe(
|
|
2039
|
+
o.oracle.hermesEndpoint
|
|
2040
|
+
).getLatestPriceFeeds(e);
|
|
2041
|
+
if (!n) return r;
|
|
2042
|
+
const a = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
2043
|
+
for (const c of n) {
|
|
2044
|
+
const i = c.getPriceUnchecked();
|
|
2045
|
+
if (i.publishTime > a) {
|
|
2042
2046
|
console.warn(
|
|
2043
|
-
`pyth price feed is invalid, id: ${
|
|
2047
|
+
`pyth price feed is invalid, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
|
|
2044
2048
|
);
|
|
2045
2049
|
continue;
|
|
2046
2050
|
}
|
|
2047
|
-
|
|
2048
|
-
`stale price feed, id: ${
|
|
2049
|
-
),
|
|
2051
|
+
a - c.getPriceUnchecked().publishTime > 30 && (console.info(
|
|
2052
|
+
`stale price feed, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
|
|
2053
|
+
), r.push(c.id));
|
|
2050
2054
|
}
|
|
2051
|
-
return
|
|
2052
|
-
} catch (
|
|
2053
|
-
throw new Error(`failed to get pyth stale price feed id, msg: ${
|
|
2055
|
+
return r;
|
|
2056
|
+
} catch (r) {
|
|
2057
|
+
throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
|
|
2054
2058
|
}
|
|
2055
2059
|
}
|
|
2056
|
-
async function
|
|
2057
|
-
const r = [], o = t?.client ?? M, n = e.map((c) => c.priceInfoObject), a = await
|
|
2060
|
+
async function At(e, t) {
|
|
2061
|
+
const r = [], o = t?.client ?? M, n = e.map((c) => c.priceInfoObject), a = await ht(o, {
|
|
2058
2062
|
ids: Array.from(new Set(n)),
|
|
2059
2063
|
options: { showContent: !0 }
|
|
2060
2064
|
});
|
|
@@ -2074,11 +2078,11 @@ async function St(e, t) {
|
|
|
2074
2078
|
console.warn(`unexpected pyth price struct, priceInfoObject: ${i.objectId}`);
|
|
2075
2079
|
continue;
|
|
2076
2080
|
}
|
|
2077
|
-
const { magnitude:
|
|
2081
|
+
const { magnitude: w, negative: g } = m, y = u.conf, d = u.timestamp;
|
|
2078
2082
|
r.push({
|
|
2079
2083
|
priceFeedId: s.priceFeedId,
|
|
2080
2084
|
priceInfoObject: s.priceInfoObject,
|
|
2081
|
-
price: g ? "-" +
|
|
2085
|
+
price: g ? "-" + w : w,
|
|
2082
2086
|
conf: y,
|
|
2083
2087
|
publishTime: Number(d),
|
|
2084
2088
|
expiration: s.expiration
|
|
@@ -2086,9 +2090,9 @@ async function St(e, t) {
|
|
|
2086
2090
|
}
|
|
2087
2091
|
return r;
|
|
2088
2092
|
}
|
|
2089
|
-
async function
|
|
2093
|
+
async function $t(e, t) {
|
|
2090
2094
|
try {
|
|
2091
|
-
const r = [], o = await
|
|
2095
|
+
const r = [], o = await At(e, t);
|
|
2092
2096
|
if (!o) return r;
|
|
2093
2097
|
const n = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
2094
2098
|
for (const a of o) {
|
|
@@ -2108,14 +2112,16 @@ async function At(e, t) {
|
|
|
2108
2112
|
throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
|
|
2109
2113
|
}
|
|
2110
2114
|
}
|
|
2111
|
-
async function
|
|
2115
|
+
async function Et(e, t, r) {
|
|
2112
2116
|
const o = r?.client ?? M, n = await I({
|
|
2113
2117
|
...r,
|
|
2114
2118
|
cacheTime: v
|
|
2115
2119
|
});
|
|
2116
2120
|
try {
|
|
2117
|
-
const a = await
|
|
2118
|
-
|
|
2121
|
+
const a = await Oe(
|
|
2122
|
+
n.oracle.hermesEndpoint
|
|
2123
|
+
).getPriceFeedsUpdateData(t);
|
|
2124
|
+
return await new dt(
|
|
2119
2125
|
o,
|
|
2120
2126
|
n.oracle.pythStateId,
|
|
2121
2127
|
n.oracle.wormholeStateId
|
|
@@ -2124,7 +2130,7 @@ async function $t(e, t, r) {
|
|
|
2124
2130
|
throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
|
|
2125
2131
|
}
|
|
2126
2132
|
}
|
|
2127
|
-
async function
|
|
2133
|
+
async function he(e, t, r) {
|
|
2128
2134
|
const o = await I({
|
|
2129
2135
|
...r,
|
|
2130
2136
|
cacheTime: v
|
|
@@ -2134,12 +2140,12 @@ async function ge(e, t, r) {
|
|
|
2134
2140
|
priceFeedId: c.pythPriceFeedId,
|
|
2135
2141
|
priceInfoObject: c.pythPriceInfoObject,
|
|
2136
2142
|
expiration: 30
|
|
2137
|
-
})), a = await
|
|
2138
|
-
a.length > 0 && await
|
|
2143
|
+
})), a = await $t(n, r);
|
|
2144
|
+
a.length > 0 && await Et(e, a, r);
|
|
2139
2145
|
}
|
|
2140
2146
|
for (const n of t)
|
|
2141
2147
|
e.moveCall({
|
|
2142
|
-
target: `${o.oracle.packageId}::oracle_pro
|
|
2148
|
+
target: `${o.oracle.packageId}::oracle_pro::${o.oracle.updateFunction ?? "update_single_price_v2"}`,
|
|
2143
2149
|
arguments: [
|
|
2144
2150
|
e.object("0x6"),
|
|
2145
2151
|
// Clock object
|
|
@@ -2158,13 +2164,13 @@ async function ge(e, t, r) {
|
|
|
2158
2164
|
});
|
|
2159
2165
|
return e;
|
|
2160
2166
|
}
|
|
2161
|
-
async function
|
|
2167
|
+
async function Ve(e) {
|
|
2162
2168
|
return (await I({
|
|
2163
2169
|
...e,
|
|
2164
2170
|
cacheTime: v
|
|
2165
2171
|
})).oracle.feeds;
|
|
2166
2172
|
}
|
|
2167
|
-
function
|
|
2173
|
+
function Ot(e, t) {
|
|
2168
2174
|
return e.filter((r) => !!(t?.lendingState && t.lendingState.find((n) => r.oracleId === n.pool.oracleId) || t?.lendingPositions && t.lendingPositions.find((n) => {
|
|
2169
2175
|
if (![
|
|
2170
2176
|
"navi-lending-supply",
|
|
@@ -2177,23 +2183,23 @@ function Et(e, t) {
|
|
|
2177
2183
|
return r.oracleId === c?.oracleId;
|
|
2178
2184
|
}) || t?.pools && t.pools.find((n) => r.oracleId === n.oracleId)));
|
|
2179
2185
|
}
|
|
2180
|
-
async function
|
|
2186
|
+
async function gr(e, t, r, o) {
|
|
2181
2187
|
let n;
|
|
2182
2188
|
try {
|
|
2183
|
-
const a = await
|
|
2189
|
+
const a = await Ve({
|
|
2184
2190
|
...o
|
|
2185
2191
|
}), c = [];
|
|
2186
2192
|
r.forEach((u) => {
|
|
2187
2193
|
c.includes(u.market) || c.push(u.market);
|
|
2188
2194
|
});
|
|
2189
|
-
const i = await
|
|
2195
|
+
const i = await St(t, {
|
|
2190
2196
|
...o,
|
|
2191
2197
|
markets: c
|
|
2192
2198
|
});
|
|
2193
|
-
return n =
|
|
2199
|
+
return n = Ot(a, {
|
|
2194
2200
|
lendingPositions: i,
|
|
2195
2201
|
pools: r
|
|
2196
|
-
}), await
|
|
2202
|
+
}), await he(e, n, {
|
|
2197
2203
|
updatePythPriceFeeds: !0,
|
|
2198
2204
|
...o
|
|
2199
2205
|
});
|
|
@@ -2202,7 +2208,7 @@ async function yr(e, t, r, o) {
|
|
|
2202
2208
|
throw a;
|
|
2203
2209
|
if (console.error(a), n)
|
|
2204
2210
|
try {
|
|
2205
|
-
return await
|
|
2211
|
+
return await he(e, n, {
|
|
2206
2212
|
...o,
|
|
2207
2213
|
updatePythPriceFeeds: !1
|
|
2208
2214
|
});
|
|
@@ -2228,10 +2234,10 @@ const ae = O(
|
|
|
2228
2234
|
}
|
|
2229
2235
|
)
|
|
2230
2236
|
);
|
|
2231
|
-
async function
|
|
2237
|
+
async function hr(e, t) {
|
|
2232
2238
|
return (await ae(t)).find((o) => typeof e == "string" ? C(o.coinType) === C(e) : typeof e == "number" ? o.assetId === e : o.assetId === e.id) || null;
|
|
2233
2239
|
}
|
|
2234
|
-
async function
|
|
2240
|
+
async function wr(e, t, r, o) {
|
|
2235
2241
|
const n = await I({
|
|
2236
2242
|
...o,
|
|
2237
2243
|
cacheTime: v
|
|
@@ -2293,13 +2299,13 @@ async function br(e, t, r, o, n) {
|
|
|
2293
2299
|
});
|
|
2294
2300
|
return [u];
|
|
2295
2301
|
}
|
|
2296
|
-
async function
|
|
2302
|
+
async function vr(e, t, r, o, n, a) {
|
|
2297
2303
|
const c = {
|
|
2298
2304
|
...a,
|
|
2299
2305
|
cacheTime: v
|
|
2300
2306
|
}, i = await I(c), s = await E(t, c), u = await E(o, c);
|
|
2301
2307
|
if (i.version === 1) {
|
|
2302
|
-
const [m,
|
|
2308
|
+
const [m, w] = e.moveCall({
|
|
2303
2309
|
target: `${i.package}::incentive_v3::liquidation`,
|
|
2304
2310
|
arguments: [
|
|
2305
2311
|
e.object("0x06"),
|
|
@@ -2327,9 +2333,9 @@ async function wr(e, t, r, o, n, a) {
|
|
|
2327
2333
|
],
|
|
2328
2334
|
typeArguments: [s.suiCoinType, u.suiCoinType]
|
|
2329
2335
|
});
|
|
2330
|
-
return [m,
|
|
2336
|
+
return [m, w];
|
|
2331
2337
|
} else {
|
|
2332
|
-
const [m,
|
|
2338
|
+
const [m, w] = e.moveCall({
|
|
2333
2339
|
target: `${i.package}::incentive_v3::liquidation_v2`,
|
|
2334
2340
|
arguments: [
|
|
2335
2341
|
e.object("0x06"),
|
|
@@ -2359,15 +2365,15 @@ async function wr(e, t, r, o, n, a) {
|
|
|
2359
2365
|
],
|
|
2360
2366
|
typeArguments: [s.suiCoinType, u.suiCoinType]
|
|
2361
2367
|
});
|
|
2362
|
-
return [m,
|
|
2368
|
+
return [m, w];
|
|
2363
2369
|
}
|
|
2364
2370
|
}
|
|
2365
|
-
async function
|
|
2371
|
+
async function Vt(e, t, r) {
|
|
2366
2372
|
const o = r?.client ?? M, n = await J({
|
|
2367
2373
|
...r,
|
|
2368
2374
|
markets: Object.values(L),
|
|
2369
2375
|
cacheTime: v
|
|
2370
|
-
}), a = await
|
|
2376
|
+
}), a = await Ve(r), c = [];
|
|
2371
2377
|
return await Promise.all(
|
|
2372
2378
|
t.map(async (i) => {
|
|
2373
2379
|
try {
|
|
@@ -2389,13 +2395,13 @@ async function Ot(e, t, r) {
|
|
|
2389
2395
|
// User address
|
|
2390
2396
|
]
|
|
2391
2397
|
});
|
|
2392
|
-
const
|
|
2398
|
+
const w = (await W(o, {
|
|
2393
2399
|
transactionBlock: u,
|
|
2394
2400
|
sender: e
|
|
2395
2401
|
}))?.results?.[0];
|
|
2396
|
-
if (!
|
|
2402
|
+
if (!w)
|
|
2397
2403
|
return;
|
|
2398
|
-
const g = Z({ results: [
|
|
2404
|
+
const g = Z({ results: [w] }, [
|
|
2399
2405
|
l.vector(l.string()),
|
|
2400
2406
|
// Asset coin types
|
|
2401
2407
|
l.vector(l.string()),
|
|
@@ -2412,11 +2418,11 @@ async function Ot(e, t, r) {
|
|
|
2412
2418
|
for (let d = 0; d < y; d++) {
|
|
2413
2419
|
const f = a.find(
|
|
2414
2420
|
(k) => C(k.coinType) === C(g[1][d])
|
|
2415
|
-
),
|
|
2421
|
+
), b = n.find(
|
|
2416
2422
|
(k) => C(k.coinType) === C(g[0][d]) && k.market === i.market
|
|
2417
2423
|
);
|
|
2418
|
-
!f || !
|
|
2419
|
-
assetId:
|
|
2424
|
+
!f || !b || c.push({
|
|
2425
|
+
assetId: b.id,
|
|
2420
2426
|
assetCoinType: C(g[0][d]),
|
|
2421
2427
|
rewardCoinType: C(g[1][d]),
|
|
2422
2428
|
option: Number(g[2][d]),
|
|
@@ -2438,8 +2444,8 @@ async function Ot(e, t, r) {
|
|
|
2438
2444
|
})
|
|
2439
2445
|
), c;
|
|
2440
2446
|
}
|
|
2441
|
-
async function
|
|
2442
|
-
const r = (t?.markets || [L.main]).map((a) => P(a)), o = await
|
|
2447
|
+
async function Cr(e, t) {
|
|
2448
|
+
const r = (t?.markets || [L.main]).map((a) => P(a)), o = await Ae(e, t), n = r.map((a) => ({
|
|
2443
2449
|
address: e,
|
|
2444
2450
|
owner: e,
|
|
2445
2451
|
market: a.key
|
|
@@ -2454,9 +2460,9 @@ async function vr(e, t) {
|
|
|
2454
2460
|
};
|
|
2455
2461
|
})
|
|
2456
2462
|
);
|
|
2457
|
-
return await
|
|
2463
|
+
return await Vt(e, n, t);
|
|
2458
2464
|
}
|
|
2459
|
-
function
|
|
2465
|
+
function kr(e) {
|
|
2460
2466
|
const t = /* @__PURE__ */ new Map();
|
|
2461
2467
|
e.forEach((o) => {
|
|
2462
2468
|
const n = o.assetId, a = o.option, c = `${n}-${a}-${o.rewardCoinType}-${o.market}`;
|
|
@@ -2485,7 +2491,7 @@ function Cr(e) {
|
|
|
2485
2491
|
}))
|
|
2486
2492
|
}));
|
|
2487
2493
|
}
|
|
2488
|
-
const
|
|
2494
|
+
const Ir = A(
|
|
2489
2495
|
async (e, t) => {
|
|
2490
2496
|
const r = U(t), o = F(
|
|
2491
2497
|
`/navi/user/total_claimed_reward?userAddress=${e}&sdk=${V.version}&market=${t?.market || z}`,
|
|
@@ -2495,7 +2501,7 @@ const kr = A(
|
|
|
2495
2501
|
headers: N(R, r)
|
|
2496
2502
|
}).then((a) => a.json())).data;
|
|
2497
2503
|
}
|
|
2498
|
-
),
|
|
2504
|
+
), jr = A(
|
|
2499
2505
|
async (e, t) => {
|
|
2500
2506
|
const r = U(t), o = F(
|
|
2501
2507
|
`/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${V.version}&market=${t?.market || z}`,
|
|
@@ -2508,14 +2514,14 @@ const kr = A(
|
|
|
2508
2514
|
});
|
|
2509
2515
|
}
|
|
2510
2516
|
);
|
|
2511
|
-
async function
|
|
2517
|
+
async function _r(e, t, r) {
|
|
2512
2518
|
const o = await J({
|
|
2513
2519
|
...r,
|
|
2514
2520
|
markets: Object.values(L),
|
|
2515
2521
|
cacheTime: v
|
|
2516
2522
|
}), n = /* @__PURE__ */ new Map();
|
|
2517
2523
|
for (const c of t) {
|
|
2518
|
-
const { rewardCoinType: i, ruleIds: s, market: u, owner: m, address:
|
|
2524
|
+
const { rewardCoinType: i, ruleIds: s, market: u, owner: m, address: w, emodeId: g } = c, y = `${i}___${w}__${u}`;
|
|
2519
2525
|
for (const d of s) {
|
|
2520
2526
|
n.has(y) || n.set(y, {
|
|
2521
2527
|
assetIds: [],
|
|
@@ -2523,7 +2529,7 @@ async function jr(e, t, r) {
|
|
|
2523
2529
|
amount: 0,
|
|
2524
2530
|
market: u,
|
|
2525
2531
|
owner: m,
|
|
2526
|
-
address:
|
|
2532
|
+
address: w,
|
|
2527
2533
|
isEMode: typeof g < "u"
|
|
2528
2534
|
});
|
|
2529
2535
|
const f = n.get(y);
|
|
@@ -2533,17 +2539,17 @@ async function jr(e, t, r) {
|
|
|
2533
2539
|
const a = [];
|
|
2534
2540
|
for (const [
|
|
2535
2541
|
c,
|
|
2536
|
-
{ assetIds: i, ruleIds: s, amount: u, market: m, owner:
|
|
2542
|
+
{ assetIds: i, ruleIds: s, amount: u, market: m, owner: w, address: g, isEMode: y }
|
|
2537
2543
|
] of n) {
|
|
2538
2544
|
const d = await I({
|
|
2539
2545
|
...r,
|
|
2540
2546
|
cacheTime: v,
|
|
2541
2547
|
market: m
|
|
2542
|
-
}), f = c.split("___")[0],
|
|
2548
|
+
}), f = c.split("___")[0], b = o.filter(
|
|
2543
2549
|
(j) => C(j.suiCoinType) === C(f)
|
|
2544
2550
|
);
|
|
2545
|
-
|
|
2546
|
-
const k =
|
|
2551
|
+
b.sort((j, T) => j.market === m ? -1 : 1);
|
|
2552
|
+
const k = b[0], _ = d.rewardFunds[C(f)];
|
|
2547
2553
|
if (!_)
|
|
2548
2554
|
throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
|
|
2549
2555
|
if (r?.accountCap && !r.customCoinReceive)
|
|
@@ -2624,7 +2630,7 @@ async function jr(e, t, r) {
|
|
|
2624
2630
|
$.plus(u).isGreaterThan(D) && r?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
|
|
2625
2631
|
[T],
|
|
2626
2632
|
e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
2627
|
-
) : await
|
|
2633
|
+
) : await Ct(e, k, T, {
|
|
2628
2634
|
...r,
|
|
2629
2635
|
market: k.market
|
|
2630
2636
|
});
|
|
@@ -2632,7 +2638,7 @@ async function jr(e, t, r) {
|
|
|
2632
2638
|
a.push({
|
|
2633
2639
|
coin: T,
|
|
2634
2640
|
identifier: k,
|
|
2635
|
-
owner:
|
|
2641
|
+
owner: w,
|
|
2636
2642
|
isEMode: y
|
|
2637
2643
|
});
|
|
2638
2644
|
} else if (r?.accountCap || y) {
|
|
@@ -2662,7 +2668,7 @@ async function jr(e, t, r) {
|
|
|
2662
2668
|
});
|
|
2663
2669
|
e.transferObjects(
|
|
2664
2670
|
[T],
|
|
2665
|
-
h(r?.accountCap ||
|
|
2671
|
+
h(r?.accountCap || w, e.pure.address)
|
|
2666
2672
|
);
|
|
2667
2673
|
} else
|
|
2668
2674
|
e.moveCall({
|
|
@@ -2690,84 +2696,84 @@ export {
|
|
|
2690
2696
|
ie as Address,
|
|
2691
2697
|
v as DEFAULT_CACHE_TIME,
|
|
2692
2698
|
z as DEFAULT_MARKET_IDENTITY,
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2699
|
+
Ht as FlashLoanAssetConfig,
|
|
2700
|
+
zt as IncentiveAPYInfo,
|
|
2701
|
+
qe as IncentivePoolInfo,
|
|
2702
|
+
Gt as IncentivePoolInfoByPhase,
|
|
2697
2703
|
L as MARKETS,
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2704
|
+
kt as Market,
|
|
2705
|
+
Qe as NaviMissingGraphQLClientError,
|
|
2706
|
+
Wt as OracleInfo,
|
|
2707
|
+
tt as PUBLIC_MAINNET_GRPC_URL,
|
|
2702
2708
|
H as PoolOperator,
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2709
|
+
ze as ReserveDataInfo,
|
|
2710
|
+
je as SuiPriceServiceConnection,
|
|
2711
|
+
dt as SuiPythClient,
|
|
2706
2712
|
G as UserPositions,
|
|
2707
|
-
|
|
2708
|
-
|
|
2713
|
+
Ge as UserStateInfo,
|
|
2714
|
+
tr as borrowCoinPTB,
|
|
2709
2715
|
F as buildNaviOpenApiUrl,
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2716
|
+
_r as claimLendingRewardsPTB,
|
|
2717
|
+
Zt as configureNaviSdk,
|
|
2718
|
+
jt as createAccountCapPTB,
|
|
2719
|
+
ir as createEModeCapPTB,
|
|
2720
|
+
Ie as createNaviLegacyJsonRpcClient,
|
|
2721
|
+
nt as createNaviSuiClient,
|
|
2722
|
+
et as createNaviSuiClientBundle,
|
|
2723
|
+
Ct as depositCoinPTB,
|
|
2724
|
+
cr as emodeIdentityId,
|
|
2725
|
+
Tt as enterEModePTB,
|
|
2726
|
+
ar as exitEModePTB,
|
|
2727
|
+
Ot as filterPriceFeeds,
|
|
2728
|
+
wr as flashloanPTB,
|
|
2729
|
+
_t as getAccountCapOwnerPTB,
|
|
2730
|
+
Kt as getAddressBalance,
|
|
2725
2731
|
ae as getAllFlashLoanAssets,
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2732
|
+
nr as getBorrowFee,
|
|
2733
|
+
Jt as getCoinObjectOnlyBalance,
|
|
2734
|
+
mr as getCoins,
|
|
2729
2735
|
I as getConfig,
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2736
|
+
xt as getFees,
|
|
2737
|
+
hr as getFlashLoanAsset,
|
|
2738
|
+
lr as getHealthFactor,
|
|
2739
|
+
Pt as getHealthFactorPTB,
|
|
2740
|
+
St as getLendingPositions,
|
|
2741
|
+
ur as getLendingState,
|
|
2742
|
+
or as getMarket,
|
|
2737
2743
|
P as getMarketConfig,
|
|
2738
|
-
|
|
2744
|
+
It as getMarkets,
|
|
2739
2745
|
E as getPool,
|
|
2740
2746
|
J as getPools,
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2747
|
+
Ve as getPriceFeeds,
|
|
2748
|
+
yr as getPythStalePriceFeedId,
|
|
2749
|
+
$t as getPythStalePriceFeedIdV2,
|
|
2750
|
+
dr as getSimulatedHealthFactor,
|
|
2751
|
+
$e as getSimulatedHealthFactorPTB,
|
|
2752
|
+
Xt as getStats,
|
|
2753
|
+
pr as getTransactions,
|
|
2754
|
+
Cr as getUserAvailableLendingRewards,
|
|
2755
|
+
jr as getUserClaimedRewardHistory,
|
|
2756
|
+
Ae as getUserEModeCaps,
|
|
2757
|
+
Ir as getUserTotalClaimedReward,
|
|
2758
|
+
vr as liquidatePTB,
|
|
2759
|
+
Qt as listAddressBalances,
|
|
2760
|
+
sr as mergeCoinsPTB,
|
|
2755
2761
|
N as mergeServiceHeaders,
|
|
2756
|
-
|
|
2762
|
+
ke as normalizeAddressBalance,
|
|
2757
2763
|
C as normalizeCoinType,
|
|
2758
|
-
|
|
2764
|
+
vt as parsePoolUID,
|
|
2759
2765
|
h as parseTxValue,
|
|
2760
|
-
|
|
2766
|
+
rr as repayCoinPTB,
|
|
2761
2767
|
br as repayFlashLoanPTB,
|
|
2762
|
-
|
|
2768
|
+
Yt as requireNaviGraphQLClient,
|
|
2763
2769
|
U as resolveNaviOpenApiEndpoint,
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2770
|
+
kr as summaryLendingRewards,
|
|
2771
|
+
gr as updateOraclePriceBeforeUserOperationPTB,
|
|
2772
|
+
he as updateOraclePricesPTB,
|
|
2773
|
+
Et as updatePythPriceFeeds,
|
|
2774
|
+
fr as verifyHealthFactorPTB,
|
|
2769
2775
|
O as withCache,
|
|
2770
2776
|
A as withSingleton,
|
|
2771
|
-
|
|
2777
|
+
er as withdrawCoinPTB
|
|
2772
2778
|
};
|
|
2773
2779
|
//# sourceMappingURL=index.esm.js.map
|