@naviprotocol/lending 1.4.6 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,435 +1,981 @@
1
- import { Transaction as F } from "@mysten/sui/transactions";
2
- import { bcs as d, toHex as ue, fromHex as pe } from "@mysten/bcs";
3
- import { SuiClient as de, getFullnodeUrl as me } from "@mysten/sui/client";
4
- import fe from "lodash.camelcase";
5
- import { normalizeStructTag as ye } from "@mysten/sui/utils";
6
- import { SuiPriceServiceConnection as x, SuiPythClient as ge } from "@pythnetwork/pyth-sui-js";
1
+ import { Transaction as N } from "@mysten/sui/transactions";
2
+ import { bcs as u } from "@mysten/sui/bcs";
3
+ import { toHex as $e, fromHex as Oe, normalizeStructTag as K, SUI_CLOCK_OBJECT_ID as Z, fromBase64 as Ee } from "@mysten/sui/utils";
4
+ import Ve from "lodash.camelcase";
7
5
  import p from "bignumber.js";
8
- import { bcs as C } from "@mysten/sui/bcs";
9
- const J = d.bytes(32).transform({
6
+ import { SuiJsonRpcClient as Me } from "@mysten/sui/jsonRpc";
7
+ import { SuiGraphQLClient as Ue } from "@mysten/sui/graphql";
8
+ import { GrpcWebFetchTransport as De, SuiGrpcClient as Fe } from "@mysten/sui/grpc";
9
+ const ne = u.bytes(32).transform({
10
10
  // To change the input type, you need to provide a type definition for the input
11
- input: (e) => pe(e),
12
- output: (e) => ue(e)
13
- }), Je = d.struct("IncentiveAPYInfo", {
11
+ input: (e) => Oe(e),
12
+ output: (e) => $e(e)
13
+ }), Rt = u.struct("IncentiveAPYInfo", {
14
14
  /** Asset identifier */
15
- asset_id: d.u8(),
15
+ asset_id: u.u8(),
16
16
  /** Annual Percentage Yield as a 256-bit integer */
17
- apy: d.u256(),
17
+ apy: u.u256(),
18
18
  /** List of supported coin types for this incentive */
19
- coin_types: d.vector(d.string())
20
- }), he = d.struct("IncentivePoolInfo", {
19
+ coin_types: u.vector(u.string())
20
+ }), Ne = u.struct("IncentivePoolInfo", {
21
21
  /** Unique pool identifier */
22
- pool_id: J,
22
+ pool_id: ne,
23
23
  /** Address holding the incentive funds */
24
- funds: J,
24
+ funds: ne,
25
25
  /** Current phase of the incentive program */
26
- phase: d.u64(),
26
+ phase: u.u64(),
27
27
  /** Timestamp when the incentive started */
28
- start_at: d.u64(),
28
+ start_at: u.u64(),
29
29
  /** Timestamp when the incentive ends */
30
- end_at: d.u64(),
30
+ end_at: u.u64(),
31
31
  /** Timestamp when the incentive was closed */
32
- closed_at: d.u64(),
32
+ closed_at: u.u64(),
33
33
  /** Total supply of incentive tokens */
34
- total_supply: d.u64(),
34
+ total_supply: u.u64(),
35
35
  /** Asset identifier for the incentive */
36
- asset_id: d.u8(),
36
+ asset_id: u.u8(),
37
37
  /** Option type for the incentive */
38
- option: d.u8(),
38
+ option: u.u8(),
39
39
  /** Factor used in incentive calculations */
40
- factor: d.u256(),
40
+ factor: u.u256(),
41
41
  /** Amount of incentives already distributed */
42
- distributed: d.u64(),
42
+ distributed: u.u64(),
43
43
  /** Amount of incentives currently available */
44
- available: d.u256(),
44
+ available: u.u256(),
45
45
  /** Total amount of incentives */
46
- total: d.u256()
47
- }), Ze = d.struct("IncentivePoolInfoByPhase", {
46
+ total: u.u256()
47
+ }), Lt = u.struct("IncentivePoolInfoByPhase", {
48
48
  /** Phase number */
49
- phase: d.u64(),
49
+ phase: u.u64(),
50
50
  /** List of incentive pools in this phase */
51
- pools: d.vector(he)
52
- }), Qe = d.struct("OracleInfo", {
51
+ pools: u.vector(Ne)
52
+ }), qt = u.struct("OracleInfo", {
53
53
  /** Oracle identifier */
54
- oracle_id: d.u8(),
54
+ oracle_id: u.u8(),
55
55
  /** Current price as a 256-bit integer */
56
- price: d.u256(),
56
+ price: u.u256(),
57
57
  /** Number of decimal places for the price */
58
- decimals: d.u8(),
58
+ decimals: u.u8(),
59
59
  /** Whether the oracle data is valid */
60
- valid: d.bool()
61
- }), Xe = d.struct("FlashLoanAssetConfig", {
60
+ valid: u.bool()
61
+ }), zt = u.struct("FlashLoanAssetConfig", {
62
62
  /** Unique identifier for the flash loan asset */
63
- id: d.string(),
63
+ id: u.string(),
64
64
  /** Asset identifier */
65
- asset_id: d.u8(),
65
+ asset_id: u.u8(),
66
66
  /** Coin type for the asset */
67
- coin_type: d.string(),
67
+ coin_type: u.string(),
68
68
  /** Pool identifier for the flash loan */
69
- pool_id: d.string(),
69
+ pool_id: u.string(),
70
70
  /** Rate paid to suppliers for flash loans */
71
- rate_to_supplier: d.u64(),
71
+ rate_to_supplier: u.u64(),
72
72
  /** Rate paid to treasury for flash loans */
73
- rate_to_treasury: d.u64(),
73
+ rate_to_treasury: u.u64(),
74
74
  /** Maximum flash loan amount */
75
- max: d.u64(),
75
+ max: u.u64(),
76
76
  /** Minimum flash loan amount */
77
- min: d.u64()
78
- }), ve = d.struct("ReserveDataInfo", {
77
+ min: u.u64()
78
+ }), Re = u.struct("ReserveDataInfo", {
79
79
  /** Reserve identifier */
80
- id: d.u8(),
80
+ id: u.u8(),
81
81
  /** Oracle identifier for price feeds */
82
- oracle_id: d.u8(),
82
+ oracle_id: u.u8(),
83
83
  /** Coin type for the reserve */
84
- coin_type: d.string(),
84
+ coin_type: u.string(),
85
85
  /** Maximum supply capacity */
86
- supply_cap: d.u256(),
86
+ supply_cap: u.u256(),
87
87
  /** Maximum borrow capacity */
88
- borrow_cap: d.u256(),
88
+ borrow_cap: u.u256(),
89
89
  /** Current supply interest rate */
90
- supply_rate: d.u256(),
90
+ supply_rate: u.u256(),
91
91
  /** Current borrow interest rate */
92
- borrow_rate: d.u256(),
92
+ borrow_rate: u.u256(),
93
93
  /** Current supply index for interest calculation */
94
- supply_index: d.u256(),
94
+ supply_index: u.u256(),
95
95
  /** Current borrow index for interest calculation */
96
- borrow_index: d.u256(),
96
+ borrow_index: u.u256(),
97
97
  /** Total amount supplied to the reserve */
98
- total_supply: d.u256(),
98
+ total_supply: u.u256(),
99
99
  /** Total amount borrowed from the reserve */
100
- total_borrow: d.u256(),
100
+ total_borrow: u.u256(),
101
101
  /** Timestamp of last update */
102
- last_update_at: d.u64(),
102
+ last_update_at: u.u64(),
103
103
  /** Loan-to-Value ratio for collateral */
104
- ltv: d.u256(),
104
+ ltv: u.u256(),
105
105
  /** Treasury factor for fee calculations */
106
- treasury_factor: d.u256(),
106
+ treasury_factor: u.u256(),
107
107
  /** Current treasury balance */
108
- treasury_balance: d.u256(),
108
+ treasury_balance: u.u256(),
109
109
  /** Base interest rate */
110
- base_rate: d.u256(),
110
+ base_rate: u.u256(),
111
111
  /** Interest rate multiplier */
112
- multiplier: d.u256(),
112
+ multiplier: u.u256(),
113
113
  /** Jump rate multiplier for high utilization */
114
- jump_rate_multiplier: d.u256(),
114
+ jump_rate_multiplier: u.u256(),
115
115
  /** Reserve factor for protocol fees */
116
- reserve_factor: d.u256(),
116
+ reserve_factor: u.u256(),
117
117
  /** Optimal utilization rate */
118
- optimal_utilization: d.u256(),
118
+ optimal_utilization: u.u256(),
119
119
  /** Liquidation ratio threshold */
120
- liquidation_ratio: d.u256(),
120
+ liquidation_ratio: u.u256(),
121
121
  /** Liquidation bonus for liquidators */
122
- liquidation_bonus: d.u256(),
122
+ liquidation_bonus: u.u256(),
123
123
  /** Liquidation threshold */
124
- liquidation_threshold: d.u256()
125
- }), we = d.struct("UserStateInfo", {
124
+ liquidation_threshold: u.u256()
125
+ }), Le = u.struct("UserStateInfo", {
126
126
  /** Asset identifier */
127
- asset_id: d.u8(),
127
+ asset_id: u.u8(),
128
128
  /** User's current borrow balance */
129
- borrow_balance: d.u256(),
129
+ borrow_balance: u.u256(),
130
130
  /** User's current supply balance */
131
- supply_balance: d.u256()
132
- }), be = "1.4.6", E = {
133
- version: be
134
- }, ke = E.version, _e = () => {
135
- if (typeof process < "u" && process.versions && process.versions.node)
136
- try {
137
- const e = require("os"), r = process.version, o = e.type(), n = e.arch();
138
- return `Node.js ${r.startsWith("v") ? r.substring(1) : r}; ${o}/${n}`;
139
- } catch {
140
- return `Node.js ${process.version}; OS/Unknown (Error)`;
141
- }
131
+ supply_balance: u.u256()
132
+ }), qe = "2.0.0-beta.1", O = {
133
+ version: qe
134
+ }, ze = O.version, Ge = () => {
135
+ if (typeof process < "u" && process.versions && process.versions.node) {
136
+ const e = process.version;
137
+ return `Node.js ${e.startsWith("v") ? e.substring(1) : e}`;
138
+ }
142
139
  return "Node/Unknown";
143
- }, Ce = () => {
140
+ }, We = () => {
144
141
  let e = "";
145
- return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ke} (${_e()})`), e;
146
- }, Z = Ce(), V = new de({
147
- url: me("mainnet")
148
- });
149
- function ee(e) {
150
- const r = [];
142
+ return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ze} (${Ge()})`), e;
143
+ }, oe = We(), me = "0x2::sui::SUI";
144
+ class He extends Error {
145
+ constructor(t) {
146
+ super(
147
+ `NAVI Sui SDK capability "${t}" requires an explicit graphql client; no public GraphQL fallback is configured`
148
+ ), this.name = "NaviMissingGraphQLClientError";
149
+ }
150
+ }
151
+ function X(e) {
152
+ return e == null ? void 0 : String(e);
153
+ }
154
+ function Je(e, t) {
155
+ return (BigInt(e) + BigInt(t)).toString();
156
+ }
157
+ function Ke(e, t) {
158
+ return (BigInt(e) - BigInt(t)).toString();
159
+ }
160
+ function fe(e) {
161
+ const t = e.core;
162
+ if (typeof t?.getBalance != "function" || typeof t?.listBalances != "function")
163
+ throw new Error("NAVI Sui balance helpers require a v2 Core API client");
164
+ return t;
165
+ }
166
+ function ye(e, t = me) {
167
+ const r = X(e.addressBalance ?? e.fundsInAddressBalance) ?? "0";
168
+ let o = X(e.balance ?? e.totalBalance), n = X(e.coinBalance);
169
+ return !n && o && (n = Ke(o, r)), !o && n && (o = Je(n, r)), {
170
+ coinType: K(e.coinType ?? t),
171
+ totalBalance: o ?? "0",
172
+ coinBalance: n ?? "0",
173
+ addressBalance: r,
174
+ ...e.coinObjectCount === null || e.coinObjectCount === void 0 ? {} : { coinObjectCount: e.coinObjectCount }
175
+ };
176
+ }
177
+ function Gt(e, t = me) {
178
+ const r = K(t);
179
+ return e.filter((o) => K(o.coinType) === r).reduce((o, n) => o + BigInt(n.balance), 0n).toString();
180
+ }
181
+ async function Wt(e, t) {
182
+ const r = await fe(e).getBalance(t), o = r.balance;
183
+ return ye((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
184
+ }
185
+ async function Ht(e, t) {
186
+ const r = await fe(e).listBalances(t), { balances: o = [] } = r;
187
+ return {
188
+ balances: o.map((n) => ye(n)),
189
+ nextCursor: r.nextCursor ?? r.cursor ?? null
190
+ };
191
+ }
192
+ function Qe(e, t) {
193
+ if ("client" in t)
194
+ return t.client;
195
+ const r = new De({
196
+ baseUrl: t.url,
197
+ meta: t.headers,
198
+ fetchInit: t.fetchInit,
199
+ fetch: t.fetch
200
+ });
201
+ return new Fe({
202
+ network: e,
203
+ transport: r
204
+ });
205
+ }
206
+ function Ye(e, t) {
207
+ return "client" in t ? t.client : new Ue({
208
+ network: e,
209
+ url: t.url,
210
+ headers: t.headers,
211
+ fetch: t.fetch
212
+ });
213
+ }
214
+ function ge(e, t) {
215
+ return "client" in t ? t.client : new Me({
216
+ network: e,
217
+ url: t.url
218
+ });
219
+ }
220
+ function Ze(e) {
221
+ const t = Qe(e.network, e.grpc);
222
+ return {
223
+ network: e.network,
224
+ coreClient: t,
225
+ grpc: t,
226
+ graphql: e.graphql ? Ye(e.network, e.graphql) : void 0,
227
+ legacyJsonRpc: e.legacyJsonRpc ? ge(e.network, e.legacyJsonRpc) : void 0,
228
+ services: e.services
229
+ };
230
+ }
231
+ function Jt(e, t) {
232
+ if (!e.graphql)
233
+ throw new He(t);
234
+ return e.graphql;
235
+ }
236
+ function Xe() {
237
+ const e = "NAVI Sui SDK requires an explicit v2 gRPC/Core client. Pass { network, grpc } or an explicit legacyJsonRpc client for deprecated compatibility.", t = new Proxy(
238
+ {},
239
+ {
240
+ get() {
241
+ throw new Error(e);
242
+ }
243
+ }
244
+ );
245
+ return new Proxy(
246
+ { core: t },
247
+ {
248
+ get(r, o) {
249
+ if (o === "core")
250
+ return r.core;
251
+ if (o === "network")
252
+ return "mainnet";
253
+ throw new Error(e);
254
+ }
255
+ }
256
+ );
257
+ }
258
+ function xe(e, t = "mainnet") {
259
+ return e ? typeof e == "string" ? ge(t, { url: e }) : Ze(e) : Xe();
260
+ }
261
+ const et = 16 * 1024;
262
+ function te(e) {
263
+ return e.replace(/^0x/i, "");
264
+ }
265
+ function ae(e) {
266
+ const t = te(e), r = new Uint8Array(t.length / 2);
267
+ for (let o = 0; o < r.length; o += 1)
268
+ r[o] = parseInt(t.slice(o * 2, o * 2 + 2), 16);
269
+ return r;
270
+ }
271
+ function tt(e, t) {
272
+ return (e[t] << 8) + e[t + 1];
273
+ }
274
+ function ie(e) {
275
+ return u.vector(u.U8).serialize(Array.from(e), {
276
+ maxSize: et
277
+ });
278
+ }
279
+ function ce(e, t) {
280
+ return {
281
+ type: e,
282
+ bcs: t
283
+ };
284
+ }
285
+ function rt(e) {
286
+ return u.vector(u.U8).serialize(Array.from(new TextEncoder().encode(e))).toBytes();
287
+ }
288
+ function nt(e) {
289
+ return u.struct("PriceIdentifier", {
290
+ bytes: u.vector(u.U8)
291
+ }).serialize({
292
+ bytes: Array.from(e)
293
+ }).toBytes();
294
+ }
295
+ function ot(e) {
296
+ const t = [];
297
+ let r = 0, o = 0;
298
+ for (let n = 0; n < e.length; n += 1) {
299
+ const a = e[n];
300
+ a === "<" ? r += 1 : a === ">" ? r -= 1 : a === "," && r === 0 && (t.push(e.slice(o, n).trim()), o = n + 1);
301
+ }
302
+ return t.push(e.slice(o).trim()), t;
303
+ }
304
+ function at(e) {
305
+ const r = e.indexOf("::table::Table"), o = e.indexOf("<", r), n = e.lastIndexOf(">"), a = "::price_identifier::PriceIdentifier";
306
+ if (r < 0 || o < 0 || n <= o)
307
+ throw new Error(`Unexpected Pyth price table type: ${e}`);
308
+ const [c, i] = ot(e.slice(o + 1, n));
309
+ if (!c?.endsWith(a) || !i?.endsWith("::object::ID"))
310
+ throw new Error(`Unexpected Pyth price table type arguments: ${e}`);
311
+ return c.slice(0, -a.length);
312
+ }
313
+ function it(e) {
314
+ return Uint8Array.from(atob(e), (t) => t.charCodeAt(0));
315
+ }
316
+ class he {
317
+ constructor(t, r) {
318
+ this.endpoint = t.replace(/\/$/, ""), this.timeout = r?.timeout ?? 1e4;
319
+ }
320
+ async getLatestPriceFeeds(t) {
321
+ return (await this.get("/api/latest_price_feeds", t)).map((o) => ({
322
+ id: o.id,
323
+ getPriceUnchecked: () => ({
324
+ price: o.price.price,
325
+ conf: o.price.conf,
326
+ expo: o.price.expo,
327
+ publishTime: o.price.publish_time
328
+ })
329
+ }));
330
+ }
331
+ async getPriceFeedsUpdateData(t) {
332
+ const r = await this.get(
333
+ "/v2/updates/price/latest",
334
+ t,
335
+ {
336
+ encoding: "base64",
337
+ parsed: "false"
338
+ }
339
+ ), o = r.binary?.encoding, n = r.binary?.data ?? [];
340
+ if (o && o !== "base64")
341
+ throw new Error(`Unsupported Hermes price update encoding: ${o}`);
342
+ if (n.length === 0)
343
+ throw new Error("Hermes price update response did not include binary update data");
344
+ return n.map(it);
345
+ }
346
+ async get(t, r, o) {
347
+ const n = new AbortController(), a = setTimeout(() => n.abort(), this.timeout), c = new URL(`${this.endpoint}${t}`);
348
+ for (const [i, s] of Object.entries(o ?? {}))
349
+ c.searchParams.set(i, s);
350
+ for (const i of r)
351
+ c.searchParams.append("ids[]", te(i));
352
+ try {
353
+ const i = await fetch(c, {
354
+ signal: n.signal
355
+ });
356
+ if (!i.ok)
357
+ throw new Error(`Hermes request failed: ${i.status} ${i.statusText}`);
358
+ return await i.json();
359
+ } finally {
360
+ clearTimeout(a);
361
+ }
362
+ }
363
+ }
364
+ class ct {
365
+ constructor(t, r, o) {
366
+ this.provider = t, this.pythStateId = r, this.wormholeStateId = o, this.priceFeedObjectIdCache = /* @__PURE__ */ new Map();
367
+ }
368
+ getCoreProvider() {
369
+ const t = this.provider.core;
370
+ return t && typeof t.getObject == "function" && typeof t.getDynamicObjectField == "function" ? t : null;
371
+ }
372
+ async getMoveObjectJson(t) {
373
+ const r = this.getCoreProvider();
374
+ if (r) {
375
+ const n = await r.getObject({
376
+ objectId: t,
377
+ include: { json: !0 }
378
+ });
379
+ return n.object ? {
380
+ objectId: n.object.objectId,
381
+ type: n.object.type,
382
+ fields: n.object.json
383
+ } : null;
384
+ }
385
+ if (!this.provider.getObject)
386
+ throw new Error("Sui Pyth provider does not support getObject");
387
+ const o = await this.provider.getObject({
388
+ id: t,
389
+ options: { showContent: !0 }
390
+ });
391
+ return !o.data || !o.data.content || o.data.content.dataType !== "moveObject" ? null : {
392
+ objectId: o.data.objectId,
393
+ type: o.data.type,
394
+ fields: o.data.content.fields
395
+ };
396
+ }
397
+ async getDynamicMoveObjectJson(t, r) {
398
+ const o = this.getCoreProvider();
399
+ if (o) {
400
+ const a = await o.getDynamicObjectField({
401
+ parentId: t,
402
+ name: r,
403
+ include: { json: !0 }
404
+ });
405
+ return a.object ? {
406
+ objectId: a.object.objectId,
407
+ type: a.object.type,
408
+ fields: a.object.json
409
+ } : null;
410
+ }
411
+ if (!this.provider.getDynamicFieldObject)
412
+ throw new Error("Sui Pyth provider does not support getDynamicFieldObject");
413
+ const n = await this.provider.getDynamicFieldObject({
414
+ parentId: t,
415
+ name: r
416
+ });
417
+ return n.data ? n.data.content ? n.data.content.dataType !== "moveObject" ? null : {
418
+ objectId: n.data.objectId,
419
+ type: n.data.type,
420
+ fields: n.data.content.fields
421
+ } : {
422
+ objectId: n.data.objectId,
423
+ type: n.data.type,
424
+ fields: void 0
425
+ } : null;
426
+ }
427
+ async updatePriceFeeds(t, r, o) {
428
+ const n = await this.getPythPackageId(), a = await this.verifyVaasAndGetHotPotato(t, r, n), c = await this.getBaseUpdateFee(), i = t.splitCoins(
429
+ t.gas,
430
+ o.map(() => t.pure.u64(c))
431
+ );
432
+ return this.executePriceFeedUpdates(t, n, o, a, i);
433
+ }
434
+ async getBaseUpdateFee() {
435
+ if (this.baseUpdateFee === void 0) {
436
+ const t = await this.getMoveObjectJson(this.pythStateId);
437
+ if (!t?.fields)
438
+ throw new Error("Unable to fetch pyth state object");
439
+ this.baseUpdateFee = Number(t.fields.base_update_fee);
440
+ }
441
+ return this.baseUpdateFee;
442
+ }
443
+ async getPackageId(t) {
444
+ const r = await this.getMoveObjectJson(t);
445
+ if (r?.fields) {
446
+ const o = r.fields;
447
+ if ("upgrade_cap" in o)
448
+ return o.upgrade_cap.fields.package;
449
+ }
450
+ throw new Error(`Cannot fetch package id for object ${t}`);
451
+ }
452
+ async verifyVaas(t, r) {
453
+ const o = await this.getWormholePackageId();
454
+ return t.map((n) => {
455
+ const [a] = r.moveCall({
456
+ target: `${o}::vaa::parse_and_verify`,
457
+ arguments: [
458
+ r.object(this.wormholeStateId),
459
+ r.pure(ie(n)),
460
+ r.object(Z)
461
+ ]
462
+ });
463
+ return a;
464
+ });
465
+ }
466
+ async verifyVaasAndGetHotPotato(t, r, o) {
467
+ if (r.length > 1)
468
+ throw new Error(
469
+ "SDK does not support sending multiple accumulator messages in a single transaction"
470
+ );
471
+ const n = this.extractVaaBytesFromAccumulatorMessage(r[0]), [a] = await this.verifyVaas([n], t), [c] = t.moveCall({
472
+ target: `${o}::pyth::create_authenticated_price_infos_using_accumulator`,
473
+ arguments: [
474
+ t.object(this.pythStateId),
475
+ t.pure(ie(r[0])),
476
+ a,
477
+ t.object(Z)
478
+ ]
479
+ });
480
+ return c;
481
+ }
482
+ async executePriceFeedUpdates(t, r, o, n, a) {
483
+ const c = [];
484
+ for (const [i, s] of o.entries()) {
485
+ const l = await this.getPriceFeedObjectId(s);
486
+ if (!l)
487
+ throw new Error(`Price feed ${s} not found, please create it first`);
488
+ c.push(l), [n] = t.moveCall({
489
+ target: `${r}::pyth::update_single_price_feed`,
490
+ arguments: [
491
+ t.object(this.pythStateId),
492
+ n,
493
+ t.object(l),
494
+ a[i],
495
+ t.object(Z)
496
+ ]
497
+ });
498
+ }
499
+ return t.moveCall({
500
+ target: `${r}::hot_potato_vector::destroy`,
501
+ arguments: [n],
502
+ typeArguments: [`${r}::price_info::PriceInfo`]
503
+ }), c;
504
+ }
505
+ async getWormholePackageId() {
506
+ return this.wormholePackageId || (this.wormholePackageId = await this.getPackageId(this.wormholeStateId)), this.wormholePackageId;
507
+ }
508
+ async getPythPackageId() {
509
+ return this.pythPackageId || (this.pythPackageId = await this.getPackageId(this.pythStateId)), this.pythPackageId;
510
+ }
511
+ async getPriceFeedObjectId(t) {
512
+ const r = te(t);
513
+ if (!this.priceFeedObjectIdCache.has(r)) {
514
+ const { id: o, fieldType: n } = await this.getPriceTableInfo(), a = this.getCoreProvider() ? ce(
515
+ `${n}::price_identifier::PriceIdentifier`,
516
+ nt(ae(r))
517
+ ) : {
518
+ type: `${n}::price_identifier::PriceIdentifier`,
519
+ value: {
520
+ bytes: Array.from(ae(r))
521
+ }
522
+ }, c = await this.getDynamicMoveObjectJson(o, a);
523
+ c?.fields ? this.priceFeedObjectIdCache.set(r, c.fields.value) : this.priceFeedObjectIdCache.set(r, void 0);
524
+ }
525
+ return this.priceFeedObjectIdCache.get(r);
526
+ }
527
+ async getPriceTableInfo() {
528
+ if (!this.priceTableInfo) {
529
+ const t = this.getCoreProvider() ? ce("vector<u8>", rt("price_info")) : {
530
+ type: "vector<u8>",
531
+ value: "price_info"
532
+ }, r = await this.getDynamicMoveObjectJson(this.pythStateId, t);
533
+ if (!r?.type)
534
+ throw new Error("Price Table not found, contract may not be initialized");
535
+ this.priceTableInfo = {
536
+ id: r.objectId,
537
+ fieldType: at(r.type)
538
+ };
539
+ }
540
+ return this.priceTableInfo;
541
+ }
542
+ extractVaaBytesFromAccumulatorMessage(t) {
543
+ const o = 7 + t[6] + 1, n = tt(t, o), a = o + 2;
544
+ return t.subarray(a, a + n);
545
+ }
546
+ }
547
+ const st = "https://open-api.naviprotocol.io/api";
548
+ let J = {}, be = 0;
549
+ function lt(e) {
550
+ return e.replace(/\/+$/, "");
551
+ }
552
+ function Kt(e) {
553
+ J = {
554
+ ...J,
555
+ ...e,
556
+ services: {
557
+ ...J.services,
558
+ ...e.services
559
+ }
560
+ }, be += 1;
561
+ }
562
+ function se() {
563
+ return be;
564
+ }
565
+ function E(e) {
566
+ const t = e?.services?.naviOpenApi ?? J.services?.naviOpenApi;
567
+ return {
568
+ baseUrl: lt(t?.baseUrl ?? st),
569
+ headers: t?.headers
570
+ };
571
+ }
572
+ function M(e, t) {
573
+ const r = E(t), o = e.startsWith("/") ? e : `/${e}`;
574
+ return `${r.baseUrl}${o}`;
575
+ }
576
+ function ut(e) {
577
+ if (e instanceof Headers) {
578
+ const t = {};
579
+ return e.forEach((r, o) => {
580
+ t[o] = r;
581
+ }), t;
582
+ }
583
+ return Array.isArray(e) ? Object.fromEntries(e) : e;
584
+ }
585
+ function U(e, t) {
586
+ return {
587
+ ...ut(e),
588
+ ...t?.headers ?? {}
589
+ };
590
+ }
591
+ const V = xe();
592
+ function le(e) {
593
+ return e ? e instanceof Uint8Array ? Array.from(e) : Array.isArray(e) ? e : Array.from(Ee(e)) : [];
594
+ }
595
+ function dt(e) {
596
+ 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];
597
+ return {
598
+ effects: r.effects,
599
+ events: r.events,
600
+ error: o,
601
+ results: t.map((n) => ({
602
+ returnValues: (n.returnValues ?? []).map((a) => [le(a.bcs), ""]),
603
+ mutableReferenceOutputs: (n.mutatedReferences ?? []).map((a) => [
604
+ "",
605
+ le(a.bcs),
606
+ ""
607
+ ])
608
+ }))
609
+ };
610
+ }
611
+ async function q(e, t) {
612
+ const r = e?.core;
613
+ if (typeof r?.simulateTransaction == "function") {
614
+ const o = t.transaction ?? t.transactionBlock;
615
+ o instanceof N && o.setSenderIfNotSet(t.sender);
616
+ const n = await r.simulateTransaction({
617
+ transaction: o,
618
+ checksEnabled: !1,
619
+ include: {
620
+ effects: !0,
621
+ events: !0,
622
+ commandResults: !0
623
+ }
624
+ });
625
+ return dt(n);
626
+ }
627
+ return e.devInspectTransactionBlock({
628
+ transactionBlock: t.transactionBlock ?? t.transaction,
629
+ sender: t.sender
630
+ });
631
+ }
632
+ function we(e) {
633
+ return {
634
+ json: !!e?.showContent,
635
+ display: !!e?.showDisplay,
636
+ previousTransaction: !!e?.showPreviousTransaction,
637
+ objectBcs: !!e?.showBcs
638
+ };
639
+ }
640
+ function ve(e) {
641
+ return !e || e instanceof Error ? {
642
+ error: e instanceof Error ? { code: "notFound", error: e.message } : void 0
643
+ } : {
644
+ data: {
645
+ objectId: e.objectId,
646
+ version: e.version,
647
+ digest: e.digest,
648
+ type: e.type,
649
+ owner: e.owner,
650
+ previousTransaction: e.previousTransaction,
651
+ content: e.json === void 0 ? void 0 : {
652
+ dataType: "moveObject",
653
+ type: e.type,
654
+ fields: e.json
655
+ },
656
+ display: e.display
657
+ }
658
+ };
659
+ }
660
+ async function pt(e, t) {
661
+ const r = e?.core;
662
+ if (typeof r?.getObject == "function") {
663
+ const { object: o } = await r.getObject({
664
+ objectId: t.id,
665
+ include: we(t.options)
666
+ });
667
+ return ve(o);
668
+ }
669
+ return e.getObject(t);
670
+ }
671
+ async function mt(e, t) {
672
+ const r = e?.core;
673
+ if (typeof r?.getObjects == "function") {
674
+ const { objects: o } = await r.getObjects({
675
+ objectIds: t.ids,
676
+ include: we(t.options)
677
+ });
678
+ return o.map(ve);
679
+ }
680
+ return e.multiGetObjects(t);
681
+ }
682
+ function Ce(e) {
683
+ const t = [];
684
+ let r = !1;
151
685
  return e.forEach((o, n) => {
152
- const t = n === e.length - 1;
153
- if (typeof o == "object" && o !== null && t) {
154
- const { client: a, disableCache: s, cacheTime: i, ...c } = o;
155
- r.push(c);
686
+ const a = n === e.length - 1;
687
+ if (typeof o == "object" && o !== null && a) {
688
+ const { client: c, disableCache: i, cacheTime: s, ...l } = o;
689
+ l.__naviSdkServiceConfigVersion = se(), t.push(l), r = !0;
156
690
  } else
157
- r.push(o);
158
- }), JSON.stringify(r);
159
- }
160
- function P(e) {
161
- const r = {};
162
- return (...o) => {
163
- const n = ee(o);
164
- return r[n] || (r[n] = e(...o).finally(() => {
165
- delete r[n];
166
- })), r[n];
691
+ t.push(o);
692
+ }), r || t.push({
693
+ __naviSdkServiceConfigVersion: se()
694
+ }), JSON.stringify(t);
695
+ }
696
+ function A(e) {
697
+ const t = {};
698
+ return (...r) => {
699
+ const o = Ce(r);
700
+ return t[o] || (t[o] = e(...r).finally(() => {
701
+ delete t[o];
702
+ })), t[o];
167
703
  };
168
704
  }
169
- function M(e) {
170
- let r = {};
171
- return (...o) => {
172
- const n = o[o.length - 1], t = ee(o), a = r[t];
173
- return !n?.disableCache && typeof a?.data < "u" && (typeof n?.cacheTime > "u" || n.cacheTime > Date.now() - a.cacheAt) ? Promise.resolve(a.data) : e(...o).then((s) => (r[t] = {
174
- data: s,
705
+ function $(e) {
706
+ let t = {};
707
+ return (...r) => {
708
+ const o = r[r.length - 1], n = Ce(r), a = t[n];
709
+ 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] = {
710
+ data: c,
175
711
  cacheAt: Date.now()
176
- }, s));
712
+ }, c));
177
713
  };
178
714
  }
