@naviprotocol/lending 1.4.5 → 2.0.0-beta.0

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