@naviprotocol/lending 2.0.5-beta.0 → 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 +367 -331
- package/dist/index.esm.js.map +1 -1
- package/dist/market.d.ts +54 -0
- package/dist/market.d.ts.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 Me, fromHex 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) =>
|
|
11
|
+
input: (e) => De(e),
|
|
12
12
|
output: (e) => Me(e)
|
|
13
|
-
}),
|
|
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,77 +174,77 @@ function Ce(e, t = be) {
|
|
|
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
|
-
const r = new
|
|
195
|
+
const r = new be({
|
|
196
196
|
baseUrl: t.url,
|
|
197
197
|
meta: t.headers,
|
|
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
|
|
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,23 +555,23 @@ 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
|
-
function
|
|
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
|
}
|
|
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
|
-
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
|
|
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) => {
|
|
@@ -685,10 +685,10 @@ 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
|
-
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 S(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,16 +732,16 @@ 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
|
-
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 vt(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
|
)}`,
|
|
@@ -796,9 +796,9 @@ const J = O(
|
|
|
796
796
|
);
|
|
797
797
|
return n.data.forEach((a) => {
|
|
798
798
|
const i = n.meta.emodes.filter((b) => {
|
|
799
|
-
const
|
|
800
|
-
return a.market ===
|
|
801
|
-
}).filter((b) => !!b.assets.find((
|
|
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
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),
|
|
@@ -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,24 +827,24 @@ 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
|
|
831
|
-
|
|
832
|
-
const t =
|
|
830
|
+
const Xt = O(
|
|
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
|
-
),
|
|
838
|
-
|
|
837
|
+
), xt = O(
|
|
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());
|
|
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,12 +1114,12 @@ async function tr(e, t, r, o) {
|
|
|
1114
1114
|
typeArguments: [a.suiCoinType]
|
|
1115
1115
|
}), e;
|
|
1116
1116
|
}
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1117
|
+
const nr = O(
|
|
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();
|
|
@@ -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;
|
|
@@ -1171,9 +1171,39 @@ 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
|
-
class
|
|
1206
|
+
class kt {
|
|
1177
1207
|
constructor(t, r) {
|
|
1178
1208
|
this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
|
|
1179
1209
|
marketTotalSupplyValue: "0",
|
|
@@ -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
|
+
}, It = O(
|
|
1275
|
+
A(
|
|
1246
1276
|
async (e, t) => {
|
|
1247
1277
|
const r = await J({
|
|
1248
1278
|
cacheTime: 6e4,
|
|
@@ -1251,18 +1281,18 @@ const P = (e) => {
|
|
|
1251
1281
|
});
|
|
1252
1282
|
return e.map((o) => {
|
|
1253
1283
|
const n = P(o), a = r.filter((c) => c.market === n.key);
|
|
1254
|
-
return new
|
|
1284
|
+
return new kt(o, a);
|
|
1255
1285
|
});
|
|
1256
1286
|
}
|
|
1257
1287
|
)
|
|
1258
|
-
),
|
|
1259
|
-
|
|
1260
|
-
async (e, t) => (await
|
|
1288
|
+
), or = O(
|
|
1289
|
+
A(
|
|
1290
|
+
async (e, t) => (await It([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
|
);
|
|
@@ -1272,7 +1302,7 @@ const P = (e) => {
|
|
|
1272
1302
|
}
|
|
1273
1303
|
)
|
|
1274
1304
|
), v = 1e3 * 60 * 5;
|
|
1275
|
-
async function
|
|
1305
|
+
async function jt(e, t) {
|
|
1276
1306
|
const r = await I({
|
|
1277
1307
|
cacheTime: v,
|
|
1278
1308
|
...t
|
|
@@ -1282,7 +1312,7 @@ async function It(e, t) {
|
|
|
1282
1312
|
arguments: []
|
|
1283
1313
|
});
|
|
1284
1314
|
}
|
|
1285
|
-
async function
|
|
1315
|
+
async function _t(e, t, r) {
|
|
1286
1316
|
const o = await I({
|
|
1287
1317
|
cacheTime: v,
|
|
1288
1318
|
...r
|
|
@@ -1292,7 +1322,7 @@ async function kt(e, t, r) {
|
|
|
1292
1322
|
arguments: [t]
|
|
1293
1323
|
});
|
|
1294
1324
|
}
|
|
1295
|
-
async function
|
|
1325
|
+
async function Tt(e, t, r) {
|
|
1296
1326
|
const o = await I({
|
|
1297
1327
|
...r,
|
|
1298
1328
|
cacheTime: v
|
|
@@ -1309,7 +1339,7 @@ async function _t(e, t, r) {
|
|
|
1309
1339
|
arguments: [e.object(o.storage), h(t, e.pure.u64)]
|
|
1310
1340
|
}), e;
|
|
1311
1341
|
}
|
|
1312
|
-
async function
|
|
1342
|
+
async function ar(e, t) {
|
|
1313
1343
|
const r = await I({
|
|
1314
1344
|
...t,
|
|
1315
1345
|
cacheTime: v
|
|
@@ -1322,16 +1352,16 @@ async function or(e, t) {
|
|
|
1322
1352
|
arguments: [e.object(r.storage)]
|
|
1323
1353
|
}), e;
|
|
1324
1354
|
}
|
|
1325
|
-
async function
|
|
1355
|
+
async function ir(e, t, r) {
|
|
1326
1356
|
const o = await I({
|
|
1327
1357
|
cacheTime: v,
|
|
1328
1358
|
...r
|
|
1329
|
-
}), n = await
|
|
1330
|
-
await
|
|
1359
|
+
}), n = await jt(e, r);
|
|
1360
|
+
await Tt(e, t, {
|
|
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 _t(e, n, r);
|
|
1335
1365
|
return e.moveCall({
|
|
1336
1366
|
target: `${o.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
|
|
1337
1367
|
arguments: [
|
|
@@ -1343,12 +1373,12 @@ async function ar(e, t, r) {
|
|
|
1343
1373
|
}), n;
|
|
1344
1374
|
}
|
|
1345
1375
|
const Ae = O(
|
|
1346
|
-
|
|
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)]
|
|
@@ -1365,21 +1395,21 @@ const Ae = O(
|
|
|
1365
1395
|
}
|
|
1366
1396
|
)
|
|
1367
1397
|
);
|
|
1368
|
-
function
|
|
1398
|
+
function cr(e) {
|
|
1369
1399
|
return `${P(e.marketId).key}-${e.emodeId}`;
|
|
1370
1400
|
}
|
|
1371
|
-
function
|
|
1401
|
+
function Bt(e, t) {
|
|
1372
1402
|
return e.coinType ? e.coinType : t || (typeof e.type == "string" ? e.type.match(/::coin::Coin<(.+)>$/) : null)?.[1];
|
|
1373
1403
|
}
|
|
1374
1404
|
function ye(e, t) {
|
|
1375
|
-
const r =
|
|
1405
|
+
const r = Bt(e, t), o = e.coinObjectId ?? e.objectId;
|
|
1376
1406
|
return !r || !o || e.balance === void 0 || e.balance === null ? null : {
|
|
1377
1407
|
...e,
|
|
1378
1408
|
coinType: C(r),
|
|
1379
1409
|
coinObjectId: o
|
|
1380
1410
|
};
|
|
1381
1411
|
}
|
|
1382
|
-
function
|
|
1412
|
+
function sr(e, t, r) {
|
|
1383
1413
|
const o = typeof r?.balance == "number", n = o ? r.balance : 0, a = BigInt(r?.addressBalance ?? 0);
|
|
1384
1414
|
let c = 0;
|
|
1385
1415
|
const i = [];
|
|
@@ -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, b = f ? a : 0n,
|
|
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, b = f ? a : 0n, k = u + b, _ = !o || u >= d ? 0n : d - u, j = f && _ > 0n && b >= _;
|
|
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 $e(e, t, r, o, n, a, c) {
|
|
1428
1458
|
const i = await I({
|
|
1429
1459
|
...c,
|
|
1430
1460
|
cacheTime: v
|
|
@@ -1435,7 +1465,7 @@ async function Se(e, t, r, o, n, a, c) {
|
|
|
1435
1465
|
e.object("0x06"),
|
|
1436
1466
|
e.object(i.storage),
|
|
1437
1467
|
e.object(i.oracle.priceOracle),
|
|
1438
|
-
|
|
1468
|
+
wt(e, s),
|
|
1439
1469
|
h(t, e.pure.address),
|
|
1440
1470
|
h(s.id, e.pure.u8),
|
|
1441
1471
|
h(o, e.pure.u64),
|
|
@@ -1445,11 +1475,11 @@ async function Se(e, t, r, o, n, a, c) {
|
|
|
1445
1475
|
typeArguments: [s.suiCoinType]
|
|
1446
1476
|
});
|
|
1447
1477
|
}
|
|
1448
|
-
async function
|
|
1449
|
-
return
|
|
1478
|
+
async function Pt(e, t, r) {
|
|
1479
|
+
return $e(e, t, 0, 0, 0, !1, r);
|
|
1450
1480
|
}
|
|
1451
|
-
async function
|
|
1452
|
-
const o = new q(), n = r?.client ??
|
|
1481
|
+
async function Ee(e, t, r) {
|
|
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));
|
|
@@ -1481,13 +1511,13 @@ async function $e(e, t, r) {
|
|
|
1481
1511
|
})).results || [], w = {};
|
|
1482
1512
|
s.forEach((d, f) => {
|
|
1483
1513
|
try {
|
|
1484
|
-
const b = m[f]?.returnValues?.map((_) => l.vector(
|
|
1514
|
+
const b = m[f]?.returnValues?.map((_) => l.vector(ze).parse(Uint8Array.from(_[0])))[0] || [], k = {};
|
|
1485
1515
|
for (const _ of b)
|
|
1486
|
-
|
|
1516
|
+
k[_.id] = {
|
|
1487
1517
|
supplyIndex: _.supply_index,
|
|
1488
1518
|
borrowIndex: _.borrow_index
|
|
1489
1519
|
};
|
|
1490
|
-
w[d.key] =
|
|
1520
|
+
w[d.key] = k;
|
|
1491
1521
|
} catch (b) {
|
|
1492
1522
|
console.warn(
|
|
1493
1523
|
`[@naviprotocol/lending] Failed to decode reserve data for market "${d.key}", falling back to open-api pool indices`,
|
|
@@ -1495,47 +1525,47 @@ async function $e(e, t, r) {
|
|
|
1495
1525
|
);
|
|
1496
1526
|
}
|
|
1497
1527
|
});
|
|
1498
|
-
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 = [];
|
|
1499
1529
|
return g.forEach((d, f) => {
|
|
1500
|
-
const b = t[f],
|
|
1501
|
-
d.forEach((
|
|
1502
|
-
if (
|
|
1530
|
+
const b = t[f], k = P(b.market), _ = w[k.key] || {};
|
|
1531
|
+
d.forEach((j) => {
|
|
1532
|
+
if (j.supply_balance === "0" && j.borrow_balance === "0" && (b.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(), Ue = me(j.borrow_balance, B).toString();
|
|
1508
1538
|
y.push({
|
|
1509
1539
|
supplyBalance: X,
|
|
1510
|
-
borrowBalance:
|
|
1511
|
-
assetId:
|
|
1512
|
-
market:
|
|
1540
|
+
borrowBalance: Ue,
|
|
1541
|
+
assetId: j.asset_id,
|
|
1542
|
+
market: k.key,
|
|
1513
1543
|
pool: T,
|
|
1514
1544
|
emodeId: b.emodeId
|
|
1515
1545
|
});
|
|
1516
1546
|
});
|
|
1517
1547
|
}), y;
|
|
1518
1548
|
}
|
|
1519
|
-
const
|
|
1549
|
+
const ur = O(
|
|
1520
1550
|
async (e, t) => {
|
|
1521
1551
|
const o = (t?.markets || Object.keys(L)).map((n) => P(n)).map((n) => ({
|
|
1522
1552
|
address: e,
|
|
1523
1553
|
market: n.key
|
|
1524
1554
|
}));
|
|
1525
|
-
return await
|
|
1555
|
+
return await Ee(e, o, t);
|
|
1526
1556
|
}
|
|
1527
1557
|
);
|
|
1528
|
-
async function
|
|
1529
|
-
const r = t?.client ??
|
|
1530
|
-
await
|
|
1558
|
+
async function lr(e, t) {
|
|
1559
|
+
const r = t?.client ?? M, o = new q();
|
|
1560
|
+
await Pt(o, e, t);
|
|
1531
1561
|
const n = await W(r, {
|
|
1532
1562
|
transactionBlock: o,
|
|
1533
1563
|
sender: e
|
|
1534
1564
|
}), a = Z(n, [l.u256()]);
|
|
1535
|
-
return
|
|
1565
|
+
return Se(Number(a[0]) || 0);
|
|
1536
1566
|
}
|
|
1537
|
-
async function
|
|
1538
|
-
const n = o?.client ??
|
|
1567
|
+
async function dr(e, t, r, o) {
|
|
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 $e(
|
|
1547
1577
|
a,
|
|
1548
1578
|
e,
|
|
1549
1579
|
s,
|
|
@@ -1556,13 +1586,13 @@ async function lr(e, t, r, o) {
|
|
|
1556
1586
|
transactionBlock: a,
|
|
1557
1587
|
sender: e
|
|
1558
1588
|
}), w = Z(m, [l.u256()]);
|
|
1559
|
-
return
|
|
1589
|
+
return Se(Number(w[0]) || 0);
|
|
1560
1590
|
}
|
|
1561
|
-
const
|
|
1591
|
+
const pr = 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
|
);
|
|
@@ -1571,9 +1601,9 @@ const dr = S(
|
|
|
1571
1601
|
}).then((c) => c.json())).data;
|
|
1572
1602
|
}
|
|
1573
1603
|
);
|
|
1574
|
-
async function
|
|
1604
|
+
async function mr(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)
|
|
@@ -1644,7 +1674,7 @@ async function pr(e, t) {
|
|
|
1644
1674
|
} while (r);
|
|
1645
1675
|
return o;
|
|
1646
1676
|
}
|
|
1647
|
-
const
|
|
1677
|
+
const St = O(
|
|
1648
1678
|
async (e, t) => {
|
|
1649
1679
|
const r = [], o = (t?.markets || Object.keys(L)).map((i) => P(i)), n = await Ae(e, t), a = o.map((i) => ({
|
|
1650
1680
|
address: e,
|
|
@@ -1656,7 +1686,7 @@ const Pt = O(
|
|
|
1656
1686
|
emodeId: i.emodeId
|
|
1657
1687
|
}))
|
|
1658
1688
|
);
|
|
1659
|
-
return (await
|
|
1689
|
+
return (await Ee(e, a, t)).forEach((i) => {
|
|
1660
1690
|
const s = typeof i.emodeId == "number" ? n.find((u) => {
|
|
1661
1691
|
const m = P(i.market);
|
|
1662
1692
|
return u.emodeId === i.emodeId && u.marketId === m.id;
|
|
@@ -1669,7 +1699,7 @@ const Pt = O(
|
|
|
1669
1699
|
if (m.gt(0) || w.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,
|
|
@@ -1691,7 +1721,7 @@ const Pt = O(
|
|
|
1691
1721
|
if (m.gt(0) || w.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: "",
|
|
@@ -1982,7 +2012,7 @@ class G {
|
|
|
1982
2012
|
};
|
|
1983
2013
|
}
|
|
1984
2014
|
}
|
|
1985
|
-
async function
|
|
2015
|
+
async function fr(e, t, r, o) {
|
|
1986
2016
|
const n = await I({
|
|
1987
2017
|
...o,
|
|
1988
2018
|
cacheTime: v
|
|
@@ -1998,33 +2028,37 @@ async function mr(e, t, r, o) {
|
|
|
1998
2028
|
]
|
|
1999
2029
|
});
|
|
2000
2030
|
}
|
|
2001
|
-
const
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
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) {
|
|
2005
2037
|
try {
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
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) {
|
|
2012
2046
|
console.warn(
|
|
2013
|
-
`pyth price feed is invalid, id: ${
|
|
2047
|
+
`pyth price feed is invalid, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
|
|
2014
2048
|
);
|
|
2015
2049
|
continue;
|
|
2016
2050
|
}
|
|
2017
|
-
|
|
2018
|
-
`stale price feed, id: ${
|
|
2019
|
-
),
|
|
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));
|
|
2020
2054
|
}
|
|
2021
|
-
return
|
|
2022
|
-
} catch (
|
|
2023
|
-
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}`);
|
|
2024
2058
|
}
|
|
2025
2059
|
}
|
|
2026
2060
|
async function At(e, t) {
|
|
2027
|
-
const r = [], o = t?.client ??
|
|
2061
|
+
const r = [], o = t?.client ?? M, n = e.map((c) => c.priceInfoObject), a = await ht(o, {
|
|
2028
2062
|
ids: Array.from(new Set(n)),
|
|
2029
2063
|
options: { showContent: !0 }
|
|
2030
2064
|
});
|
|
@@ -2056,7 +2090,7 @@ async function At(e, t) {
|
|
|
2056
2090
|
}
|
|
2057
2091
|
return r;
|
|
2058
2092
|
}
|
|
2059
|
-
async function
|
|
2093
|
+
async function $t(e, t) {
|
|
2060
2094
|
try {
|
|
2061
2095
|
const r = [], o = await At(e, t);
|
|
2062
2096
|
if (!o) return r;
|
|
@@ -2078,14 +2112,16 @@ async function St(e, t) {
|
|
|
2078
2112
|
throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
|
|
2079
2113
|
}
|
|
2080
2114
|
}
|
|
2081
|
-
async function
|
|
2082
|
-
const o = r?.client ??
|
|
2115
|
+
async function Et(e, t, r) {
|
|
2116
|
+
const o = r?.client ?? M, n = await I({
|
|
2083
2117
|
...r,
|
|
2084
2118
|
cacheTime: v
|
|
2085
2119
|
});
|
|
2086
2120
|
try {
|
|
2087
|
-
const a = await
|
|
2088
|
-
|
|
2121
|
+
const a = await Oe(
|
|
2122
|
+
n.oracle.hermesEndpoint
|
|
2123
|
+
).getPriceFeedsUpdateData(t);
|
|
2124
|
+
return await new dt(
|
|
2089
2125
|
o,
|
|
2090
2126
|
n.oracle.pythStateId,
|
|
2091
2127
|
n.oracle.wormholeStateId
|
|
@@ -2094,7 +2130,7 @@ async function $t(e, t, r) {
|
|
|
2094
2130
|
throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
|
|
2095
2131
|
}
|
|
2096
2132
|
}
|
|
2097
|
-
async function
|
|
2133
|
+
async function he(e, t, r) {
|
|
2098
2134
|
const o = await I({
|
|
2099
2135
|
...r,
|
|
2100
2136
|
cacheTime: v
|
|
@@ -2104,12 +2140,12 @@ async function ge(e, t, r) {
|
|
|
2104
2140
|
priceFeedId: c.pythPriceFeedId,
|
|
2105
2141
|
priceInfoObject: c.pythPriceInfoObject,
|
|
2106
2142
|
expiration: 30
|
|
2107
|
-
})), a = await
|
|
2108
|
-
a.length > 0 && await
|
|
2143
|
+
})), a = await $t(n, r);
|
|
2144
|
+
a.length > 0 && await Et(e, a, r);
|
|
2109
2145
|
}
|
|
2110
2146
|
for (const n of t)
|
|
2111
2147
|
e.moveCall({
|
|
2112
|
-
target: `${o.oracle.packageId}::oracle_pro
|
|
2148
|
+
target: `${o.oracle.packageId}::oracle_pro::${o.oracle.updateFunction ?? "update_single_price_v2"}`,
|
|
2113
2149
|
arguments: [
|
|
2114
2150
|
e.object("0x6"),
|
|
2115
2151
|
// Clock object
|
|
@@ -2128,13 +2164,13 @@ async function ge(e, t, r) {
|
|
|
2128
2164
|
});
|
|
2129
2165
|
return e;
|
|
2130
2166
|
}
|
|
2131
|
-
async function
|
|
2167
|
+
async function Ve(e) {
|
|
2132
2168
|
return (await I({
|
|
2133
2169
|
...e,
|
|
2134
2170
|
cacheTime: v
|
|
2135
2171
|
})).oracle.feeds;
|
|
2136
2172
|
}
|
|
2137
|
-
function
|
|
2173
|
+
function Ot(e, t) {
|
|
2138
2174
|
return e.filter((r) => !!(t?.lendingState && t.lendingState.find((n) => r.oracleId === n.pool.oracleId) || t?.lendingPositions && t.lendingPositions.find((n) => {
|
|
2139
2175
|
if (![
|
|
2140
2176
|
"navi-lending-supply",
|
|
@@ -2147,23 +2183,23 @@ function Et(e, t) {
|
|
|
2147
2183
|
return r.oracleId === c?.oracleId;
|
|
2148
2184
|
}) || t?.pools && t.pools.find((n) => r.oracleId === n.oracleId)));
|
|
2149
2185
|
}
|
|
2150
|
-
async function
|
|
2186
|
+
async function gr(e, t, r, o) {
|
|
2151
2187
|
let n;
|
|
2152
2188
|
try {
|
|
2153
|
-
const a = await
|
|
2189
|
+
const a = await Ve({
|
|
2154
2190
|
...o
|
|
2155
2191
|
}), c = [];
|
|
2156
2192
|
r.forEach((u) => {
|
|
2157
2193
|
c.includes(u.market) || c.push(u.market);
|
|
2158
2194
|
});
|
|
2159
|
-
const i = await
|
|
2195
|
+
const i = await St(t, {
|
|
2160
2196
|
...o,
|
|
2161
2197
|
markets: c
|
|
2162
2198
|
});
|
|
2163
|
-
return n =
|
|
2199
|
+
return n = Ot(a, {
|
|
2164
2200
|
lendingPositions: i,
|
|
2165
2201
|
pools: r
|
|
2166
|
-
}), await
|
|
2202
|
+
}), await he(e, n, {
|
|
2167
2203
|
updatePythPriceFeeds: !0,
|
|
2168
2204
|
...o
|
|
2169
2205
|
});
|
|
@@ -2172,7 +2208,7 @@ async function yr(e, t, r, o) {
|
|
|
2172
2208
|
throw a;
|
|
2173
2209
|
if (console.error(a), n)
|
|
2174
2210
|
try {
|
|
2175
|
-
return await
|
|
2211
|
+
return await he(e, n, {
|
|
2176
2212
|
...o,
|
|
2177
2213
|
updatePythPriceFeeds: !1
|
|
2178
2214
|
});
|
|
@@ -2183,9 +2219,9 @@ async function yr(e, t, r, o) {
|
|
|
2183
2219
|
}
|
|
2184
2220
|
}
|
|
2185
2221
|
const ae = O(
|
|
2186
|
-
|
|
2222
|
+
A(
|
|
2187
2223
|
async (e) => {
|
|
2188
|
-
const t =
|
|
2224
|
+
const t = U(e), r = F(
|
|
2189
2225
|
`/navi/flashloan?env=${e?.env || "prod"}&sdk=${V.version}&market=${e?.market || z}`,
|
|
2190
2226
|
e
|
|
2191
2227
|
), o = await fetch(r, {
|
|
@@ -2198,10 +2234,10 @@ const ae = O(
|
|
|
2198
2234
|
}
|
|
2199
2235
|
)
|
|
2200
2236
|
);
|
|
2201
|
-
async function
|
|
2237
|
+
async function hr(e, t) {
|
|
2202
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;
|
|
2203
2239
|
}
|
|
2204
|
-
async function
|
|
2240
|
+
async function wr(e, t, r, o) {
|
|
2205
2241
|
const n = await I({
|
|
2206
2242
|
...o,
|
|
2207
2243
|
cacheTime: v
|
|
@@ -2238,7 +2274,7 @@ async function hr(e, t, r, o) {
|
|
|
2238
2274
|
return [s, u];
|
|
2239
2275
|
}
|
|
2240
2276
|
}
|
|
2241
|
-
async function
|
|
2277
|
+
async function br(e, t, r, o, n) {
|
|
2242
2278
|
const a = await I({
|
|
2243
2279
|
...n,
|
|
2244
2280
|
cacheTime: v
|
|
@@ -2263,7 +2299,7 @@ async function wr(e, t, r, o, n) {
|
|
|
2263
2299
|
});
|
|
2264
2300
|
return [u];
|
|
2265
2301
|
}
|
|
2266
|
-
async function
|
|
2302
|
+
async function vr(e, t, r, o, n, a) {
|
|
2267
2303
|
const c = {
|
|
2268
2304
|
...a,
|
|
2269
2305
|
cacheTime: v
|
|
@@ -2332,12 +2368,12 @@ async function br(e, t, r, o, n, a) {
|
|
|
2332
2368
|
return [m, w];
|
|
2333
2369
|
}
|
|
2334
2370
|
}
|
|
2335
|
-
async function
|
|
2336
|
-
const o = r?.client ??
|
|
2371
|
+
async function Vt(e, t, r) {
|
|
2372
|
+
const o = r?.client ?? M, n = await J({
|
|
2337
2373
|
...r,
|
|
2338
2374
|
markets: Object.values(L),
|
|
2339
2375
|
cacheTime: v
|
|
2340
|
-
}), a = await
|
|
2376
|
+
}), a = await Ve(r), c = [];
|
|
2341
2377
|
return await Promise.all(
|
|
2342
2378
|
t.map(async (i) => {
|
|
2343
2379
|
try {
|
|
@@ -2381,9 +2417,9 @@ async function Ot(e, t, r) {
|
|
|
2381
2417
|
const y = g[0].length;
|
|
2382
2418
|
for (let d = 0; d < y; d++) {
|
|
2383
2419
|
const f = a.find(
|
|
2384
|
-
(
|
|
2420
|
+
(k) => C(k.coinType) === C(g[1][d])
|
|
2385
2421
|
), b = n.find(
|
|
2386
|
-
(
|
|
2422
|
+
(k) => C(k.coinType) === C(g[0][d]) && k.market === i.market
|
|
2387
2423
|
);
|
|
2388
2424
|
!f || !b || c.push({
|
|
2389
2425
|
assetId: b.id,
|
|
@@ -2408,7 +2444,7 @@ async function Ot(e, t, r) {
|
|
|
2408
2444
|
})
|
|
2409
2445
|
), c;
|
|
2410
2446
|
}
|
|
2411
|
-
async function
|
|
2447
|
+
async function Cr(e, t) {
|
|
2412
2448
|
const r = (t?.markets || [L.main]).map((a) => P(a)), o = await Ae(e, t), n = r.map((a) => ({
|
|
2413
2449
|
address: e,
|
|
2414
2450
|
owner: e,
|
|
@@ -2424,9 +2460,9 @@ async function vr(e, t) {
|
|
|
2424
2460
|
};
|
|
2425
2461
|
})
|
|
2426
2462
|
);
|
|
2427
|
-
return await
|
|
2463
|
+
return await Vt(e, n, t);
|
|
2428
2464
|
}
|
|
2429
|
-
function
|
|
2465
|
+
function kr(e) {
|
|
2430
2466
|
const t = /* @__PURE__ */ new Map();
|
|
2431
2467
|
e.forEach((o) => {
|
|
2432
2468
|
const n = o.assetId, a = o.option, c = `${n}-${a}-${o.rewardCoinType}-${o.market}`;
|
|
@@ -2455,9 +2491,9 @@ function Cr(e) {
|
|
|
2455
2491
|
}))
|
|
2456
2492
|
}));
|
|
2457
2493
|
}
|
|
2458
|
-
const
|
|
2494
|
+
const Ir = A(
|
|
2459
2495
|
async (e, t) => {
|
|
2460
|
-
const r =
|
|
2496
|
+
const r = U(t), o = F(
|
|
2461
2497
|
`/navi/user/total_claimed_reward?userAddress=${e}&sdk=${V.version}&market=${t?.market || z}`,
|
|
2462
2498
|
t
|
|
2463
2499
|
);
|
|
@@ -2465,9 +2501,9 @@ const jr = S(
|
|
|
2465
2501
|
headers: N(R, r)
|
|
2466
2502
|
}).then((a) => a.json())).data;
|
|
2467
2503
|
}
|
|
2468
|
-
),
|
|
2504
|
+
), jr = A(
|
|
2469
2505
|
async (e, t) => {
|
|
2470
|
-
const r =
|
|
2506
|
+
const r = U(t), o = F(
|
|
2471
2507
|
`/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${V.version}&market=${t?.market || z}`,
|
|
2472
2508
|
t
|
|
2473
2509
|
), n = await fetch(o, {
|
|
@@ -2478,7 +2514,7 @@ const jr = S(
|
|
|
2478
2514
|
});
|
|
2479
2515
|
}
|
|
2480
2516
|
);
|
|
2481
|
-
async function
|
|
2517
|
+
async function _r(e, t, r) {
|
|
2482
2518
|
const o = await J({
|
|
2483
2519
|
...r,
|
|
2484
2520
|
markets: Object.values(L),
|
|
@@ -2510,17 +2546,17 @@ async function kr(e, t, r) {
|
|
|
2510
2546
|
cacheTime: v,
|
|
2511
2547
|
market: m
|
|
2512
2548
|
}), f = c.split("___")[0], b = o.filter(
|
|
2513
|
-
(
|
|
2549
|
+
(j) => C(j.suiCoinType) === C(f)
|
|
2514
2550
|
);
|
|
2515
|
-
b.sort((
|
|
2516
|
-
const
|
|
2551
|
+
b.sort((j, T) => j.market === m ? -1 : 1);
|
|
2552
|
+
const k = b[0], _ = d.rewardFunds[C(f)];
|
|
2517
2553
|
if (!_)
|
|
2518
2554
|
throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
|
|
2519
2555
|
if (r?.accountCap && !r.customCoinReceive)
|
|
2520
2556
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
2521
2557
|
if (r?.customCoinReceive) {
|
|
2522
|
-
let
|
|
2523
|
-
r.accountCap ?
|
|
2558
|
+
let j;
|
|
2559
|
+
r.accountCap ? j = e.moveCall({
|
|
2524
2560
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2525
2561
|
arguments: [
|
|
2526
2562
|
e.object("0x06"),
|
|
@@ -2539,7 +2575,7 @@ async function kr(e, t, r) {
|
|
|
2539
2575
|
// Account capability
|
|
2540
2576
|
],
|
|
2541
2577
|
typeArguments: [f]
|
|
2542
|
-
}) : y ?
|
|
2578
|
+
}) : y ? j = e.moveCall({
|
|
2543
2579
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2544
2580
|
arguments: [
|
|
2545
2581
|
e.object("0x06"),
|
|
@@ -2558,7 +2594,7 @@ async function kr(e, t, r) {
|
|
|
2558
2594
|
// Account capability
|
|
2559
2595
|
],
|
|
2560
2596
|
typeArguments: [f]
|
|
2561
|
-
}) :
|
|
2597
|
+
}) : j = e.moveCall({
|
|
2562
2598
|
target: `${d.package}::incentive_v3::claim_reward`,
|
|
2563
2599
|
arguments: [
|
|
2564
2600
|
e.object("0x06"),
|
|
@@ -2578,7 +2614,7 @@ async function kr(e, t, r) {
|
|
|
2578
2614
|
});
|
|
2579
2615
|
const [T] = e.moveCall({
|
|
2580
2616
|
target: "0x2::coin::from_balance",
|
|
2581
|
-
arguments: [
|
|
2617
|
+
arguments: [j],
|
|
2582
2618
|
typeArguments: [f]
|
|
2583
2619
|
});
|
|
2584
2620
|
if (r?.customCoinReceive.type === "transfer") {
|
|
@@ -2590,23 +2626,23 @@ async function kr(e, t, r) {
|
|
|
2590
2626
|
);
|
|
2591
2627
|
}
|
|
2592
2628
|
if (r?.customCoinReceive.type === "depositNAVI") {
|
|
2593
|
-
const $ = p(
|
|
2629
|
+
const $ = p(k.totalSupplyAmount).shiftedBy(-9), D = p(k.supplyCapCeiling).shiftedBy(-27);
|
|
2594
2630
|
$.plus(u).isGreaterThan(D) && r?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
|
|
2595
2631
|
[T],
|
|
2596
2632
|
e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
2597
|
-
) : await
|
|
2633
|
+
) : await Ct(e, k, T, {
|
|
2598
2634
|
...r,
|
|
2599
|
-
market:
|
|
2635
|
+
market: k.market
|
|
2600
2636
|
});
|
|
2601
2637
|
} else
|
|
2602
2638
|
a.push({
|
|
2603
2639
|
coin: T,
|
|
2604
|
-
identifier:
|
|
2640
|
+
identifier: k,
|
|
2605
2641
|
owner: w,
|
|
2606
2642
|
isEMode: y
|
|
2607
2643
|
});
|
|
2608
2644
|
} else if (r?.accountCap || y) {
|
|
2609
|
-
const
|
|
2645
|
+
const j = e.moveCall({
|
|
2610
2646
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2611
2647
|
arguments: [
|
|
2612
2648
|
e.object("0x06"),
|
|
@@ -2627,7 +2663,7 @@ async function kr(e, t, r) {
|
|
|
2627
2663
|
typeArguments: [f]
|
|
2628
2664
|
}), [T] = e.moveCall({
|
|
2629
2665
|
target: "0x2::coin::from_balance",
|
|
2630
|
-
arguments: [
|
|
2666
|
+
arguments: [j],
|
|
2631
2667
|
typeArguments: [f]
|
|
2632
2668
|
});
|
|
2633
2669
|
e.transferObjects(
|
|
@@ -2660,84 +2696,84 @@ export {
|
|
|
2660
2696
|
ie as Address,
|
|
2661
2697
|
v as DEFAULT_CACHE_TIME,
|
|
2662
2698
|
z as DEFAULT_MARKET_IDENTITY,
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2699
|
+
Ht as FlashLoanAssetConfig,
|
|
2700
|
+
zt as IncentiveAPYInfo,
|
|
2701
|
+
qe as IncentivePoolInfo,
|
|
2702
|
+
Gt as IncentivePoolInfoByPhase,
|
|
2667
2703
|
L as MARKETS,
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2704
|
+
kt as Market,
|
|
2705
|
+
Qe as NaviMissingGraphQLClientError,
|
|
2706
|
+
Wt as OracleInfo,
|
|
2707
|
+
tt as PUBLIC_MAINNET_GRPC_URL,
|
|
2672
2708
|
H as PoolOperator,
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2709
|
+
ze as ReserveDataInfo,
|
|
2710
|
+
je as SuiPriceServiceConnection,
|
|
2711
|
+
dt as SuiPythClient,
|
|
2676
2712
|
G as UserPositions,
|
|
2677
|
-
|
|
2678
|
-
|
|
2713
|
+
Ge as UserStateInfo,
|
|
2714
|
+
tr as borrowCoinPTB,
|
|
2679
2715
|
F as buildNaviOpenApiUrl,
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
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,
|
|
2695
2731
|
ae as getAllFlashLoanAssets,
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2732
|
+
nr as getBorrowFee,
|
|
2733
|
+
Jt as getCoinObjectOnlyBalance,
|
|
2734
|
+
mr as getCoins,
|
|
2699
2735
|
I as getConfig,
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
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,
|
|
2707
2743
|
P as getMarketConfig,
|
|
2708
|
-
|
|
2744
|
+
It as getMarkets,
|
|
2709
2745
|
E as getPool,
|
|
2710
2746
|
J as getPools,
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
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,
|
|
2720
2756
|
Ae as getUserEModeCaps,
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2757
|
+
Ir as getUserTotalClaimedReward,
|
|
2758
|
+
vr as liquidatePTB,
|
|
2759
|
+
Qt as listAddressBalances,
|
|
2760
|
+
sr as mergeCoinsPTB,
|
|
2725
2761
|
N as mergeServiceHeaders,
|
|
2726
|
-
|
|
2762
|
+
ke as normalizeAddressBalance,
|
|
2727
2763
|
C as normalizeCoinType,
|
|
2728
|
-
|
|
2764
|
+
vt as parsePoolUID,
|
|
2729
2765
|
h as parseTxValue,
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2766
|
+
rr as repayCoinPTB,
|
|
2767
|
+
br as repayFlashLoanPTB,
|
|
2768
|
+
Yt as requireNaviGraphQLClient,
|
|
2769
|
+
U as resolveNaviOpenApiEndpoint,
|
|
2770
|
+
kr as summaryLendingRewards,
|
|
2771
|
+
gr as updateOraclePriceBeforeUserOperationPTB,
|
|
2772
|
+
he as updateOraclePricesPTB,
|
|
2773
|
+
Et as updatePythPriceFeeds,
|
|
2774
|
+
fr as verifyHealthFactorPTB,
|
|
2739
2775
|
O as withCache,
|
|
2740
|
-
|
|
2741
|
-
|
|
2776
|
+
A as withSingleton,
|
|
2777
|
+
er as withdrawCoinPTB
|
|
2742
2778
|
};
|
|
2743
2779
|
//# sourceMappingURL=index.esm.js.map
|