179
- function K(e) {
180
- return Array.isArray(e) ? e.map((r) => K(r)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
181
- (r, o) => ({
182
- ...r,
183
- [fe(o)]: K(e[o])
715
+ function x(e) {
716
+ return Array.isArray(e) ? e.map((t) => x(t)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
717
+ (t, r) => ({
718
+ ...t,
719
+ [Ve(r)]: x(e[r])
184
720
  }),
185
721
  {}
186
722
  ) : e;
187
723
  }
188
- function g(e, r) {
189
- return typeof e == "object" ? e : r(e);
724
+ function h(e, t) {
725
+ if (e == null)
726
+ throw new Error("Transaction value is required");
727
+ return typeof e == "object" ? e : t(e);
190
728
  }
191
- function je(e, r) {
192
- return typeof r == "string" ? e.object(r) : typeof r == "object" && r.$kind ? r : e.object(r.contract.pool);
729
+ function ft(e, t) {
730
+ return typeof t == "string" ? e.object(t) : typeof t == "object" && t.$kind ? t : e.object(t.contract.pool);
193
731
  }
194
- function H(e, r, o) {
732
+ function Q(e, t, r) {
195
733
  if (e.results && e.results.length > 0) {
196
734
  if (e.results[0].returnValues && e.results[0].returnValues.length > 0)
197
- return e.results[0].returnValues.map((n, t) => (r[t] || r[0]).parse(Uint8Array.from(n[0])));
735
+ return e.results[0].returnValues.map((o, n) => (t[n] || t[0]).parse(Uint8Array.from(o[0])));
198
736
  } else if (e.error)
199
737
  return console.log(`Get an error, msg: ${e.error}`), [];
200
738
  return [];
201
739
  }
202
- function k(e) {
203
- return ye(e);
740
+ function C(e) {
741
+ return K(e);
204
742
  }
205
- function te(e) {
206
- const r = (e || 0) / Math.pow(10, 27);
207
- return r > Math.pow(10, 5) ? 1 / 0 : r;
743
+ function je(e) {
744
+ const t = (e || 0) / Math.pow(10, 27);
745
+ return t > Math.pow(10, 5) ? 1 / 0 : t;
208
746
  }
209
- new x("https://hermes.pyth.network", {
747
+ new he("https://hermes.pyth.network", {
210
748
  timeout: 2e4
211
749
  });
212
- const Ie = 27, Q = (e, r) => {
213
- if (!Number(e) || !Number(r)) return new p(0);
214
- const o = new p(1).shiftedBy(1 * Ie), n = o.multipliedBy(new p(0.5));
215
- return new p(e).multipliedBy(new p(r)).plus(n).dividedBy(o).integerValue(p.ROUND_DOWN);
216
- }, D = Z ? {
217
- "User-Agent": Z
750
+ const yt = 27, ue = (e, t) => {
751
+ if (!Number(e) || !Number(t)) return new p(0);
752
+ const r = new p(1).shiftedBy(1 * yt), o = r.multipliedBy(new p(0.5));
753
+ return new p(e).multipliedBy(new p(t)).plus(o).dividedBy(r).integerValue(p.ROUND_DOWN);
754
+ }, D = oe ? {
755
+ "User-Agent": oe
218
756
  } : {};
219
- function z(e, r = "uniqueId") {
757
+ function ee(e, t = "uniqueId") {
220
758
  return e.reduce(
221
- (o, n) => (o[n[r]] = n, o),
759
+ (r, o) => (r[o[t]] = o, r),
222
760
  {}
223
761
  );
224
762
  }
225
- function X(e, r = "uniqueId") {
763
+ function de(e, t = "uniqueId") {
226
764
  return e.reduce(
227
- (o, n) => (o[n[r]] = n, o),
765
+ (r, o) => (r[o[t]] = o, r),
228
766
  {}
229
767
  );
230
768
  }
231
- function W(e, r) {
232
- const o = e.emodes.find((t) => t.emodeId === r.emodeId);
233
- if (!o)
769
+ function H(e, t) {
770
+ const r = e.emodes.find((n) => n.emodeId === t.emodeId);
771
+ if (!r)
234
772
  throw new Error("EMode not found in pool");
235
- const n = o.assets.find((t) => t.assetId === e.id);
773
+ const o = r.assets.find((n) => n.assetId === e.id);
236
774
  return {
237
775
  ...e,
238
776
  emode: {
239
- ...n,
240
- emodeId: o.emodeId
777
+ ...o,
778
+ emodeId: r.emodeId
241
779
  },
242
780
  isEMode: !0
243
781
  };
244
782
  }
245
- function Te(e) {
246
- const [r, o] = e.split("-");
247
- return !r || !o ? null : {
248
- marketKey: r,
249
- poolId: parseInt(o)
783
+ function gt(e) {
784
+ const [t, r] = e.split("-");
785
+ return !t || !r ? null : {
786
+ marketKey: t,
787
+ poolId: parseInt(r)
250
788
  };
251
789
  }
252
- function $() {
790
+ function P() {
253
791
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
254
792
  }
255
- var R = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(R || {});
256
- const q = M(
257
- P(
793
+ var z = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(z || {});
794
+ const G = $(
795
+ A(
258
796
  async (e) => {
259
- const r = (e?.markets || [U.main]).map((t) => T(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.map(
260
- (t) => t.key
261
- )}`, n = await fetch(o, { headers: D }).then((t) => t.json());
262
- return n.data.forEach((t) => {
263
- const s = n.meta.emodes.filter((f) => {
264
- const w = T(f.marketId);
265
- return t.market === w.key && f.isActive;
266
- }).filter((f) => !!f.assets.find((w) => w.assetId === t.id));
267
- t.emodes = s;
268
- const i = p(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), c = p(t.borrowedAmount).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), u = p(i).multipliedBy(t.oracle.price).toString(), m = p(c).multipliedBy(t.oracle.price).toString(), h = p(t.supplyCapCeiling).shiftedBy(-27).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), v = p.max(
269
- p(t.borrowedAmount),
270
- p(t.validBorrowAmount)
271
- ).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), y = p(h).multipliedBy(t.oracle.price).toString(), l = p(v).multipliedBy(t.oracle.price).toString();
272
- t.poolSupplyAmount = i, t.poolBorrowAmount = c, t.poolSupplyValue = u, t.poolBorrowValue = m, t.poolSupplyCapAmount = h, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = y, t.poolBorrowCapValue = l;
797
+ const t = (e?.markets || [F.main]).map((a) => _(a)), r = E(e), o = M(
798
+ `/navi/pools?env=${e?.env || "prod"}&sdk=${O.version}&market=${t.map(
799
+ (a) => a.key
800
+ )}`,
801
+ e
802
+ ), n = await fetch(o, { headers: U(D, r) }).then(
803
+ (a) => a.json()
804
+ );
805
+ return n.data.forEach((a) => {
806
+ const i = n.meta.emodes.filter((w) => {
807
+ const k = _(w.marketId);
808
+ return a.market === k.key && w.isActive;
809
+ }).filter((w) => !!w.assets.find((k) => k.assetId === a.id));
810
+ a.emodes = i;
811
+ const s = p(a.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), l = p(a.borrowedAmount).shiftedBy(-9).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), m = p(s).multipliedBy(a.oracle.price).toString(), g = p(l).multipliedBy(a.oracle.price).toString(), b = p(a.supplyCapCeiling).shiftedBy(-27).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), y = p.max(
812
+ p(a.borrowedAmount),
813
+ p(a.validBorrowAmount)
814
+ ).shiftedBy(-9).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), d = p(b).multipliedBy(a.oracle.price).toString(), f = p(y).multipliedBy(a.oracle.price).toString();
815
+ a.poolSupplyAmount = s, a.poolBorrowAmount = l, a.poolSupplyValue = m, a.poolBorrowValue = g, a.poolSupplyCapAmount = b, a.poolBorrowCapAmount = y, a.poolSupplyCapValue = d, a.poolBorrowCapValue = f;
273
816
  }), n.data;
274
817
  }
275
818
  )
276
819
  );
277
- async function S(e, r) {
278
- let o = r?.market;
820
+ async function S(e, t) {
821
+ let r = t?.market;
279
822
  if (typeof e == "string") {
280
- const a = Te(e);
281
- a && (o = a.marketKey, e = a.poolId);
823
+ const a = gt(e);
824
+ a && (r = a.marketKey, e = a.poolId);
282
825
  }
283
- const n = await q({
284
- ...r,
285
- markets: [o || O],
286
- cacheTime: b
826
+ const o = await G({
827
+ ...t,
828
+ markets: [r || R],
829
+ cacheTime: v
287
830
  });
288
831
  if (typeof e == "object")
289
832
  return e;
290
- const t = n.find((a) => typeof e == "string" ? k(a.suiCoinType) === k(e) : typeof e == "number" ? a.id === e : !1);
291
- if (!t)
833
+ const n = o.find((a) => typeof e == "string" ? C(a.suiCoinType) === C(e) : typeof e == "number" ? a.id === e : !1);
834
+ if (!n)
292
835
  throw new Error("Pool not found");
293
- return t.isDeprecated && console.log(`The lending pool for coinType ${t.suiCoinType} is going to be deprecated.`), t;
836
+ return n.isDeprecated && console.log(`The lending pool for coinType ${n.suiCoinType} is going to be deprecated.`), n;
294
837
  }
295
- const xe = M(
296
- P(async (e) => {
297
- const r = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${E.version}`;
298
- return (await fetch(r, { headers: D }).then((n) => n.json())).data;
838
+ const Qt = $(
839
+ A(async (e) => {
840
+ const t = E(e), r = M(`/navi/stats?sdk=${O.version}`, e);
841
+ return (await fetch(r, {
842
+ headers: U(D, t)
843
+ }).then((n) => n.json())).data;
299
844
  })
300
- ), et = M(
301
- P(
845
+ ), Yt = $(
846
+ A(
302
847
  async (e) => {
303
- const r = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${E.version}`;
304
- return await fetch(r, { headers: D }).then((n) => n.json());
848
+ const t = E(e), r = M(`/navi/fee?sdk=${O.version}`, e);
849
+ return await fetch(r, {
850
+ headers: U(D, t)
851
+ }).then((n) => n.json());
305
852
  }
306
853
  )
307
854
  );
308
- async function Be(e, r, o, n) {
309
- const t = await _({
310
- ...n,
311
- cacheTime: b
312
- }), a = await S(r, n), s = n?.market || O, i = n?.env || "prod";
855
+ async function ht(e, t, r, o) {
856
+ const n = await j({
857
+ ...o,
858
+ cacheTime: v
859
+ }), a = await S(t, o), c = o?.market || R, i = o?.env || "prod";
313
860
  if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
314
861
  throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
315
- const c = typeof o == "object" && o.$kind === "GasCoin";
316
- if (k(a.suiCoinType) === k("0x2::sui::SUI") && c) {
317
- if (!n?.amount)
862
+ if (C(a.suiCoinType) === C("0x2::sui::SUI") && typeof r == "object" && r?.$kind === "GasCoin") {
863
+ if (!o?.amount)
318
864
  throw new Error("Amount is required for sui coin");
319
- o = e.splitCoins(o, [n.amount]);
865
+ r = e.splitCoins(r, [o.amount]);
320
866
  }
321
- let u;
322
- return typeof n?.amount < "u" ? u = g(n.amount, e.pure.u64) : u = e.moveCall({
867
+ let s;
868
+ return typeof o?.amount < "u" ? s = h(o.amount, e.pure.u64) : s = e.moveCall({
323
869
  target: "0x2::coin::value",
324
- arguments: [g(o, e.object)],
870
+ arguments: [h(r, e.object)],
325
871
  typeArguments: [a.suiCoinType]
326
- }), n?.accountCap ? e.moveCall({
327
- target: `${t.package}::incentive_v3::deposit_with_account_cap`,
872
+ }), o?.accountCap ? e.moveCall({
873
+ target: `${n.package}::incentive_v3::deposit_with_account_cap`,
328
874
  arguments: [
329
875
  e.object("0x06"),
330
- e.object(t.storage),
876
+ e.object(n.storage),
331
877
  e.object(a.contract.pool),
332
878
  e.pure.u8(a.id),
333
- g(o, e.object),
334
- e.object(t.incentiveV2),
335
- e.object(t.incentiveV3),
336
- g(n.accountCap, e.object)
879
+ h(r, e.object),
880
+ e.object(n.incentiveV2),
881
+ e.object(n.incentiveV3),
882
+ h(o.accountCap, e.object)
337
883
  ],
338
884
  typeArguments: [a.suiCoinType]
339
885
  }) : e.moveCall({
340
- target: `${t.package}::incentive_v3::entry_deposit`,
886
+ target: `${n.package}::incentive_v3::entry_deposit`,
341
887
  arguments: [
342
888
  e.object("0x06"),
343
- e.object(t.storage),
889
+ e.object(n.storage),
344
890
  e.object(a.contract.pool),
345
891
  e.pure.u8(a.id),
346
- g(o, e.object),
347
- u,
348
- e.object(t.incentiveV2),
349
- e.object(t.incentiveV3)
892
+ h(r, e.object),
893
+ s,
894
+ e.object(n.incentiveV2),
895
+ e.object(n.incentiveV3)
350
896
  ],
351
897
  typeArguments: [a.suiCoinType]
352
- }), t.version === 2 && a.token.symbol === "SUI" && i === "prod" && s === "main" && e.moveCall({
353
- target: `${t.package}::pool::refresh_stake`,
898
+ }), n.version === 2 && a.token.symbol === "SUI" && i === "prod" && c === "main" && e.moveCall({
899
+ target: `${n.package}::pool::refresh_stake`,
354
900
  arguments: [e.object(a.contract.pool), e.object("0x05")]
355
901
  }), e;
356
902
  }
357
- async function tt(e, r, o, n) {
358
- const t = await _({
359
- ...n,
360
- cacheTime: b
361
- }), a = await S(r, n), s = g(o, e.pure.u64);
903
+ async function Zt(e, t, r, o) {
904
+ const n = await j({
905
+ ...o,
906
+ cacheTime: v
907
+ }), a = await S(t, o), c = h(r, e.pure.u64);
362
908
  let i;
363
- if (t.version === 1)
364
- if (n?.accountCap) {
365
- const [u] = e.moveCall({
366
- target: `${t.package}::incentive_v3::withdraw_with_account_cap`,
909
+ if (n.version === 1)
910
+ if (o?.accountCap) {
911
+ const [l] = e.moveCall({
912
+ target: `${n.package}::incentive_v3::withdraw_with_account_cap`,
367
913
  arguments: [
368
914
  e.object("0x06"),
369
- e.object(t.priceOracle),
370
- e.object(t.storage),
915
+ e.object(n.priceOracle),
916
+ e.object(n.storage),
371
917
  e.object(a.contract.pool),
372
918
  e.pure.u8(a.id),
373
- s,
374
- e.object(t.incentiveV2),
375
- e.object(t.incentiveV3),
376
- g(n.accountCap, e.object)
919
+ c,
920
+ e.object(n.incentiveV2),
921
+ e.object(n.incentiveV3),
922
+ h(o.accountCap, e.object)
377
923
  ],
378
924
  typeArguments: [a.suiCoinType]
379
925
  });
380
- i = u;
926
+ i = l;
381
927
  } else {
382
- const [u] = e.moveCall({
383
- target: `${t.package}::incentive_v3::withdraw`,
928
+ const [l] = e.moveCall({
929
+ target: `${n.package}::incentive_v3::withdraw`,
384
930
  arguments: [
385
931
  e.object("0x06"),
386
- e.object(t.priceOracle),
387
- e.object(t.storage),
932
+ e.object(n.priceOracle),
933
+ e.object(n.storage),
388
934
  e.object(a.contract.pool),
389
935
  e.pure.u8(a.id),
390
- s,
391
- e.object(t.incentiveV2),
392
- e.object(t.incentiveV3)
936
+ c,
937
+ e.object(n.incentiveV2),
938
+ e.object(n.incentiveV3)
393
939
  ],
394
940
  typeArguments: [a.suiCoinType]
395
941
  });
396
- i = u;
942
+ i = l;
397
943
  }
398
- else if (n?.accountCap) {
399
- const [u] = e.moveCall({
400
- target: `${t.package}::incentive_v3::withdraw_with_account_cap_v2`,
944
+ else if (o?.accountCap) {
945
+ const [l] = e.moveCall({
946
+ target: `${n.package}::incentive_v3::withdraw_with_account_cap_v2`,
401
947
  arguments: [
402
948
  e.object("0x06"),
403
- e.object(t.priceOracle),
404
- e.object(t.storage),
949
+ e.object(n.priceOracle),
950
+ e.object(n.storage),
405
951
  e.object(a.contract.pool),
406
952
  e.pure.u8(a.id),
407
- s,
408
- e.object(t.incentiveV2),
409
- e.object(t.incentiveV3),
410
- g(n.accountCap, e.object),
953
+ c,
954
+ e.object(n.incentiveV2),
955
+ e.object(n.incentiveV3),
956
+ h(o.accountCap, e.object),
411
957
  e.object("0x05")
412
958
  ],
413
959
  typeArguments: [a.suiCoinType]
414
960
  });
415
- i = u;
961
+ i = l;
416
962
  } else {
417
- const [u] = e.moveCall({
418
- target: `${t.package}::incentive_v3::withdraw_v2`,
963
+ const [l] = e.moveCall({
964
+ target: `${n.package}::incentive_v3::withdraw_v2`,
419
965
  arguments: [
420
966
  e.object("0x06"),
421
- e.object(t.priceOracle),
422
- e.object(t.storage),
967
+ e.object(n.priceOracle),
968
+ e.object(n.storage),
423
969
  e.object(a.contract.pool),
424
970
  e.pure.u8(a.id),
425
- s,
426
- e.object(t.incentiveV2),
427
- e.object(t.incentiveV3),
971
+ c,
972
+ e.object(n.incentiveV2),
973
+ e.object(n.incentiveV3),
428
974
  e.object("0x05")
429
975
  ],
430
976
  typeArguments: [a.suiCoinType]
431
977
  });
432
- i = u;
978
+ i = l;
433
979
  }
434
980
  return e.moveCall({
435
981
  target: "0x2::coin::from_balance",
@@ -437,85 +983,85 @@ async function tt(e, r, o, n) {
437
983
  typeArguments: [a.suiCoinType]
438
984
  });
439
985
  }
440
- async function ot(e, r, o, n) {
441
- const t = await _({
442
- ...n,
443
- cacheTime: b
444
- }), a = await S(r, n);
986
+ async function Xt(e, t, r, o) {
987
+ const n = await j({
988
+ ...o,
989
+ cacheTime: v
990
+ }), a = await S(t, o);
445
991
  if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
446
992
  throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
447
- const s = g(o, e.pure.u64);
993
+ const c = h(r, e.pure.u64);
448
994
  let i;
449
- if (t.version === 1)
450
- if (n?.accountCap) {
451
- const [u] = e.moveCall({
452
- target: `${t.package}::incentive_v3::borrow_with_account_cap`,
995
+ if (n.version === 1)
996
+ if (o?.accountCap) {
997
+ const [l] = e.moveCall({
998
+ target: `${n.package}::incentive_v3::borrow_with_account_cap`,
453
999
  arguments: [
454
1000
  e.object("0x06"),
455
- e.object(t.priceOracle),
456
- e.object(t.storage),
1001
+ e.object(n.priceOracle),
1002
+ e.object(n.storage),
457
1003
  e.object(a.contract.pool),
458
1004
  e.pure.u8(a.id),
459
- s,
460
- e.object(t.incentiveV2),
461
- e.object(t.incentiveV3),
462
- g(n.accountCap, e.object)
1005
+ c,
1006
+ e.object(n.incentiveV2),
1007
+ e.object(n.incentiveV3),
1008
+ h(o.accountCap, e.object)
463
1009
  ],
464
1010
  typeArguments: [a.suiCoinType]
465
1011
  });
466
- i = u;
1012
+ i = l;
467
1013
  } else {
468
- const [u] = e.moveCall({
469
- target: `${t.package}::incentive_v3::borrow`,
1014
+ const [l] = e.moveCall({
1015
+ target: `${n.package}::incentive_v3::borrow`,
470
1016
  arguments: [
471
1017
  e.object("0x06"),
472
- e.object(t.priceOracle),
473
- e.object(t.storage),
1018
+ e.object(n.priceOracle),
1019
+ e.object(n.storage),
474
1020
  e.object(a.contract.pool),
475
1021
  e.pure.u8(a.id),
476
- s,
477
- e.object(t.incentiveV2),
478
- e.object(t.incentiveV3)
1022
+ c,
1023
+ e.object(n.incentiveV2),
1024
+ e.object(n.incentiveV3)
479
1025
  ],
480
1026
  typeArguments: [a.suiCoinType]
481
1027
  });
482
- i = u;
1028
+ i = l;
483
1029
  }
484
- else if (n?.accountCap) {
485
- const [u] = e.moveCall({
486
- target: `${t.package}::incentive_v3::borrow_with_account_cap_v2`,
1030
+ else if (o?.accountCap) {
1031
+ const [l] = e.moveCall({
1032
+ target: `${n.package}::incentive_v3::borrow_with_account_cap_v2`,
487
1033
  arguments: [
488
1034
  e.object("0x06"),
489
- e.object(t.priceOracle),
490
- e.object(t.storage),
1035
+ e.object(n.priceOracle),
1036
+ e.object(n.storage),
491
1037
  e.object(a.contract.pool),
492
1038
  e.pure.u8(a.id),
493
- s,
494
- e.object(t.incentiveV2),
495
- e.object(t.incentiveV3),
496
- g(n.accountCap, e.object),
1039
+ c,
1040
+ e.object(n.incentiveV2),
1041
+ e.object(n.incentiveV3),
1042
+ h(o.accountCap, e.object),
497
1043
  e.object("0x05")
498
1044
  ],
499
1045
  typeArguments: [a.suiCoinType]
500
1046
  });
501
- i = u;
1047
+ i = l;
502
1048
  } else {
503
- const [u] = e.moveCall({
504
- target: `${t.package}::incentive_v3::borrow_v2`,
1049
+ const [l] = e.moveCall({
1050
+ target: `${n.package}::incentive_v3::borrow_v2`,
505
1051
  arguments: [
506
1052
  e.object("0x06"),
507
- e.object(t.priceOracle),
508
- e.object(t.storage),
1053
+ e.object(n.priceOracle),
1054
+ e.object(n.storage),
509
1055
  e.object(a.contract.pool),
510
1056
  e.pure.u8(a.id),
511
- s,
512
- e.object(t.incentiveV2),
513
- e.object(t.incentiveV3),
1057
+ c,
1058
+ e.object(n.incentiveV2),
1059
+ e.object(n.incentiveV3),
514
1060
  e.object("0x05")
515
1061
  ],
516
1062
  typeArguments: [a.suiCoinType]
517
1063
  });
518
- i = u;
1064
+ i = l;
519
1065
  }
520
1066
  return e.moveCall({
521
1067
  target: "0x2::coin::from_balance",
@@ -523,94 +1069,94 @@ async function ot(e, r, o, n) {
523
1069
  typeArguments: [a.suiCoinType]
524
1070
  });
525
1071
  }
526
- async function rt(e, r, o, n) {
527
- const t = await _({
528
- ...n,
529
- cacheTime: b
530
- }), a = await S(r, n), s = typeof o == "object" && o.$kind === "GasCoin";
531
- if (k(a.suiCoinType) === k("0x2::sui::SUI") && s) {
532
- if (!n?.amount)
1072
+ async function xt(e, t, r, o) {
1073
+ const n = await j({
1074
+ ...o,
1075
+ cacheTime: v
1076
+ }), a = await S(t, o);
1077
+ if (C(a.suiCoinType) === C("0x2::sui::SUI") && typeof r == "object" && r?.$kind === "GasCoin") {
1078
+ if (!o?.amount)
533
1079
  throw new Error("Amount is required for sui coin");
534
- o = e.splitCoins(o, [n.amount]);
1080
+ r = e.splitCoins(r, [o.amount]);
535
1081
  }
536
- let i;
537
- if (typeof n?.amount < "u" ? i = g(n.amount, e.pure.u64) : i = e.moveCall({
1082
+ let c;
1083
+ if (typeof o?.amount < "u" ? c = h(o.amount, e.pure.u64) : c = e.moveCall({
538
1084
  target: "0x2::coin::value",
539
- arguments: [g(o, e.object)],
1085
+ arguments: [h(r, e.object)],
540
1086
  typeArguments: [a.suiCoinType]
541
- }), n?.accountCap) {
542
- const [c] = e.moveCall({
543
- target: `${t.package}::incentive_v3::repay_with_account_cap`,
1087
+ }), o?.accountCap) {
1088
+ const [i] = e.moveCall({
1089
+ target: `${n.package}::incentive_v3::repay_with_account_cap`,
544
1090
  arguments: [
545
1091
  e.object("0x06"),
546
- e.object(t.priceOracle),
547
- e.object(t.storage),
1092
+ e.object(n.priceOracle),
1093
+ e.object(n.storage),
548
1094
  e.object(a.contract.pool),
549
1095
  e.pure.u8(a.id),
550
- g(o, e.object),
551
- e.object(t.incentiveV2),
552
- e.object(t.incentiveV3),
553
- g(n.accountCap, e.object)
1096
+ h(r, e.object),
1097
+ e.object(n.incentiveV2),
1098
+ e.object(n.incentiveV3),
1099
+ h(o.accountCap, e.object)
554
1100
  ],
555
1101
  typeArguments: [a.suiCoinType]
556
1102
  });
557
1103
  return e.moveCall({
558
1104
  target: "0x2::coin::from_balance",
559
- arguments: [c],
1105
+ arguments: [i],
560
1106
  typeArguments: [a.suiCoinType]
561
1107
  });
562
1108
  } else
563
1109
  return e.moveCall({
564
- target: `${t.package}::incentive_v3::entry_repay`,
1110
+ target: `${n.package}::incentive_v3::entry_repay`,
565
1111
  arguments: [
566
1112
  e.object("0x06"),
567
- e.object(t.priceOracle),
568
- e.object(t.storage),
1113
+ e.object(n.priceOracle),
1114
+ e.object(n.storage),
569
1115
  e.object(a.contract.pool),
570
1116
  e.pure.u8(a.id),
571
- g(o, e.object),
572
- i,
573
- e.object(t.incentiveV2),
574
- e.object(t.incentiveV3)
1117
+ h(r, e.object),
1118
+ c,
1119
+ e.object(n.incentiveV2),
1120
+ e.object(n.incentiveV3)
575
1121
  ],
576
1122
  typeArguments: [a.suiCoinType]
577
1123
  }), e;
578
1124
  }
579
- const nt = M(
580
- P(
1125
+ const er = $(
1126
+ A(
581
1127
  async (e) => {
582
- const r = await _({
1128
+ const t = await j({
583
1129
  ...e
584
- });
1130
+ }), r = e?.client ?? V;
585
1131
  if (e?.address && typeof e?.asset < "u")
586
1132
  try {
587
- const t = await S(e.asset, e), a = e?.client ?? V, s = new F();
588
- s.moveCall({
589
- target: `${r.package}::incentive_v3::get_borrow_fee_v2`,
1133
+ const a = await S(e.asset, e), c = new N();
1134
+ c.moveCall({
1135
+ target: `${t.package}::incentive_v3::get_borrow_fee_v2`,
590
1136
  arguments: [
591
- s.object(r.incentiveV3),
592
- s.pure.address(e.address),
593
- s.pure.u8(t.id),
594
- s.pure.u64(1e4)
1137
+ c.object(t.incentiveV3),
1138
+ c.pure.address(e.address),
1139
+ c.pure.u8(a.id),
1140
+ c.pure.u64(1e4)
595
1141
  ],
596
1142
  typeArguments: []
597
1143
  });
598
- const i = await a.devInspectTransactionBlock({
599
- transactionBlock: s,
1144
+ const i = await q(r, {
1145
+ transactionBlock: c,
600
1146
  sender: e.address
601
- }), c = H(i, [C.u64()]);
602
- return (Number(c[0]) || 0) / 100;
603
- } catch (t) {
604
- console.error(t);
1147
+ }), s = Q(i, [u.u64()]);
1148
+ return (Number(s[0]) || 0) / 100;
1149
+ } catch (a) {
1150
+ console.error(a);
605
1151
  }
606
- const n = (await V.getObject({
607
- id: r.incentiveV3,
1152
+ const n = (await pt(r, {
1153
+ id: t.incentiveV3,
608
1154
  options: { showType: !0, showOwner: !0, showContent: !0 }
609
1155
  })).data.content.fields.borrow_fee_rate;
610
1156
  return Number(n) / 100;
611
1157
  }
612
1158
  )
613
- ), O = "main", U = {
1159
+ ), R = "main", F = {
614
1160
  main: {
615
1161
  id: 0,
616
1162
  key: "main",
@@ -632,487 +1178,561 @@ const nt = M(
632
1178
  name: "Sui Eco Market"
633
1179
  }
634
1180
  };
635
- class Ae {
636
- constructor(r, o) {
1181
+ class bt {
1182
+ constructor(t, r) {
637
1183
  this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
638
1184
  marketTotalSupplyValue: "0",
639
1185
  marketTotalBorrowValue: "0"
640
- }, this.config = T(r), this.initPools(o);
1186
+ }, this.config = _(t), this.initPools(r);
641
1187
  }
642
1188
  get overview() {
643
1189
  return this._overview;
644
1190
  }
645
- initPools(r) {
646
- const o = z(this.pools), n = X(this.emodes), t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
647
- let s = p(0), i = p(0);
648
- r.forEach((c) => {
649
- if (!this.checkMarket(c.market)) {
650
- console.warn(`Pool is not in market ${this.config.name}`, c);
1191
+ initPools(t) {
1192
+ const r = ee(this.pools), o = de(this.emodes), n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
1193
+ let c = p(0), i = p(0);
1194
+ t.forEach((s) => {
1195
+ if (!this.checkMarket(s.market)) {
1196
+ console.warn(`Pool is not in market ${this.config.name}`, s);
651
1197
  return;
652
1198
  }
653
- o[c.uniqueId] || this.pools.push(c), c?.emodes?.forEach((m) => {
654
- n[m.uniqueId] || this.emodes.push(m), m.assets.forEach((h) => {
655
- h.isDebt && m.assets.find(
656
- (y) => y.isCollateral && y.ltv > 0 && y.assetId !== c.id
657
- ) && t.add(c.uniqueId), h.isCollateral && m.assets.find((y) => y.isDebt && y.assetId !== c.id) && a.add(c.uniqueId);
1199
+ r[s.uniqueId] || this.pools.push(s), s?.emodes?.forEach((m) => {
1200
+ o[m.uniqueId] || this.emodes.push(m), m.assets.forEach((g) => {
1201
+ g.isDebt && m.assets.find(
1202
+ (y) => y.isCollateral && y.ltv > 0 && y.assetId !== s.id
1203
+ ) && n.add(s.uniqueId), g.isCollateral && m.assets.find((y) => y.isDebt && y.assetId !== s.id) && a.add(s.uniqueId);
658
1204
  });
659
- }), i = i.plus(c.poolBorrowValue), s = s.plus(c.poolSupplyValue);
660
- }), this.poolMap = z(this.pools, "id"), this.emodeMap = X(this.emodes, "emodeId"), this.emodes.forEach((c) => {
661
- const u = this.getEModePools(c.emodeId);
662
- this.emodePools.push(...u);
1205
+ }), i = i.plus(s.poolBorrowValue), c = c.plus(s.poolSupplyValue);
1206
+ }), this.poolMap = ee(this.pools, "id"), this.emodeMap = de(this.emodes, "emodeId"), this.emodes.forEach((s) => {
1207
+ const l = this.getEModePools(s.emodeId);
1208
+ this.emodePools.push(...l);
663
1209
  }), this._overview = {
664
- marketTotalSupplyValue: s.toString(),
1210
+ marketTotalSupplyValue: c.toString(),
665
1211
  marketTotalBorrowValue: i.toString()
666
- }, this.emodeBorrowablePools = this.pools.filter((c) => t.has(c.uniqueId)), this.emodeSupplyablePools = this.pools.filter((c) => a.has(c.uniqueId));
1212
+ }, this.emodeBorrowablePools = this.pools.filter((s) => n.has(s.uniqueId)), this.emodeSupplyablePools = this.pools.filter((s) => a.has(s.uniqueId));
667
1213
  }
668
- getEMode(r) {
669
- return this.emodeMap[r] || null;
1214
+ getEMode(t) {
1215
+ return this.emodeMap[t] || null;
670
1216
  }
671
- getEModeRelatePools(r, o) {
672
- const { collateral: n, debt: t, emodeId: a } = o || {}, s = [];
673
- return r.emodes.forEach((i) => {
674
- typeof a == "number" && a !== i.emodeId || i.assets.forEach((c) => {
675
- typeof n == "boolean" && n && c.isCollateral && c.assetId === r.id && s.push(this.poolMap[c.assetId]), typeof t == "boolean" && t && c.isDebt && c.assetId === r.id && s.push(this.poolMap[c.assetId]);
1217
+ getEModeRelatePools(t, r) {
1218
+ const { collateral: o, debt: n, emodeId: a } = r || {}, c = [];
1219
+ return t.emodes.forEach((i) => {
1220
+ typeof a == "number" && a !== i.emodeId || i.assets.forEach((s) => {
1221
+ typeof o == "boolean" && o && s.isCollateral && s.assetId === t.id && c.push(this.poolMap[s.assetId]), typeof n == "boolean" && n && s.isDebt && s.assetId === t.id && c.push(this.poolMap[s.assetId]);
676
1222
  });
677
- }), s;
1223
+ }), c;
678
1224
  }
679
- getEModePools(r) {
680
- const o = this.getEMode(r);
681
- return o ? o.assets.map((t) => t.assetId).map((t) => this.poolMap[t]).filter((t) => !!t).map((t) => {
682
- const a = o.assets.find((s) => s.assetId === t.id);
1225
+ getEModePools(t) {
1226
+ const r = this.getEMode(t);
1227
+ return r ? r.assets.map((n) => n.assetId).map((n) => this.poolMap[n]).filter((n) => !!n).map((n) => {
1228
+ const a = r.assets.find((c) => c.assetId === n.id);
683
1229
  return {
684
- ...t,
1230
+ ...n,
685
1231
  emode: {
686
1232
  ...a,
687
- emodeId: o.emodeId
1233
+ emodeId: r.emodeId
688
1234
  },
689
1235
  isEMode: !0
690
1236
  };
691
1237
  }) : [];
692
1238
  }
693
- checkMarket(r) {
694
- let o = !1;
695
- return typeof r == "number" && r === this.config.id && (o = !0), typeof r == "string" && r === this.config.key && (o = !0), typeof r == "object" && r.id === this.config.id && (o = !0), o;
1239
+ checkMarket(t) {
1240
+ let r = !1;
1241
+ return typeof t == "number" && t === this.config.id && (r = !0), typeof t == "string" && t === this.config.key && (r = !0), typeof t == "object" && t.id === this.config.id && (r = !0), r;
696
1242
  }
697
1243
  }
698
- const T = (e) => {
699
- const o = Object.values(U).find((n) => typeof e == "number" ? n.id === e : typeof e == "string" ? n.key === e : n.id === e.id);
700
- if (!o)
1244
+ const _ = (e) => {
1245
+ const r = Object.values(F).find((o) => typeof e == "number" ? o.id === e : typeof e == "string" ? o.key === e : o.id === e.id);
1246
+ if (!r)
701
1247
  throw new Error("Market not found");
702
- return o;
703
- }, $e = M(
704
- P(
705
- async (e, r) => {
706
- const o = await q({
1248
+ return r;
1249
+ }, wt = $(
1250
+ A(
1251
+ async (e, t) => {
1252
+ const r = await G({
707
1253
  cacheTime: 6e4,
708
- ...r,
1254
+ ...t,
709
1255
  markets: e
710
1256
  });
711
- return e.map((n) => {
712
- const t = T(n), a = o.filter((s) => s.market === t.key);
713
- return new Ae(n, a);
1257
+ return e.map((o) => {
1258
+ const n = _(o), a = r.filter((c) => c.market === n.key);
1259
+ return new bt(o, a);
714
1260
  });
715
1261
  }
716
1262
  )
717
- ), at = M(
718
- P(
719
- async (e, r) => (await $e([e], r))[0]
1263
+ ), tr = $(
1264
+ A(
1265
+ async (e, t) => (await wt([e], t))[0]
720
1266
  )
721
- ), _ = M(
722
- P(
1267
+ ), j = $(
1268
+ A(
723
1269
  async (e) => {
724
- const r = T(e?.market || O), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.key}`;
725
- return (await fetch(o, { headers: D }).then((t) => t.json())).data;
1270
+ const t = _(e?.market || R), r = E(e), o = M(
1271
+ `/navi/config?env=${e?.env || "prod"}&sdk=${O.version}&market=${t.key}`,
1272
+ e
1273
+ );
1274
+ return (await fetch(o, {
1275
+ headers: U(D, r)
1276
+ }).then((a) => a.json())).data;
726
1277
  }
727
1278
  )
728
- ), b = 1e3 * 60 * 5;
729
- async function Pe(e, r) {
730
- const o = await _({
731
- cacheTime: b,
732
- ...r
1279
+ ), v = 1e3 * 60 * 5;
1280
+ async function vt(e, t) {
1281
+ const r = await j({
1282
+ cacheTime: v,
1283
+ ...t
733
1284
  });
734
1285
  return e.moveCall({
735
- target: `${o.package}::lending::create_account`,
1286
+ target: `${r.package}::lending::create_account`,
736
1287
  arguments: []
737
1288
  });
738
1289
  }
739
- async function Se(e, r, o) {
740
- const n = await _({
741
- cacheTime: b,
742
- ...o
1290
+ async function Ct(e, t, r) {
1291
+ const o = await j({
1292
+ cacheTime: v,
1293
+ ...r
743
1294
  });
744
1295
  return e.moveCall({
745
- target: `${n.package}::account::account_owner`,
746
- arguments: [r]
1296
+ target: `${o.package}::account::account_owner`,
1297
+ arguments: [t]
747
1298
  });
748
1299
  }
749
- async function Me(e, r, o) {
750
- const n = await _({
751
- ...o,
752
- cacheTime: b
1300
+ async function jt(e, t, r) {
1301
+ const o = await j({
1302
+ ...r,
1303
+ cacheTime: v
753
1304
  });
754
- return o?.accountCap ? e.moveCall({
755
- target: `${n.package}::lending::enter_emode_with_account_cap`,
1305
+ return r?.accountCap ? e.moveCall({
1306
+ target: `${o.package}::lending::enter_emode_with_account_cap`,
756
1307
  arguments: [
757
- e.object(n.storage),
758
- g(r, e.pure.u64),
759
- g(o.accountCap, e.object)
1308
+ e.object(o.storage),
1309
+ h(t, e.pure.u64),
1310
+ h(r.accountCap, e.object)
760
1311
  ]
761
1312
  }) : e.moveCall({
762
- target: `${n.package}::lending::enter_emode`,
763
- arguments: [e.object(n.storage), g(r, e.pure.u64)]
1313
+ target: `${o.package}::lending::enter_emode`,
1314
+ arguments: [e.object(o.storage), h(t, e.pure.u64)]
764
1315
  }), e;
765
1316
  }
766
- async function it(e, r) {
767
- const o = await _({
768
- ...r,
769
- cacheTime: b
1317
+ async function rr(e, t) {
1318
+ const r = await j({
1319
+ ...t,
1320
+ cacheTime: v
770
1321
  });
771
- return r?.accountCap ? e.moveCall({
772
- target: `${o.package}::lending::exit_emode_with_account_cap`,
773
- arguments: [e.object(o.storage), g(r.accountCap, e.object)]
1322
+ return t?.accountCap ? e.moveCall({
1323
+ target: `${r.package}::lending::exit_emode_with_account_cap`,
1324
+ arguments: [e.object(r.storage), h(t.accountCap, e.object)]
774
1325
  }) : e.moveCall({
775
- target: `${o.package}::lending::exit_emode`,
776
- arguments: [e.object(o.storage)]
1326
+ target: `${r.package}::lending::exit_emode`,
1327
+ arguments: [e.object(r.storage)]
777
1328
  }), e;
778
1329
  }
779
- async function ct(e, r, o) {
780
- const n = await _({
781
- cacheTime: b,
782
- ...o
783
- }), t = await Pe(e, o);
784
- await Me(e, r, {
785
- ...o,
786
- accountCap: t
1330
+ async function nr(e, t, r) {
1331
+ const o = await j({
1332
+ cacheTime: v,
1333
+ ...r
1334
+ }), n = await vt(e, r);
1335
+ await jt(e, t, {
1336
+ ...r,
1337
+ accountCap: n
787
1338
  });
788
- const a = await T(o?.market || O), s = await Se(e, t, o);
1339
+ const a = await _(r?.market || R), c = await Ct(e, n, r);
789
1340
  return e.moveCall({
790
- target: `${n.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
1341
+ target: `${o.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
791
1342
  arguments: [
792
- e.object(n.emode.contract.registryObject),
793
- s,
794
- g(a.id, e.pure.u64),
795
- g(r, e.pure.u64)
1343
+ e.object(o.emode.contract.registryObject),
1344
+ c,
1345
+ h(a.id, e.pure.u64),
1346
+ h(t, e.pure.u64)
796
1347
  ]
797
- }), t;
798
- }
799
- const oe = M(
800
- P(
801
- async (e, r) => {
802
- const o = await _({
803
- cacheTime: b,
804
- ...r
805
- }), n = new F(), t = r?.client ?? V;
806
- n.moveCall({
807
- target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
808
- arguments: [n.object(o.emode.contract.registryObject), n.pure.address(e)]
1348
+ }), n;
1349
+ }
1350
+ const ke = $(
1351
+ A(
1352
+ async (e, t) => {
1353
+ const r = await j({
1354
+ cacheTime: v,
1355
+ ...t
1356
+ }), o = new N(), n = t?.client ?? V;
1357
+ o.moveCall({
1358
+ target: `${r.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
1359
+ arguments: [o.object(r.emode.contract.registryObject), o.pure.address(e)]
809
1360
  });
810
- const s = (await t.devInspectTransactionBlock({
811
- transactionBlock: n,
1361
+ const c = (await q(n, {
1362
+ transactionBlock: o,
812
1363
  sender: e
813
- })).results[0].returnValues, i = C.vector(C.u64()).parse(Uint8Array.from(s[0][0])), c = C.vector(C.u64()).parse(Uint8Array.from(s[1][0])), u = C.vector(C.Address).parse(Uint8Array.from(s[2][0]));
814
- return i.map((m, h) => ({
1364
+ })).results[0].returnValues, i = u.vector(u.u64()).parse(Uint8Array.from(c[0][0])), s = u.vector(u.u64()).parse(Uint8Array.from(c[1][0])), l = u.vector(u.Address).parse(Uint8Array.from(c[2][0]));
1365
+ return i.map((m, g) => ({
815
1366
  marketId: Number(m),
816
- emodeId: Number(c[h]),
817
- accountCap: u[h].toString()
1367
+ emodeId: Number(s[g]),
1368
+ accountCap: l[g].toString()
818
1369
  }));
819
1370
  }
820
1371
  )
821
1372
  );
822
- function st(e) {
823
- return `${T(e.marketId).key}-${e.emodeId}`;
1373
+ function or(e) {
1374
+ return `${_(e.marketId).key}-${e.emodeId}`;
1375
+ }
1376
+ function kt(e, t) {
1377
+ return e.coinType ? e.coinType : t || (typeof e.type == "string" ? e.type.match(/::coin::Coin<(.+)>$/) : null)?.[1];
1378
+ }
1379
+ function pe(e, t) {
1380
+ const r = kt(e, t), o = e.coinObjectId ?? e.objectId;
1381
+ return !r || !o || e.balance === void 0 || e.balance === null ? null : {
1382
+ ...e,
1383
+ coinType: C(r),
1384
+ coinObjectId: o
1385
+ };
824
1386
  }
825
- function lt(e, r, o) {
826
- const n = typeof o?.balance == "number", t = n ? o.balance : 0;
1387
+ function ar(e, t, r) {
1388
+ const o = typeof r?.balance == "number", n = o ? r.balance : 0;
827
1389
  let a = 0;
828
- const s = [];
1390
+ const c = [];
829
1391
  let i = "";
830
- if (r.sort((c, u) => Number(u.balance) - Number(c.balance)).forEach((c) => {
831
- if (!(n && a >= t) && Number(c.balance) !== 0) {
832
- if (i || (i = c.coinType), i !== c.coinType)
1392
+ if (t.sort((s, l) => Number(l.balance) - Number(s.balance)).forEach((s) => {
1393
+ if (!(o && a >= n) && Number(s.balance) !== 0) {
1394
+ if (i || (i = s.coinType), i !== s.coinType)
833
1395
  throw new Error("All coins must be of the same type");
834
- a += Number(c.balance), s.push(c.coinObjectId);
1396
+ a += Number(s.balance), c.push(s.coinObjectId);
835
1397
  }
836
- }), s.length === 0)
1398
+ }), c.length === 0)
837
1399
  throw new Error("No coins to merge");
838
- if (n && a < t)
1400
+ if (o && a < n)
839
1401
  throw new Error(
840
- `Balance is less than the specified balance: ${a} < ${t}`
1402
+ `Balance is less than the specified balance: ${a} < ${n}`
841
1403
  );
842
- return k(i) === k("0x2::sui::SUI") && o?.useGasCoin ? n ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (s.length === 1 ? e.object(s[0]) : e.mergeCoins(s[0], s.slice(1)), n ? e.splitCoins(s[0], [e.pure.u64(t)]) : s[0]);
1404
+ 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]);
843
1405
  }
844
- async function re(e, r, o, n, t, a, s) {
845
- const i = await _({
846
- ...s,
847
- cacheTime: b
848
- }), c = await S(o, s);
1406
+ async function Ie(e, t, r, o, n, a, c) {
1407
+ const i = await j({
1408
+ ...c,
1409
+ cacheTime: v
1410
+ }), s = await S(r, c);
849
1411
  return e.moveCall({
850
1412
  target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
851
1413
  arguments: [
852
1414
  e.object("0x06"),
853
1415
  e.object(i.storage),
854
1416
  e.object(i.oracle.priceOracle),
855
- je(e, c),
856
- g(r, e.pure.address),
857
- g(c.id, e.pure.u8),
858
- g(n, e.pure.u64),
859
- g(t, e.pure.u64),
860
- g(a, e.pure.bool)
1417
+ ft(e, s),
1418
+ h(t, e.pure.address),
1419
+ h(s.id, e.pure.u8),
1420
+ h(o, e.pure.u64),
1421
+ h(n, e.pure.u64),
1422
+ h(a, e.pure.bool)
861
1423
  ],
862
- typeArguments: [c.suiCoinType]
1424
+ typeArguments: [s.suiCoinType]
863
1425
  });
864
1426
  }
865
- async function Ve(e, r, o) {
866
- return re(e, r, 0, 0, 0, !1, o);
1427
+ async function It(e, t, r) {
1428
+ return Ie(e, t, 0, 0, 0, !1, r);
867
1429
  }
868
- async function ne(e, r, o) {
869
- const n = new F(), t = o?.client ?? V, a = await q({
870
- ...o,
871
- markets: Object.values(U)
872
- }), s = z(a), c = Array.from(new Set(r.map((l) => l.market))).map((l) => T(l));
873
- for (const l of c) {
874
- const f = await _({
875
- ...o,
876
- cacheTime: b,
877
- market: l.key
1430
+ async function _e(e, t, r) {
1431
+ const o = new N(), n = r?.client ?? V, a = await G({
1432
+ ...r,
1433
+ markets: Object.values(F)
1434
+ }), c = ee(a), s = Array.from(new Set(t.map((d) => d.market))).map((d) => _(d));
1435
+ for (const d of s) {
1436
+ const f = await j({
1437
+ ...r,
1438
+ cacheTime: v,
1439
+ market: d.key
878
1440
  });
879
- n.moveCall({
1441
+ o.moveCall({
880
1442
  target: `${f.uiGetter}::getter::get_reserve_data`,
881
- arguments: [n.object(f.storage)]
1443
+ arguments: [o.object(f.storage)]
882
1444
  });
883
1445
  }
884
- for (let l of r) {
885
- const f = await _({
886
- ...o,
887
- cacheTime: b,
888
- market: l.market
1446
+ for (let d of t) {
1447
+ const f = await j({
1448
+ ...r,
1449
+ cacheTime: v,
1450
+ market: d.market
889
1451
  });
890
- n.moveCall({
1452
+ o.moveCall({
891
1453
  target: `${f.uiGetter}::getter_unchecked::get_user_state`,
892
- arguments: [n.object(f.storage), n.pure.address(l.address)]
1454
+ arguments: [o.object(f.storage), o.pure.address(d.address)]
893
1455
  });
894
1456
  }
895
- const m = (await t.devInspectTransactionBlock({
896
- transactionBlock: n,
1457
+ const m = (await q(n, {
1458
+ transactionBlock: o,
897
1459
  sender: e
898
- })).results || [], h = {};
899
- c.forEach((l, f) => {
1460
+ })).results || [], g = {};
1461
+ s.forEach((d, f) => {
900
1462
  try {
901
- const w = m[f]?.returnValues?.map((B) => C.vector(ve).parse(Uint8Array.from(B[0])))[0] || [], I = {};
902
- for (const B of w)
903
- I[B.id] = {
904
- supplyIndex: B.supply_index,
905
- borrowIndex: B.borrow_index
1463
+ const w = m[f]?.returnValues?.map((T) => u.vector(Re).parse(Uint8Array.from(T[0])))[0] || [], k = {};
1464
+ for (const T of w)
1465
+ k[T.id] = {
1466
+ supplyIndex: T.supply_index,
1467
+ borrowIndex: T.borrow_index
906
1468
  };
907
- h[l.key] = I;
1469
+ g[d.key] = k;
908
1470
  } catch (w) {
909
1471
  console.warn(
910
- `[@naviprotocol/lending] Failed to decode reserve data for market "${l.key}", falling back to open-api pool indices`,
1472
+ `[@naviprotocol/lending] Failed to decode reserve data for market "${d.key}", falling back to open-api pool indices`,
911
1473
  w
912
1474
  );
913
1475
  }
914
1476
  });
915
- const v = m.slice(c.length).map((l) => l.returnValues?.map((f) => C.vector(we).parse(Uint8Array.from(f[0])))[0] || []), y = [];
916
- return v.forEach((l, f) => {
917
- const w = r[f], I = T(w.market), B = h[I.key] || {};
918
- l.forEach((j) => {
919
- if (j.supply_balance === "0" && j.borrow_balance === "0" && (w.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
1477
+ const b = m.slice(s.length).map((d) => d.returnValues?.map((f) => u.vector(Le).parse(Uint8Array.from(f[0])))[0] || []), y = [];
1478
+ return b.forEach((d, f) => {
1479
+ const w = t[f], k = _(w.market), T = g[k.key] || {};
1480
+ d.forEach((I) => {
1481
+ if (I.supply_balance === "0" && I.borrow_balance === "0" && (w.emodeId === void 0 || !r?.includeZeroBalanceEmodePositions))
920
1482
  return;
921
- const A = s[`${I.key}-${j.asset_id}`];
922
- if (!A)
1483
+ const B = c[`${k.key}-${I.asset_id}`];
1484
+ if (!B)
923
1485
  return;
924
- const L = B[j.asset_id], G = L?.supplyIndex ?? A.currentSupplyIndex, ce = L?.borrowIndex ?? A.currentBorrowIndex, se = Q(j.supply_balance, G).toString(), le = Q(j.borrow_balance, ce).toString();
1486
+ const W = T[I.asset_id], Y = W?.supplyIndex ?? B.currentSupplyIndex, Pe = W?.borrowIndex ?? B.currentBorrowIndex, Ae = ue(I.supply_balance, Y).toString(), Se = ue(I.borrow_balance, Pe).toString();
925
1487
  y.push({
926
- supplyBalance: se,
927
- borrowBalance: le,
928
- assetId: j.asset_id,
929
- market: I.key,
930
- pool: A,
1488
+ supplyBalance: Ae,
1489
+ borrowBalance: Se,
1490
+ assetId: I.asset_id,
1491
+ market: k.key,
1492
+ pool: B,
931
1493
  emodeId: w.emodeId
932
1494
  });
933
1495
  });
934
1496
  }), y;
935
1497
  }
936
- const ut = M(
937
- async (e, r) => {
938
- const n = (r?.markets || Object.keys(U)).map((t) => T(t)).map((t) => ({
1498
+ const ir = $(
1499
+ async (e, t) => {
1500
+ const o = (t?.markets || Object.keys(F)).map((n) => _(n)).map((n) => ({
939
1501
  address: e,
940
- market: t.key
1502
+ market: n.key
941
1503
  }));
942
- return await ne(e, n, r);
1504
+ return await _e(e, o, t);
943
1505
  }
944
1506
  );
945
- async function pt(e, r) {
946
- const o = r?.client ?? V, n = new F();
947
- await Ve(n, e, r);
948
- const t = await o.devInspectTransactionBlock({
949
- transactionBlock: n,
1507
+ async function cr(e, t) {
1508
+ const r = t?.client ?? V, o = new N();
1509
+ await It(o, e, t);
1510
+ const n = await q(r, {
1511
+ transactionBlock: o,
950
1512
  sender: e
951
- }), a = H(t, [C.u256()]);
952
- return te(Number(a[0]) || 0);
953
- }
954
- async function dt(e, r, o, n) {
955
- const t = n?.client ?? V, a = new F();
956
- let s = 0, i = 0;
957
- const c = await S(r, n);
958
- if (o.forEach((v) => {
959
- v.type === R.Supply ? s += v.amount : v.type === R.Withdraw ? s -= v.amount : v.type === R.Borrow ? i += v.amount : v.type === R.Repay && (i -= v.amount);
960
- }), s * i < 0)
1513
+ }), a = Q(n, [u.u256()]);
1514
+ return je(Number(a[0]) || 0);
1515
+ }
1516
+ async function sr(e, t, r, o) {
1517
+ const n = o?.client ?? V, a = new N();
1518
+ let c = 0, i = 0;
1519
+ const s = await S(t, o);
1520
+ if (r.forEach((b) => {
1521
+ b.type === z.Supply ? c += b.amount : b.type === z.Withdraw ? c -= b.amount : b.type === z.Borrow ? i += b.amount : b.type === z.Repay && (i -= b.amount);
1522
+ }), c * i < 0)
961
1523
  throw new Error("Invalid operations");
962
- const u = s > 0 || i > 0;
963
- await re(
1524
+ const l = c > 0 || i > 0;
1525
+ await Ie(
964
1526
  a,
965
1527
  e,
966
- c,
967
- Math.abs(s),
1528
+ s,
1529
+ Math.abs(c),
968
1530
  Math.abs(i),
969
- u,
970
- n
1531
+ l,
1532
+ o
971
1533
  );
972
- const m = await t.devInspectTransactionBlock({
1534
+ const m = await q(n, {
973
1535
  transactionBlock: a,
974
1536
  sender: e
975
- }), h = H(m, [C.u256()]);
976
- return te(Number(h[0]) || 0);
1537
+ }), g = Q(m, [u.u256()]);
1538
+ return je(Number(g[0]) || 0);
977
1539
  }
978
- const mt = P(
979
- async (e, r) => {
980
- const o = new URLSearchParams();
981
- r?.cursor && o.set("cursor", r.cursor), o.set("userAddress", e);
982
- const n = `https://open-api.naviprotocol.io/api/navi/user/transactions?${o.toString()}&sdk=${E.version}`;
983
- return (await fetch(n, { headers: D }).then((a) => a.json())).data;
1540
+ const lr = A(
1541
+ async (e, t) => {
1542
+ const r = new URLSearchParams();
1543
+ t?.cursor && r.set("cursor", t.cursor), r.set("userAddress", e);
1544
+ const o = E(t), n = M(
1545
+ `/navi/user/transactions?${r.toString()}&sdk=${O.version}`,
1546
+ t
1547
+ );
1548
+ return (await fetch(n, {
1549
+ headers: U(D, o)
1550
+ }).then((c) => c.json())).data;
984
1551
  }
985
1552
  );
986
- async function ft(e, r) {
987
- let o = null;
988
- const n = [], t = r?.client ?? V;
1553
+ async function ur(e, t) {
1554
+ let r = null;
1555
+ const o = [], n = t?.client ?? V, a = n.core;
989
1556
  do {
990
- let a;
991
- if (r?.coinType ? a = await t.getCoins({
992
- owner: e,
993
- coinType: r?.coinType,
994
- cursor: o,
995
- limit: 100
996
- }) : a = await t.getAllCoins({
997
- owner: e,
998
- cursor: o,
999
- limit: 100
1000
- }), !a.data || !a.data.length)
1557
+ let c;
1558
+ if (t?.coinType)
1559
+ if (typeof a?.listCoins == "function") {
1560
+ const i = await a.listCoins({
1561
+ owner: e,
1562
+ coinType: t?.coinType,
1563
+ cursor: r,
1564
+ limit: 100
1565
+ });
1566
+ c = {
1567
+ data: (i.objects ?? i.data ?? []).map((s) => pe(s, t?.coinType)).filter(Boolean),
1568
+ nextCursor: i.cursor ?? i.nextCursor ?? null,
1569
+ hasNextPage: i.hasNextPage ?? !1
1570
+ };
1571
+ } else {
1572
+ if (typeof n.getCoins != "function")
1573
+ throw new Error("getCoins requires core.listCoins or an explicit legacy getCoins client");
1574
+ c = await n.getCoins({
1575
+ owner: e,
1576
+ coinType: t?.coinType,
1577
+ cursor: r,
1578
+ limit: 100
1579
+ });
1580
+ }
1581
+ else if (typeof a?.listBalances == "function" && typeof a?.listCoins == "function") {
1582
+ const i = [];
1583
+ let s = null;
1584
+ do {
1585
+ const l = await a.listBalances({
1586
+ owner: e,
1587
+ cursor: s,
1588
+ limit: 100
1589
+ });
1590
+ i.push(
1591
+ ...(l.balances ?? []).map((m) => m.coinType).filter(Boolean)
1592
+ ), s = l.cursor ?? l.nextCursor ?? null;
1593
+ } while (s);
1594
+ for (const l of i) {
1595
+ let m = null;
1596
+ do {
1597
+ const g = await a.listCoins({
1598
+ owner: e,
1599
+ coinType: l,
1600
+ cursor: m,
1601
+ limit: 100
1602
+ });
1603
+ o.push(
1604
+ ...(g.objects ?? g.data ?? []).map((b) => pe(b, l)).filter(Boolean)
1605
+ ), m = g.cursor ?? g.nextCursor ?? null;
1606
+ } while (m);
1607
+ }
1001
1608
  break;
1002
- n.push(...a.data), o = a.nextCursor;
1003
- } while (o);
1004
- return n;
1005
- }
1006
- const Ee = M(
1007
- async (e, r) => {
1008
- const o = [], n = (r?.markets || Object.keys(U)).map((i) => T(i));
1009
- let t = [];
1609
+ } else {
1610
+ if (typeof n.getAllCoins != "function")
1611
+ throw new Error(
1612
+ "getCoins requires core.listBalances/core.listCoins or an explicit legacy getAllCoins client"
1613
+ );
1614
+ c = await n.getAllCoins({
1615
+ owner: e,
1616
+ cursor: r,
1617
+ limit: 100
1618
+ });
1619
+ }
1620
+ if (!c.data || !c.data.length)
1621
+ break;
1622
+ o.push(...c.data), r = c.nextCursor;
1623
+ } while (r);
1624
+ return o;
1625
+ }
1626
+ const _t = $(
1627
+ async (e, t) => {
1628
+ const r = [], o = (t?.markets || Object.keys(F)).map((i) => _(i));
1629
+ let n = [];
1010
1630
  try {
1011
- t = await oe(e, r);
1631
+ n = await ke(e, t);
1012
1632
  } catch (i) {
1013
1633
  console.error(i);
1014
1634
  }
1015
- const a = n.map((i) => ({
1635
+ const a = o.map((i) => ({
1016
1636
  address: e,
1017
1637
  market: i.key
1018
1638
  })).concat(
1019
- t.filter((i) => !!n.find((c) => c.id === i.marketId)).map((i) => ({
1639
+ n.filter((i) => !!o.find((s) => s.id === i.marketId)).map((i) => ({
1020
1640
  address: i.accountCap,
1021
- market: T(i.marketId).key,
1641
+ market: _(i.marketId).key,
1022
1642
  emodeId: i.emodeId
1023
1643
  }))
1024
1644
  );
1025
- return (await ne(e, a, r)).forEach((i) => {
1026
- const c = typeof i.emodeId == "number" ? t.find((u) => {
1027
- const m = T(i.market);
1028
- return u.emodeId === i.emodeId && u.marketId === m.id;
1645
+ return (await _e(e, a, t)).forEach((i) => {
1646
+ const s = typeof i.emodeId == "number" ? n.find((l) => {
1647
+ const m = _(i.market);
1648
+ return l.emodeId === i.emodeId && l.marketId === m.id;
1029
1649
  }) : void 0;
1030
- if (c) {
1031
- if (!i.pool.emodes.find((m) => m.emodeId === c.emodeId))
1650
+ if (s) {
1651
+ if (!i.pool.emodes.find((m) => m.emodeId === s.emodeId))
1032
1652
  return;
1033
1653
  if (p(i.supplyBalance).gte(0)) {
1034
- const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), h = W(i.pool, c);
1035
- if (m.gt(0) || h.emode.isCollateral)
1654
+ const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), g = H(i.pool, s);
1655
+ if (m.gt(0) || g.emode.isCollateral)
1036
1656
  try {
1037
- o.push({
1038
- id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${$()}`,
1657
+ r.push({
1658
+ id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${P()}`,
1039
1659
  wallet: e,
1040
1660
  protocol: "navi",
1041
1661
  market: i.market,
1042
1662
  type: "navi-lending-emode-supply",
1043
1663
  "navi-lending-emode-supply": {
1044
1664
  amount: m.toString(),
1045
- pool: W(i.pool, c),
1665
+ pool: H(i.pool, s),
1046
1666
  token: i.pool.token,
1047
1667
  valueUSD: m.multipliedBy(i.pool.oracle.price).toString(),
1048
- emodeCap: c
1668
+ emodeCap: s
1049
1669
  }
1050
1670
  });
1051
- } catch (v) {
1052
- console.error(v);
1671
+ } catch (b) {
1672
+ console.error(b);
1053
1673
  }
1054
1674
  }
1055
1675
  if (p(i.borrowBalance).gte(0)) {
1056
- const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), h = W(i.pool, c);
1057
- if (m.gt(0) || h.emode.isDebt)
1676
+ const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), g = H(i.pool, s);
1677
+ if (m.gt(0) || g.emode.isDebt)
1058
1678
  try {
1059
- o.push({
1060
- id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${$()}`,
1679
+ r.push({
1680
+ id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${P()}`,
1061
1681
  wallet: e,
1062
1682
  protocol: "navi",
1063
1683
  market: i.market,
1064
1684
  type: "navi-lending-emode-borrow",
1065
1685
  "navi-lending-emode-borrow": {
1066
1686
  amount: m.toString(),
1067
- pool: W(i.pool, c),
1687
+ pool: H(i.pool, s),
1068
1688
  token: i.pool.token,
1069
1689
  valueUSD: m.multipliedBy(i.pool.oracle.price).toString(),
1070
- emodeCap: c
1690
+ emodeCap: s
1071
1691
  }
1072
1692
  });
1073
- } catch (v) {
1074
- console.error(v);
1693
+ } catch (b) {
1694
+ console.error(b);
1075
1695
  }
1076
1696
  }
1077
1697
  } else {
1078
1698
  if (p(i.supplyBalance).gt(0)) {
1079
- const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1080
- o.push({
1081
- id: `${i.pool.uniqueId}_navi-lending-supply-${$()}`,
1699
+ const l = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1700
+ r.push({
1701
+ id: `${i.pool.uniqueId}_navi-lending-supply-${P()}`,
1082
1702
  wallet: e,
1083
1703
  protocol: "navi",
1084
1704
  type: "navi-lending-supply",
1085
1705
  market: i.market,
1086
1706
  "navi-lending-supply": {
1087
- amount: u.toString(),
1707
+ amount: l.toString(),
1088
1708
  pool: i.pool,
1089
1709
  token: i.pool.token,
1090
- valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
1710
+ valueUSD: l.multipliedBy(i.pool.oracle.price).toString()
1091
1711
  }
1092
1712
  });
1093
1713
  }
1094
1714
  if (p(i.borrowBalance).gt(0)) {
1095
- const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1096
- o.push({
1097
- id: `${i.pool.uniqueId}_navi-lending-borrow-${$()}`,
1715
+ const l = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1716
+ r.push({
1717
+ id: `${i.pool.uniqueId}_navi-lending-borrow-${P()}`,
1098
1718
  wallet: e,
1099
1719
  protocol: "navi",
1100
1720
  market: i.market,
1101
1721
  type: "navi-lending-borrow",
1102
1722
  "navi-lending-borrow": {
1103
- amount: u.toString(),
1723
+ amount: l.toString(),
1104
1724
  pool: i.pool,
1105
1725
  token: i.pool.token,
1106
- valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
1726
+ valueUSD: l.multipliedBy(i.pool.oracle.price).toString()
1107
1727
  }
1108
1728
  });
1109
1729
  }
1110
1730
  }
1111
- }), o;
1731
+ }), r;
1112
1732
  }
1113
1733
  );
1114
- class N {
1115
- constructor(r, o) {
1734
+ class L {
1735
+ constructor(t, r) {
1116
1736
  this._positions = [], this._priceMap = {}, this._overview = {
1117
1737
  hf: 1 / 0,
1118
1738
  netVaule: "0",
@@ -1125,7 +1745,7 @@ class N {
1125
1745
  maxLoanToVaule: "0",
1126
1746
  supply: {},
1127
1747
  borrow: {}
1128
- }, this._priceMap = o || {}, this.positions = r;
1748
+ }, this._priceMap = r || {}, this.positions = t;
1129
1749
  }
1130
1750
  get positions() {
1131
1751
  return this._positions;
@@ -1136,433 +1756,438 @@ class N {
1136
1756
  get priceMap() {
1137
1757
  return this._priceMap;
1138
1758
  }
1139
- set positions(r) {
1140
- this._positions = r, this._overview = this.getPositionsOverview(r);
1141
- }
1142
- updatePriceMap(r) {
1143
- return this._priceMap = r, this._overview = this.getPositionsOverview(this._positions), this;
1144
- }
1145
- getPrice(r) {
1146
- const o = k(r.suiCoinType);
1147
- if (this._priceMap[o] !== void 0)
1148
- return this._priceMap[o].toString();
1149
- const n = r.suiCoinType;
1150
- return this._priceMap[n] !== void 0 ? this._priceMap[n].toString() : r.oracle.price;
1151
- }
1152
- filterPositionsByPool(r) {
1153
- const n = !!r.isEMode ? ["navi-lending-emode-supply", "navi-lending-emode-borrow"] : ["navi-lending-supply", "navi-lending-borrow"];
1154
- return new N(
1155
- this.positions.filter((t) => {
1156
- const a = t[t.type];
1157
- return n.includes(t.type) && a.pool.uniqueId === r.uniqueId;
1759
+ set positions(t) {
1760
+ this._positions = t, this._overview = this.getPositionsOverview(t);
1761
+ }
1762
+ updatePriceMap(t) {
1763
+ return this._priceMap = t, this._overview = this.getPositionsOverview(this._positions), this;
1764
+ }
1765
+ getPrice(t) {
1766
+ const r = C(t.suiCoinType);
1767
+ if (this._priceMap[r] !== void 0)
1768
+ return this._priceMap[r].toString();
1769
+ const o = t.suiCoinType;
1770
+ return this._priceMap[o] !== void 0 ? this._priceMap[o].toString() : t.oracle.price;
1771
+ }
1772
+ filterPositionsByPool(t) {
1773
+ const o = !!t.isEMode ? ["navi-lending-emode-supply", "navi-lending-emode-borrow"] : ["navi-lending-supply", "navi-lending-borrow"];
1774
+ return new L(
1775
+ this.positions.filter((n) => {
1776
+ const a = n[n.type];
1777
+ return o.includes(n.type) && a.pool.uniqueId === t.uniqueId;
1158
1778
  }),
1159
1779
  this._priceMap
1160
1780
  );
1161
1781
  }
1162
- deposit(r, o) {
1163
- const n = !!r.isEMode, t = this.getPrice(r);
1782
+ deposit(t, r) {
1783
+ const o = !!t.isEMode, n = this.getPrice(t);
1164
1784
  let a;
1165
- return n ? a = {
1166
- id: $(),
1785
+ return o ? a = {
1786
+ id: P(),
1167
1787
  wallet: "",
1168
1788
  protocol: "navi",
1169
1789
  market: "",
1170
1790
  type: "navi-lending-emode-supply",
1171
1791
  "navi-lending-emode-supply": {
1172
- amount: o.toString(),
1173
- valueUSD: p(o).multipliedBy(t).toString(),
1174
- token: r.token,
1175
- pool: r,
1792
+ amount: r.toString(),
1793
+ valueUSD: p(r).multipliedBy(n).toString(),
1794
+ token: t.token,
1795
+ pool: t,
1176
1796
  emodeCap: {}
1177
1797
  }
1178
1798
  } : a = {
1179
- id: $(),
1799
+ id: P(),
1180
1800
  wallet: "",
1181
1801
  protocol: "navi",
1182
1802
  market: "",
1183
1803
  type: "navi-lending-supply",
1184
1804
  "navi-lending-supply": {
1185
- amount: o.toString(),
1186
- valueUSD: p(o).multipliedBy(t).toString(),
1187
- token: r.token,
1188
- pool: r
1805
+ amount: r.toString(),
1806
+ valueUSD: p(r).multipliedBy(n).toString(),
1807
+ token: t.token,
1808
+ pool: t
1189
1809
  }
1190
- }, new N([...this.positions, a], this._priceMap);
1810
+ }, new L([...this.positions, a], this._priceMap);
1191
1811
  }
1192
- withdraw(r, o) {
1193
- const n = !!r.isEMode, t = this.getPrice(r);
1812
+ withdraw(t, r) {
1813
+ const o = !!t.isEMode, n = this.getPrice(t);
1194
1814
  let a;
1195
- return n ? a = {
1196
- id: $(),
1815
+ return o ? a = {
1816
+ id: P(),
1197
1817
  wallet: "",
1198
1818
  protocol: "navi",
1199
1819
  market: "",
1200
1820
  type: "navi-lending-emode-supply",
1201
1821
  "navi-lending-emode-supply": {
1202
- amount: (-o).toString(),
1203
- valueUSD: p(-o).multipliedBy(t).toString(),
1204
- token: r.token,
1205
- pool: r,
1822
+ amount: (-r).toString(),
1823
+ valueUSD: p(-r).multipliedBy(n).toString(),
1824
+ token: t.token,
1825
+ pool: t,
1206
1826
  emodeCap: {}
1207
1827
  }
1208
1828
  } : a = {
1209
- id: $(),
1829
+ id: P(),
1210
1830
  wallet: "",
1211
1831
  protocol: "navi",
1212
1832
  market: "",
1213
1833
  type: "navi-lending-supply",
1214
1834
  "navi-lending-supply": {
1215
- amount: (-o).toString(),
1216
- valueUSD: p(-o).multipliedBy(t).toString(),
1217
- token: r.token,
1218
- pool: r
1835
+ amount: (-r).toString(),
1836
+ valueUSD: p(-r).multipliedBy(n).toString(),
1837
+ token: t.token,
1838
+ pool: t
1219
1839
  }
1220
- }, new N([...this.positions, a], this._priceMap);
1840
+ }, new L([...this.positions, a], this._priceMap);
1221
1841
  }
1222
- borrow(r, o) {
1223
- const n = !!r.isEMode, t = this.getPrice(r);
1842
+ borrow(t, r) {
1843
+ const o = !!t.isEMode, n = this.getPrice(t);
1224
1844
  let a;
1225
- return n ? a = {
1226
- id: $(),
1845
+ return o ? a = {
1846
+ id: P(),
1227
1847
  wallet: "",
1228
1848
  protocol: "navi",
1229
1849
  market: "",
1230
1850
  type: "navi-lending-emode-borrow",
1231
1851
  "navi-lending-emode-borrow": {
1232
- amount: o.toString(),
1233
- valueUSD: p(o).multipliedBy(t).toString(),
1234
- token: r.token,
1235
- pool: r,
1852
+ amount: r.toString(),
1853
+ valueUSD: p(r).multipliedBy(n).toString(),
1854
+ token: t.token,
1855
+ pool: t,
1236
1856
  emodeCap: {}
1237
1857
  }
1238
1858
  } : a = {
1239
- id: $(),
1859
+ id: P(),
1240
1860
  wallet: "",
1241
1861
  protocol: "navi",
1242
1862
  market: "",
1243
1863
  type: "navi-lending-borrow",
1244
1864
  "navi-lending-borrow": {
1245
- amount: o.toString(),
1246
- valueUSD: p(o).multipliedBy(t).toString(),
1247
- token: r.token,
1248
- pool: r
1865
+ amount: r.toString(),
1866
+ valueUSD: p(r).multipliedBy(n).toString(),
1867
+ token: t.token,
1868
+ pool: t
1249
1869
  }
1250
- }, new N([...this.positions, a], this._priceMap);
1870
+ }, new L([...this.positions, a], this._priceMap);
1251
1871
  }
1252
- repay(r, o) {
1253
- const n = !!r.isEMode, t = this.getPrice(r);
1872
+ repay(t, r) {
1873
+ const o = !!t.isEMode, n = this.getPrice(t);
1254
1874
  let a;
1255
- return n ? a = {
1256
- id: $(),
1875
+ return o ? a = {
1876
+ id: P(),
1257
1877
  wallet: "",
1258
1878
  protocol: "navi",
1259
1879
  market: "",
1260
1880
  type: "navi-lending-emode-borrow",
1261
1881
  "navi-lending-emode-borrow": {
1262
- amount: (-o).toString(),
1263
- valueUSD: p(-o).multipliedBy(t).toString(),
1264
- token: r.token,
1265
- pool: r,
1882
+ amount: (-r).toString(),
1883
+ valueUSD: p(-r).multipliedBy(n).toString(),
1884
+ token: t.token,
1885
+ pool: t,
1266
1886
  emodeCap: {}
1267
1887
  }
1268
1888
  } : a = {
1269
- id: $(),
1889
+ id: P(),
1270
1890
  wallet: "",
1271
1891
  protocol: "navi",
1272
1892
  market: "",
1273
1893
  type: "navi-lending-borrow",
1274
1894
  "navi-lending-borrow": {
1275
- amount: (-o).toString(),
1276
- valueUSD: p(-o).multipliedBy(t).toString(),
1277
- token: r.token,
1278
- pool: r
1895
+ amount: (-r).toString(),
1896
+ valueUSD: p(-r).multipliedBy(n).toString(),
1897
+ token: t.token,
1898
+ pool: t
1279
1899
  }
1280
- }, new N([...this.positions, a], this._priceMap);
1900
+ }, new L([...this.positions, a], this._priceMap);
1281
1901
  }
1282
- resolveValueUSD(r) {
1283
- return Object.keys(this._priceMap).length > 0 ? p(r.amount).multipliedBy(this.getPrice(r.pool)).toString() : r.valueUSD;
1902
+ resolveValueUSD(t) {
1903
+ return Object.keys(this._priceMap).length > 0 ? p(t.amount).multipliedBy(this.getPrice(t.pool)).toString() : t.valueUSD;
1284
1904
  }
1285
- getPositionsOverview(r) {
1286
- const o = {}, n = {};
1287
- let t = new p(0), a = new p(0), s = new p(0), i = new p(0), c = new p(0), u = new p(0);
1288
- r.forEach((y) => {
1905
+ getPositionsOverview(t) {
1906
+ const r = {}, o = {};
1907
+ let n = new p(0), a = new p(0), c = new p(0), i = new p(0), s = new p(0), l = new p(0);
1908
+ t.forEach((y) => {
1289
1909
  if (y.type === "navi-lending-supply") {
1290
- const l = y["navi-lending-supply"], f = this.resolveValueUSD(l);
1291
- t = t.plus(f), c = c.plus(
1292
- new p(f).multipliedBy(l.pool.liquidationFactor.threshold)
1293
- ), u = u.plus(
1294
- new p(f).multipliedBy(l.pool.ltvValue)
1910
+ const d = y["navi-lending-supply"], f = this.resolveValueUSD(d);
1911
+ n = n.plus(f), s = s.plus(
1912
+ new p(f).multipliedBy(d.pool.liquidationFactor.threshold)
1913
+ ), l = l.plus(
1914
+ new p(f).multipliedBy(d.pool.ltvValue)
1295
1915
  );
1296
1916
  } else if (y.type === "navi-lending-borrow") {
1297
- const l = y["navi-lending-borrow"];
1298
- a = a.plus(this.resolveValueUSD(l));
1917
+ const d = y["navi-lending-borrow"];
1918
+ a = a.plus(this.resolveValueUSD(d));
1299
1919
  } else if (y.type === "navi-lending-emode-supply") {
1300
- const l = y["navi-lending-emode-supply"], f = this.resolveValueUSD(l);
1301
- t = t.plus(f);
1302
- const w = l.pool.emode;
1303
- c = c.plus(
1920
+ const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d);
1921
+ n = n.plus(f);
1922
+ const w = d.pool.emode;
1923
+ s = s.plus(
1304
1924
  new p(f).multipliedBy(w.lt)
1305
- ), u = u.plus(
1925
+ ), l = l.plus(
1306
1926
  new p(f).multipliedBy(w.ltv)
1307
1927
  );
1308
1928
  } else if (y.type === "navi-lending-emode-borrow") {
1309
- const l = y["navi-lending-emode-borrow"];
1310
- a = a.plus(this.resolveValueUSD(l));
1929
+ const d = y["navi-lending-emode-borrow"];
1930
+ a = a.plus(this.resolveValueUSD(d));
1311
1931
  }
1312
- }), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0), u = p.max(u, 0), r.forEach((y) => {
1932
+ }), a = p.max(a, 0), n = p.max(n, 0), s = p.max(s, 0), l = p.max(l, 0), t.forEach((y) => {
1313
1933
  if (y.type === "navi-lending-supply") {
1314
- const l = y["navi-lending-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
1315
- t.gt(0) && (s = s.plus(
1316
- new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
1317
- )), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1934
+ const d = y["navi-lending-supply"], f = this.resolveValueUSD(d), w = d.pool.supplyIncentiveApyInfo.apy;
1935
+ n.gt(0) && (c = c.plus(
1936
+ new p(f).dividedBy(n).multipliedBy(new p(w).dividedBy(100))
1937
+ )), r[d.pool.suiCoinType] = p(r[d.pool.suiCoinType] || 0).plus(d.amount).toString();
1318
1938
  } else if (y.type === "navi-lending-borrow") {
1319
- const l = y["navi-lending-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
1939
+ const d = y["navi-lending-borrow"], f = this.resolveValueUSD(d), w = d.pool.borrowIncentiveApyInfo.apy;
1320
1940
  a.gt(0) && (i = i.plus(
1321
1941
  new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
1322
- )), n[l.pool.suiCoinType] = p(n[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1942
+ )), o[d.pool.suiCoinType] = p(o[d.pool.suiCoinType] || 0).plus(d.amount).toString();
1323
1943
  } else if (y.type === "navi-lending-emode-supply") {
1324
- const l = y["navi-lending-emode-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
1325
- t.gt(0) && (s = s.plus(
1326
- new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
1327
- )), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1944
+ const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d), w = d.pool.supplyIncentiveApyInfo.apy;
1945
+ n.gt(0) && (c = c.plus(
1946
+ new p(f).dividedBy(n).multipliedBy(new p(w).dividedBy(100))
1947
+ )), r[d.pool.suiCoinType] = p(r[d.pool.suiCoinType] || 0).plus(d.amount).toString();
1328
1948
  } else if (y.type === "navi-lending-emode-borrow") {
1329
- const l = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
1949
+ const d = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(d), w = d.pool.borrowIncentiveApyInfo.apy;
1330
1950
  a.gt(0) && (i = i.plus(
1331
1951
  new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
1332
- )), n[l.pool.suiCoinType] = p(n[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1952
+ )), o[d.pool.suiCoinType] = p(o[d.pool.suiCoinType] || 0).plus(d.amount).toString();
1333
1953
  }
1334
1954
  });
1335
- const m = t.minus(a), h = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(s).minus(a.multipliedBy(i)).div(t.minus(a));
1955
+ const m = n.minus(a), g = n.minus(a).eq(0) ? new p(0) : n.multipliedBy(c).minus(a.multipliedBy(i)).div(n.minus(a));
1336
1956
  return {
1337
- hf: a.toNumber() !== 0 ? c.dividedBy(a).toNumber() : 1 / 0,
1957
+ hf: a.toNumber() !== 0 ? s.dividedBy(a).toNumber() : 1 / 0,
1338
1958
  netVaule: m.toString(),
1339
- netWorthApr: h.toString(),
1340
- totalSupplyValue: t.toString(),
1959
+ netWorthApr: g.toString(),
1960
+ totalSupplyValue: n.toString(),
1341
1961
  totalBorrowValue: a.toString(),
1342
- totalsupplyApy: s.toString(),
1962
+ totalsupplyApy: c.toString(),
1343
1963
  totalBorrowApy: i.toString(),
1344
- maxLiquidationValue: c.toString(),
1345
- maxLoanToVaule: u.toString(),
1346
- supply: o,
1347
- borrow: n
1964
+ maxLiquidationValue: s.toString(),
1965
+ maxLoanToVaule: l.toString(),
1966
+ supply: r,
1967
+ borrow: o
1348
1968
  };
1349
1969
  }
1350
1970
  }
1351
- async function yt(e, r, o, n) {
1352
- const t = await _({
1353
- ...n,
1354
- cacheTime: b
1971
+ async function dr(e, t, r, o) {
1972
+ const n = await j({
1973
+ ...o,
1974
+ cacheTime: v
1355
1975
  });
1356
- t.limter && e.moveCall({
1357
- target: `${t.limter}::navi_adaptor::verify_navi_position_healthy`,
1976
+ n.limter && e.moveCall({
1977
+ target: `${n.limter}::navi_adaptor::verify_navi_position_healthy`,
1358
1978
  arguments: [
1359
1979
  e.object("0x06"),
1360
- e.object(t.storage),
1361
- e.object(t.priceOracle),
1362
- g(r, e.pure.address),
1363
- e.pure.u256(new p(o).shiftedBy(27).toNumber())
1980
+ e.object(n.storage),
1981
+ e.object(n.priceOracle),
1982
+ h(t, e.pure.address),
1983
+ e.pure.u256(new p(r).shiftedBy(27).toNumber())
1364
1984
  ]
1365
1985
  });
1366
1986
  }
1367
- const ae = new x("https://hermes.pyth.network", {
1987
+ const Te = new he("https://hermes.pyth.network", {
1368
1988
  timeout: 1e4
1369
1989
  });
1370
- async function gt(e) {
1990
+ async function pr(e) {
1371
1991
  try {
1372
- const r = [], o = await ae.getLatestPriceFeeds(e);
1373
- if (!o) return r;
1374
- const n = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
1375
- for (const t of o) {
1376
- const a = t.getPriceUnchecked();
1377
- if (a.publishTime > n) {
1992
+ const t = [], r = await Te.getLatestPriceFeeds(e);
1993
+ if (!r) return t;
1994
+ const o = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
1995
+ for (const n of r) {
1996
+ const a = n.getPriceUnchecked();
1997
+ if (a.publishTime > o) {
1378
1998
  console.warn(
1379
- `pyth price feed is invalid, id: ${t.id}, publish time: ${a.publishTime}, current timestamp: ${n}`
1999
+ `pyth price feed is invalid, id: ${n.id}, publish time: ${a.publishTime}, current timestamp: ${o}`
1380
2000
  );
1381
2001
  continue;
1382
2002
  }
1383
- n - t.getPriceUnchecked().publishTime > 30 && (console.info(
1384
- `stale price feed, id: ${t.id}, publish time: ${a.publishTime}, current timestamp: ${n}`
1385
- ), r.push(t.id));
2003
+ o - n.getPriceUnchecked().publishTime > 30 && (console.info(
2004
+ `stale price feed, id: ${n.id}, publish time: ${a.publishTime}, current timestamp: ${o}`
2005
+ ), t.push(n.id));
1386
2006
  }
1387
- return r;
1388
- } catch (r) {
1389
- throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
2007
+ return t;
2008
+ } catch (t) {
2009
+ throw new Error(`failed to get pyth stale price feed id, msg: ${t.message}`);
1390
2010
  }
1391
2011
  }
1392
- async function De(e, r) {
2012
+ async function Tt(e, t) {
1393
2013
  try {
1394
- const o = [], n = r?.client ?? V, t = e.map((s) => s.priceInfoObject), a = await n.multiGetObjects({
1395
- ids: Array.from(new Set(t)),
2014
+ const r = [], o = t?.client ?? V, n = e.map((c) => c.priceInfoObject), a = await mt(o, {
2015
+ ids: Array.from(new Set(n)),
1396
2016
  options: { showContent: !0 }
1397
2017
  });
1398
- for (const s of a) {
1399
- const i = s.data;
2018
+ for (const c of a) {
2019
+ const i = c.data;
1400
2020
  if (!i || !i.content || i.content.dataType !== "moveObject") {
1401
2021
  console.warn(`fetched object ${i?.objectId} datatype should be moveObject`);
1402
2022
  continue;
1403
2023
  }
1404
- const c = e.find((l) => l.priceInfoObject == i.objectId);
1405
- if (!c) {
2024
+ const s = e.find((d) => d.priceInfoObject == i.objectId);
2025
+ if (!s) {
1406
2026
  console.warn(`unable to find pyth info from array, priceInfoObject: ${i.objectId}`);
1407
2027
  continue;
1408
2028
  }
1409
- const u = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: m, negative: h } = u.price.fields, v = u.conf, y = u.timestamp;
1410
- o.push({
1411
- priceFeedId: c.priceFeedId,
1412
- priceInfoObject: c.priceInfoObject,
1413
- price: h ? "-" + m : m,
1414
- conf: v,
2029
+ const l = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: m, negative: g } = l.price.fields, b = l.conf, y = l.timestamp;
2030
+ r.push({
2031
+ priceFeedId: s.priceFeedId,
2032
+ priceInfoObject: s.priceInfoObject,
2033
+ price: g ? "-" + m : m,
2034
+ conf: b,
1415
2035
  publishTime: Number(y),
1416
- expiration: c.expiration
2036
+ expiration: s.expiration
1417
2037
  });
1418
2038
  }
1419
- return o;
1420
- } catch (o) {
1421
- console.error(o, `Polling Sui on-chain price for ${e} failed.`);
2039
+ return r;
2040
+ } catch (r) {
2041
+ console.error(r, `Polling Sui on-chain price for ${e} failed.`);
1422
2042
  return;
1423
2043
  }
1424
2044
  }
1425
- async function Ue(e, r) {
2045
+ async function Bt(e, t) {
1426
2046
  try {
1427
- const o = [], n = await De(e, r);
1428
- if (!n) return o;
1429
- const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
1430
- for (const a of n) {
1431
- if (a.publishTime > t) {
2047
+ const r = [], o = await Tt(e, t);
2048
+ if (!o) return r;
2049
+ const n = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
2050
+ for (const a of o) {
2051
+ if (a.publishTime > n) {
1432
2052
  console.warn(
1433
- `pyth price feed is invalid, id: ${a.priceFeedId}, publish time: ${a.publishTime}, current timestamp: ${t}`
2053
+ `pyth price feed is invalid, id: ${a.priceFeedId}, publish time: ${a.publishTime}, current timestamp: ${n}`
1434
2054
  );
1435
2055
  continue;
1436
2056
  }
1437
- const s = a.expiration || 60;
1438
- t - a.publishTime > s && (console.info(
1439
- `stale price feed, id: ${a.priceFeedId}, publish time: ${a.publishTime}, current timestamp: ${t}`
1440
- ), o.push(a.priceFeedId));
2057
+ const c = a.expiration || 60;
2058
+ n - a.publishTime > c && (console.info(
2059
+ `stale price feed, id: ${a.priceFeedId}, publish time: ${a.publishTime}, current timestamp: ${n}`
2060
+ ), r.push(a.priceFeedId));
1441
2061
  }
1442
- return o;
1443
- } catch (o) {
1444
- throw new Error(`failed to get pyth stale price feed id, msg: ${o.message}`);
2062
+ return r;
2063
+ } catch (r) {
2064
+ throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
1445
2065
  }
1446
2066
  }
1447
- async function Oe(e, r, o) {
1448
- const n = o?.client ?? V, t = await _({
1449
- ...o,
1450
- cacheTime: b
2067
+ async function Pt(e, t, r) {
2068
+ const o = r?.client ?? V, n = await j({
2069
+ ...r,
2070
+ cacheTime: v
1451
2071
  });
1452
2072
  try {
1453
- const a = await ae.getPriceFeedsUpdateData(r);
1454
- return await new ge(
1455
- n,
1456
- t.oracle.pythStateId,
1457
- t.oracle.wormholeStateId
1458
- ).updatePriceFeeds(e, a, r);
2073
+ const a = await Te.getPriceFeedsUpdateData(t);
2074
+ return await new ct(
2075
+ o,
2076
+ n.oracle.pythStateId,
2077
+ n.oracle.wormholeStateId
2078
+ ).updatePriceFeeds(e, a, t);
1459
2079
  } catch (a) {
1460
2080
  throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
1461
2081
  }
1462
2082
  }
1463
- async function Ne(e, r, o) {
1464
- const n = await _({
1465
- ...o,
1466
- cacheTime: b
2083
+ async function At(e, t, r) {
2084
+ const o = await j({
2085
+ ...r,
2086
+ cacheTime: v
1467
2087
  });
1468
- if (o?.updatePythPriceFeeds) {
1469
- const t = r.filter((a) => !!a.pythPriceFeedId && !!a.pythPriceInfoObject).map((a) => ({
2088
+ if (r?.updatePythPriceFeeds) {
2089
+ const n = t.filter((a) => !!a.pythPriceFeedId && !!a.pythPriceInfoObject).map((a) => ({
1470
2090
  priceFeedId: a.pythPriceFeedId,
1471
2091
  priceInfoObject: a.pythPriceInfoObject,
1472
2092
  expiration: 30
1473
2093
  }));
1474
2094
  try {
1475
- const a = await Ue(t, o);
1476
- a.length > 0 && await Oe(e, a, o);
2095
+ const a = await Bt(n, r);
2096
+ a.length > 0 && await Pt(e, a, r);
1477
2097
  } catch {
1478
2098
  console.error("Failed to update Pyth price feeds");
1479
2099
  }
1480
2100
  }
1481
- for (const t of r)
1482
- o?.env === "dev" ? e.moveCall({
1483
- target: `${n.oracle.packageId}::oracle_pro::update_single_price`,
2101
+ for (const n of t)
2102
+ r?.env === "dev" ? e.moveCall({
2103
+ target: `${o.oracle.packageId}::oracle_pro::update_single_price`,
1484
2104
  arguments: [
1485
2105
  e.object("0x6"),
1486
2106
  // Clock object
1487
- e.object(n.oracle.oracleConfig),
2107
+ e.object(o.oracle.oracleConfig),
1488
2108
  // Oracle configuration
1489
- e.object(n.oracle.priceOracle),
2109
+ e.object(o.oracle.priceOracle),
1490
2110
  // Price oracle contract
1491
- e.object(n.oracle.supraOracleHolder),
2111
+ e.object(o.oracle.supraOracleHolder),
1492
2112
  // Supra oracle holder
1493
- e.object(t.pythPriceInfoObject),
2113
+ e.object(n.pythPriceInfoObject),
1494
2114
  // Pyth price info object
1495
- e.pure.address(t.feedId)
2115
+ e.pure.address(n.feedId)
1496
2116
  // Price feed ID
1497
2117
  ]
1498
2118
  }) : e.moveCall({
1499
- target: `${n.oracle.packageId}::oracle_pro::update_single_price_v2`,
2119
+ target: `${o.oracle.packageId}::oracle_pro::update_single_price_v2`,
1500
2120
  arguments: [
1501
2121
  e.object("0x6"),
1502
2122
  // Clock object
1503
- e.object(n.oracle.oracleConfig),
2123
+ e.object(o.oracle.oracleConfig),
1504
2124
  // Oracle configuration
1505
- e.object(n.oracle.priceOracle),
2125
+ e.object(o.oracle.priceOracle),
1506
2126
  // Price oracle contract
1507
- e.object(n.oracle.supraOracleHolder),
2127
+ e.object(o.oracle.supraOracleHolder),
1508
2128
  // Supra oracle holder
1509
- e.object(t.pythPriceInfoObject),
2129
+ e.object(n.pythPriceInfoObject),
1510
2130
  // Pyth price info object
1511
- e.object(n.oracle.switchboardAggregator),
1512
- e.pure.address(t.feedId)
2131
+ e.object(o.oracle.switchboardAggregator),
2132
+ e.pure.address(n.feedId)
1513
2133
  // Price feed ID
1514
2134
  ]
1515
2135
  });
1516
2136
  return e;
1517
2137
  }
1518
- async function ie(e) {
1519
- return (await _({
2138
+ async function Be(e) {
2139
+ return (await j({
1520
2140
  ...e,
1521
- cacheTime: b
2141
+ cacheTime: v
1522
2142
  })).oracle.feeds;
1523
2143
  }
1524
- function Fe(e, r) {
1525
- return e.filter((o) => !!(r?.lendingState && r.lendingState.find((t) => o.oracleId === t.pool.oracleId) || r?.lendingPositions && r.lendingPositions.find((t) => {
2144
+ function St(e, t) {
2145
+ return e.filter((r) => !!(t?.lendingState && t.lendingState.find((n) => r.oracleId === n.pool.oracleId) || t?.lendingPositions && t.lendingPositions.find((n) => {
1526
2146
  if (![
1527
2147
  "navi-lending-supply",
1528
2148
  "navi-lending-borrow",
1529
2149
  "navi-lending-emode-supply",
1530
2150
  "navi-lending-emode-borrow"
1531
- ].includes(t.type))
2151
+ ].includes(n.type))
1532
2152
  return !1;
1533
- const s = t[t.type]?.pool;
1534
- return o.oracleId === s?.oracleId;
1535
- }) || r?.pools && r.pools.find((t) => o.oracleId === t.oracleId)));
2153
+ const c = n[n.type]?.pool;
2154
+ return r.oracleId === c?.oracleId;
2155
+ }) || t?.pools && t.pools.find((n) => r.oracleId === n.oracleId)));
1536
2156
  }
1537
- async function ht(e, r, o, n) {
2157
+ async function mr(e, t, r, o) {
1538
2158
  try {
1539
- const t = await ie({
1540
- ...n
2159
+ const n = await Be({
2160
+ ...o
1541
2161
  }), a = [];
1542
- o.forEach((u) => {
1543
- a.includes(u.market) || a.push(u.market);
2162
+ r.forEach((l) => {
2163
+ a.includes(l.market) || a.push(l.market);
1544
2164
  });
1545
- const s = await Ee(r, {
1546
- ...n,
2165
+ const c = await _t(t, {
2166
+ ...o,
1547
2167
  markets: a
1548
- }), i = Fe(t, {
1549
- lendingPositions: s,
1550
- pools: o
2168
+ }), i = St(n, {
2169
+ lendingPositions: c,
2170
+ pools: r
1551
2171
  });
1552
- return await Ne(e, i, {
2172
+ return await At(e, i, {
1553
2173
  updatePythPriceFeeds: !0,
1554
- ...n
2174
+ ...o
1555
2175
  });
1556
- } catch (t) {
1557
- if (n?.throws)
1558
- throw t;
1559
- return console.error(t), e;
2176
+ } catch (n) {
2177
+ if (o?.throws)
2178
+ throw n;
2179
+ return console.error(n), e;
1560
2180
  }
1561
2181
  }
1562
- const Y = M(
1563
- P(
2182
+ const re = $(
2183
+ A(
1564
2184
  async (e) => {
1565
- const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${E.version}&market=${e?.market || O}`, o = await fetch(r, { headers: D }).then((n) => n.json());
2185
+ const t = E(e), r = M(
2186
+ `/navi/flashloan?env=${e?.env || "prod"}&sdk=${O.version}&market=${e?.market || R}`,
2187
+ e
2188
+ ), o = await fetch(r, {
2189
+ headers: U(D, t)
2190
+ }).then((n) => n.json());
1566
2191
  return Object.keys(o.data).map((n) => ({
1567
2192
  ...o.data[n],
1568
2193
  coinType: n
@@ -1570,78 +2195,78 @@ const Y = M(
1570
2195
  }
1571
2196
  )
1572
2197
  );
1573
- async function vt(e, r) {
1574
- return (await Y(r)).find((n) => typeof e == "string" ? k(n.coinType) === k(e) : typeof e == "number" ? n.assetId === e : n.assetId === e.id) || null;
2198
+ async function fr(e, t) {
2199
+ return (await re(t)).find((o) => typeof e == "string" ? C(o.coinType) === C(e) : typeof e == "number" ? o.assetId === e : o.assetId === e.id) || null;
1575
2200
  }
1576
- async function wt(e, r, o, n) {
1577
- const t = await _({
1578
- ...n,
1579
- cacheTime: b
1580
- }), a = await S(r, n);
1581
- if (!(await Y({
1582
- ...n,
1583
- cacheTime: b
2201
+ async function yr(e, t, r, o) {
2202
+ const n = await j({
2203
+ ...o,
2204
+ cacheTime: v
2205
+ }), a = await S(t, o);
2206
+ if (!(await re({
2207
+ ...o,
2208
+ cacheTime: v
1584
2209
  })).some(
1585
- (c) => k(c.coinType) === k(a.suiCoinType)
2210
+ (s) => C(s.coinType) === C(a.suiCoinType)
1586
2211
  ))
1587
2212
  throw new Error("Pool does not support flashloan");
1588
- if (t.version === 1) {
1589
- const [c, u] = e.moveCall({
1590
- target: `${t.package}::lending::flash_loan_with_ctx`,
2213
+ if (n.version === 1) {
2214
+ const [s, l] = e.moveCall({
2215
+ target: `${n.package}::lending::flash_loan_with_ctx`,
1591
2216
  arguments: [
1592
- e.object(t.flashloanConfig),
2217
+ e.object(n.flashloanConfig),
1593
2218
  e.object(a.contract.pool),
1594
- g(o, e.pure.u64)
2219
+ h(r, e.pure.u64)
1595
2220
  ],
1596
2221
  typeArguments: [a.suiCoinType]
1597
2222
  });
1598
- return [c, u];
2223
+ return [s, l];
1599
2224
  } else {
1600
- const [c, u] = e.moveCall({
1601
- target: `${t.package}::lending::flash_loan_with_ctx_v2`,
2225
+ const [s, l] = e.moveCall({
2226
+ target: `${n.package}::lending::flash_loan_with_ctx_v2`,
1602
2227
  arguments: [
1603
- e.object(t.flashloanConfig),
2228
+ e.object(n.flashloanConfig),
1604
2229
  e.object(a.contract.pool),
1605
- g(o, e.pure.u64),
2230
+ h(r, e.pure.u64),
1606
2231
  e.object("0x05")
1607
2232
  ],
1608
2233
  typeArguments: [a.suiCoinType]
1609
2234
  });
1610
- return [c, u];
2235
+ return [s, l];
1611
2236
  }
1612
2237
  }
1613
- async function bt(e, r, o, n, t) {
1614
- const a = await _({
1615
- ...t,
1616
- cacheTime: b
1617
- }), s = await S(r, t);
1618
- if (!(await Y({
1619
- ...t,
1620
- cacheTime: b
2238
+ async function gr(e, t, r, o, n) {
2239
+ const a = await j({
2240
+ ...n,
2241
+ cacheTime: v
2242
+ }), c = await S(t, n);
2243
+ if (!(await re({
2244
+ ...n,
2245
+ cacheTime: v
1621
2246
  })).some(
1622
- (m) => k(m.coinType) === k(s.suiCoinType)
2247
+ (m) => C(m.coinType) === C(c.suiCoinType)
1623
2248
  ))
1624
2249
  throw new Error("Pool does not support flashloan");
1625
- const [u] = e.moveCall({
2250
+ const [l] = e.moveCall({
1626
2251
  target: `${a.package}::lending::flash_repay_with_ctx`,
1627
2252
  arguments: [
1628
2253
  e.object("0x06"),
1629
2254
  e.object(a.storage),
1630
- e.object(s.contract.pool),
1631
- g(o, e.object),
1632
- g(n, e.object)
2255
+ e.object(c.contract.pool),
2256
+ h(r, e.object),
2257
+ h(o, e.object)
1633
2258
  ],
1634
- typeArguments: [s.suiCoinType]
2259
+ typeArguments: [c.suiCoinType]
1635
2260
  });
1636
- return [u];
2261
+ return [l];
1637
2262
  }
1638
- async function kt(e, r, o, n, t, a) {
1639
- const s = {
2263
+ async function hr(e, t, r, o, n, a) {
2264
+ const c = {
1640
2265
  ...a,
1641
- cacheTime: b
1642
- }, i = await _(s), c = await S(r, s), u = await S(n, s);
2266
+ cacheTime: v
2267
+ }, i = await j(c), s = await S(t, c), l = await S(o, c);
1643
2268
  if (i.version === 1) {
1644
- const [m, h] = e.moveCall({
2269
+ const [m, g] = e.moveCall({
1645
2270
  target: `${i.package}::incentive_v3::liquidation`,
1646
2271
  arguments: [
1647
2272
  e.object("0x06"),
@@ -1650,28 +2275,28 @@ async function kt(e, r, o, n, t, a) {
1650
2275
  // Price oracle for asset pricing
1651
2276
  e.object(i.storage),
1652
2277
  // Protocol storage
1653
- e.pure.u8(c.id),
2278
+ e.pure.u8(s.id),
1654
2279
  // Pay asset ID
1655
- e.object(c.contract.pool),
2280
+ e.object(s.contract.pool),
1656
2281
  // Pay asset pool contract
1657
- g(o, e.object),
2282
+ h(r, e.object),
1658
2283
  // Debt repayment amount
1659
- e.pure.u8(u.id),
2284
+ e.pure.u8(l.id),
1660
2285
  // Collateral asset ID
1661
- e.object(u.contract.pool),
2286
+ e.object(l.contract.pool),
1662
2287
  // Collateral asset pool contract
1663
- g(t, e.pure.address),
2288
+ h(n, e.pure.address),
1664
2289
  // Borrower address
1665
2290
  e.object(i.incentiveV2),
1666
2291
  // Incentive V2 contract
1667
2292
  e.object(i.incentiveV3)
1668
2293
  // Incentive V3 contract
1669
2294
  ],
1670
- typeArguments: [c.suiCoinType, u.suiCoinType]
2295
+ typeArguments: [s.suiCoinType, l.suiCoinType]
1671
2296
  });
1672
- return [m, h];
2297
+ return [m, g];
1673
2298
  } else {
1674
- const [m, h] = e.moveCall({
2299
+ const [m, g] = e.moveCall({
1675
2300
  target: `${i.package}::incentive_v3::liquidation_v2`,
1676
2301
  arguments: [
1677
2302
  e.object("0x06"),
@@ -1680,17 +2305,17 @@ async function kt(e, r, o, n, t, a) {
1680
2305
  // Price oracle for asset pricing
1681
2306
  e.object(i.storage),
1682
2307
  // Protocol storage
1683
- e.pure.u8(c.id),
2308
+ e.pure.u8(s.id),
1684
2309
  // Pay asset ID
1685
- e.object(c.contract.pool),
2310
+ e.object(s.contract.pool),
1686
2311
  // Pay asset pool contract
1687
- g(o, e.object),
2312
+ h(r, e.object),
1688
2313
  // Debt repayment amount
1689
- e.pure.u8(u.id),
2314
+ e.pure.u8(l.id),
1690
2315
  // Collateral asset ID
1691
- e.object(u.contract.pool),
2316
+ e.object(l.contract.pool),
1692
2317
  // Collateral asset pool contract
1693
- g(t, e.pure.address),
2318
+ h(n, e.pure.address),
1694
2319
  // Borrower address
1695
2320
  e.object(i.incentiveV2),
1696
2321
  // Incentive V2 contract
@@ -1699,327 +2324,337 @@ async function kt(e, r, o, n, t, a) {
1699
2324
  e.object("0x05")
1700
2325
  // SuiSystemState object
1701
2326
  ],
1702
- typeArguments: [c.suiCoinType, u.suiCoinType]
2327
+ typeArguments: [s.suiCoinType, l.suiCoinType]
1703
2328
  });
1704
- return [m, h];
2329
+ return [m, g];
1705
2330
  }
1706
2331
  }
1707
- async function Re(e, r, o) {
1708
- const n = o?.client ?? V, t = new F(), a = await q({
1709
- ...o,
1710
- markets: Object.values(U),
1711
- cacheTime: b
1712
- }), s = await ie(o);
1713
- for (let m of r) {
1714
- const h = await _({
1715
- ...o,
1716
- cacheTime: b,
2332
+ async function $t(e, t, r) {
2333
+ const o = r?.client ?? V, n = new N(), a = await G({
2334
+ ...r,
2335
+ markets: Object.values(F),
2336
+ cacheTime: v
2337
+ }), c = await Be(r);
2338
+ for (let m of t) {
2339
+ const g = await j({
2340
+ ...r,
2341
+ cacheTime: v,
1717
2342
  market: m.market
1718
2343
  });
1719
- t.moveCall({
1720
- target: `${h.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
2344
+ n.moveCall({
2345
+ target: `${g.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
1721
2346
  arguments: [
1722
- t.object("0x06"),
2347
+ n.object("0x06"),
1723
2348
  // Clock object
1724
- t.object(h.storage),
2349
+ n.object(g.storage),
1725
2350
  // Protocol storage
1726
- t.object(h.incentiveV3),
2351
+ n.object(g.incentiveV3),
1727
2352
  // Incentive V3 contract
1728
- t.pure.address(m.address)
2353
+ n.pure.address(m.address)
1729
2354
  // User address
1730
2355
  ]
1731
2356
  });
1732
2357
  }
1733
- const i = await n.devInspectTransactionBlock({
1734
- transactionBlock: t,
2358
+ const i = await q(o, {
2359
+ transactionBlock: n,
1735
2360
  sender: e
1736
- }), c = [];
2361
+ }), s = [];
1737
2362
  i?.results?.forEach((m) => {
1738
- c.push(
1739
- H(
2363
+ s.push(
2364
+ Q(
1740
2365
  {
1741
2366
  results: [m]
1742
2367
  },
1743
2368
  [
1744
- C.vector(C.string()),
2369
+ u.vector(u.string()),
1745
2370
  // Asset coin types
1746
- C.vector(C.string()),
2371
+ u.vector(u.string()),
1747
2372
  // Reward coin types
1748
- C.vector(C.u8()),
2373
+ u.vector(u.u8()),
1749
2374
  // Reward options
1750
- C.vector(C.Address),
2375
+ u.vector(u.Address),
1751
2376
  // Rule IDs
1752
- C.vector(C.u256())
2377
+ u.vector(u.u256())
1753
2378
  // Claimable amounts
1754
2379
  ]
1755
2380
  )
1756
2381
  );
1757
2382
  });
1758
- const u = [];
1759
- return c.forEach((m, h) => {
1760
- const v = r[h];
2383
+ const l = [];
2384
+ return s.forEach((m, g) => {
2385
+ const b = t[g];
1761
2386
  if (m.length === 5 && Array.isArray(m[0])) {
1762
2387
  const y = m[0].length;
1763
- for (let l = 0; l < y; l++) {
1764
- const f = s.find(
1765
- (I) => k(I.coinType) === k(m[1][l])
2388
+ for (let d = 0; d < y; d++) {
2389
+ const f = c.find(
2390
+ (k) => C(k.coinType) === C(m[1][d])
1766
2391
  ), w = a.find(
1767
- (I) => k(I.coinType) === k(m[0][l]) && I.market === v.market
2392
+ (k) => C(k.coinType) === C(m[0][d]) && k.market === b.market
1768
2393
  );
1769
- !f || !w || u.push({
2394
+ !f || !w || l.push({
1770
2395
  assetId: w.id,
1771
- assetCoinType: k(m[0][l]),
1772
- rewardCoinType: k(m[1][l]),
1773
- option: Number(m[2][l]),
1774
- userClaimableReward: Number(m[4][l]) / Math.pow(10, f.priceDecimal),
1775
- ruleIds: Array.isArray(m[3][l]) ? m[3][l] : [m[3][l]],
1776
- market: v.market,
1777
- owner: v.owner,
1778
- address: v.address,
1779
- emodeId: v.emodeId
2396
+ assetCoinType: C(m[0][d]),
2397
+ rewardCoinType: C(m[1][d]),
2398
+ option: Number(m[2][d]),
2399
+ userClaimableReward: Number(m[4][d]) / Math.pow(10, f.priceDecimal),
2400
+ ruleIds: Array.isArray(m[3][d]) ? m[3][d] : [m[3][d]],
2401
+ market: b.market,
2402
+ owner: b.owner,
2403
+ address: b.address,
2404
+ emodeId: b.emodeId
1780
2405
  });
1781
2406
  }
1782
2407
  }
1783
- }), u;
2408
+ }), l;
1784
2409
  }
1785
- async function _t(e, r) {
1786
- const o = (r?.markets || [U.main]).map((a) => T(a));
1787
- let n = [];
2410
+ async function br(e, t) {
2411
+ const r = (t?.markets || [F.main]).map((a) => _(a));
2412
+ let o = [];
1788
2413
  try {
1789
- n = await oe(e, r);
2414
+ o = await ke(e, t);
1790
2415
  } catch (a) {
1791
2416
  console.error(a);
1792
2417
  }
1793
- const t = o.map((a) => ({
2418
+ const n = r.map((a) => ({
1794
2419
  address: e,
1795
2420
  owner: e,
1796
2421
  market: a.key
1797
2422
  })).concat(
1798
- n.filter((a) => !!o.find((s) => s.id === a.marketId)).map((a) => {
1799
- const s = T(a.marketId);
2423
+ o.filter((a) => !!r.find((c) => c.id === a.marketId)).map((a) => {
2424
+ const c = _(a.marketId);
1800
2425
  return {
1801
2426
  address: a.accountCap,
1802
2427
  owner: e,
1803
- market: s.key,
2428
+ market: c.key,
1804
2429
  emodeId: a.emodeId
1805
2430
  };
1806
2431
  })
1807
2432
  );
1808
- return await Re(e, t, r);
2433
+ return await $t(e, n, t);
1809
2434
  }
1810
- function Ct(e) {
1811
- const r = /* @__PURE__ */ new Map();
1812
- e.forEach((n) => {
1813
- const t = n.assetId, a = n.option, s = `${t}-${a}-${n.rewardCoinType}-${n.market}`;
1814
- r.has(s) ? r.get(s).total += n.userClaimableReward : r.set(s, {
1815
- assetId: t,
2435
+ function wr(e) {
2436
+ const t = /* @__PURE__ */ new Map();
2437
+ e.forEach((o) => {
2438
+ const n = o.assetId, a = o.option, c = `${n}-${a}-${o.rewardCoinType}-${o.market}`;
2439
+ t.has(c) ? t.get(c).total += o.userClaimableReward : t.set(c, {
2440
+ assetId: n,
1816
2441
  rewardType: a,
1817
- coinType: n.rewardCoinType,
1818
- total: Number(n.userClaimableReward),
1819
- market: n.market
2442
+ coinType: o.rewardCoinType,
2443
+ total: Number(o.userClaimableReward),
2444
+ market: o.market
1820
2445
  });
1821
2446
  });
1822
- const o = /* @__PURE__ */ new Map();
1823
- for (const { assetId: n, rewardType: t, coinType: a, total: s, market: i } of r.values()) {
1824
- const c = `${n}-${t}-${i}`;
1825
- o.has(c) || o.set(c, { assetId: n, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
1826
- const u = o.get(c);
1827
- u.rewards.set(a, (u.rewards.get(a) || 0) + s);
1828
- }
1829
- return Array.from(o.values()).map((n) => ({
1830
- assetId: n.assetId,
1831
- rewardType: n.rewardType,
1832
- market: n.market,
1833
- rewards: Array.from(n.rewards.entries()).map(([t, a]) => ({
1834
- coinType: t,
2447
+ const r = /* @__PURE__ */ new Map();
2448
+ for (const { assetId: o, rewardType: n, coinType: a, total: c, market: i } of t.values()) {
2449
+ const s = `${o}-${n}-${i}`;
2450
+ r.has(s) || r.set(s, { assetId: o, rewardType: n, market: i, rewards: /* @__PURE__ */ new Map() });
2451
+ const l = r.get(s);
2452
+ l.rewards.set(a, (l.rewards.get(a) || 0) + c);
2453
+ }
2454
+ return Array.from(r.values()).map((o) => ({
2455
+ assetId: o.assetId,
2456
+ rewardType: o.rewardType,
2457
+ market: o.market,
2458
+ rewards: Array.from(o.rewards.entries()).map(([n, a]) => ({
2459
+ coinType: n,
1835
2460
  available: a.toFixed(6)
1836
2461
  }))
1837
2462
  }));
1838
2463
  }
1839
- const jt = P(
1840
- async (e, r) => {
1841
- const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${E.version}&market=${r?.market || O}`;
1842
- return (await fetch(o, { headers: D }).then((t) => t.json())).data;
2464
+ const vr = A(
2465
+ async (e, t) => {
2466
+ const r = E(t), o = M(
2467
+ `/navi/user/total_claimed_reward?userAddress=${e}&sdk=${O.version}&market=${t?.market || R}`,
2468
+ t
2469
+ );
2470
+ return (await fetch(o, {
2471
+ headers: U(D, r)
2472
+ }).then((a) => a.json())).data;
1843
2473
  }
1844
- ), It = P(
1845
- async (e, r) => {
1846
- const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${r?.page || 1}&pageSize=${r?.size || 400}&sdk=${E.version}&market=${r?.market || O}`, n = await fetch(o, { headers: D }).then((t) => t.json());
1847
- return K({
2474
+ ), Cr = A(
2475
+ async (e, t) => {
2476
+ const r = E(t), o = M(
2477
+ `/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${O.version}&market=${t?.market || R}`,
2478
+ t
2479
+ ), n = await fetch(o, {
2480
+ headers: U(D, r)
2481
+ }).then((a) => a.json());
2482
+ return x({
1848
2483
  data: n.data.rewards
1849
2484
  });
1850
2485
  }
1851
2486
  );
1852
- async function Tt(e, r, o) {
1853
- const n = await q({
1854
- ...o,
1855
- markets: Object.values(U),
1856
- cacheTime: b
1857
- }), t = /* @__PURE__ */ new Map();
1858
- for (const s of r) {
1859
- const { rewardCoinType: i, ruleIds: c, market: u, owner: m, address: h, emodeId: v } = s, y = `${i}___${h}__${u}`;
1860
- for (const l of c) {
1861
- t.has(y) || t.set(y, {
2487
+ async function jr(e, t, r) {
2488
+ const o = await G({
2489
+ ...r,
2490
+ markets: Object.values(F),
2491
+ cacheTime: v
2492
+ }), n = /* @__PURE__ */ new Map();
2493
+ for (const c of t) {
2494
+ const { rewardCoinType: i, ruleIds: s, market: l, owner: m, address: g, emodeId: b } = c, y = `${i}___${g}__${l}`;
2495
+ for (const d of s) {
2496
+ n.has(y) || n.set(y, {
1862
2497
  assetIds: [],
1863
2498
  ruleIds: [],
1864
2499
  amount: 0,
1865
- market: u,
2500
+ market: l,
1866
2501
  owner: m,
1867
- address: h,
1868
- isEMode: typeof v < "u"
2502
+ address: g,
2503
+ isEMode: typeof b < "u"
1869
2504
  });
1870
- const f = t.get(y);
1871
- f.assetIds.push(s.assetCoinType.replace("0x", "")), f.ruleIds.push(l), f.amount += s.userClaimableReward;
2505
+ const f = n.get(y);
2506
+ f.assetIds.push(c.assetCoinType.replace("0x", "")), f.ruleIds.push(d), f.amount += c.userClaimableReward;
1872
2507
  }
1873
2508
  }
1874
2509
  const a = [];
1875
2510
  for (const [
1876
- s,
1877
- { assetIds: i, ruleIds: c, amount: u, market: m, owner: h, address: v, isEMode: y }
1878
- ] of t) {
1879
- const l = await _({
1880
- ...o,
1881
- cacheTime: b,
2511
+ c,
2512
+ { assetIds: i, ruleIds: s, amount: l, market: m, owner: g, address: b, isEMode: y }
2513
+ ] of n) {
2514
+ const d = await j({
2515
+ ...r,
2516
+ cacheTime: v,
1882
2517
  market: m
1883
- }), f = s.split("___")[0], w = n.filter(
1884
- (j) => k(j.suiCoinType) === k(f)
2518
+ }), f = c.split("___")[0], w = o.filter(
2519
+ (I) => C(I.suiCoinType) === C(f)
1885
2520
  );
1886
- w.sort((j, A) => j.market === m ? -1 : 1);
1887
- const I = w[0], B = l.rewardFunds[k(f)];
1888
- if (!B)
2521
+ w.sort((I, B) => I.market === m ? -1 : 1);
2522
+ const k = w[0], T = d.rewardFunds[C(f)];
2523
+ if (!T)
1889
2524
  throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
1890
- if (o?.accountCap && !o.customCoinReceive)
2525
+ if (r?.accountCap && !r.customCoinReceive)
1891
2526
  throw new Error("customCoinReceive is required when accountCap is provided");
1892
- if (o?.customCoinReceive) {
1893
- let j;
1894
- o.accountCap ? j = e.moveCall({
1895
- target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
2527
+ if (r?.customCoinReceive) {
2528
+ let I;
2529
+ r.accountCap ? I = e.moveCall({
2530
+ target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
1896
2531
  arguments: [
1897
2532
  e.object("0x06"),
1898
2533
  // Clock object
1899
- e.object(l.incentiveV3),
2534
+ e.object(d.incentiveV3),
1900
2535
  // Incentive V3 contract
1901
- e.object(l.storage),
2536
+ e.object(d.storage),
1902
2537
  // Protocol storage
1903
- e.object(B),
2538
+ e.object(T),
1904
2539
  // Reward fund
1905
2540
  e.pure.vector("string", i),
1906
2541
  // Asset IDs
1907
- e.pure.vector("address", c),
2542
+ e.pure.vector("address", s),
1908
2543
  // Rule IDs
1909
- g(o.accountCap, e.object)
2544
+ h(r.accountCap, e.object)
1910
2545
  // Account capability
1911
2546
  ],
1912
2547
  typeArguments: [f]
1913
- }) : y ? j = e.moveCall({
1914
- target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
2548
+ }) : y ? I = e.moveCall({
2549
+ target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
1915
2550
  arguments: [
1916
2551
  e.object("0x06"),
1917
2552
  // Clock object
1918
- e.object(l.incentiveV3),
2553
+ e.object(d.incentiveV3),
1919
2554
  // Incentive V3 contract
1920
- e.object(l.storage),
2555
+ e.object(d.storage),
1921
2556
  // Protocol storage
1922
- e.object(B),
2557
+ e.object(T),
1923
2558
  // Reward fund
1924
2559
  e.pure.vector("string", i),
1925
2560
  // Asset IDs
1926
- e.pure.vector("address", c),
2561
+ e.pure.vector("address", s),
1927
2562
  // Rule IDs
1928
- g(v, e.object)
2563
+ h(b, e.object)
1929
2564
  // Account capability
1930
2565
  ],
1931
2566
  typeArguments: [f]
1932
- }) : j = e.moveCall({
1933
- target: `${l.package}::incentive_v3::claim_reward`,
2567
+ }) : I = e.moveCall({
2568
+ target: `${d.package}::incentive_v3::claim_reward`,
1934
2569
  arguments: [
1935
2570
  e.object("0x06"),
1936
2571
  // Clock object
1937
- e.object(l.incentiveV3),
2572
+ e.object(d.incentiveV3),
1938
2573
  // Incentive V3 contract
1939
- e.object(l.storage),
2574
+ e.object(d.storage),
1940
2575
  // Protocol storage
1941
- e.object(B),
2576
+ e.object(T),
1942
2577
  // Reward fund
1943
2578
  e.pure.vector("string", i),
1944
2579
  // Asset IDs
1945
- e.pure.vector("address", c)
2580
+ e.pure.vector("address", s)
1946
2581
  // Rule IDs
1947
2582
  ],
1948
2583
  typeArguments: [f]
1949
2584
  });
1950
- const [A] = e.moveCall({
2585
+ const [B] = e.moveCall({
1951
2586
  target: "0x2::coin::from_balance",
1952
- arguments: [j],
2587
+ arguments: [I],
1953
2588
  typeArguments: [f]
1954
2589
  });
1955
- if (o?.customCoinReceive.type === "transfer") {
1956
- if (!o.customCoinReceive.transfer)
2590
+ if (r?.customCoinReceive.type === "transfer") {
2591
+ if (!r.customCoinReceive.transfer)
1957
2592
  throw new Error("customCoinReceive.transfer is required");
1958
2593
  e.transferObjects(
1959
- [A],
1960
- g(o.customCoinReceive.transfer, e.pure.address)
2594
+ [B],
2595
+ h(r.customCoinReceive.transfer, e.pure.address)
1961
2596
  );
1962
2597
  }
1963
- if (o?.customCoinReceive.type === "depositNAVI") {
1964
- const L = p(I.totalSupplyAmount).shiftedBy(-9), G = p(I.supplyCapCeiling).shiftedBy(-27);
1965
- L.plus(u).isGreaterThan(G) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
1966
- [A],
1967
- e.pure.address(o.customCoinReceive.depositNAVI.fallbackReceiveAddress)
1968
- ) : await Be(e, I, A, {
1969
- ...o,
1970
- market: I.market
2598
+ if (r?.customCoinReceive.type === "depositNAVI") {
2599
+ const W = p(k.totalSupplyAmount).shiftedBy(-9), Y = p(k.supplyCapCeiling).shiftedBy(-27);
2600
+ W.plus(l).isGreaterThan(Y) && r?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
2601
+ [B],
2602
+ e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
2603
+ ) : await ht(e, k, B, {
2604
+ ...r,
2605
+ market: k.market
1971
2606
  });
1972
2607
  } else
1973
2608
  a.push({
1974
- coin: A,
1975
- identifier: I,
1976
- owner: h,
2609
+ coin: B,
2610
+ identifier: k,
2611
+ owner: g,
1977
2612
  isEMode: y
1978
2613
  });
1979
- } else if (o?.accountCap || y) {
1980
- const j = e.moveCall({
1981
- target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
2614
+ } else if (r?.accountCap || y) {
2615
+ const I = e.moveCall({
2616
+ target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
1982
2617
  arguments: [
1983
2618
  e.object("0x06"),
1984
2619
  // Clock object
1985
- e.object(l.incentiveV3),
2620
+ e.object(d.incentiveV3),
1986
2621
  // Incentive V3 contract
1987
- e.object(l.storage),
2622
+ e.object(d.storage),
1988
2623
  // Protocol storage
1989
- e.object(B),
2624
+ e.object(T),
1990
2625
  // Reward fund
1991
2626
  e.pure.vector("string", i),
1992
2627
  // Asset IDs
1993
- e.pure.vector("address", c),
2628
+ e.pure.vector("address", s),
1994
2629
  // Rule IDs
1995
- g(o?.accountCap || v, e.object)
2630
+ h(r?.accountCap || b, e.object)
1996
2631
  // Account capability
1997
2632
  ],
1998
2633
  typeArguments: [f]
1999
- }), [A] = e.moveCall({
2634
+ }), [B] = e.moveCall({
2000
2635
  target: "0x2::coin::from_balance",
2001
- arguments: [j],
2636
+ arguments: [I],
2002
2637
  typeArguments: [f]
2003
2638
  });
2004
2639
  e.transferObjects(
2005
- [A],
2006
- g(o?.accountCap || h, e.pure.address)
2640
+ [B],
2641
+ h(r?.accountCap || g, e.pure.address)
2007
2642
  );
2008
2643
  } else
2009
2644
  e.moveCall({
2010
- target: `${l.package}::incentive_v3::claim_reward_entry`,
2645
+ target: `${d.package}::incentive_v3::claim_reward_entry`,
2011
2646
  arguments: [
2012
2647
  e.object("0x06"),
2013
2648
  // Clock object
2014
- e.object(l.incentiveV3),
2649
+ e.object(d.incentiveV3),
2015
2650
  // Incentive V3 contract
2016
- e.object(l.storage),
2651
+ e.object(d.storage),
2017
2652
  // Protocol storage
2018
- e.object(B),
2653
+ e.object(T),
2019
2654
  // Reward fund
2020
2655
  e.pure.vector("string", i),
2021
2656
  // Asset IDs
2022
- e.pure.vector("address", c)
2657
+ e.pure.vector("address", s)
2023
2658
  // Rule IDs
2024
2659
  ],
2025
2660
  typeArguments: [f]
@@ -2028,71 +2663,86 @@ async function Tt(e, r, o) {
2028
2663
  return a;
2029
2664
  }
2030
2665
  export {
2031
- J as Address,
2032
- b as DEFAULT_CACHE_TIME,
2033
- O as DEFAULT_MARKET_IDENTITY,
2034
- Xe as FlashLoanAssetConfig,
2035
- Je as IncentiveAPYInfo,
2036
- he as IncentivePoolInfo,
2037
- Ze as IncentivePoolInfoByPhase,
2038
- U as MARKETS,
2039
- Ae as Market,
2040
- Qe as OracleInfo,
2041
- R as PoolOperator,
2042
- ve as ReserveDataInfo,
2043
- N as UserPositions,
2044
- we as UserStateInfo,
2045
- ot as borrowCoinPTB,
2046
- Tt as claimLendingRewardsPTB,
2047
- Pe as createAccountCapPTB,
2048
- ct as createEModeCapPTB,
2049
- Be as depositCoinPTB,
2050
- st as emodeIdentityId,
2051
- Me as enterEModePTB,
2052
- it as exitEModePTB,
2053
- Fe as filterPriceFeeds,
2054
- wt as flashloanPTB,
2055
- Se as getAccountCapOwnerPTB,
2056
- Y as getAllFlashLoanAssets,
2057
- nt as getBorrowFee,
2058
- ft as getCoins,
2059
- _ as getConfig,
2060
- et as getFees,
2061
- vt as getFlashLoanAsset,
2062
- pt as getHealthFactor,
2063
- Ve as getHealthFactorPTB,
2064
- Ee as getLendingPositions,
2065
- ut as getLendingState,
2066
- at as getMarket,
2067
- T as getMarketConfig,
2068
- $e as getMarkets,
2666
+ ne as Address,
2667
+ v as DEFAULT_CACHE_TIME,
2668
+ R as DEFAULT_MARKET_IDENTITY,
2669
+ zt as FlashLoanAssetConfig,
2670
+ Rt as IncentiveAPYInfo,
2671
+ Ne as IncentivePoolInfo,
2672
+ Lt as IncentivePoolInfoByPhase,
2673
+ F as MARKETS,
2674
+ bt as Market,
2675
+ He as NaviMissingGraphQLClientError,
2676
+ qt as OracleInfo,
2677
+ z as PoolOperator,
2678
+ Re as ReserveDataInfo,
2679
+ he as SuiPriceServiceConnection,
2680
+ ct as SuiPythClient,
2681
+ L as UserPositions,
2682
+ Le as UserStateInfo,
2683
+ Xt as borrowCoinPTB,
2684
+ M as buildNaviOpenApiUrl,
2685
+ jr as claimLendingRewardsPTB,
2686
+ Kt as configureNaviSdk,
2687
+ vt as createAccountCapPTB,
2688
+ nr as createEModeCapPTB,
2689
+ ge as createNaviLegacyJsonRpcClient,
2690
+ xe as createNaviSuiClient,
2691
+ Ze as createNaviSuiClientBundle,
2692
+ ht as depositCoinPTB,
2693
+ or as emodeIdentityId,
2694
+ jt as enterEModePTB,
2695
+ rr as exitEModePTB,
2696
+ St as filterPriceFeeds,
2697
+ yr as flashloanPTB,
2698
+ Ct as getAccountCapOwnerPTB,
2699
+ Wt as getAddressBalance,
2700
+ re as getAllFlashLoanAssets,
2701
+ er as getBorrowFee,
2702
+ Gt as getCoinObjectOnlyBalance,
2703
+ ur as getCoins,
2704
+ j as getConfig,
2705
+ Yt as getFees,
2706
+ fr as getFlashLoanAsset,
2707
+ cr as getHealthFactor,
2708
+ It as getHealthFactorPTB,
2709
+ _t as getLendingPositions,
2710
+ ir as getLendingState,
2711
+ tr as getMarket,
2712
+ _ as getMarketConfig,
2713
+ wt as getMarkets,
2069
2714
  S as getPool,
2070
- q as getPools,
2071
- ie as getPriceFeeds,
2072
- gt as getPythStalePriceFeedId,
2073
- Ue as getPythStalePriceFeedIdV2,
2074
- dt as getSimulatedHealthFactor,
2075
- re as getSimulatedHealthFactorPTB,
2076
- xe as getStats,
2077
- mt as getTransactions,
2078
- _t as getUserAvailableLendingRewards,
2079
- It as getUserClaimedRewardHistory,
2080
- oe as getUserEModeCaps,
2081
- jt as getUserTotalClaimedReward,
2082
- kt as liquidatePTB,
2083
- lt as mergeCoinsPTB,
2084
- k as normalizeCoinType,
2085
- Te as parsePoolUID,
2086
- g as parseTxValue,
2087
- rt as repayCoinPTB,
2088
- bt as repayFlashLoanPTB,
2089
- Ct as summaryLendingRewards,
2090
- ht as updateOraclePriceBeforeUserOperationPTB,
2091
- Ne as updateOraclePricesPTB,
2092
- Oe as updatePythPriceFeeds,
2093
- yt as verifyHealthFactorPTB,
2094
- M as withCache,
2095
- P as withSingleton,
2096
- tt as withdrawCoinPTB
2715
+ G as getPools,
2716
+ Be as getPriceFeeds,
2717
+ pr as getPythStalePriceFeedId,
2718
+ Bt as getPythStalePriceFeedIdV2,
2719
+ sr as getSimulatedHealthFactor,
2720
+ Ie as getSimulatedHealthFactorPTB,
2721
+ Qt as getStats,
2722
+ lr as getTransactions,
2723
+ br as getUserAvailableLendingRewards,
2724
+ Cr as getUserClaimedRewardHistory,
2725
+ ke as getUserEModeCaps,
2726
+ vr as getUserTotalClaimedReward,
2727
+ hr as liquidatePTB,
2728
+ Ht as listAddressBalances,
2729
+ ar as mergeCoinsPTB,
2730
+ U as mergeServiceHeaders,
2731
+ ye as normalizeAddressBalance,
2732
+ C as normalizeCoinType,
2733
+ gt as parsePoolUID,
2734
+ h as parseTxValue,
2735
+ xt as repayCoinPTB,
2736
+ gr as repayFlashLoanPTB,
2737
+ Jt as requireNaviGraphQLClient,
2738
+ E as resolveNaviOpenApiEndpoint,
2739
+ wr as summaryLendingRewards,
2740
+ mr as updateOraclePriceBeforeUserOperationPTB,
2741
+ At as updateOraclePricesPTB,
2742
+ Pt as updatePythPriceFeeds,
2743
+ dr as verifyHealthFactorPTB,
2744
+ $ as withCache,
2745
+ A as withSingleton,
2746
+ Zt as withdrawCoinPTB
2097
2747
  };
2098
2748
  //# sourceMappingURL=index.esm.js.map