@naviprotocol/lending 2.0.2 → 2.0.4-beta.0
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 +323 -324
- 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/pyth.d.ts.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { Transaction as N } from "@mysten/sui/transactions";
|
|
2
2
|
import { bcs as l } from "@mysten/sui/bcs";
|
|
3
|
-
import { toHex as
|
|
4
|
-
import
|
|
3
|
+
import { toHex as Ue, fromHex as De, normalizeStructTag as K, SUI_CLOCK_OBJECT_ID as Z, 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 ge, GrpcWebFetchTransport as he } from "@mysten/sui/grpc";
|
|
9
9
|
const oe = 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) => Ue(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: oe,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
@@ -44,12 +44,12 @@ const oe = 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 oe = 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 oe = 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 oe = 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.4-beta.0", E = {
|
|
133
|
+
version: We
|
|
134
|
+
}, He = E.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
|
-
}, ae =
|
|
144
|
-
class
|
|
142
|
+
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${He} (${Je()})`), e;
|
|
143
|
+
}, ae = Ke(), we = "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 X(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 be(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 ve(e, t = we) {
|
|
167
167
|
const r = X(e.addressBalance ?? e.fundsInAddressBalance) ?? "0";
|
|
168
168
|
let o = X(e.balance ?? e.totalBalance), n = X(e.coinBalance);
|
|
169
|
-
return !n && o && (n =
|
|
169
|
+
return !n && o && (n = Ze(o, r)), !o && n && (o = Ye(n, r)), {
|
|
170
170
|
coinType: K(e.coinType ?? t),
|
|
171
171
|
totalBalance: o ?? "0",
|
|
172
172
|
coinBalance: n ?? "0",
|
|
@@ -174,77 +174,77 @@ function be(e, t = he) {
|
|
|
174
174
|
...e.coinObjectCount === null || e.coinObjectCount === void 0 ? {} : { coinObjectCount: e.coinObjectCount }
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function Jt(e, t = we) {
|
|
178
178
|
const r = K(t);
|
|
179
179
|
return e.filter((o) => K(o.coinType) === r).reduce((o, n) => o + BigInt(n.balance), 0n).toString();
|
|
180
180
|
}
|
|
181
|
-
async function Jt(e, t) {
|
|
182
|
-
const r = await we(e).getBalance(t), o = r.balance;
|
|
183
|
-
return be((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
|
|
184
|
-
}
|
|
185
181
|
async function Kt(e, t) {
|
|
186
|
-
const r = await
|
|
182
|
+
const r = await be(e).getBalance(t), o = r.balance;
|
|
183
|
+
return ve((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
|
|
184
|
+
}
|
|
185
|
+
async function Qt(e, t) {
|
|
186
|
+
const r = await be(e).listBalances(t), { balances: o = [] } = r;
|
|
187
187
|
return {
|
|
188
|
-
balances: o.map((n) =>
|
|
188
|
+
balances: o.map((n) => ve(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 he({
|
|
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 ge({
|
|
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 Ce(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 ? Ce(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 x;
|
|
238
|
-
function
|
|
239
|
-
return x || (x = new
|
|
238
|
+
function rt() {
|
|
239
|
+
return x || (x = new ge({
|
|
240
240
|
network: "mainnet",
|
|
241
|
-
transport: new
|
|
241
|
+
transport: new he({ baseUrl: tt })
|
|
242
242
|
})), x;
|
|
243
243
|
}
|
|
244
|
-
function
|
|
245
|
-
return e ? typeof e == "string" ?
|
|
244
|
+
function nt(e, t = "mainnet") {
|
|
245
|
+
return e ? typeof e == "string" ? Ce(t, { url: e }) : et(e) : rt();
|
|
246
246
|
}
|
|
247
|
-
const
|
|
247
|
+
const ot = 16 * 1024;
|
|
248
248
|
function re(e) {
|
|
249
249
|
return e.replace(/^0x/i, "");
|
|
250
250
|
}
|
|
@@ -254,12 +254,12 @@ function ie(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 ce(e) {
|
|
261
261
|
return l.vector(l.U8).serialize(Array.from(e), {
|
|
262
|
-
maxSize:
|
|
262
|
+
maxSize: ot
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
265
|
function se(e, t) {
|
|
@@ -268,17 +268,17 @@ function se(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 Ce {
|
|
|
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,13 +347,13 @@ class Ce {
|
|
|
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
|
}
|
|
354
354
|
getCoreProvider() {
|
|
355
355
|
const t = this.provider.core;
|
|
356
|
-
return t && typeof t.getObject == "function" && typeof t.getDynamicObjectField == "function" ? t : null;
|
|
356
|
+
return t && typeof t.getObject == "function" && typeof t.getDynamicObjectField == "function" && typeof t.getDynamicField == "function" ? t : null;
|
|
357
357
|
}
|
|
358
358
|
async getMoveObjectJson(t) {
|
|
359
359
|
const r = this.getCoreProvider();
|
|
@@ -500,22 +500,31 @@ class lt {
|
|
|
500
500
|
async getPriceFeedObjectId(t) {
|
|
501
501
|
const r = re(t);
|
|
502
502
|
if (!this.priceFeedObjectIdCache.has(r)) {
|
|
503
|
-
const { id: o, fieldType: n } = await this.getPriceTableInfo(), a = this.getCoreProvider()
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
value
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
503
|
+
const { id: o, fieldType: n } = await this.getPriceTableInfo(), a = `${n}::price_identifier::PriceIdentifier`, c = this.getCoreProvider();
|
|
504
|
+
if (c) {
|
|
505
|
+
const { dynamicField: i } = await c.getDynamicField({
|
|
506
|
+
parentId: o,
|
|
507
|
+
name: se(a, ct(ie(r)))
|
|
508
|
+
}), s = i?.value?.bcs;
|
|
509
|
+
this.priceFeedObjectIdCache.set(
|
|
510
|
+
r,
|
|
511
|
+
s && s.length === 32 ? l.Address.parse(Uint8Array.from(s)) : void 0
|
|
512
|
+
);
|
|
513
|
+
} else {
|
|
514
|
+
const i = await this.getDynamicMoveObjectJson(o, {
|
|
515
|
+
type: a,
|
|
516
|
+
value: {
|
|
517
|
+
bytes: Array.from(ie(r))
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
i?.fields ? this.priceFeedObjectIdCache.set(r, i.fields.value) : this.priceFeedObjectIdCache.set(r, void 0);
|
|
521
|
+
}
|
|
513
522
|
}
|
|
514
523
|
return this.priceFeedObjectIdCache.get(r);
|
|
515
524
|
}
|
|
516
525
|
async getPriceTableInfo() {
|
|
517
526
|
if (!this.priceTableInfo) {
|
|
518
|
-
const t = this.getCoreProvider() ? se("vector<u8>",
|
|
527
|
+
const t = this.getCoreProvider() ? se("vector<u8>", it("price_info")) : {
|
|
519
528
|
type: "vector<u8>",
|
|
520
529
|
value: "price_info"
|
|
521
530
|
}, r = await this.getDynamicMoveObjectJson(this.pythStateId, t);
|
|
@@ -523,22 +532,22 @@ class lt {
|
|
|
523
532
|
throw new Error("Price Table not found, contract may not be initialized");
|
|
524
533
|
this.priceTableInfo = {
|
|
525
534
|
id: r.objectId,
|
|
526
|
-
fieldType:
|
|
535
|
+
fieldType: ut(r.type)
|
|
527
536
|
};
|
|
528
537
|
}
|
|
529
538
|
return this.priceTableInfo;
|
|
530
539
|
}
|
|
531
540
|
extractVaaBytesFromAccumulatorMessage(t) {
|
|
532
|
-
const o = 7 + t[6] + 1, n =
|
|
541
|
+
const o = 7 + t[6] + 1, n = at(t, o), a = o + 2;
|
|
533
542
|
return t.subarray(a, a + n);
|
|
534
543
|
}
|
|
535
544
|
}
|
|
536
|
-
const
|
|
537
|
-
let J = {},
|
|
538
|
-
function
|
|
545
|
+
const pt = "https://open-api.naviprotocol.io/api";
|
|
546
|
+
let J = {}, ke = 0;
|
|
547
|
+
function mt(e) {
|
|
539
548
|
return e.replace(/\/+$/, "");
|
|
540
549
|
}
|
|
541
|
-
function
|
|
550
|
+
function Zt(e) {
|
|
542
551
|
J = {
|
|
543
552
|
...J,
|
|
544
553
|
...e,
|
|
@@ -546,23 +555,23 @@ function Yt(e) {
|
|
|
546
555
|
...J.services,
|
|
547
556
|
...e.services
|
|
548
557
|
}
|
|
549
|
-
},
|
|
558
|
+
}, ke += 1;
|
|
550
559
|
}
|
|
551
560
|
function ue() {
|
|
552
|
-
return
|
|
561
|
+
return ke;
|
|
553
562
|
}
|
|
554
|
-
function
|
|
563
|
+
function O(e) {
|
|
555
564
|
const t = e?.services?.naviOpenApi ?? J.services?.naviOpenApi;
|
|
556
565
|
return {
|
|
557
|
-
baseUrl:
|
|
566
|
+
baseUrl: mt(t?.baseUrl ?? pt),
|
|
558
567
|
headers: t?.headers
|
|
559
568
|
};
|
|
560
569
|
}
|
|
561
570
|
function M(e, t) {
|
|
562
|
-
const r =
|
|
571
|
+
const r = O(t), o = e.startsWith("/") ? e : `/${e}`;
|
|
563
572
|
return `${r.baseUrl}${o}`;
|
|
564
573
|
}
|
|
565
|
-
function
|
|
574
|
+
function ft(e) {
|
|
566
575
|
if (e instanceof Headers) {
|
|
567
576
|
const t = {};
|
|
568
577
|
return e.forEach((r, o) => {
|
|
@@ -573,15 +582,15 @@ function mt(e) {
|
|
|
573
582
|
}
|
|
574
583
|
function U(e, t) {
|
|
575
584
|
return {
|
|
576
|
-
...
|
|
585
|
+
...ft(e),
|
|
577
586
|
...t?.headers ?? {}
|
|
578
587
|
};
|
|
579
588
|
}
|
|
580
|
-
const V =
|
|
589
|
+
const V = nt();
|
|
581
590
|
function le(e) {
|
|
582
|
-
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)) : [];
|
|
583
592
|
}
|
|
584
|
-
function
|
|
593
|
+
function yt(e) {
|
|
585
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];
|
|
586
595
|
return o && console.warn("[lending] devInspect(core simulate) returned error:", o), {
|
|
587
596
|
effects: r.effects,
|
|
@@ -612,7 +621,7 @@ async function q(e, t) {
|
|
|
612
621
|
commandResults: !0
|
|
613
622
|
}
|
|
614
623
|
});
|
|
615
|
-
return
|
|
624
|
+
return yt(n);
|
|
616
625
|
}
|
|
617
626
|
function Ie(e) {
|
|
618
627
|
return {
|
|
@@ -622,7 +631,7 @@ function Ie(e) {
|
|
|
622
631
|
objectBcs: !!e?.showBcs
|
|
623
632
|
};
|
|
624
633
|
}
|
|
625
|
-
function
|
|
634
|
+
function _e(e) {
|
|
626
635
|
return !e || e instanceof Error ? {
|
|
627
636
|
error: e instanceof Error ? { code: "notFound", error: e.message } : void 0
|
|
628
637
|
} : {
|
|
@@ -642,7 +651,7 @@ function ke(e) {
|
|
|
642
651
|
}
|
|
643
652
|
};
|
|
644
653
|
}
|
|
645
|
-
async function
|
|
654
|
+
async function gt(e, t) {
|
|
646
655
|
const r = e?.core;
|
|
647
656
|
if (typeof r?.getObject != "function")
|
|
648
657
|
throw new Error("getSuiObject requires a Sui v2 Core-capable client");
|
|
@@ -650,9 +659,9 @@ async function yt(e, t) {
|
|
|
650
659
|
objectId: t.id,
|
|
651
660
|
include: Ie(t.options)
|
|
652
661
|
});
|
|
653
|
-
return
|
|
662
|
+
return _e(o);
|
|
654
663
|
}
|
|
655
|
-
async function
|
|
664
|
+
async function ht(e, t) {
|
|
656
665
|
const r = e?.core;
|
|
657
666
|
if (typeof r?.getObjects != "function")
|
|
658
667
|
throw new Error("multiGetSuiObjects requires a Sui v2 Core-capable client");
|
|
@@ -660,9 +669,9 @@ async function gt(e, t) {
|
|
|
660
669
|
objectIds: t.ids,
|
|
661
670
|
include: Ie(t.options)
|
|
662
671
|
});
|
|
663
|
-
return o.map(
|
|
672
|
+
return o.map(_e);
|
|
664
673
|
}
|
|
665
|
-
function
|
|
674
|
+
function Te(e) {
|
|
666
675
|
const t = [];
|
|
667
676
|
let r = !1;
|
|
668
677
|
return e.forEach((o, n) => {
|
|
@@ -679,7 +688,7 @@ function _e(e) {
|
|
|
679
688
|
function A(e) {
|
|
680
689
|
const t = {};
|
|
681
690
|
return (...r) => {
|
|
682
|
-
const o =
|
|
691
|
+
const o = Te(r);
|
|
683
692
|
return t[o] || (t[o] = e(...r).finally(() => {
|
|
684
693
|
delete t[o];
|
|
685
694
|
})), t[o];
|
|
@@ -688,7 +697,7 @@ function A(e) {
|
|
|
688
697
|
function $(e) {
|
|
689
698
|
let t = {};
|
|
690
699
|
return (...r) => {
|
|
691
|
-
const o = r[r.length - 1], n =
|
|
700
|
+
const o = r[r.length - 1], n = Te(r), a = t[n];
|
|
692
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] = {
|
|
693
702
|
data: c,
|
|
694
703
|
cacheAt: Date.now()
|
|
@@ -699,7 +708,7 @@ function ee(e) {
|
|
|
699
708
|
return Array.isArray(e) ? e.map((t) => ee(t)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
700
709
|
(t, r) => ({
|
|
701
710
|
...t,
|
|
702
|
-
[
|
|
711
|
+
[Ne(r)]: ee(e[r])
|
|
703
712
|
}),
|
|
704
713
|
{}
|
|
705
714
|
) : e;
|
|
@@ -709,7 +718,7 @@ function h(e, t) {
|
|
|
709
718
|
throw new Error("Transaction value is required");
|
|
710
719
|
return typeof e == "object" ? e : t(e);
|
|
711
720
|
}
|
|
712
|
-
function
|
|
721
|
+
function wt(e, t) {
|
|
713
722
|
return typeof t == "string" ? e.object(t) : typeof t == "object" && t.$kind ? t : e.object(t.contract.pool);
|
|
714
723
|
}
|
|
715
724
|
function Q(e, t, r) {
|
|
@@ -723,16 +732,16 @@ function Q(e, t, r) {
|
|
|
723
732
|
function C(e) {
|
|
724
733
|
return K(e);
|
|
725
734
|
}
|
|
726
|
-
function
|
|
735
|
+
function Be(e) {
|
|
727
736
|
const t = (e || 0) / Math.pow(10, 27);
|
|
728
737
|
return t > Math.pow(10, 5) ? 1 / 0 : t;
|
|
729
738
|
}
|
|
730
|
-
new
|
|
739
|
+
new je("https://hermes.pyth.network", {
|
|
731
740
|
timeout: 2e4
|
|
732
741
|
});
|
|
733
|
-
const
|
|
742
|
+
const bt = 27, de = (e, t) => {
|
|
734
743
|
if (!Number(e) || !Number(t)) return new p(0);
|
|
735
|
-
const r = new p(1).shiftedBy(1 *
|
|
744
|
+
const r = new p(1).shiftedBy(1 * bt), o = r.multipliedBy(new p(0.5));
|
|
736
745
|
return new p(e).multipliedBy(new p(t)).plus(o).dividedBy(r).integerValue(p.ROUND_DOWN);
|
|
737
746
|
}, D = ae ? {
|
|
738
747
|
"User-Agent": ae
|
|
@@ -763,7 +772,7 @@ function H(e, t) {
|
|
|
763
772
|
isEMode: !0
|
|
764
773
|
};
|
|
765
774
|
}
|
|
766
|
-
function
|
|
775
|
+
function vt(e) {
|
|
767
776
|
const [t, r] = e.split("-");
|
|
768
777
|
return !t || !r ? null : {
|
|
769
778
|
marketKey: t,
|
|
@@ -777,8 +786,8 @@ var z = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] =
|
|
|
777
786
|
const G = $(
|
|
778
787
|
A(
|
|
779
788
|
async (e) => {
|
|
780
|
-
const t = (e?.markets || [F.main]).map((a) => _(a)), r =
|
|
781
|
-
`/navi/pools?env=${e?.env || "prod"}&sdk=${
|
|
789
|
+
const t = (e?.markets || [F.main]).map((a) => _(a)), r = O(e), o = M(
|
|
790
|
+
`/navi/pools?env=${e?.env || "prod"}&sdk=${E.version}&market=${t.map(
|
|
782
791
|
(a) => a.key
|
|
783
792
|
)}`,
|
|
784
793
|
e
|
|
@@ -787,9 +796,9 @@ const G = $(
|
|
|
787
796
|
);
|
|
788
797
|
return n.data.forEach((a) => {
|
|
789
798
|
const i = n.meta.emodes.filter((b) => {
|
|
790
|
-
const
|
|
791
|
-
return a.market ===
|
|
792
|
-
}).filter((b) => !!b.assets.find((
|
|
799
|
+
const k = _(b.marketId);
|
|
800
|
+
return a.market === k.key && b.isActive;
|
|
801
|
+
}).filter((b) => !!b.assets.find((k) => k.assetId === a.id));
|
|
793
802
|
a.emodes = i;
|
|
794
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(), y = p(a.supplyCapCeiling).shiftedBy(-27).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), g = p.max(
|
|
795
804
|
p(a.borrowedAmount),
|
|
@@ -803,7 +812,7 @@ const G = $(
|
|
|
803
812
|
async function S(e, t) {
|
|
804
813
|
let r = t?.market;
|
|
805
814
|
if (typeof e == "string") {
|
|
806
|
-
const a =
|
|
815
|
+
const a = vt(e);
|
|
807
816
|
a && (r = a.marketKey, e = a.poolId);
|
|
808
817
|
}
|
|
809
818
|
const o = await G({
|
|
@@ -818,24 +827,24 @@ async function S(e, t) {
|
|
|
818
827
|
throw new Error("Pool not found");
|
|
819
828
|
return n.isDeprecated && console.log(`The lending pool for coinType ${n.suiCoinType} is going to be deprecated.`), n;
|
|
820
829
|
}
|
|
821
|
-
const
|
|
830
|
+
const Xt = $(
|
|
822
831
|
A(async (e) => {
|
|
823
|
-
const t =
|
|
832
|
+
const t = O(e), r = M(`/navi/stats?sdk=${E.version}`, e);
|
|
824
833
|
return (await fetch(r, {
|
|
825
834
|
headers: U(D, t)
|
|
826
835
|
}).then((n) => n.json())).data;
|
|
827
836
|
})
|
|
828
|
-
),
|
|
837
|
+
), xt = $(
|
|
829
838
|
A(
|
|
830
839
|
async (e) => {
|
|
831
|
-
const t =
|
|
840
|
+
const t = O(e), r = M(`/navi/fee?sdk=${E.version}`, e);
|
|
832
841
|
return await fetch(r, {
|
|
833
842
|
headers: U(D, t)
|
|
834
843
|
}).then((n) => n.json());
|
|
835
844
|
}
|
|
836
845
|
)
|
|
837
846
|
);
|
|
838
|
-
async function
|
|
847
|
+
async function Ct(e, t, r, o) {
|
|
839
848
|
const n = await j({
|
|
840
849
|
...o,
|
|
841
850
|
cacheTime: v
|
|
@@ -883,7 +892,7 @@ async function vt(e, t, r, o) {
|
|
|
883
892
|
arguments: [e.object(a.contract.pool), e.object("0x05")]
|
|
884
893
|
}), e;
|
|
885
894
|
}
|
|
886
|
-
async function
|
|
895
|
+
async function er(e, t, r, o) {
|
|
887
896
|
const n = await j({
|
|
888
897
|
...o,
|
|
889
898
|
cacheTime: v
|
|
@@ -966,7 +975,7 @@ async function xt(e, t, r, o) {
|
|
|
966
975
|
typeArguments: [a.suiCoinType]
|
|
967
976
|
});
|
|
968
977
|
}
|
|
969
|
-
async function
|
|
978
|
+
async function tr(e, t, r, o) {
|
|
970
979
|
const n = await j({
|
|
971
980
|
...o,
|
|
972
981
|
cacheTime: v
|
|
@@ -1052,7 +1061,7 @@ async function er(e, t, r, o) {
|
|
|
1052
1061
|
typeArguments: [a.suiCoinType]
|
|
1053
1062
|
});
|
|
1054
1063
|
}
|
|
1055
|
-
async function
|
|
1064
|
+
async function rr(e, t, r, o) {
|
|
1056
1065
|
const n = await j({
|
|
1057
1066
|
...o,
|
|
1058
1067
|
cacheTime: v
|
|
@@ -1105,7 +1114,7 @@ async function tr(e, t, r, o) {
|
|
|
1105
1114
|
typeArguments: [a.suiCoinType]
|
|
1106
1115
|
}), e;
|
|
1107
1116
|
}
|
|
1108
|
-
const
|
|
1117
|
+
const nr = $(
|
|
1109
1118
|
A(
|
|
1110
1119
|
async (e) => {
|
|
1111
1120
|
const t = await j({
|
|
@@ -1135,7 +1144,7 @@ const rr = $(
|
|
|
1135
1144
|
a
|
|
1136
1145
|
);
|
|
1137
1146
|
}
|
|
1138
|
-
const n = (await
|
|
1147
|
+
const n = (await gt(r, {
|
|
1139
1148
|
id: t.incentiveV3,
|
|
1140
1149
|
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
1141
1150
|
})).data.content.fields.borrow_fee_rate;
|
|
@@ -1164,7 +1173,7 @@ const rr = $(
|
|
|
1164
1173
|
name: "Sui Eco Market"
|
|
1165
1174
|
}
|
|
1166
1175
|
};
|
|
1167
|
-
class
|
|
1176
|
+
class jt {
|
|
1168
1177
|
constructor(t, r) {
|
|
1169
1178
|
this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
|
|
1170
1179
|
marketTotalSupplyValue: "0",
|
|
@@ -1232,7 +1241,7 @@ const _ = (e) => {
|
|
|
1232
1241
|
if (!r)
|
|
1233
1242
|
throw new Error("Market not found");
|
|
1234
1243
|
return r;
|
|
1235
|
-
},
|
|
1244
|
+
}, kt = $(
|
|
1236
1245
|
A(
|
|
1237
1246
|
async (e, t) => {
|
|
1238
1247
|
const r = await G({
|
|
@@ -1242,19 +1251,19 @@ const _ = (e) => {
|
|
|
1242
1251
|
});
|
|
1243
1252
|
return e.map((o) => {
|
|
1244
1253
|
const n = _(o), a = r.filter((c) => c.market === n.key);
|
|
1245
|
-
return new
|
|
1254
|
+
return new jt(o, a);
|
|
1246
1255
|
});
|
|
1247
1256
|
}
|
|
1248
1257
|
)
|
|
1249
|
-
),
|
|
1258
|
+
), or = $(
|
|
1250
1259
|
A(
|
|
1251
|
-
async (e, t) => (await
|
|
1260
|
+
async (e, t) => (await kt([e], t))[0]
|
|
1252
1261
|
)
|
|
1253
1262
|
), j = $(
|
|
1254
1263
|
A(
|
|
1255
1264
|
async (e) => {
|
|
1256
|
-
const t = _(e?.market || R), r =
|
|
1257
|
-
`/navi/config?env=${e?.env || "prod"}&sdk=${
|
|
1265
|
+
const t = _(e?.market || R), r = O(e), o = M(
|
|
1266
|
+
`/navi/config?env=${e?.env || "prod"}&sdk=${E.version}&market=${t.key}`,
|
|
1258
1267
|
e
|
|
1259
1268
|
);
|
|
1260
1269
|
return (await fetch(o, {
|
|
@@ -1273,7 +1282,7 @@ async function It(e, t) {
|
|
|
1273
1282
|
arguments: []
|
|
1274
1283
|
});
|
|
1275
1284
|
}
|
|
1276
|
-
async function
|
|
1285
|
+
async function _t(e, t, r) {
|
|
1277
1286
|
const o = await j({
|
|
1278
1287
|
cacheTime: v,
|
|
1279
1288
|
...r
|
|
@@ -1283,7 +1292,7 @@ async function kt(e, t, r) {
|
|
|
1283
1292
|
arguments: [t]
|
|
1284
1293
|
});
|
|
1285
1294
|
}
|
|
1286
|
-
async function
|
|
1295
|
+
async function Tt(e, t, r) {
|
|
1287
1296
|
const o = await j({
|
|
1288
1297
|
...r,
|
|
1289
1298
|
cacheTime: v
|
|
@@ -1300,7 +1309,7 @@ async function _t(e, t, r) {
|
|
|
1300
1309
|
arguments: [e.object(o.storage), h(t, e.pure.u64)]
|
|
1301
1310
|
}), e;
|
|
1302
1311
|
}
|
|
1303
|
-
async function
|
|
1312
|
+
async function ar(e, t) {
|
|
1304
1313
|
const r = await j({
|
|
1305
1314
|
...t,
|
|
1306
1315
|
cacheTime: v
|
|
@@ -1313,16 +1322,16 @@ async function or(e, t) {
|
|
|
1313
1322
|
arguments: [e.object(r.storage)]
|
|
1314
1323
|
}), e;
|
|
1315
1324
|
}
|
|
1316
|
-
async function
|
|
1325
|
+
async function ir(e, t, r) {
|
|
1317
1326
|
const o = await j({
|
|
1318
1327
|
cacheTime: v,
|
|
1319
1328
|
...r
|
|
1320
1329
|
}), n = await It(e, r);
|
|
1321
|
-
await
|
|
1330
|
+
await Tt(e, t, {
|
|
1322
1331
|
...r,
|
|
1323
1332
|
accountCap: n
|
|
1324
1333
|
});
|
|
1325
|
-
const a = await _(r?.market || R), c = await
|
|
1334
|
+
const a = await _(r?.market || R), c = await _t(e, n, r);
|
|
1326
1335
|
return e.moveCall({
|
|
1327
1336
|
target: `${o.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
|
|
1328
1337
|
arguments: [
|
|
@@ -1333,7 +1342,7 @@ async function ar(e, t, r) {
|
|
|
1333
1342
|
]
|
|
1334
1343
|
}), n;
|
|
1335
1344
|
}
|
|
1336
|
-
const
|
|
1345
|
+
const Pe = $(
|
|
1337
1346
|
A(
|
|
1338
1347
|
async (e, t) => {
|
|
1339
1348
|
const r = await j({
|
|
@@ -1356,21 +1365,21 @@ const Be = $(
|
|
|
1356
1365
|
}
|
|
1357
1366
|
)
|
|
1358
1367
|
);
|
|
1359
|
-
function
|
|
1368
|
+
function cr(e) {
|
|
1360
1369
|
return `${_(e.marketId).key}-${e.emodeId}`;
|
|
1361
1370
|
}
|
|
1362
|
-
function
|
|
1371
|
+
function Bt(e, t) {
|
|
1363
1372
|
return e.coinType ? e.coinType : t || (typeof e.type == "string" ? e.type.match(/::coin::Coin<(.+)>$/) : null)?.[1];
|
|
1364
1373
|
}
|
|
1365
1374
|
function me(e, t) {
|
|
1366
|
-
const r =
|
|
1375
|
+
const r = Bt(e, t), o = e.coinObjectId ?? e.objectId;
|
|
1367
1376
|
return !r || !o || e.balance === void 0 || e.balance === null ? null : {
|
|
1368
1377
|
...e,
|
|
1369
1378
|
coinType: C(r),
|
|
1370
1379
|
coinObjectId: o
|
|
1371
1380
|
};
|
|
1372
1381
|
}
|
|
1373
|
-
function
|
|
1382
|
+
function sr(e, t, r) {
|
|
1374
1383
|
const o = typeof r?.balance == "number", n = o ? r.balance : 0;
|
|
1375
1384
|
let a = 0;
|
|
1376
1385
|
const c = [];
|
|
@@ -1389,7 +1398,7 @@ function cr(e, t, r) {
|
|
|
1389
1398
|
);
|
|
1390
1399
|
return C(i) === C("0x2::sui::SUI") && r?.useGasCoin ? o ? e.splitCoins(e.gas, [e.pure.u64(n)]) : e.gas : (c.length === 1 ? e.object(c[0]) : e.mergeCoins(c[0], c.slice(1)), o ? e.splitCoins(c[0], [e.pure.u64(n)]) : c[0]);
|
|
1391
1400
|
}
|
|
1392
|
-
async function
|
|
1401
|
+
async function Ae(e, t, r, o, n, a, c) {
|
|
1393
1402
|
const i = await j({
|
|
1394
1403
|
...c,
|
|
1395
1404
|
cacheTime: v
|
|
@@ -1400,7 +1409,7 @@ async function Pe(e, t, r, o, n, a, c) {
|
|
|
1400
1409
|
e.object("0x06"),
|
|
1401
1410
|
e.object(i.storage),
|
|
1402
1411
|
e.object(i.oracle.priceOracle),
|
|
1403
|
-
|
|
1412
|
+
wt(e, s),
|
|
1404
1413
|
h(t, e.pure.address),
|
|
1405
1414
|
h(s.id, e.pure.u8),
|
|
1406
1415
|
h(o, e.pure.u64),
|
|
@@ -1410,10 +1419,10 @@ async function Pe(e, t, r, o, n, a, c) {
|
|
|
1410
1419
|
typeArguments: [s.suiCoinType]
|
|
1411
1420
|
});
|
|
1412
1421
|
}
|
|
1413
|
-
async function
|
|
1414
|
-
return
|
|
1422
|
+
async function Pt(e, t, r) {
|
|
1423
|
+
return Ae(e, t, 0, 0, 0, !1, r);
|
|
1415
1424
|
}
|
|
1416
|
-
async function
|
|
1425
|
+
async function Se(e, t, r) {
|
|
1417
1426
|
const o = new N(), n = r?.client ?? V, a = await G({
|
|
1418
1427
|
...r,
|
|
1419
1428
|
markets: Object.values(F)
|
|
@@ -1446,13 +1455,13 @@ async function Ae(e, t, r) {
|
|
|
1446
1455
|
})).results || [], w = {};
|
|
1447
1456
|
s.forEach((d, f) => {
|
|
1448
1457
|
try {
|
|
1449
|
-
const b = m[f]?.returnValues?.map((T) => l.vector(
|
|
1458
|
+
const b = m[f]?.returnValues?.map((T) => l.vector(ze).parse(Uint8Array.from(T[0])))[0] || [], k = {};
|
|
1450
1459
|
for (const T of b)
|
|
1451
|
-
|
|
1460
|
+
k[T.id] = {
|
|
1452
1461
|
supplyIndex: T.supply_index,
|
|
1453
1462
|
borrowIndex: T.borrow_index
|
|
1454
1463
|
};
|
|
1455
|
-
w[d.key] =
|
|
1464
|
+
w[d.key] = k;
|
|
1456
1465
|
} catch (b) {
|
|
1457
1466
|
console.warn(
|
|
1458
1467
|
`[@naviprotocol/lending] Failed to decode reserve data for market "${d.key}", falling back to open-api pool indices`,
|
|
@@ -1460,46 +1469,46 @@ async function Ae(e, t, r) {
|
|
|
1460
1469
|
);
|
|
1461
1470
|
}
|
|
1462
1471
|
});
|
|
1463
|
-
const y = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(
|
|
1472
|
+
const y = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(Ge).parse(Uint8Array.from(f[0])))[0] || []), g = [];
|
|
1464
1473
|
return y.forEach((d, f) => {
|
|
1465
|
-
const b = t[f],
|
|
1466
|
-
d.forEach((
|
|
1467
|
-
if (
|
|
1474
|
+
const b = t[f], k = _(b.market), T = w[k.key] || {};
|
|
1475
|
+
d.forEach((I) => {
|
|
1476
|
+
if (I.supply_balance === "0" && I.borrow_balance === "0" && (b.emodeId === void 0 || !r?.includeZeroBalanceEmodePositions))
|
|
1468
1477
|
return;
|
|
1469
|
-
const B = c[`${
|
|
1478
|
+
const B = c[`${k.key}-${I.asset_id}`];
|
|
1470
1479
|
if (!B)
|
|
1471
1480
|
return;
|
|
1472
|
-
const W = T[
|
|
1481
|
+
const W = T[I.asset_id], Y = W?.supplyIndex ?? B.currentSupplyIndex, Oe = W?.borrowIndex ?? B.currentBorrowIndex, Ve = de(I.supply_balance, Y).toString(), Me = de(I.borrow_balance, Oe).toString();
|
|
1473
1482
|
g.push({
|
|
1474
|
-
supplyBalance:
|
|
1475
|
-
borrowBalance:
|
|
1476
|
-
assetId:
|
|
1477
|
-
market:
|
|
1483
|
+
supplyBalance: Ve,
|
|
1484
|
+
borrowBalance: Me,
|
|
1485
|
+
assetId: I.asset_id,
|
|
1486
|
+
market: k.key,
|
|
1478
1487
|
pool: B,
|
|
1479
1488
|
emodeId: b.emodeId
|
|
1480
1489
|
});
|
|
1481
1490
|
});
|
|
1482
1491
|
}), g;
|
|
1483
1492
|
}
|
|
1484
|
-
const
|
|
1493
|
+
const ur = $(
|
|
1485
1494
|
async (e, t) => {
|
|
1486
1495
|
const o = (t?.markets || Object.keys(F)).map((n) => _(n)).map((n) => ({
|
|
1487
1496
|
address: e,
|
|
1488
1497
|
market: n.key
|
|
1489
1498
|
}));
|
|
1490
|
-
return await
|
|
1499
|
+
return await Se(e, o, t);
|
|
1491
1500
|
}
|
|
1492
1501
|
);
|
|
1493
|
-
async function
|
|
1502
|
+
async function lr(e, t) {
|
|
1494
1503
|
const r = t?.client ?? V, o = new N();
|
|
1495
|
-
await
|
|
1504
|
+
await Pt(o, e, t);
|
|
1496
1505
|
const n = await q(r, {
|
|
1497
1506
|
transactionBlock: o,
|
|
1498
1507
|
sender: e
|
|
1499
1508
|
}), a = Q(n, [l.u256()]);
|
|
1500
|
-
return
|
|
1509
|
+
return Be(Number(a[0]) || 0);
|
|
1501
1510
|
}
|
|
1502
|
-
async function
|
|
1511
|
+
async function dr(e, t, r, o) {
|
|
1503
1512
|
const n = o?.client ?? V, a = new N();
|
|
1504
1513
|
let c = 0, i = 0;
|
|
1505
1514
|
const s = await S(t, o);
|
|
@@ -1508,7 +1517,7 @@ async function lr(e, t, r, o) {
|
|
|
1508
1517
|
}), c * i < 0)
|
|
1509
1518
|
throw new Error("Invalid operations");
|
|
1510
1519
|
const u = c > 0 || i > 0;
|
|
1511
|
-
await
|
|
1520
|
+
await Ae(
|
|
1512
1521
|
a,
|
|
1513
1522
|
e,
|
|
1514
1523
|
s,
|
|
@@ -1521,14 +1530,14 @@ async function lr(e, t, r, o) {
|
|
|
1521
1530
|
transactionBlock: a,
|
|
1522
1531
|
sender: e
|
|
1523
1532
|
}), w = Q(m, [l.u256()]);
|
|
1524
|
-
return
|
|
1533
|
+
return Be(Number(w[0]) || 0);
|
|
1525
1534
|
}
|
|
1526
|
-
const
|
|
1535
|
+
const pr = A(
|
|
1527
1536
|
async (e, t) => {
|
|
1528
1537
|
const r = new URLSearchParams();
|
|
1529
1538
|
t?.cursor && r.set("cursor", t.cursor), r.set("userAddress", e);
|
|
1530
|
-
const o =
|
|
1531
|
-
`/navi/user/transactions?${r.toString()}&sdk=${
|
|
1539
|
+
const o = O(t), n = M(
|
|
1540
|
+
`/navi/user/transactions?${r.toString()}&sdk=${E.version}`,
|
|
1532
1541
|
t
|
|
1533
1542
|
);
|
|
1534
1543
|
return (await fetch(n, {
|
|
@@ -1536,7 +1545,7 @@ const dr = A(
|
|
|
1536
1545
|
}).then((c) => c.json())).data;
|
|
1537
1546
|
}
|
|
1538
1547
|
);
|
|
1539
|
-
async function
|
|
1548
|
+
async function mr(e, t) {
|
|
1540
1549
|
let r = null;
|
|
1541
1550
|
const o = [], n = t?.client ?? V, a = n.core;
|
|
1542
1551
|
do {
|
|
@@ -1609,9 +1618,9 @@ async function pr(e, t) {
|
|
|
1609
1618
|
} while (r);
|
|
1610
1619
|
return o;
|
|
1611
1620
|
}
|
|
1612
|
-
const
|
|
1621
|
+
const At = $(
|
|
1613
1622
|
async (e, t) => {
|
|
1614
|
-
const r = [], o = (t?.markets || Object.keys(F)).map((i) => _(i)), n = await
|
|
1623
|
+
const r = [], o = (t?.markets || Object.keys(F)).map((i) => _(i)), n = await Pe(e, t), a = o.map((i) => ({
|
|
1615
1624
|
address: e,
|
|
1616
1625
|
market: i.key
|
|
1617
1626
|
})).concat(
|
|
@@ -1621,7 +1630,7 @@ const Pt = $(
|
|
|
1621
1630
|
emodeId: i.emodeId
|
|
1622
1631
|
}))
|
|
1623
1632
|
);
|
|
1624
|
-
return (await
|
|
1633
|
+
return (await Se(e, a, t)).forEach((i) => {
|
|
1625
1634
|
const s = typeof i.emodeId == "number" ? n.find((u) => {
|
|
1626
1635
|
const m = _(i.market);
|
|
1627
1636
|
return u.emodeId === i.emodeId && u.marketId === m.id;
|
|
@@ -1947,7 +1956,7 @@ class L {
|
|
|
1947
1956
|
};
|
|
1948
1957
|
}
|
|
1949
1958
|
}
|
|
1950
|
-
async function
|
|
1959
|
+
async function fr(e, t, r, o) {
|
|
1951
1960
|
const n = await j({
|
|
1952
1961
|
...o,
|
|
1953
1962
|
cacheTime: v
|
|
@@ -1963,33 +1972,37 @@ async function mr(e, t, r, o) {
|
|
|
1963
1972
|
]
|
|
1964
1973
|
});
|
|
1965
1974
|
}
|
|
1966
|
-
const
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1975
|
+
const fe = /* @__PURE__ */ new Map(), $e = (e) => {
|
|
1976
|
+
const t = e ?? "https://hermes.pyth.network";
|
|
1977
|
+
let r = fe.get(t);
|
|
1978
|
+
return r || (r = new je(t, { timeout: 1e4 }), fe.set(t, r)), r;
|
|
1979
|
+
};
|
|
1980
|
+
async function yr(e, t) {
|
|
1970
1981
|
try {
|
|
1971
|
-
const
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1982
|
+
const r = [], o = await j({ ...t, cacheTime: v }), n = await $e(
|
|
1983
|
+
o.oracle.hermesEndpoint
|
|
1984
|
+
).getLatestPriceFeeds(e);
|
|
1985
|
+
if (!n) return r;
|
|
1986
|
+
const a = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
1987
|
+
for (const c of n) {
|
|
1988
|
+
const i = c.getPriceUnchecked();
|
|
1989
|
+
if (i.publishTime > a) {
|
|
1977
1990
|
console.warn(
|
|
1978
|
-
`pyth price feed is invalid, id: ${
|
|
1991
|
+
`pyth price feed is invalid, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
|
|
1979
1992
|
);
|
|
1980
1993
|
continue;
|
|
1981
1994
|
}
|
|
1982
|
-
|
|
1983
|
-
`stale price feed, id: ${
|
|
1984
|
-
),
|
|
1995
|
+
a - c.getPriceUnchecked().publishTime > 30 && (console.info(
|
|
1996
|
+
`stale price feed, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
|
|
1997
|
+
), r.push(c.id));
|
|
1985
1998
|
}
|
|
1986
|
-
return
|
|
1987
|
-
} catch (
|
|
1988
|
-
throw new Error(`failed to get pyth stale price feed id, msg: ${
|
|
1999
|
+
return r;
|
|
2000
|
+
} catch (r) {
|
|
2001
|
+
throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
|
|
1989
2002
|
}
|
|
1990
2003
|
}
|
|
1991
|
-
async function
|
|
1992
|
-
const r = [], o = t?.client ?? V, n = e.map((c) => c.priceInfoObject), a = await
|
|
2004
|
+
async function St(e, t) {
|
|
2005
|
+
const r = [], o = t?.client ?? V, n = e.map((c) => c.priceInfoObject), a = await ht(o, {
|
|
1993
2006
|
ids: Array.from(new Set(n)),
|
|
1994
2007
|
options: { showContent: !0 }
|
|
1995
2008
|
});
|
|
@@ -2021,9 +2034,9 @@ async function At(e, t) {
|
|
|
2021
2034
|
}
|
|
2022
2035
|
return r;
|
|
2023
2036
|
}
|
|
2024
|
-
async function
|
|
2037
|
+
async function $t(e, t) {
|
|
2025
2038
|
try {
|
|
2026
|
-
const r = [], o = await
|
|
2039
|
+
const r = [], o = await St(e, t);
|
|
2027
2040
|
if (!o) return r;
|
|
2028
2041
|
const n = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
2029
2042
|
for (const a of o) {
|
|
@@ -2043,14 +2056,16 @@ async function St(e, t) {
|
|
|
2043
2056
|
throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
|
|
2044
2057
|
}
|
|
2045
2058
|
}
|
|
2046
|
-
async function
|
|
2059
|
+
async function Et(e, t, r) {
|
|
2047
2060
|
const o = r?.client ?? V, n = await j({
|
|
2048
2061
|
...r,
|
|
2049
2062
|
cacheTime: v
|
|
2050
2063
|
});
|
|
2051
2064
|
try {
|
|
2052
|
-
const a = await
|
|
2053
|
-
|
|
2065
|
+
const a = await $e(
|
|
2066
|
+
n.oracle.hermesEndpoint
|
|
2067
|
+
).getPriceFeedsUpdateData(t);
|
|
2068
|
+
return await new dt(
|
|
2054
2069
|
o,
|
|
2055
2070
|
n.oracle.pythStateId,
|
|
2056
2071
|
n.oracle.wormholeStateId
|
|
@@ -2059,7 +2074,7 @@ async function $t(e, t, r) {
|
|
|
2059
2074
|
throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
|
|
2060
2075
|
}
|
|
2061
2076
|
}
|
|
2062
|
-
async function
|
|
2077
|
+
async function ye(e, t, r) {
|
|
2063
2078
|
const o = await j({
|
|
2064
2079
|
...r,
|
|
2065
2080
|
cacheTime: v
|
|
@@ -2069,28 +2084,12 @@ async function fe(e, t, r) {
|
|
|
2069
2084
|
priceFeedId: c.pythPriceFeedId,
|
|
2070
2085
|
priceInfoObject: c.pythPriceInfoObject,
|
|
2071
2086
|
expiration: 30
|
|
2072
|
-
})), a = await
|
|
2073
|
-
a.length > 0 && await
|
|
2087
|
+
})), a = await $t(n, r);
|
|
2088
|
+
a.length > 0 && await Et(e, a, r);
|
|
2074
2089
|
}
|
|
2075
2090
|
for (const n of t)
|
|
2076
|
-
|
|
2077
|
-
target: `${o.oracle.packageId}::oracle_pro
|
|
2078
|
-
arguments: [
|
|
2079
|
-
e.object("0x6"),
|
|
2080
|
-
// Clock object
|
|
2081
|
-
e.object(o.oracle.oracleConfig),
|
|
2082
|
-
// Oracle configuration
|
|
2083
|
-
e.object(o.oracle.priceOracle),
|
|
2084
|
-
// Price oracle contract
|
|
2085
|
-
e.object(o.oracle.supraOracleHolder),
|
|
2086
|
-
// Supra oracle holder
|
|
2087
|
-
e.object(n.pythPriceInfoObject),
|
|
2088
|
-
// Pyth price info object
|
|
2089
|
-
e.pure.address(n.feedId)
|
|
2090
|
-
// Price feed ID
|
|
2091
|
-
]
|
|
2092
|
-
}) : e.moveCall({
|
|
2093
|
-
target: `${o.oracle.packageId}::oracle_pro::update_single_price_v2`,
|
|
2091
|
+
e.moveCall({
|
|
2092
|
+
target: `${o.oracle.packageId}::oracle_pro::${o.oracle.updateFunction ?? "update_single_price_v2"}`,
|
|
2094
2093
|
arguments: [
|
|
2095
2094
|
e.object("0x6"),
|
|
2096
2095
|
// Clock object
|
|
@@ -2109,7 +2108,7 @@ async function fe(e, t, r) {
|
|
|
2109
2108
|
});
|
|
2110
2109
|
return e;
|
|
2111
2110
|
}
|
|
2112
|
-
async function
|
|
2111
|
+
async function Ee(e) {
|
|
2113
2112
|
return (await j({
|
|
2114
2113
|
...e,
|
|
2115
2114
|
cacheTime: v
|
|
@@ -2128,23 +2127,23 @@ function Ot(e, t) {
|
|
|
2128
2127
|
return r.oracleId === c?.oracleId;
|
|
2129
2128
|
}) || t?.pools && t.pools.find((n) => r.oracleId === n.oracleId)));
|
|
2130
2129
|
}
|
|
2131
|
-
async function
|
|
2130
|
+
async function gr(e, t, r, o) {
|
|
2132
2131
|
let n;
|
|
2133
2132
|
try {
|
|
2134
|
-
const a = await
|
|
2133
|
+
const a = await Ee({
|
|
2135
2134
|
...o
|
|
2136
2135
|
}), c = [];
|
|
2137
2136
|
r.forEach((u) => {
|
|
2138
2137
|
c.includes(u.market) || c.push(u.market);
|
|
2139
2138
|
});
|
|
2140
|
-
const i = await
|
|
2139
|
+
const i = await At(t, {
|
|
2141
2140
|
...o,
|
|
2142
2141
|
markets: c
|
|
2143
2142
|
});
|
|
2144
2143
|
return n = Ot(a, {
|
|
2145
2144
|
lendingPositions: i,
|
|
2146
2145
|
pools: r
|
|
2147
|
-
}), await
|
|
2146
|
+
}), await ye(e, n, {
|
|
2148
2147
|
updatePythPriceFeeds: !0,
|
|
2149
2148
|
...o
|
|
2150
2149
|
});
|
|
@@ -2153,7 +2152,7 @@ async function yr(e, t, r, o) {
|
|
|
2153
2152
|
throw a;
|
|
2154
2153
|
if (console.error(a), n)
|
|
2155
2154
|
try {
|
|
2156
|
-
return await
|
|
2155
|
+
return await ye(e, n, {
|
|
2157
2156
|
...o,
|
|
2158
2157
|
updatePythPriceFeeds: !1
|
|
2159
2158
|
});
|
|
@@ -2166,8 +2165,8 @@ async function yr(e, t, r, o) {
|
|
|
2166
2165
|
const ne = $(
|
|
2167
2166
|
A(
|
|
2168
2167
|
async (e) => {
|
|
2169
|
-
const t =
|
|
2170
|
-
`/navi/flashloan?env=${e?.env || "prod"}&sdk=${
|
|
2168
|
+
const t = O(e), r = M(
|
|
2169
|
+
`/navi/flashloan?env=${e?.env || "prod"}&sdk=${E.version}&market=${e?.market || R}`,
|
|
2171
2170
|
e
|
|
2172
2171
|
), o = await fetch(r, {
|
|
2173
2172
|
headers: U(D, t)
|
|
@@ -2179,10 +2178,10 @@ const ne = $(
|
|
|
2179
2178
|
}
|
|
2180
2179
|
)
|
|
2181
2180
|
);
|
|
2182
|
-
async function
|
|
2181
|
+
async function hr(e, t) {
|
|
2183
2182
|
return (await ne(t)).find((o) => typeof e == "string" ? C(o.coinType) === C(e) : typeof e == "number" ? o.assetId === e : o.assetId === e.id) || null;
|
|
2184
2183
|
}
|
|
2185
|
-
async function
|
|
2184
|
+
async function wr(e, t, r, o) {
|
|
2186
2185
|
const n = await j({
|
|
2187
2186
|
...o,
|
|
2188
2187
|
cacheTime: v
|
|
@@ -2219,7 +2218,7 @@ async function hr(e, t, r, o) {
|
|
|
2219
2218
|
return [s, u];
|
|
2220
2219
|
}
|
|
2221
2220
|
}
|
|
2222
|
-
async function
|
|
2221
|
+
async function br(e, t, r, o, n) {
|
|
2223
2222
|
const a = await j({
|
|
2224
2223
|
...n,
|
|
2225
2224
|
cacheTime: v
|
|
@@ -2244,7 +2243,7 @@ async function wr(e, t, r, o, n) {
|
|
|
2244
2243
|
});
|
|
2245
2244
|
return [u];
|
|
2246
2245
|
}
|
|
2247
|
-
async function
|
|
2246
|
+
async function vr(e, t, r, o, n, a) {
|
|
2248
2247
|
const c = {
|
|
2249
2248
|
...a,
|
|
2250
2249
|
cacheTime: v
|
|
@@ -2313,12 +2312,12 @@ async function br(e, t, r, o, n, a) {
|
|
|
2313
2312
|
return [m, w];
|
|
2314
2313
|
}
|
|
2315
2314
|
}
|
|
2316
|
-
async function
|
|
2315
|
+
async function Vt(e, t, r) {
|
|
2317
2316
|
const o = r?.client ?? V, n = await G({
|
|
2318
2317
|
...r,
|
|
2319
2318
|
markets: Object.values(F),
|
|
2320
2319
|
cacheTime: v
|
|
2321
|
-
}), a = await
|
|
2320
|
+
}), a = await Ee(r), c = [];
|
|
2322
2321
|
return await Promise.all(
|
|
2323
2322
|
t.map(async (i) => {
|
|
2324
2323
|
try {
|
|
@@ -2362,9 +2361,9 @@ async function Et(e, t, r) {
|
|
|
2362
2361
|
const g = y[0].length;
|
|
2363
2362
|
for (let d = 0; d < g; d++) {
|
|
2364
2363
|
const f = a.find(
|
|
2365
|
-
(
|
|
2364
|
+
(k) => C(k.coinType) === C(y[1][d])
|
|
2366
2365
|
), b = n.find(
|
|
2367
|
-
(
|
|
2366
|
+
(k) => C(k.coinType) === C(y[0][d]) && k.market === i.market
|
|
2368
2367
|
);
|
|
2369
2368
|
!f || !b || c.push({
|
|
2370
2369
|
assetId: b.id,
|
|
@@ -2389,8 +2388,8 @@ async function Et(e, t, r) {
|
|
|
2389
2388
|
})
|
|
2390
2389
|
), c;
|
|
2391
2390
|
}
|
|
2392
|
-
async function
|
|
2393
|
-
const r = (t?.markets || [F.main]).map((a) => _(a)), o = await
|
|
2391
|
+
async function Cr(e, t) {
|
|
2392
|
+
const r = (t?.markets || [F.main]).map((a) => _(a)), o = await Pe(e, t), n = r.map((a) => ({
|
|
2394
2393
|
address: e,
|
|
2395
2394
|
owner: e,
|
|
2396
2395
|
market: a.key
|
|
@@ -2405,9 +2404,9 @@ async function vr(e, t) {
|
|
|
2405
2404
|
};
|
|
2406
2405
|
})
|
|
2407
2406
|
);
|
|
2408
|
-
return await
|
|
2407
|
+
return await Vt(e, n, t);
|
|
2409
2408
|
}
|
|
2410
|
-
function
|
|
2409
|
+
function jr(e) {
|
|
2411
2410
|
const t = /* @__PURE__ */ new Map();
|
|
2412
2411
|
e.forEach((o) => {
|
|
2413
2412
|
const n = o.assetId, a = o.option, c = `${n}-${a}-${o.rewardCoinType}-${o.market}`;
|
|
@@ -2436,10 +2435,10 @@ function Cr(e) {
|
|
|
2436
2435
|
}))
|
|
2437
2436
|
}));
|
|
2438
2437
|
}
|
|
2439
|
-
const
|
|
2438
|
+
const kr = A(
|
|
2440
2439
|
async (e, t) => {
|
|
2441
|
-
const r =
|
|
2442
|
-
`/navi/user/total_claimed_reward?userAddress=${e}&sdk=${
|
|
2440
|
+
const r = O(t), o = M(
|
|
2441
|
+
`/navi/user/total_claimed_reward?userAddress=${e}&sdk=${E.version}&market=${t?.market || R}`,
|
|
2443
2442
|
t
|
|
2444
2443
|
);
|
|
2445
2444
|
return (await fetch(o, {
|
|
@@ -2448,8 +2447,8 @@ const jr = A(
|
|
|
2448
2447
|
}
|
|
2449
2448
|
), Ir = A(
|
|
2450
2449
|
async (e, t) => {
|
|
2451
|
-
const r =
|
|
2452
|
-
`/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${
|
|
2450
|
+
const r = O(t), o = M(
|
|
2451
|
+
`/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${E.version}&market=${t?.market || R}`,
|
|
2453
2452
|
t
|
|
2454
2453
|
), n = await fetch(o, {
|
|
2455
2454
|
headers: U(D, r)
|
|
@@ -2459,7 +2458,7 @@ const jr = A(
|
|
|
2459
2458
|
});
|
|
2460
2459
|
}
|
|
2461
2460
|
);
|
|
2462
|
-
async function
|
|
2461
|
+
async function _r(e, t, r) {
|
|
2463
2462
|
const o = await G({
|
|
2464
2463
|
...r,
|
|
2465
2464
|
markets: Object.values(F),
|
|
@@ -2491,17 +2490,17 @@ async function kr(e, t, r) {
|
|
|
2491
2490
|
cacheTime: v,
|
|
2492
2491
|
market: m
|
|
2493
2492
|
}), f = c.split("___")[0], b = o.filter(
|
|
2494
|
-
(
|
|
2493
|
+
(I) => C(I.suiCoinType) === C(f)
|
|
2495
2494
|
);
|
|
2496
|
-
b.sort((
|
|
2497
|
-
const
|
|
2495
|
+
b.sort((I, B) => I.market === m ? -1 : 1);
|
|
2496
|
+
const k = b[0], T = d.rewardFunds[C(f)];
|
|
2498
2497
|
if (!T)
|
|
2499
2498
|
throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
|
|
2500
2499
|
if (r?.accountCap && !r.customCoinReceive)
|
|
2501
2500
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
2502
2501
|
if (r?.customCoinReceive) {
|
|
2503
|
-
let
|
|
2504
|
-
r.accountCap ?
|
|
2502
|
+
let I;
|
|
2503
|
+
r.accountCap ? I = e.moveCall({
|
|
2505
2504
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2506
2505
|
arguments: [
|
|
2507
2506
|
e.object("0x06"),
|
|
@@ -2520,7 +2519,7 @@ async function kr(e, t, r) {
|
|
|
2520
2519
|
// Account capability
|
|
2521
2520
|
],
|
|
2522
2521
|
typeArguments: [f]
|
|
2523
|
-
}) : g ?
|
|
2522
|
+
}) : g ? I = e.moveCall({
|
|
2524
2523
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2525
2524
|
arguments: [
|
|
2526
2525
|
e.object("0x06"),
|
|
@@ -2539,7 +2538,7 @@ async function kr(e, t, r) {
|
|
|
2539
2538
|
// Account capability
|
|
2540
2539
|
],
|
|
2541
2540
|
typeArguments: [f]
|
|
2542
|
-
}) :
|
|
2541
|
+
}) : I = e.moveCall({
|
|
2543
2542
|
target: `${d.package}::incentive_v3::claim_reward`,
|
|
2544
2543
|
arguments: [
|
|
2545
2544
|
e.object("0x06"),
|
|
@@ -2559,7 +2558,7 @@ async function kr(e, t, r) {
|
|
|
2559
2558
|
});
|
|
2560
2559
|
const [B] = e.moveCall({
|
|
2561
2560
|
target: "0x2::coin::from_balance",
|
|
2562
|
-
arguments: [
|
|
2561
|
+
arguments: [I],
|
|
2563
2562
|
typeArguments: [f]
|
|
2564
2563
|
});
|
|
2565
2564
|
if (r?.customCoinReceive.type === "transfer") {
|
|
@@ -2571,23 +2570,23 @@ async function kr(e, t, r) {
|
|
|
2571
2570
|
);
|
|
2572
2571
|
}
|
|
2573
2572
|
if (r?.customCoinReceive.type === "depositNAVI") {
|
|
2574
|
-
const W = p(
|
|
2573
|
+
const W = p(k.totalSupplyAmount).shiftedBy(-9), Y = p(k.supplyCapCeiling).shiftedBy(-27);
|
|
2575
2574
|
W.plus(u).isGreaterThan(Y) && r?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
|
|
2576
2575
|
[B],
|
|
2577
2576
|
e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
2578
|
-
) : await
|
|
2577
|
+
) : await Ct(e, k, B, {
|
|
2579
2578
|
...r,
|
|
2580
|
-
market:
|
|
2579
|
+
market: k.market
|
|
2581
2580
|
});
|
|
2582
2581
|
} else
|
|
2583
2582
|
a.push({
|
|
2584
2583
|
coin: B,
|
|
2585
|
-
identifier:
|
|
2584
|
+
identifier: k,
|
|
2586
2585
|
owner: w,
|
|
2587
2586
|
isEMode: g
|
|
2588
2587
|
});
|
|
2589
2588
|
} else if (r?.accountCap || g) {
|
|
2590
|
-
const
|
|
2589
|
+
const I = e.moveCall({
|
|
2591
2590
|
target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
2592
2591
|
arguments: [
|
|
2593
2592
|
e.object("0x06"),
|
|
@@ -2608,7 +2607,7 @@ async function kr(e, t, r) {
|
|
|
2608
2607
|
typeArguments: [f]
|
|
2609
2608
|
}), [B] = e.moveCall({
|
|
2610
2609
|
target: "0x2::coin::from_balance",
|
|
2611
|
-
arguments: [
|
|
2610
|
+
arguments: [I],
|
|
2612
2611
|
typeArguments: [f]
|
|
2613
2612
|
});
|
|
2614
2613
|
e.transferObjects(
|
|
@@ -2641,84 +2640,84 @@ export {
|
|
|
2641
2640
|
oe as Address,
|
|
2642
2641
|
v as DEFAULT_CACHE_TIME,
|
|
2643
2642
|
R as DEFAULT_MARKET_IDENTITY,
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2643
|
+
Ht as FlashLoanAssetConfig,
|
|
2644
|
+
zt as IncentiveAPYInfo,
|
|
2645
|
+
qe as IncentivePoolInfo,
|
|
2646
|
+
Gt as IncentivePoolInfoByPhase,
|
|
2648
2647
|
F as MARKETS,
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2648
|
+
jt as Market,
|
|
2649
|
+
Qe as NaviMissingGraphQLClientError,
|
|
2650
|
+
Wt as OracleInfo,
|
|
2651
|
+
tt as PUBLIC_MAINNET_GRPC_URL,
|
|
2653
2652
|
z as PoolOperator,
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2653
|
+
ze as ReserveDataInfo,
|
|
2654
|
+
je as SuiPriceServiceConnection,
|
|
2655
|
+
dt as SuiPythClient,
|
|
2657
2656
|
L as UserPositions,
|
|
2658
|
-
|
|
2659
|
-
|
|
2657
|
+
Ge as UserStateInfo,
|
|
2658
|
+
tr as borrowCoinPTB,
|
|
2660
2659
|
M as buildNaviOpenApiUrl,
|
|
2661
|
-
|
|
2662
|
-
|
|
2660
|
+
_r as claimLendingRewardsPTB,
|
|
2661
|
+
Zt as configureNaviSdk,
|
|
2663
2662
|
It as createAccountCapPTB,
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2663
|
+
ir as createEModeCapPTB,
|
|
2664
|
+
Ce as createNaviLegacyJsonRpcClient,
|
|
2665
|
+
nt as createNaviSuiClient,
|
|
2666
|
+
et as createNaviSuiClientBundle,
|
|
2667
|
+
Ct as depositCoinPTB,
|
|
2668
|
+
cr as emodeIdentityId,
|
|
2669
|
+
Tt as enterEModePTB,
|
|
2670
|
+
ar as exitEModePTB,
|
|
2672
2671
|
Ot as filterPriceFeeds,
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2672
|
+
wr as flashloanPTB,
|
|
2673
|
+
_t as getAccountCapOwnerPTB,
|
|
2674
|
+
Kt as getAddressBalance,
|
|
2676
2675
|
ne as getAllFlashLoanAssets,
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2676
|
+
nr as getBorrowFee,
|
|
2677
|
+
Jt as getCoinObjectOnlyBalance,
|
|
2678
|
+
mr as getCoins,
|
|
2680
2679
|
j as getConfig,
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2680
|
+
xt as getFees,
|
|
2681
|
+
hr as getFlashLoanAsset,
|
|
2682
|
+
lr as getHealthFactor,
|
|
2683
|
+
Pt as getHealthFactorPTB,
|
|
2684
|
+
At as getLendingPositions,
|
|
2685
|
+
ur as getLendingState,
|
|
2686
|
+
or as getMarket,
|
|
2688
2687
|
_ as getMarketConfig,
|
|
2689
|
-
|
|
2688
|
+
kt as getMarkets,
|
|
2690
2689
|
S as getPool,
|
|
2691
2690
|
G as getPools,
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2691
|
+
Ee as getPriceFeeds,
|
|
2692
|
+
yr as getPythStalePriceFeedId,
|
|
2693
|
+
$t as getPythStalePriceFeedIdV2,
|
|
2694
|
+
dr as getSimulatedHealthFactor,
|
|
2695
|
+
Ae as getSimulatedHealthFactorPTB,
|
|
2696
|
+
Xt as getStats,
|
|
2697
|
+
pr as getTransactions,
|
|
2698
|
+
Cr as getUserAvailableLendingRewards,
|
|
2700
2699
|
Ir as getUserClaimedRewardHistory,
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2700
|
+
Pe as getUserEModeCaps,
|
|
2701
|
+
kr as getUserTotalClaimedReward,
|
|
2702
|
+
vr as liquidatePTB,
|
|
2703
|
+
Qt as listAddressBalances,
|
|
2704
|
+
sr as mergeCoinsPTB,
|
|
2706
2705
|
U as mergeServiceHeaders,
|
|
2707
|
-
|
|
2706
|
+
ve as normalizeAddressBalance,
|
|
2708
2707
|
C as normalizeCoinType,
|
|
2709
|
-
|
|
2708
|
+
vt as parsePoolUID,
|
|
2710
2709
|
h as parseTxValue,
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2710
|
+
rr as repayCoinPTB,
|
|
2711
|
+
br as repayFlashLoanPTB,
|
|
2712
|
+
Yt as requireNaviGraphQLClient,
|
|
2713
|
+
O as resolveNaviOpenApiEndpoint,
|
|
2714
|
+
jr as summaryLendingRewards,
|
|
2715
|
+
gr as updateOraclePriceBeforeUserOperationPTB,
|
|
2716
|
+
ye as updateOraclePricesPTB,
|
|
2717
|
+
Et as updatePythPriceFeeds,
|
|
2718
|
+
fr as verifyHealthFactorPTB,
|
|
2720
2719
|
$ as withCache,
|
|
2721
2720
|
A as withSingleton,
|
|
2722
|
-
|
|
2721
|
+
er as withdrawCoinPTB
|
|
2723
2722
|
};
|
|
2724
2723
|
//# sourceMappingURL=index.esm.js.map
|