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