@naviprotocol/lending 1.4.1-beta.5 → 1.4.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,15 +1,15 @@
1
- import { Transaction as U } from "@mysten/sui/transactions";
2
- import { bcs as m, toHex as ce, fromHex as ie } from "@mysten/bcs";
3
- import { SuiClient as se, getFullnodeUrl as le } from "@mysten/sui/client";
4
- import ue from "lodash.camelcase";
1
+ import { Transaction as O } from "@mysten/sui/transactions";
2
+ import { bcs as m, toHex as ie, fromHex as ce } from "@mysten/bcs";
3
+ import { SuiClient as se, getFullnodeUrl as ue } from "@mysten/sui/client";
4
+ import le from "lodash.camelcase";
5
5
  import { normalizeStructTag as pe } from "@mysten/sui/utils";
6
6
  import { SuiPriceServiceConnection as Z, SuiPythClient as de } from "@pythnetwork/pyth-sui-js";
7
7
  import p from "bignumber.js";
8
8
  import { bcs as C } from "@mysten/sui/bcs";
9
9
  const z = m.bytes(32).transform({
10
10
  // To change the input type, you need to provide a type definition for the input
11
- input: (e) => ie(e),
12
- output: (e) => ce(e)
11
+ input: (e) => ce(e),
12
+ output: (e) => ie(e)
13
13
  }), He = m.struct("IncentiveAPYInfo", {
14
14
  /** Asset identifier */
15
15
  asset_id: m.u8(),
@@ -129,7 +129,7 @@ const z = m.bytes(32).transform({
129
129
  borrow_balance: m.u256(),
130
130
  /** User's current supply balance */
131
131
  supply_balance: m.u256()
132
- }), ye = "1.4.1-beta.5", V = {
132
+ }), ye = "1.4.1-dev.1", V = {
133
133
  version: ye
134
134
  }, ge = V.version, he = () => {
135
135
  if (typeof process < "u" && process.versions && process.versions.node)
@@ -144,15 +144,15 @@ const z = m.bytes(32).transform({
144
144
  let e = "";
145
145
  return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ge} (${he()})`), e;
146
146
  }, K = ve(), P = new se({
147
- url: le("mainnet")
147
+ url: ue("mainnet")
148
148
  });
149
149
  function Q(e) {
150
150
  const n = [];
151
151
  return e.forEach((o, r) => {
152
152
  const t = r === e.length - 1;
153
153
  if (typeof o == "object" && o !== null && t) {
154
- const { client: a, disableCache: i, cacheTime: c, ...s } = o;
155
- n.push(s);
154
+ const { client: a, disableCache: s, cacheTime: i, ...c } = o;
155
+ n.push(c);
156
156
  } else
157
157
  n.push(o);
158
158
  }), JSON.stringify(n);
@@ -170,22 +170,22 @@ function $(e) {
170
170
  let n = {};
171
171
  return (...o) => {
172
172
  const r = o[o.length - 1], t = Q(o), a = n[t];
173
- return !r?.disableCache && typeof a?.data < "u" && (typeof r?.cacheTime > "u" || r.cacheTime > Date.now() - a.cacheAt) ? a.data : e(...o).then((i) => (n[t] = {
174
- data: i,
173
+ return !r?.disableCache && typeof a?.data < "u" && (typeof r?.cacheTime > "u" || r.cacheTime > Date.now() - a.cacheAt) ? a.data : e(...o).then((s) => (n[t] = {
174
+ data: s,
175
175
  cacheAt: Date.now()
176
- }, i));
176
+ }, s));
177
177
  };
178
178
  }
179
179
  function W(e) {
180
180
  return Array.isArray(e) ? e.map((n) => W(n)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
181
181
  (n, o) => ({
182
182
  ...n,
183
- [ue(o)]: W(e[o])
183
+ [le(o)]: W(e[o])
184
184
  }),
185
185
  {}
186
186
  ) : e;
187
187
  }
188
- function g(e, n) {
188
+ function h(e, n) {
189
189
  return typeof e == "object" ? e : n(e);
190
190
  }
191
191
  function we(e, n) {
@@ -199,7 +199,7 @@ function L(e, n, o) {
199
199
  return console.log(`Get an error, msg: ${e.error}`), [];
200
200
  return [];
201
201
  }
202
- function b(e) {
202
+ function k(e) {
203
203
  return pe(e);
204
204
  }
205
205
  function X(e) {
@@ -213,7 +213,7 @@ const be = 27, Y = (e, n) => {
213
213
  if (!Number(e) || !Number(n)) return new p(0);
214
214
  const o = new p(1).shiftedBy(1 * be), r = o.multipliedBy(new p(0.5));
215
215
  return new p(e).multipliedBy(new p(n)).plus(r).dividedBy(o).integerValue(p.ROUND_DOWN);
216
- }, E = K ? {
216
+ }, M = K ? {
217
217
  "User-Agent": K
218
218
  } : {};
219
219
  function H(e, n = "uniqueId") {
@@ -249,27 +249,27 @@ function ke(e) {
249
249
  poolId: parseInt(o)
250
250
  };
251
251
  }
252
- function T() {
252
+ function I() {
253
253
  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
254
  }
255
255
  var F = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(F || {});
256
256
  const R = $(
257
257
  B(
258
258
  async (e) => {
259
- const n = (e?.markets || [M.main]).map((t) => _(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${V.version}&market=${n.map(
259
+ const n = (e?.markets || [E.main]).map((t) => j(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${V.version}&market=${n.map(
260
260
  (t) => t.key
261
- )}`, r = await fetch(o, { headers: E }).then((t) => t.json());
261
+ )}`, r = await fetch(o, { headers: M }).then((t) => t.json());
262
262
  return r.data.forEach((t) => {
263
- const i = r.meta.emodes.filter((h) => {
264
- const j = _(h.marketId);
265
- return t.market === j.key && h.isActive;
266
- }).filter((h) => !!h.assets.find((j) => j.assetId === t.id));
267
- t.emodes = i;
268
- const c = p(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), s = p(t.borrowedAmount).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), l = p(c).multipliedBy(t.oracle.price).toString(), d = p(s).multipliedBy(t.oracle.price).toString(), f = p(t.supplyCapCeiling).shiftedBy(-27).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), v = p.max(
263
+ const s = r.meta.emodes.filter((f) => {
264
+ const w = j(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(), d = p(c).multipliedBy(t.oracle.price).toString(), y = p(t.supplyCapCeiling).shiftedBy(-27).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), v = p.max(
269
269
  p(t.borrowedAmount),
270
270
  p(t.validBorrowAmount)
271
- ).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), y = p(f).multipliedBy(t.oracle.price).toString(), u = p(v).multipliedBy(t.oracle.price).toString();
272
- t.poolSupplyAmount = c, t.poolBorrowAmount = s, t.poolSupplyValue = l, t.poolBorrowValue = d, t.poolSupplyCapAmount = f, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = y, t.poolBorrowCapValue = u;
271
+ ).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), g = p(y).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 = d, t.poolSupplyCapAmount = y, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = g, t.poolBorrowCapValue = l;
273
273
  }), r.data;
274
274
  }
275
275
  )
@@ -283,11 +283,11 @@ async function A(e, n) {
283
283
  const r = await R({
284
284
  ...n,
285
285
  markets: [o || N],
286
- cacheTime: w
286
+ cacheTime: b
287
287
  });
288
288
  if (typeof e == "object")
289
289
  return e;
290
- const t = r.find((a) => typeof e == "string" ? b(a.suiCoinType) === b(e) : typeof e == "number" ? a.id === e : !1);
290
+ const t = r.find((a) => typeof e == "string" ? k(a.suiCoinType) === k(e) : typeof e == "number" ? a.id === e : !1);
291
291
  if (!t)
292
292
  throw new Error("Pool not found");
293
293
  return t.isDeprecated && console.log(`The lending pool for coinType ${t.suiCoinType} is going to be deprecated.`), t;
@@ -295,33 +295,33 @@ async function A(e, n) {
295
295
  const Je = $(
296
296
  B(async (e) => {
297
297
  const n = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${V.version}`;
298
- return (await fetch(n, { headers: E }).then((r) => r.json())).data;
298
+ return (await fetch(n, { headers: M }).then((r) => r.json())).data;
299
299
  })
300
300
  ), Ze = $(
301
301
  B(
302
302
  async (e) => {
303
303
  const n = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${V.version}`;
304
- return await fetch(n, { headers: E }).then((r) => r.json());
304
+ return await fetch(n, { headers: M }).then((r) => r.json());
305
305
  }
306
306
  )
307
307
  );
308
- async function Ce(e, n, o, r) {
309
- const t = await k({
308
+ async function _e(e, n, o, r) {
309
+ const t = await _({
310
310
  ...r,
311
- cacheTime: w
311
+ cacheTime: b
312
312
  }), a = await A(n, r);
313
313
  if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
314
314
  throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
315
- const i = typeof o == "object" && o.$kind === "GasCoin";
316
- if (b(a.suiCoinType) === b("0x2::sui::SUI") && i) {
315
+ const s = typeof o == "object" && o.$kind === "GasCoin";
316
+ if (k(a.suiCoinType) === k("0x2::sui::SUI") && s) {
317
317
  if (!r?.amount)
318
318
  throw new Error("Amount is required for sui coin");
319
319
  o = e.splitCoins(o, [r.amount]);
320
320
  }
321
- let c;
322
- return typeof r?.amount < "u" ? c = g(r.amount, e.pure.u64) : c = e.moveCall({
321
+ let i;
322
+ return typeof r?.amount < "u" ? i = h(r.amount, e.pure.u64) : i = e.moveCall({
323
323
  target: "0x2::coin::value",
324
- arguments: [g(o, e.object)],
324
+ arguments: [h(o, e.object)],
325
325
  typeArguments: [a.suiCoinType]
326
326
  }), r?.accountCap ? e.moveCall({
327
327
  target: `${t.package}::incentive_v3::deposit_with_account_cap`,
@@ -330,10 +330,10 @@ async function Ce(e, n, o, r) {
330
330
  e.object(t.storage),
331
331
  e.object(a.contract.pool),
332
332
  e.pure.u8(a.id),
333
- g(o, e.object),
333
+ h(o, e.object),
334
334
  e.object(t.incentiveV2),
335
335
  e.object(t.incentiveV3),
336
- g(r.accountCap, e.object)
336
+ h(r.accountCap, e.object)
337
337
  ],
338
338
  typeArguments: [a.suiCoinType]
339
339
  }) : e.moveCall({
@@ -343,8 +343,8 @@ async function Ce(e, n, o, r) {
343
343
  e.object(t.storage),
344
344
  e.object(a.contract.pool),
345
345
  e.pure.u8(a.id),
346
- g(o, e.object),
347
- c,
346
+ h(o, e.object),
347
+ i,
348
348
  e.object(t.incentiveV2),
349
349
  e.object(t.incentiveV3)
350
350
  ],
@@ -355,14 +355,14 @@ async function Ce(e, n, o, r) {
355
355
  }), e;
356
356
  }
357
357
  async function Qe(e, n, o, r) {
358
- const t = await k({
358
+ const t = await _({
359
359
  ...r,
360
- cacheTime: w
361
- }), a = await A(n, r), i = g(o, e.pure.u64);
362
- let c;
360
+ cacheTime: b
361
+ }), a = await A(n, r), s = h(o, e.pure.u64);
362
+ let i;
363
363
  if (t.version === 1)
364
364
  if (r?.accountCap) {
365
- const [l] = e.moveCall({
365
+ const [u] = e.moveCall({
366
366
  target: `${t.package}::incentive_v3::withdraw_with_account_cap`,
367
367
  arguments: [
368
368
  e.object("0x06"),
@@ -370,16 +370,16 @@ async function Qe(e, n, o, r) {
370
370
  e.object(t.storage),
371
371
  e.object(a.contract.pool),
372
372
  e.pure.u8(a.id),
373
- i,
373
+ s,
374
374
  e.object(t.incentiveV2),
375
375
  e.object(t.incentiveV3),
376
- g(r.accountCap, e.object)
376
+ h(r.accountCap, e.object)
377
377
  ],
378
378
  typeArguments: [a.suiCoinType]
379
379
  });
380
- c = l;
380
+ i = u;
381
381
  } else {
382
- const [l] = e.moveCall({
382
+ const [u] = e.moveCall({
383
383
  target: `${t.package}::incentive_v3::withdraw`,
384
384
  arguments: [
385
385
  e.object("0x06"),
@@ -387,16 +387,16 @@ async function Qe(e, n, o, r) {
387
387
  e.object(t.storage),
388
388
  e.object(a.contract.pool),
389
389
  e.pure.u8(a.id),
390
- i,
390
+ s,
391
391
  e.object(t.incentiveV2),
392
392
  e.object(t.incentiveV3)
393
393
  ],
394
394
  typeArguments: [a.suiCoinType]
395
395
  });
396
- c = l;
396
+ i = u;
397
397
  }
398
398
  else if (r?.accountCap) {
399
- const [l] = e.moveCall({
399
+ const [u] = e.moveCall({
400
400
  target: `${t.package}::incentive_v3::withdraw_with_account_cap_v2`,
401
401
  arguments: [
402
402
  e.object("0x06"),
@@ -404,17 +404,17 @@ async function Qe(e, n, o, r) {
404
404
  e.object(t.storage),
405
405
  e.object(a.contract.pool),
406
406
  e.pure.u8(a.id),
407
- i,
407
+ s,
408
408
  e.object(t.incentiveV2),
409
409
  e.object(t.incentiveV3),
410
- g(r.accountCap, e.object),
410
+ h(r.accountCap, e.object),
411
411
  e.object("0x05")
412
412
  ],
413
413
  typeArguments: [a.suiCoinType]
414
414
  });
415
- c = l;
415
+ i = u;
416
416
  } else {
417
- const [l] = e.moveCall({
417
+ const [u] = e.moveCall({
418
418
  target: `${t.package}::incentive_v3::withdraw_v2`,
419
419
  arguments: [
420
420
  e.object("0x06"),
@@ -422,33 +422,33 @@ async function Qe(e, n, o, r) {
422
422
  e.object(t.storage),
423
423
  e.object(a.contract.pool),
424
424
  e.pure.u8(a.id),
425
- i,
425
+ s,
426
426
  e.object(t.incentiveV2),
427
427
  e.object(t.incentiveV3),
428
428
  e.object("0x05")
429
429
  ],
430
430
  typeArguments: [a.suiCoinType]
431
431
  });
432
- c = l;
432
+ i = u;
433
433
  }
434
434
  return e.moveCall({
435
435
  target: "0x2::coin::from_balance",
436
- arguments: [c],
436
+ arguments: [i],
437
437
  typeArguments: [a.suiCoinType]
438
438
  });
439
439
  }
440
440
  async function Xe(e, n, o, r) {
441
- const t = await k({
441
+ const t = await _({
442
442
  ...r,
443
- cacheTime: w
443
+ cacheTime: b
444
444
  }), a = await A(n, r);
445
445
  if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
446
446
  throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
447
- const i = g(o, e.pure.u64);
448
- let c;
447
+ const s = h(o, e.pure.u64);
448
+ let i;
449
449
  if (t.version === 1)
450
450
  if (r?.accountCap) {
451
- const [l] = e.moveCall({
451
+ const [u] = e.moveCall({
452
452
  target: `${t.package}::incentive_v3::borrow_with_account_cap`,
453
453
  arguments: [
454
454
  e.object("0x06"),
@@ -456,16 +456,16 @@ async function Xe(e, n, o, r) {
456
456
  e.object(t.storage),
457
457
  e.object(a.contract.pool),
458
458
  e.pure.u8(a.id),
459
- i,
459
+ s,
460
460
  e.object(t.incentiveV2),
461
461
  e.object(t.incentiveV3),
462
- g(r.accountCap, e.object)
462
+ h(r.accountCap, e.object)
463
463
  ],
464
464
  typeArguments: [a.suiCoinType]
465
465
  });
466
- c = l;
466
+ i = u;
467
467
  } else {
468
- const [l] = e.moveCall({
468
+ const [u] = e.moveCall({
469
469
  target: `${t.package}::incentive_v3::borrow`,
470
470
  arguments: [
471
471
  e.object("0x06"),
@@ -473,16 +473,16 @@ async function Xe(e, n, o, r) {
473
473
  e.object(t.storage),
474
474
  e.object(a.contract.pool),
475
475
  e.pure.u8(a.id),
476
- i,
476
+ s,
477
477
  e.object(t.incentiveV2),
478
478
  e.object(t.incentiveV3)
479
479
  ],
480
480
  typeArguments: [a.suiCoinType]
481
481
  });
482
- c = l;
482
+ i = u;
483
483
  }
484
484
  else if (r?.accountCap) {
485
- const [l] = e.moveCall({
485
+ const [u] = e.moveCall({
486
486
  target: `${t.package}::incentive_v3::borrow_with_account_cap_v2`,
487
487
  arguments: [
488
488
  e.object("0x06"),
@@ -490,17 +490,17 @@ async function Xe(e, n, o, r) {
490
490
  e.object(t.storage),
491
491
  e.object(a.contract.pool),
492
492
  e.pure.u8(a.id),
493
- i,
493
+ s,
494
494
  e.object(t.incentiveV2),
495
495
  e.object(t.incentiveV3),
496
- g(r.accountCap, e.object),
496
+ h(r.accountCap, e.object),
497
497
  e.object("0x05")
498
498
  ],
499
499
  typeArguments: [a.suiCoinType]
500
500
  });
501
- c = l;
501
+ i = u;
502
502
  } else {
503
- const [l] = e.moveCall({
503
+ const [u] = e.moveCall({
504
504
  target: `${t.package}::incentive_v3::borrow_v2`,
505
505
  arguments: [
506
506
  e.object("0x06"),
@@ -508,38 +508,38 @@ async function Xe(e, n, o, r) {
508
508
  e.object(t.storage),
509
509
  e.object(a.contract.pool),
510
510
  e.pure.u8(a.id),
511
- i,
511
+ s,
512
512
  e.object(t.incentiveV2),
513
513
  e.object(t.incentiveV3),
514
514
  e.object("0x05")
515
515
  ],
516
516
  typeArguments: [a.suiCoinType]
517
517
  });
518
- c = l;
518
+ i = u;
519
519
  }
520
520
  return e.moveCall({
521
521
  target: "0x2::coin::from_balance",
522
- arguments: [e.object(c)],
522
+ arguments: [e.object(i)],
523
523
  typeArguments: [a.suiCoinType]
524
524
  });
525
525
  }
526
526
  async function xe(e, n, o, r) {
527
- const t = await k({
527
+ const t = await _({
528
528
  ...r,
529
- cacheTime: w
530
- }), a = await A(n, r), i = typeof o == "object" && o.$kind === "GasCoin";
531
- if (b(a.suiCoinType) === b("0x2::sui::SUI") && i) {
529
+ cacheTime: b
530
+ }), a = await A(n, r), s = typeof o == "object" && o.$kind === "GasCoin";
531
+ if (k(a.suiCoinType) === k("0x2::sui::SUI") && s) {
532
532
  if (!r?.amount)
533
533
  throw new Error("Amount is required for sui coin");
534
534
  o = e.splitCoins(o, [r.amount]);
535
535
  }
536
- let c;
537
- if (typeof r?.amount < "u" ? c = g(r.amount, e.pure.u64) : c = e.moveCall({
536
+ let i;
537
+ if (typeof r?.amount < "u" ? i = h(r.amount, e.pure.u64) : i = e.moveCall({
538
538
  target: "0x2::coin::value",
539
- arguments: [g(o, e.object)],
539
+ arguments: [h(o, e.object)],
540
540
  typeArguments: [a.suiCoinType]
541
541
  }), r?.accountCap) {
542
- const [s] = e.moveCall({
542
+ const [c] = e.moveCall({
543
543
  target: `${t.package}::incentive_v3::repay_with_account_cap`,
544
544
  arguments: [
545
545
  e.object("0x06"),
@@ -547,16 +547,16 @@ async function xe(e, n, o, r) {
547
547
  e.object(t.storage),
548
548
  e.object(a.contract.pool),
549
549
  e.pure.u8(a.id),
550
- g(o, e.object),
550
+ h(o, e.object),
551
551
  e.object(t.incentiveV2),
552
552
  e.object(t.incentiveV3),
553
- g(r.accountCap, e.object)
553
+ h(r.accountCap, e.object)
554
554
  ],
555
555
  typeArguments: [a.suiCoinType]
556
556
  });
557
557
  return e.moveCall({
558
558
  target: "0x2::coin::from_balance",
559
- arguments: [s],
559
+ arguments: [c],
560
560
  typeArguments: [a.suiCoinType]
561
561
  });
562
562
  } else
@@ -568,8 +568,8 @@ async function xe(e, n, o, r) {
568
568
  e.object(t.storage),
569
569
  e.object(a.contract.pool),
570
570
  e.pure.u8(a.id),
571
- g(o, e.object),
572
- c,
571
+ h(o, e.object),
572
+ i,
573
573
  e.object(t.incentiveV2),
574
574
  e.object(t.incentiveV3)
575
575
  ],
@@ -579,27 +579,27 @@ async function xe(e, n, o, r) {
579
579
  const et = $(
580
580
  B(
581
581
  async (e) => {
582
- const n = await k({
582
+ const n = await _({
583
583
  ...e
584
584
  });
585
585
  if (e?.address && typeof e?.asset < "u")
586
586
  try {
587
- const t = await A(e.asset, e), a = e?.client ?? P, i = new U();
588
- i.moveCall({
587
+ const t = await A(e.asset, e), a = e?.client ?? P, s = new O();
588
+ s.moveCall({
589
589
  target: `${n.package}::incentive_v3::get_borrow_fee_v2`,
590
590
  arguments: [
591
- i.object(n.incentiveV3),
592
- i.pure.address(e.address),
593
- i.pure.u8(t.id),
594
- i.pure.u64(1e4)
591
+ s.object(n.incentiveV3),
592
+ s.pure.address(e.address),
593
+ s.pure.u8(t.id),
594
+ s.pure.u64(1e4)
595
595
  ],
596
596
  typeArguments: []
597
597
  });
598
- const c = await a.devInspectTransactionBlock({
599
- transactionBlock: i,
598
+ const i = await a.devInspectTransactionBlock({
599
+ transactionBlock: s,
600
600
  sender: e.address
601
- }), s = L(c, [C.u64()]);
602
- return (Number(s[0]) || 0) / 100;
601
+ }), c = L(i, [C.u64()]);
602
+ return (Number(c[0]) || 0) / 100;
603
603
  } catch (t) {
604
604
  console.error(t);
605
605
  }
@@ -610,66 +610,61 @@ const et = $(
610
610
  return Number(r) / 100;
611
611
  }
612
612
  )
613
- ), N = "main", M = {
613
+ ), N = "main", E = {
614
614
  main: {
615
615
  id: 0,
616
616
  key: "main",
617
617
  name: "Main Market"
618
- },
619
- ember: {
620
- id: 1,
621
- key: "ember",
622
- name: "Ember Market"
623
618
  }
624
619
  };
625
- class je {
620
+ class Ce {
626
621
  constructor(n, o) {
627
622
  this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
628
623
  marketTotalSupplyValue: "0",
629
624
  marketTotalBorrowValue: "0"
630
- }, this.config = _(n), this.initPools(o);
625
+ }, this.config = j(n), this.initPools(o);
631
626
  }
632
627
  get overview() {
633
628
  return this._overview;
634
629
  }
635
630
  initPools(n) {
636
631
  const o = H(this.pools), r = J(this.emodes), t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
637
- let i = p(0), c = p(0);
638
- n.forEach((s) => {
639
- if (!this.checkMarket(s.market)) {
640
- console.warn(`Pool is not in market ${this.config.name}`, s);
632
+ let s = p(0), i = p(0);
633
+ n.forEach((c) => {
634
+ if (!this.checkMarket(c.market)) {
635
+ console.warn(`Pool is not in market ${this.config.name}`, c);
641
636
  return;
642
637
  }
643
- o[s.uniqueId] || this.pools.push(s), s?.emodes?.forEach((d) => {
644
- r[d.uniqueId] || this.emodes.push(d), d.assets.forEach((f) => {
645
- f.isDebt && d.assets.find(
646
- (y) => y.isCollateral && y.ltv > 0 && y.assetId !== s.id
647
- ) && t.add(s.uniqueId), f.isCollateral && d.assets.find((y) => y.isDebt && y.assetId !== s.id) && a.add(s.uniqueId);
638
+ o[c.uniqueId] || this.pools.push(c), c?.emodes?.forEach((d) => {
639
+ r[d.uniqueId] || this.emodes.push(d), d.assets.forEach((y) => {
640
+ y.isDebt && d.assets.find(
641
+ (g) => g.isCollateral && g.ltv > 0 && g.assetId !== c.id
642
+ ) && t.add(c.uniqueId), y.isCollateral && d.assets.find((g) => g.isDebt && g.assetId !== c.id) && a.add(c.uniqueId);
648
643
  });
649
- }), c = c.plus(s.poolBorrowValue), i = i.plus(s.poolSupplyValue);
650
- }), this.poolMap = H(this.pools, "id"), this.emodeMap = J(this.emodes, "emodeId"), this.emodes.forEach((s) => {
651
- const l = this.getEModePools(s.emodeId);
652
- this.emodePools.push(...l);
644
+ }), i = i.plus(c.poolBorrowValue), s = s.plus(c.poolSupplyValue);
645
+ }), this.poolMap = H(this.pools, "id"), this.emodeMap = J(this.emodes, "emodeId"), this.emodes.forEach((c) => {
646
+ const u = this.getEModePools(c.emodeId);
647
+ this.emodePools.push(...u);
653
648
  }), this._overview = {
654
- marketTotalSupplyValue: i.toString(),
655
- marketTotalBorrowValue: c.toString()
656
- }, this.emodeBorrowablePools = this.pools.filter((s) => t.has(s.uniqueId)), this.emodeSupplyablePools = this.pools.filter((s) => a.has(s.uniqueId));
649
+ marketTotalSupplyValue: s.toString(),
650
+ marketTotalBorrowValue: i.toString()
651
+ }, this.emodeBorrowablePools = this.pools.filter((c) => t.has(c.uniqueId)), this.emodeSupplyablePools = this.pools.filter((c) => a.has(c.uniqueId));
657
652
  }
658
653
  getEMode(n) {
659
654
  return this.emodeMap[n] || null;
660
655
  }
661
656
  getEModeRelatePools(n, o) {
662
- const { collateral: r, debt: t, emodeId: a } = o || {}, i = [];
663
- return n.emodes.forEach((c) => {
664
- typeof a == "number" && a !== c.emodeId || c.assets.forEach((s) => {
665
- typeof r == "boolean" && r && s.isCollateral && s.assetId === n.id && i.push(this.poolMap[s.assetId]), typeof t == "boolean" && t && s.isDebt && s.assetId === n.id && i.push(this.poolMap[s.assetId]);
657
+ const { collateral: r, debt: t, emodeId: a } = o || {}, s = [];
658
+ return n.emodes.forEach((i) => {
659
+ typeof a == "number" && a !== i.emodeId || i.assets.forEach((c) => {
660
+ typeof r == "boolean" && r && c.isCollateral && c.assetId === n.id && s.push(this.poolMap[c.assetId]), typeof t == "boolean" && t && c.isDebt && c.assetId === n.id && s.push(this.poolMap[c.assetId]);
666
661
  });
667
- }), i;
662
+ }), s;
668
663
  }
669
664
  getEModePools(n) {
670
665
  const o = this.getEMode(n);
671
666
  return o ? o.assets.map((t) => t.assetId).map((t) => this.poolMap[t]).filter((t) => !!t).map((t) => {
672
- const a = o.assets.find((i) => i.assetId === t.id);
667
+ const a = o.assets.find((s) => s.assetId === t.id);
673
668
  return {
674
669
  ...t,
675
670
  emode: {
@@ -685,12 +680,12 @@ class je {
685
680
  return typeof n == "number" && n === this.config.id && (o = !0), typeof n == "string" && n === this.config.key && (o = !0), typeof n == "object" && n.id === this.config.id && (o = !0), o;
686
681
  }
687
682
  }
688
- const _ = (e) => {
689
- const o = Object.values(M).find((r) => typeof e == "number" ? r.id === e : typeof e == "string" ? r.key === e : r.id === e.id);
683
+ const j = (e) => {
684
+ const o = Object.values(E).find((r) => typeof e == "number" ? r.id === e : typeof e == "string" ? r.key === e : r.id === e.id);
690
685
  if (!o)
691
686
  throw new Error("Market not found");
692
687
  return o;
693
- }, _e = $(
688
+ }, je = $(
694
689
  B(
695
690
  async (e, n) => {
696
691
  const o = await R({
@@ -699,26 +694,26 @@ const _ = (e) => {
699
694
  markets: e
700
695
  });
701
696
  return e.map((r) => {
702
- const t = _(r), a = o.filter((i) => i.market === t.key);
703
- return new je(r, a);
697
+ const t = j(r), a = o.filter((s) => s.market === t.key);
698
+ return new Ce(r, a);
704
699
  });
705
700
  }
706
701
  )
707
702
  ), tt = $(
708
703
  B(
709
- async (e, n) => (await _e([e], n))[0]
704
+ async (e, n) => (await je([e], n))[0]
710
705
  )
711
- ), k = $(
706
+ ), _ = $(
712
707
  B(
713
708
  async (e) => {
714
- const n = _(e?.market || N), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${V.version}&market=${n.key}`;
715
- return (await fetch(o, { headers: E }).then((t) => t.json())).data;
709
+ const n = j(e?.market || N), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${V.version}&market=${n.key}`;
710
+ return (await fetch(o, { headers: M }).then((t) => t.json())).data;
716
711
  }
717
712
  )
718
- ), w = 1e3 * 60 * 5;
719
- async function Ie(e, n) {
720
- const o = await k({
721
- cacheTime: w,
713
+ ), b = 1e3 * 60 * 5;
714
+ async function Te(e, n) {
715
+ const o = await _({
716
+ cacheTime: b,
722
717
  ...n
723
718
  });
724
719
  return e.moveCall({
@@ -726,9 +721,9 @@ async function Ie(e, n) {
726
721
  arguments: []
727
722
  });
728
723
  }
729
- async function Te(e, n, o) {
730
- const r = await k({
731
- cacheTime: w,
724
+ async function Ie(e, n, o) {
725
+ const r = await _({
726
+ cacheTime: b,
732
727
  ...o
733
728
  });
734
729
  return e.moveCall({
@@ -737,181 +732,181 @@ async function Te(e, n, o) {
737
732
  });
738
733
  }
739
734
  async function Be(e, n, o) {
740
- const r = await k({
735
+ const r = await _({
741
736
  ...o,
742
- cacheTime: w
737
+ cacheTime: b
743
738
  });
744
739
  return o?.accountCap ? e.moveCall({
745
740
  target: `${r.package}::lending::enter_emode_with_account_cap`,
746
741
  arguments: [
747
742
  e.object(r.storage),
748
- g(n, e.pure.u64),
749
- g(o.accountCap, e.object)
743
+ h(n, e.pure.u64),
744
+ h(o.accountCap, e.object)
750
745
  ]
751
746
  }) : e.moveCall({
752
747
  target: `${r.package}::lending::enter_emode`,
753
- arguments: [e.object(r.storage), g(n, e.pure.u64)]
748
+ arguments: [e.object(r.storage), h(n, e.pure.u64)]
754
749
  }), e;
755
750
  }
756
751
  async function ot(e, n) {
757
- const o = await k({
752
+ const o = await _({
758
753
  ...n,
759
- cacheTime: w
754
+ cacheTime: b
760
755
  });
761
756
  return n?.accountCap ? e.moveCall({
762
757
  target: `${o.package}::lending::exit_emode_with_account_cap`,
763
- arguments: [e.object(o.storage), g(n.accountCap, e.object)]
758
+ arguments: [e.object(o.storage), h(n.accountCap, e.object)]
764
759
  }) : e.moveCall({
765
760
  target: `${o.package}::lending::exit_emode`,
766
761
  arguments: [e.object(o.storage)]
767
762
  }), e;
768
763
  }
769
764
  async function nt(e, n, o) {
770
- const r = await k({
771
- cacheTime: w,
765
+ const r = await _({
766
+ cacheTime: b,
772
767
  ...o
773
- }), t = await Ie(e, o);
768
+ }), t = await Te(e, o);
774
769
  await Be(e, n, {
775
770
  ...o,
776
771
  accountCap: t
777
772
  });
778
- const a = await _(o?.market || N), i = await Te(e, t, o);
773
+ const a = await j(o?.market || N), s = await Ie(e, t, o);
779
774
  return e.moveCall({
780
775
  target: `${r.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
781
776
  arguments: [
782
777
  e.object(r.emode.contract.registryObject),
783
- i,
784
- g(a.id, e.pure.u64),
785
- g(n, e.pure.u64)
778
+ s,
779
+ h(a.id, e.pure.u64),
780
+ h(n, e.pure.u64)
786
781
  ]
787
782
  }), t;
788
783
  }
789
784
  const x = $(
790
785
  B(
791
786
  async (e, n) => {
792
- const o = await k({
793
- cacheTime: w,
787
+ const o = await _({
788
+ cacheTime: b,
794
789
  ...n
795
- }), r = new U(), t = n?.client ?? P;
790
+ }), r = new O(), t = n?.client ?? P;
796
791
  r.moveCall({
797
792
  target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
798
793
  arguments: [r.object(o.emode.contract.registryObject), r.pure.address(e)]
799
794
  });
800
- const i = (await t.devInspectTransactionBlock({
795
+ const s = (await t.devInspectTransactionBlock({
801
796
  transactionBlock: r,
802
797
  sender: e
803
- })).results[0].returnValues, c = C.vector(C.u64()).parse(Uint8Array.from(i[0][0])), s = C.vector(C.u64()).parse(Uint8Array.from(i[1][0])), l = C.vector(C.Address).parse(Uint8Array.from(i[2][0]));
804
- return c.map((d, f) => ({
798
+ })).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]));
799
+ return i.map((d, y) => ({
805
800
  marketId: Number(d),
806
- emodeId: Number(s[f]),
807
- accountCap: l[f].toString()
801
+ emodeId: Number(c[y]),
802
+ accountCap: u[y].toString()
808
803
  }));
809
804
  }
810
805
  )
811
806
  );
812
807
  function rt(e) {
813
- return `${_(e.marketId).key}-${e.emodeId}`;
808
+ return `${j(e.marketId).key}-${e.emodeId}`;
814
809
  }
815
810
  function at(e, n, o) {
816
811
  const r = typeof o?.balance == "number", t = r ? o.balance : 0;
817
812
  let a = 0;
818
- const i = [];
819
- let c = "";
820
- if (n.sort((s, l) => Number(l.balance) - Number(s.balance)).forEach((s) => {
821
- if (!(r && a >= t) && Number(s.balance) !== 0) {
822
- if (c || (c = s.coinType), c !== s.coinType)
813
+ const s = [];
814
+ let i = "";
815
+ if (n.sort((c, u) => Number(u.balance) - Number(c.balance)).forEach((c) => {
816
+ if (!(r && a >= t) && Number(c.balance) !== 0) {
817
+ if (i || (i = c.coinType), i !== c.coinType)
823
818
  throw new Error("All coins must be of the same type");
824
- a += Number(s.balance), i.push(s.coinObjectId);
819
+ a += Number(c.balance), s.push(c.coinObjectId);
825
820
  }
826
- }), i.length === 0)
821
+ }), s.length === 0)
827
822
  throw new Error("No coins to merge");
828
823
  if (r && a < t)
829
824
  throw new Error(
830
825
  `Balance is less than the specified balance: ${a} < ${t}`
831
826
  );
832
- return b(c) === b("0x2::sui::SUI") && o?.useGasCoin ? r ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (i.length === 1 ? e.object(i[0]) : e.mergeCoins(i[0], i.slice(1)), r ? e.splitCoins(i[0], [e.pure.u64(t)]) : i[0]);
827
+ return k(i) === k("0x2::sui::SUI") && o?.useGasCoin ? r ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (s.length === 1 ? e.object(s[0]) : e.mergeCoins(s[0], s.slice(1)), r ? e.splitCoins(s[0], [e.pure.u64(t)]) : s[0]);
833
828
  }
834
- async function ee(e, n, o, r, t, a, i) {
835
- const c = await k({
836
- ...i,
837
- cacheTime: w
838
- }), s = await A(o, i);
829
+ async function ee(e, n, o, r, t, a, s) {
830
+ const i = await _({
831
+ ...s,
832
+ cacheTime: b
833
+ }), c = await A(o, s);
839
834
  return e.moveCall({
840
- target: `${c.uiGetter}::calculator_unchecked::dynamic_health_factor`,
835
+ target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
841
836
  arguments: [
842
837
  e.object("0x06"),
843
- e.object(c.storage),
844
- e.object(c.oracle.priceOracle),
845
- we(e, s),
846
- g(n, e.pure.address),
847
- g(s.id, e.pure.u8),
848
- g(r, e.pure.u64),
849
- g(t, e.pure.u64),
850
- g(a, e.pure.bool)
838
+ e.object(i.storage),
839
+ e.object(i.oracle.priceOracle),
840
+ we(e, c),
841
+ h(n, e.pure.address),
842
+ h(c.id, e.pure.u8),
843
+ h(r, e.pure.u64),
844
+ h(t, e.pure.u64),
845
+ h(a, e.pure.bool)
851
846
  ],
852
- typeArguments: [s.suiCoinType]
847
+ typeArguments: [c.suiCoinType]
853
848
  });
854
849
  }
855
850
  async function Ae(e, n, o) {
856
851
  return ee(e, n, 0, 0, 0, !1, o);
857
852
  }
858
853
  async function te(e, n, o) {
859
- const r = new U(), t = o?.client ?? P, a = await R({
854
+ const r = new O(), t = o?.client ?? P, a = await R({
860
855
  ...o,
861
- markets: Object.values(M)
862
- }), i = H(a);
856
+ markets: Object.values(E)
857
+ }), s = H(a);
863
858
  for (let d of n) {
864
- const f = await k({
859
+ const y = await _({
865
860
  ...o,
866
- cacheTime: w,
861
+ cacheTime: b,
867
862
  market: d.market
868
863
  });
869
864
  r.moveCall({
870
- target: `${f.uiGetter}::getter_unchecked::get_user_state`,
871
- arguments: [r.object(f.storage), r.pure.address(d.address)]
865
+ target: `${y.uiGetter}::getter_unchecked::get_user_state`,
866
+ arguments: [r.object(y.storage), r.pure.address(d.address)]
872
867
  });
873
868
  }
874
- const s = ((await t.devInspectTransactionBlock({
869
+ const c = ((await t.devInspectTransactionBlock({
875
870
  transactionBlock: r,
876
871
  sender: e
877
- })).results || []).map((d) => d.returnValues?.map((f) => C.vector(fe).parse(Uint8Array.from(f[0])))[0] || []), l = [];
878
- return s.forEach((d, f) => {
879
- const v = n[f], y = _(v.market);
880
- d.forEach((u) => {
881
- if (u.supply_balance === "0" && u.borrow_balance === "0" && (v.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
872
+ })).results || []).map((d) => d.returnValues?.map((y) => C.vector(fe).parse(Uint8Array.from(y[0])))[0] || []), u = [];
873
+ return c.forEach((d, y) => {
874
+ const v = n[y], g = j(v.market);
875
+ d.forEach((l) => {
876
+ if (l.supply_balance === "0" && l.borrow_balance === "0" && (v.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
882
877
  return;
883
- const h = i[`${y.key}-${u.asset_id}`];
884
- if (!h)
878
+ const f = s[`${g.key}-${l.asset_id}`];
879
+ if (!f)
885
880
  return;
886
- const j = Y(
887
- u.supply_balance,
888
- h.currentSupplyIndex
889
- ).toString(), I = Y(
890
- u.borrow_balance,
891
- h.currentBorrowIndex
881
+ const w = Y(
882
+ l.supply_balance,
883
+ f.currentSupplyIndex
884
+ ).toString(), T = Y(
885
+ l.borrow_balance,
886
+ f.currentBorrowIndex
892
887
  ).toString();
893
- l.push({
894
- supplyBalance: j,
895
- borrowBalance: I,
896
- assetId: u.asset_id,
897
- market: y.key,
898
- pool: h,
888
+ u.push({
889
+ supplyBalance: w,
890
+ borrowBalance: T,
891
+ assetId: l.asset_id,
892
+ market: g.key,
893
+ pool: f,
899
894
  emodeId: v.emodeId
900
895
  });
901
896
  });
902
- }), l;
897
+ }), u;
903
898
  }
904
- const ct = $(
899
+ const it = $(
905
900
  async (e, n) => {
906
- const r = (n?.markets || Object.keys(M)).map((t) => _(t)).map((t) => ({
901
+ const r = (n?.markets || Object.keys(E)).map((t) => j(t)).map((t) => ({
907
902
  address: e,
908
903
  market: t.key
909
904
  }));
910
905
  return await te(e, r, n);
911
906
  }
912
907
  );
913
- async function it(e, n) {
914
- const o = n?.client ?? P, r = new U();
908
+ async function ct(e, n) {
909
+ const o = n?.client ?? P, r = new O();
915
910
  await Ae(r, e, n);
916
911
  const t = await o.devInspectTransactionBlock({
917
912
  transactionBlock: r,
@@ -920,38 +915,38 @@ async function it(e, n) {
920
915
  return X(Number(a[0]) || 0);
921
916
  }
922
917
  async function st(e, n, o, r) {
923
- const t = r?.client ?? P, a = new U();
924
- let i = 0, c = 0;
925
- const s = await A(n, r);
918
+ const t = r?.client ?? P, a = new O();
919
+ let s = 0, i = 0;
920
+ const c = await A(n, r);
926
921
  if (o.forEach((v) => {
927
- v.type === F.Supply ? i += v.amount : v.type === F.Withdraw ? i -= v.amount : v.type === F.Borrow ? c += v.amount : v.type === F.Repay && (c -= v.amount);
928
- }), i * c < 0)
922
+ v.type === F.Supply ? s += v.amount : v.type === F.Withdraw ? s -= v.amount : v.type === F.Borrow ? i += v.amount : v.type === F.Repay && (i -= v.amount);
923
+ }), s * i < 0)
929
924
  throw new Error("Invalid operations");
930
- const l = i > 0 || c > 0;
925
+ const u = s > 0 || i > 0;
931
926
  await ee(
932
927
  a,
933
928
  e,
934
- s,
929
+ c,
930
+ Math.abs(s),
935
931
  Math.abs(i),
936
- Math.abs(c),
937
- l,
932
+ u,
938
933
  r
939
934
  );
940
935
  const d = await t.devInspectTransactionBlock({
941
936
  transactionBlock: a,
942
937
  sender: e
943
- }), f = L(d, [C.u256()]);
944
- return X(Number(f[0]) || 0);
938
+ }), y = L(d, [C.u256()]);
939
+ return X(Number(y[0]) || 0);
945
940
  }
946
- const lt = B(
941
+ const ut = B(
947
942
  async (e, n) => {
948
943
  const o = new URLSearchParams();
949
944
  n?.cursor && o.set("cursor", n.cursor), o.set("userAddress", e);
950
945
  const r = `https://open-api.naviprotocol.io/api/navi/user/transactions?${o.toString()}&sdk=${V.version}`;
951
- return (await fetch(r, { headers: E }).then((a) => a.json())).data;
946
+ return (await fetch(r, { headers: M }).then((a) => a.json())).data;
952
947
  }
953
948
  );
954
- async function ut(e, n) {
949
+ async function lt(e, n) {
955
950
  let o = null;
956
951
  const r = [], t = n?.client ?? P;
957
952
  do {
@@ -973,69 +968,69 @@ async function ut(e, n) {
973
968
  }
974
969
  const $e = $(
975
970
  async (e, n) => {
976
- const o = [], r = (n?.markets || Object.keys(M)).map((c) => _(c));
971
+ const o = [], r = (n?.markets || Object.keys(E)).map((i) => j(i));
977
972
  let t = [];
978
973
  try {
979
974
  t = await x(e, n);
980
- } catch (c) {
981
- console.error(c);
975
+ } catch (i) {
976
+ console.error(i);
982
977
  }
983
- const a = r.map((c) => ({
978
+ const a = r.map((i) => ({
984
979
  address: e,
985
- market: c.key
980
+ market: i.key
986
981
  })).concat(
987
- t.filter((c) => !!r.find((s) => s.id === c.marketId)).map((c) => ({
988
- address: c.accountCap,
989
- market: _(c.marketId).key,
990
- emodeId: c.emodeId
982
+ t.filter((i) => !!r.find((c) => c.id === i.marketId)).map((i) => ({
983
+ address: i.accountCap,
984
+ market: j(i.marketId).key,
985
+ emodeId: i.emodeId
991
986
  }))
992
987
  );
993
- return (await te(e, a, n)).forEach((c) => {
994
- const s = typeof c.emodeId == "number" ? t.find((l) => {
995
- const d = _(c.market);
996
- return l.emodeId === c.emodeId && l.marketId === d.id;
988
+ return (await te(e, a, n)).forEach((i) => {
989
+ const c = typeof i.emodeId == "number" ? t.find((u) => {
990
+ const d = j(i.market);
991
+ return u.emodeId === i.emodeId && u.marketId === d.id;
997
992
  }) : void 0;
998
- if (s) {
999
- if (!c.pool.emodes.find((d) => d.emodeId === s.emodeId))
993
+ if (c) {
994
+ if (!i.pool.emodes.find((d) => d.emodeId === c.emodeId))
1000
995
  return;
1001
- if (p(c.supplyBalance).gte(0)) {
1002
- const d = p(c.supplyBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, p.ROUND_DOWN), f = q(c.pool, s);
1003
- if (d.gt(0) || f.emode.isCollateral)
996
+ if (p(i.supplyBalance).gte(0)) {
997
+ const d = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), y = q(i.pool, c);
998
+ if (d.gt(0) || y.emode.isCollateral)
1004
999
  try {
1005
1000
  o.push({
1006
- id: `${c.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${T()}`,
1001
+ id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${I()}`,
1007
1002
  wallet: e,
1008
1003
  protocol: "navi",
1009
- market: c.market,
1004
+ market: i.market,
1010
1005
  type: "navi-lending-emode-supply",
1011
1006
  "navi-lending-emode-supply": {
1012
1007
  amount: d.toString(),
1013
- pool: q(c.pool, s),
1014
- token: c.pool.token,
1015
- valueUSD: d.multipliedBy(c.pool.oracle.price).toString(),
1016
- emodeCap: s
1008
+ pool: q(i.pool, c),
1009
+ token: i.pool.token,
1010
+ valueUSD: d.multipliedBy(i.pool.oracle.price).toString(),
1011
+ emodeCap: c
1017
1012
  }
1018
1013
  });
1019
1014
  } catch (v) {
1020
1015
  console.error(v);
1021
1016
  }
1022
1017
  }
1023
- if (p(c.borrowBalance).gte(0)) {
1024
- const d = p(c.borrowBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, p.ROUND_DOWN), f = q(c.pool, s);
1025
- if (d.gt(0) || f.emode.isDebt)
1018
+ if (p(i.borrowBalance).gte(0)) {
1019
+ const d = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), y = q(i.pool, c);
1020
+ if (d.gt(0) || y.emode.isDebt)
1026
1021
  try {
1027
1022
  o.push({
1028
- id: `${c.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${T()}`,
1023
+ id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${I()}`,
1029
1024
  wallet: e,
1030
1025
  protocol: "navi",
1031
- market: c.market,
1026
+ market: i.market,
1032
1027
  type: "navi-lending-emode-borrow",
1033
1028
  "navi-lending-emode-borrow": {
1034
1029
  amount: d.toString(),
1035
- pool: q(c.pool, s),
1036
- token: c.pool.token,
1037
- valueUSD: d.multipliedBy(c.pool.oracle.price).toString(),
1038
- emodeCap: s
1030
+ pool: q(i.pool, c),
1031
+ token: i.pool.token,
1032
+ valueUSD: d.multipliedBy(i.pool.oracle.price).toString(),
1033
+ emodeCap: c
1039
1034
  }
1040
1035
  });
1041
1036
  } catch (v) {
@@ -1043,35 +1038,35 @@ const $e = $(
1043
1038
  }
1044
1039
  }
1045
1040
  } else {
1046
- if (p(c.supplyBalance).gt(0)) {
1047
- const l = p(c.supplyBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, p.ROUND_DOWN);
1041
+ if (p(i.supplyBalance).gt(0)) {
1042
+ const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1048
1043
  o.push({
1049
- id: `${c.pool.uniqueId}_navi-lending-supply-${T()}`,
1044
+ id: `${i.pool.uniqueId}_navi-lending-supply-${I()}`,
1050
1045
  wallet: e,
1051
1046
  protocol: "navi",
1052
1047
  type: "navi-lending-supply",
1053
- market: c.market,
1048
+ market: i.market,
1054
1049
  "navi-lending-supply": {
1055
- amount: l.toString(),
1056
- pool: c.pool,
1057
- token: c.pool.token,
1058
- valueUSD: l.multipliedBy(c.pool.oracle.price).toString()
1050
+ amount: u.toString(),
1051
+ pool: i.pool,
1052
+ token: i.pool.token,
1053
+ valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
1059
1054
  }
1060
1055
  });
1061
1056
  }
1062
- if (p(c.borrowBalance).gt(0)) {
1063
- const l = p(c.borrowBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, p.ROUND_DOWN);
1057
+ if (p(i.borrowBalance).gt(0)) {
1058
+ const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1064
1059
  o.push({
1065
- id: `${c.pool.uniqueId}_navi-lending-borrow-${T()}`,
1060
+ id: `${i.pool.uniqueId}_navi-lending-borrow-${I()}`,
1066
1061
  wallet: e,
1067
1062
  protocol: "navi",
1068
- market: c.market,
1063
+ market: i.market,
1069
1064
  type: "navi-lending-borrow",
1070
1065
  "navi-lending-borrow": {
1071
- amount: l.toString(),
1072
- pool: c.pool,
1073
- token: c.pool.token,
1074
- valueUSD: l.multipliedBy(c.pool.oracle.price).toString()
1066
+ amount: u.toString(),
1067
+ pool: i.pool,
1068
+ token: i.pool.token,
1069
+ valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
1075
1070
  }
1076
1071
  });
1077
1072
  }
@@ -1079,9 +1074,9 @@ const $e = $(
1079
1074
  }), o;
1080
1075
  }
1081
1076
  );
1082
- class O {
1083
- constructor(n) {
1084
- this._positions = [], this._overview = {
1077
+ class U {
1078
+ constructor(n, o) {
1079
+ this._positions = [], this._priceMap = {}, this._overview = {
1085
1080
  hf: 1 / 0,
1086
1081
  netVaule: "0",
1087
1082
  netWorthApr: "0",
@@ -1093,7 +1088,7 @@ class O {
1093
1088
  maxLoanToVaule: "0",
1094
1089
  supply: {},
1095
1090
  borrow: {}
1096
- }, this.positions = n;
1091
+ }, this._priceMap = o || {}, this.positions = n;
1097
1092
  }
1098
1093
  get positions() {
1099
1094
  return this._positions;
@@ -1101,204 +1096,225 @@ class O {
1101
1096
  get overview() {
1102
1097
  return this._overview;
1103
1098
  }
1099
+ get priceMap() {
1100
+ return this._priceMap;
1101
+ }
1104
1102
  set positions(n) {
1105
1103
  this._positions = n, this._overview = this.getPositionsOverview(n);
1106
1104
  }
1105
+ updatePriceMap(n) {
1106
+ return this._priceMap = n, this._overview = this.getPositionsOverview(this._positions), this;
1107
+ }
1108
+ getPrice(n) {
1109
+ const o = k(n.suiCoinType);
1110
+ if (this._priceMap[o] !== void 0)
1111
+ return this._priceMap[o].toString();
1112
+ const r = n.suiCoinType;
1113
+ return this._priceMap[r] !== void 0 ? this._priceMap[r].toString() : n.oracle.price;
1114
+ }
1107
1115
  filterPositionsByPool(n) {
1108
1116
  const r = !!n.isEMode ? ["navi-lending-emode-supply", "navi-lending-emode-borrow"] : ["navi-lending-supply", "navi-lending-borrow"];
1109
- return new O(
1117
+ return new U(
1110
1118
  this.positions.filter((t) => {
1111
1119
  const a = t[t.type];
1112
1120
  return r.includes(t.type) && a.pool.uniqueId === n.uniqueId;
1113
- })
1121
+ }),
1122
+ this._priceMap
1114
1123
  );
1115
1124
  }
1116
1125
  deposit(n, o) {
1117
- const r = !!n.isEMode;
1118
- let t;
1119
- return r ? t = {
1120
- id: T(),
1126
+ const r = !!n.isEMode, t = this.getPrice(n);
1127
+ let a;
1128
+ return r ? a = {
1129
+ id: I(),
1121
1130
  wallet: "",
1122
1131
  protocol: "navi",
1123
1132
  market: "",
1124
1133
  type: "navi-lending-emode-supply",
1125
1134
  "navi-lending-emode-supply": {
1126
1135
  amount: o.toString(),
1127
- valueUSD: p(o).multipliedBy(n.oracle.price).toString(),
1136
+ valueUSD: p(o).multipliedBy(t).toString(),
1128
1137
  token: n.token,
1129
1138
  pool: n,
1130
1139
  emodeCap: {}
1131
1140
  }
1132
- } : t = {
1133
- id: T(),
1141
+ } : a = {
1142
+ id: I(),
1134
1143
  wallet: "",
1135
1144
  protocol: "navi",
1136
1145
  market: "",
1137
1146
  type: "navi-lending-supply",
1138
1147
  "navi-lending-supply": {
1139
1148
  amount: o.toString(),
1140
- valueUSD: p(o).multipliedBy(n.oracle.price).toString(),
1149
+ valueUSD: p(o).multipliedBy(t).toString(),
1141
1150
  token: n.token,
1142
1151
  pool: n
1143
1152
  }
1144
- }, new O([...this.positions, t]);
1153
+ }, new U([...this.positions, a], this._priceMap);
1145
1154
  }
1146
1155
  withdraw(n, o) {
1147
- const r = !!n.isEMode;
1148
- let t;
1149
- return r ? t = {
1150
- id: T(),
1156
+ const r = !!n.isEMode, t = this.getPrice(n);
1157
+ let a;
1158
+ return r ? a = {
1159
+ id: I(),
1151
1160
  wallet: "",
1152
1161
  protocol: "navi",
1153
1162
  market: "",
1154
1163
  type: "navi-lending-emode-supply",
1155
1164
  "navi-lending-emode-supply": {
1156
1165
  amount: (-o).toString(),
1157
- valueUSD: p(-o).multipliedBy(n.oracle.price).toString(),
1166
+ valueUSD: p(-o).multipliedBy(t).toString(),
1158
1167
  token: n.token,
1159
1168
  pool: n,
1160
1169
  emodeCap: {}
1161
1170
  }
1162
- } : t = {
1163
- id: T(),
1171
+ } : a = {
1172
+ id: I(),
1164
1173
  wallet: "",
1165
1174
  protocol: "navi",
1166
1175
  market: "",
1167
1176
  type: "navi-lending-supply",
1168
1177
  "navi-lending-supply": {
1169
1178
  amount: (-o).toString(),
1170
- valueUSD: p(-o).multipliedBy(n.oracle.price).toString(),
1179
+ valueUSD: p(-o).multipliedBy(t).toString(),
1171
1180
  token: n.token,
1172
1181
  pool: n
1173
1182
  }
1174
- }, new O([...this.positions, t]);
1183
+ }, new U([...this.positions, a], this._priceMap);
1175
1184
  }
1176
1185
  borrow(n, o) {
1177
- const r = !!n.isEMode;
1178
- let t;
1179
- return r ? t = {
1180
- id: T(),
1186
+ const r = !!n.isEMode, t = this.getPrice(n);
1187
+ let a;
1188
+ return r ? a = {
1189
+ id: I(),
1181
1190
  wallet: "",
1182
1191
  protocol: "navi",
1183
1192
  market: "",
1184
1193
  type: "navi-lending-emode-borrow",
1185
1194
  "navi-lending-emode-borrow": {
1186
1195
  amount: o.toString(),
1187
- valueUSD: p(o).multipliedBy(n.oracle.price).toString(),
1196
+ valueUSD: p(o).multipliedBy(t).toString(),
1188
1197
  token: n.token,
1189
1198
  pool: n,
1190
1199
  emodeCap: {}
1191
1200
  }
1192
- } : t = {
1193
- id: T(),
1201
+ } : a = {
1202
+ id: I(),
1194
1203
  wallet: "",
1195
1204
  protocol: "navi",
1196
1205
  market: "",
1197
1206
  type: "navi-lending-borrow",
1198
1207
  "navi-lending-borrow": {
1199
1208
  amount: o.toString(),
1200
- valueUSD: p(o).multipliedBy(n.oracle.price).toString(),
1209
+ valueUSD: p(o).multipliedBy(t).toString(),
1201
1210
  token: n.token,
1202
1211
  pool: n
1203
1212
  }
1204
- }, new O([...this.positions, t]);
1213
+ }, new U([...this.positions, a], this._priceMap);
1205
1214
  }
1206
1215
  repay(n, o) {
1207
- const r = !!n.isEMode;
1208
- let t;
1209
- return r ? t = {
1210
- id: T(),
1216
+ const r = !!n.isEMode, t = this.getPrice(n);
1217
+ let a;
1218
+ return r ? a = {
1219
+ id: I(),
1211
1220
  wallet: "",
1212
1221
  protocol: "navi",
1213
1222
  market: "",
1214
1223
  type: "navi-lending-emode-borrow",
1215
1224
  "navi-lending-emode-borrow": {
1216
1225
  amount: (-o).toString(),
1217
- valueUSD: p(-o).multipliedBy(n.oracle.price).toString(),
1226
+ valueUSD: p(-o).multipliedBy(t).toString(),
1218
1227
  token: n.token,
1219
1228
  pool: n,
1220
1229
  emodeCap: {}
1221
1230
  }
1222
- } : t = {
1223
- id: T(),
1231
+ } : a = {
1232
+ id: I(),
1224
1233
  wallet: "",
1225
1234
  protocol: "navi",
1226
1235
  market: "",
1227
1236
  type: "navi-lending-borrow",
1228
1237
  "navi-lending-borrow": {
1229
1238
  amount: (-o).toString(),
1230
- valueUSD: p(-o).multipliedBy(n.oracle.price).toString(),
1239
+ valueUSD: p(-o).multipliedBy(t).toString(),
1231
1240
  token: n.token,
1232
1241
  pool: n
1233
1242
  }
1234
- }, new O([...this.positions, t]);
1243
+ }, new U([...this.positions, a], this._priceMap);
1244
+ }
1245
+ resolveValueUSD(n) {
1246
+ return Object.keys(this._priceMap).length > 0 ? p(n.amount).multipliedBy(this.getPrice(n.pool)).toString() : n.valueUSD;
1235
1247
  }
1236
1248
  getPositionsOverview(n) {
1237
1249
  const o = {}, r = {};
1238
- let t = new p(0), a = new p(0), i = new p(0), c = new p(0), s = new p(0), l = new p(0);
1239
- n.forEach((y) => {
1240
- if (y.type === "navi-lending-supply") {
1241
- const u = y["navi-lending-supply"];
1242
- t = t.plus(u.valueUSD), s = s.plus(
1243
- new p(u.valueUSD).multipliedBy(u.pool.liquidationFactor.threshold)
1244
- ), l = l.plus(
1245
- new p(u.valueUSD).multipliedBy(u.pool.ltvValue)
1250
+ 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);
1251
+ n.forEach((g) => {
1252
+ if (g.type === "navi-lending-supply") {
1253
+ const l = g["navi-lending-supply"], f = this.resolveValueUSD(l);
1254
+ t = t.plus(f), c = c.plus(
1255
+ new p(f).multipliedBy(l.pool.liquidationFactor.threshold)
1256
+ ), u = u.plus(
1257
+ new p(f).multipliedBy(l.pool.ltvValue)
1246
1258
  );
1247
- } else if (y.type === "navi-lending-borrow")
1248
- a = a.plus(y["navi-lending-borrow"].valueUSD);
1249
- else if (y.type === "navi-lending-emode-supply") {
1250
- const u = y["navi-lending-emode-supply"];
1251
- t = t.plus(u.valueUSD);
1252
- const h = u.pool.emode;
1253
- s = s.plus(
1254
- new p(u.valueUSD).multipliedBy(h.lt)
1255
- ), l = l.plus(
1256
- new p(u.valueUSD).multipliedBy(h.ltv)
1259
+ } else if (g.type === "navi-lending-borrow") {
1260
+ const l = g["navi-lending-borrow"];
1261
+ a = a.plus(this.resolveValueUSD(l));
1262
+ } else if (g.type === "navi-lending-emode-supply") {
1263
+ const l = g["navi-lending-emode-supply"], f = this.resolveValueUSD(l);
1264
+ t = t.plus(f);
1265
+ const w = l.pool.emode;
1266
+ c = c.plus(
1267
+ new p(f).multipliedBy(w.lt)
1268
+ ), u = u.plus(
1269
+ new p(f).multipliedBy(w.ltv)
1257
1270
  );
1258
- } else y.type === "navi-lending-emode-borrow" && (a = a.plus(y["navi-lending-emode-borrow"].valueUSD));
1259
- }), a = p.max(a, 0), t = p.max(t, 0), s = p.max(s, 0), l = p.max(l, 0), n.forEach((y) => {
1260
- if (y.type === "navi-lending-supply") {
1261
- const u = y["navi-lending-supply"], h = u.pool.supplyIncentiveApyInfo.apy;
1262
- t.gt(0) && (i = i.plus(
1263
- new p(u.valueUSD).dividedBy(t).multipliedBy(new p(h).dividedBy(100))
1264
- )), o[u.pool.suiCoinType] = p(o[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1265
- } else if (y.type === "navi-lending-borrow") {
1266
- const u = y["navi-lending-borrow"], h = u.pool.borrowIncentiveApyInfo.apy;
1267
- a.gt(0) && (c = c.plus(
1268
- new p(u.valueUSD).dividedBy(a).multipliedBy(new p(h).dividedBy(100))
1269
- )), r[u.pool.suiCoinType] = p(r[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1270
- } else if (y.type === "navi-lending-emode-supply") {
1271
- const u = y["navi-lending-emode-supply"], h = u.pool.supplyIncentiveApyInfo.apy;
1272
- t.gt(0) && (i = i.plus(
1273
- new p(u.valueUSD).dividedBy(t).multipliedBy(new p(h).dividedBy(100))
1274
- )), o[u.pool.suiCoinType] = p(o[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1275
- } else if (y.type === "navi-lending-emode-borrow") {
1276
- const u = y["navi-lending-emode-borrow"], h = u.pool.borrowIncentiveApyInfo.apy;
1277
- a.gt(0) && (c = c.plus(
1278
- new p(u.valueUSD).dividedBy(a).multipliedBy(new p(h).dividedBy(100))
1279
- )), r[u.pool.suiCoinType] = p(r[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1271
+ } else if (g.type === "navi-lending-emode-borrow") {
1272
+ const l = g["navi-lending-emode-borrow"];
1273
+ a = a.plus(this.resolveValueUSD(l));
1274
+ }
1275
+ }), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0), u = p.max(u, 0), n.forEach((g) => {
1276
+ if (g.type === "navi-lending-supply") {
1277
+ const l = g["navi-lending-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
1278
+ t.gt(0) && (s = s.plus(
1279
+ new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
1280
+ )), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1281
+ } else if (g.type === "navi-lending-borrow") {
1282
+ const l = g["navi-lending-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
1283
+ a.gt(0) && (i = i.plus(
1284
+ new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
1285
+ )), r[l.pool.suiCoinType] = p(r[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1286
+ } else if (g.type === "navi-lending-emode-supply") {
1287
+ const l = g["navi-lending-emode-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
1288
+ t.gt(0) && (s = s.plus(
1289
+ new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
1290
+ )), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1291
+ } else if (g.type === "navi-lending-emode-borrow") {
1292
+ const l = g["navi-lending-emode-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
1293
+ a.gt(0) && (i = i.plus(
1294
+ new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
1295
+ )), r[l.pool.suiCoinType] = p(r[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1280
1296
  }
1281
1297
  });
1282
- const d = t.minus(a), f = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(i).minus(a.multipliedBy(c)).div(t.minus(a));
1298
+ const d = t.minus(a), y = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(s).minus(a.multipliedBy(i)).div(t.minus(a));
1283
1299
  return {
1284
- hf: a.toNumber() !== 0 ? s.dividedBy(a).toNumber() : 1 / 0,
1300
+ hf: a.toNumber() !== 0 ? c.dividedBy(a).toNumber() : 1 / 0,
1285
1301
  netVaule: d.toString(),
1286
- netWorthApr: f.toString(),
1302
+ netWorthApr: y.toString(),
1287
1303
  totalSupplyValue: t.toString(),
1288
1304
  totalBorrowValue: a.toString(),
1289
- totalsupplyApy: i.toString(),
1290
- totalBorrowApy: c.toString(),
1291
- maxLiquidationValue: s.toString(),
1292
- maxLoanToVaule: l.toString(),
1305
+ totalsupplyApy: s.toString(),
1306
+ totalBorrowApy: i.toString(),
1307
+ maxLiquidationValue: c.toString(),
1308
+ maxLoanToVaule: u.toString(),
1293
1309
  supply: o,
1294
1310
  borrow: r
1295
1311
  };
1296
1312
  }
1297
1313
  }
1298
1314
  async function pt(e, n, o, r) {
1299
- const t = await k({
1315
+ const t = await _({
1300
1316
  ...r,
1301
- cacheTime: w
1317
+ cacheTime: b
1302
1318
  });
1303
1319
  t.limter && e.moveCall({
1304
1320
  target: `${t.limter}::navi_adaptor::verify_navi_position_healthy`,
@@ -1306,7 +1322,7 @@ async function pt(e, n, o, r) {
1306
1322
  e.object("0x06"),
1307
1323
  e.object(t.storage),
1308
1324
  e.object(t.priceOracle),
1309
- g(n, e.pure.address),
1325
+ h(n, e.pure.address),
1310
1326
  e.pure.u256(new p(o).shiftedBy(27).toNumber())
1311
1327
  ]
1312
1328
  });
@@ -1338,29 +1354,29 @@ async function dt(e) {
1338
1354
  }
1339
1355
  async function Pe(e, n) {
1340
1356
  try {
1341
- const o = [], r = n?.client ?? P, t = e.map((i) => i.priceInfoObject), a = await r.multiGetObjects({
1357
+ const o = [], r = n?.client ?? P, t = e.map((s) => s.priceInfoObject), a = await r.multiGetObjects({
1342
1358
  ids: Array.from(new Set(t)),
1343
1359
  options: { showContent: !0 }
1344
1360
  });
1345
- for (const i of a) {
1346
- const c = i.data;
1347
- if (!c || !c.content || c.content.dataType !== "moveObject") {
1348
- console.warn(`fetched object ${c?.objectId} datatype should be moveObject`);
1361
+ for (const s of a) {
1362
+ const i = s.data;
1363
+ if (!i || !i.content || i.content.dataType !== "moveObject") {
1364
+ console.warn(`fetched object ${i?.objectId} datatype should be moveObject`);
1349
1365
  continue;
1350
1366
  }
1351
- const s = e.find((u) => u.priceInfoObject == c.objectId);
1352
- if (!s) {
1353
- console.warn(`unable to find pyth info from array, priceInfoObject: ${c.objectId}`);
1367
+ const c = e.find((l) => l.priceInfoObject == i.objectId);
1368
+ if (!c) {
1369
+ console.warn(`unable to find pyth info from array, priceInfoObject: ${i.objectId}`);
1354
1370
  continue;
1355
1371
  }
1356
- const l = c.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: d, negative: f } = l.price.fields, v = l.conf, y = l.timestamp;
1372
+ const u = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: d, negative: y } = u.price.fields, v = u.conf, g = u.timestamp;
1357
1373
  o.push({
1358
- priceFeedId: s.priceFeedId,
1359
- priceInfoObject: s.priceInfoObject,
1360
- price: f ? "-" + d : d,
1374
+ priceFeedId: c.priceFeedId,
1375
+ priceInfoObject: c.priceInfoObject,
1376
+ price: y ? "-" + d : d,
1361
1377
  conf: v,
1362
- publishTime: Number(y),
1363
- expiration: s.expiration
1378
+ publishTime: Number(g),
1379
+ expiration: c.expiration
1364
1380
  });
1365
1381
  }
1366
1382
  return o;
@@ -1381,8 +1397,8 @@ async function Se(e, n) {
1381
1397
  );
1382
1398
  continue;
1383
1399
  }
1384
- const i = a.expiration || 60;
1385
- t - a.publishTime > i && (console.info(
1400
+ const s = a.expiration || 60;
1401
+ t - a.publishTime > s && (console.info(
1386
1402
  `stale price feed, id: ${a.priceFeedId}, publish time: ${a.publishTime}, current timestamp: ${t}`
1387
1403
  ), o.push(a.priceFeedId));
1388
1404
  }
@@ -1392,9 +1408,9 @@ async function Se(e, n) {
1392
1408
  }
1393
1409
  }
1394
1410
  async function Ve(e, n, o) {
1395
- const r = o?.client ?? P, t = await k({
1411
+ const r = o?.client ?? P, t = await _({
1396
1412
  ...o,
1397
- cacheTime: w
1413
+ cacheTime: b
1398
1414
  });
1399
1415
  try {
1400
1416
  const a = await oe.getPriceFeedsUpdateData(n);
@@ -1407,10 +1423,10 @@ async function Ve(e, n, o) {
1407
1423
  throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
1408
1424
  }
1409
1425
  }
1410
- async function Ee(e, n, o) {
1411
- const r = await k({
1426
+ async function Me(e, n, o) {
1427
+ const r = await _({
1412
1428
  ...o,
1413
- cacheTime: w
1429
+ cacheTime: b
1414
1430
  });
1415
1431
  if (o?.updatePythPriceFeeds) {
1416
1432
  const t = n.filter((a) => !!a.pythPriceFeedId && !!a.pythPriceInfoObject).map((a) => ({
@@ -1463,40 +1479,35 @@ async function Ee(e, n, o) {
1463
1479
  return e;
1464
1480
  }
1465
1481
  async function ne(e) {
1466
- return (await k({
1482
+ return (await _({
1467
1483
  ...e,
1468
- cacheTime: w
1484
+ cacheTime: b
1469
1485
  })).oracle.feeds;
1470
1486
  }
1471
- function Me(e, n) {
1472
- return e.filter((o) => !!(n?.lendingState && n.lendingState.find((t) => o.oracleId === t.pool.oracleId) || n?.lendingPositions && n.lendingPositions.find((t) => {
1473
- if (![
1474
- "navi-lending-supply",
1475
- "navi-lending-borrow",
1476
- "navi-lending-emode-supply",
1477
- "navi-lending-emode-borrow"
1478
- ].includes(t.type))
1479
- return !1;
1480
- const i = t[t.type]?.pool;
1481
- return o.oracleId === i?.oracleId;
1482
- }) || n?.pools && n.pools.find((t) => o.oracleId === t.oracleId)));
1487
+ function Ee(e, n) {
1488
+ return e.filter((o) => !!(n?.lendingState && n.lendingState.find((t) => t.assetId === o.assetId) || n?.lendingPositions && n.lendingPositions.find((t) => [
1489
+ "navi-lending-supply",
1490
+ "navi-lending-borrow",
1491
+ "navi-lending-emode-supply",
1492
+ "navi-lending-emode-borrow"
1493
+ ].includes(t.type) ? t[t.type]?.pool?.id === o.assetId : !1) || n?.pools && n.pools.find((t) => t.id === o.assetId)));
1483
1494
  }
1484
1495
  async function mt(e, n, o, r) {
1485
1496
  try {
1486
1497
  const t = await ne({
1487
1498
  ...r
1488
1499
  }), a = [];
1489
- o.forEach((l) => {
1490
- a.includes(l.market) || a.push(l.market);
1500
+ o.forEach((u) => {
1501
+ a.includes(u.market) || a.push(u.market);
1491
1502
  });
1492
- const i = await $e(n, {
1503
+ const s = await $e(n, {
1493
1504
  ...r,
1494
1505
  markets: a
1495
- }), c = Me(t, {
1496
- lendingPositions: i,
1506
+ }), i = Ee(t, {
1507
+ lendingPositions: s,
1497
1508
  pools: o
1498
1509
  });
1499
- return await Ee(e, c, {
1510
+ return await Me(e, i, {
1500
1511
  updatePythPriceFeeds: !0,
1501
1512
  ...r
1502
1513
  });
@@ -1509,7 +1520,7 @@ async function mt(e, n, o, r) {
1509
1520
  const G = $(
1510
1521
  B(
1511
1522
  async (e) => {
1512
- const n = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${V.version}&market=${e?.market || N}`, o = await fetch(n, { headers: E }).then((r) => r.json());
1523
+ const n = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${V.version}&market=${e?.market || N}`, o = await fetch(n, { headers: M }).then((r) => r.json());
1513
1524
  return Object.keys(o.data).map((r) => ({
1514
1525
  ...o.data[r],
1515
1526
  coinType: r
@@ -1518,171 +1529,171 @@ const G = $(
1518
1529
  )
1519
1530
  );
1520
1531
  async function ft(e, n) {
1521
- return (await G(n)).find((r) => typeof e == "string" ? b(r.coinType) === b(e) : typeof e == "number" ? r.assetId === e : r.assetId === e.id) || null;
1532
+ return (await G(n)).find((r) => typeof e == "string" ? k(r.coinType) === k(e) : typeof e == "number" ? r.assetId === e : r.assetId === e.id) || null;
1522
1533
  }
1523
1534
  async function yt(e, n, o, r) {
1524
- const t = await k({
1535
+ const t = await _({
1525
1536
  ...r,
1526
- cacheTime: w
1537
+ cacheTime: b
1527
1538
  }), a = await A(n, r);
1528
1539
  if (!(await G({
1529
1540
  ...r,
1530
- cacheTime: w
1541
+ cacheTime: b
1531
1542
  })).some(
1532
- (s) => b(s.coinType) === b(a.suiCoinType)
1543
+ (c) => k(c.coinType) === k(a.suiCoinType)
1533
1544
  ))
1534
1545
  throw new Error("Pool does not support flashloan");
1535
1546
  if (t.version === 1) {
1536
- const [s, l] = e.moveCall({
1547
+ const [c, u] = e.moveCall({
1537
1548
  target: `${t.package}::lending::flash_loan_with_ctx`,
1538
1549
  arguments: [
1539
1550
  e.object(t.flashloanConfig),
1540
1551
  e.object(a.contract.pool),
1541
- g(o, e.pure.u64)
1552
+ h(o, e.pure.u64)
1542
1553
  ],
1543
1554
  typeArguments: [a.suiCoinType]
1544
1555
  });
1545
- return [s, l];
1556
+ return [c, u];
1546
1557
  } else {
1547
- const [s, l] = e.moveCall({
1558
+ const [c, u] = e.moveCall({
1548
1559
  target: `${t.package}::lending::flash_loan_with_ctx_v2`,
1549
1560
  arguments: [
1550
1561
  e.object(t.flashloanConfig),
1551
1562
  e.object(a.contract.pool),
1552
- g(o, e.pure.u64),
1563
+ h(o, e.pure.u64),
1553
1564
  e.object("0x05")
1554
1565
  ],
1555
1566
  typeArguments: [a.suiCoinType]
1556
1567
  });
1557
- return [s, l];
1568
+ return [c, u];
1558
1569
  }
1559
1570
  }
1560
1571
  async function gt(e, n, o, r, t) {
1561
- const a = await k({
1572
+ const a = await _({
1562
1573
  ...t,
1563
- cacheTime: w
1564
- }), i = await A(n, t);
1574
+ cacheTime: b
1575
+ }), s = await A(n, t);
1565
1576
  if (!(await G({
1566
1577
  ...t,
1567
- cacheTime: w
1578
+ cacheTime: b
1568
1579
  })).some(
1569
- (d) => b(d.coinType) === b(i.suiCoinType)
1580
+ (d) => k(d.coinType) === k(s.suiCoinType)
1570
1581
  ))
1571
1582
  throw new Error("Pool does not support flashloan");
1572
- const [l] = e.moveCall({
1583
+ const [u] = e.moveCall({
1573
1584
  target: `${a.package}::lending::flash_repay_with_ctx`,
1574
1585
  arguments: [
1575
1586
  e.object("0x06"),
1576
1587
  e.object(a.storage),
1577
- e.object(i.contract.pool),
1578
- g(o, e.object),
1579
- g(r, e.object)
1588
+ e.object(s.contract.pool),
1589
+ h(o, e.object),
1590
+ h(r, e.object)
1580
1591
  ],
1581
- typeArguments: [i.suiCoinType]
1592
+ typeArguments: [s.suiCoinType]
1582
1593
  });
1583
- return [l];
1594
+ return [u];
1584
1595
  }
1585
1596
  async function ht(e, n, o, r, t, a) {
1586
- const i = {
1597
+ const s = {
1587
1598
  ...a,
1588
- cacheTime: w
1589
- }, c = await k(i), s = await A(n, i), l = await A(r, i);
1590
- if (c.version === 1) {
1591
- const [d, f] = e.moveCall({
1592
- target: `${c.package}::incentive_v3::liquidation`,
1599
+ cacheTime: b
1600
+ }, i = await _(s), c = await A(n, s), u = await A(r, s);
1601
+ if (i.version === 1) {
1602
+ const [d, y] = e.moveCall({
1603
+ target: `${i.package}::incentive_v3::liquidation`,
1593
1604
  arguments: [
1594
1605
  e.object("0x06"),
1595
1606
  // Clock object
1596
- e.object(c.priceOracle),
1607
+ e.object(i.priceOracle),
1597
1608
  // Price oracle for asset pricing
1598
- e.object(c.storage),
1609
+ e.object(i.storage),
1599
1610
  // Protocol storage
1600
- e.pure.u8(s.id),
1611
+ e.pure.u8(c.id),
1601
1612
  // Pay asset ID
1602
- e.object(s.contract.pool),
1613
+ e.object(c.contract.pool),
1603
1614
  // Pay asset pool contract
1604
- g(o, e.object),
1615
+ h(o, e.object),
1605
1616
  // Debt repayment amount
1606
- e.pure.u8(l.id),
1617
+ e.pure.u8(u.id),
1607
1618
  // Collateral asset ID
1608
- e.object(l.contract.pool),
1619
+ e.object(u.contract.pool),
1609
1620
  // Collateral asset pool contract
1610
- g(t, e.pure.address),
1621
+ h(t, e.pure.address),
1611
1622
  // Borrower address
1612
- e.object(c.incentiveV2),
1623
+ e.object(i.incentiveV2),
1613
1624
  // Incentive V2 contract
1614
- e.object(c.incentiveV3)
1625
+ e.object(i.incentiveV3)
1615
1626
  // Incentive V3 contract
1616
1627
  ],
1617
- typeArguments: [s.suiCoinType, l.suiCoinType]
1628
+ typeArguments: [c.suiCoinType, u.suiCoinType]
1618
1629
  });
1619
- return [d, f];
1630
+ return [d, y];
1620
1631
  } else {
1621
- const [d, f] = e.moveCall({
1622
- target: `${c.package}::incentive_v3::liquidation_v2`,
1632
+ const [d, y] = e.moveCall({
1633
+ target: `${i.package}::incentive_v3::liquidation_v2`,
1623
1634
  arguments: [
1624
1635
  e.object("0x06"),
1625
1636
  // Clock object
1626
- e.object(c.priceOracle),
1637
+ e.object(i.priceOracle),
1627
1638
  // Price oracle for asset pricing
1628
- e.object(c.storage),
1639
+ e.object(i.storage),
1629
1640
  // Protocol storage
1630
- e.pure.u8(s.id),
1641
+ e.pure.u8(c.id),
1631
1642
  // Pay asset ID
1632
- e.object(s.contract.pool),
1643
+ e.object(c.contract.pool),
1633
1644
  // Pay asset pool contract
1634
- g(o, e.object),
1645
+ h(o, e.object),
1635
1646
  // Debt repayment amount
1636
- e.pure.u8(l.id),
1647
+ e.pure.u8(u.id),
1637
1648
  // Collateral asset ID
1638
- e.object(l.contract.pool),
1649
+ e.object(u.contract.pool),
1639
1650
  // Collateral asset pool contract
1640
- g(t, e.pure.address),
1651
+ h(t, e.pure.address),
1641
1652
  // Borrower address
1642
- e.object(c.incentiveV2),
1653
+ e.object(i.incentiveV2),
1643
1654
  // Incentive V2 contract
1644
- e.object(c.incentiveV3),
1655
+ e.object(i.incentiveV3),
1645
1656
  // Incentive V3 contract
1646
1657
  e.object("0x05")
1647
1658
  // SuiSystemState object
1648
1659
  ],
1649
- typeArguments: [s.suiCoinType, l.suiCoinType]
1660
+ typeArguments: [c.suiCoinType, u.suiCoinType]
1650
1661
  });
1651
- return [d, f];
1662
+ return [d, y];
1652
1663
  }
1653
1664
  }
1654
1665
  async function De(e, n, o) {
1655
- const r = o?.client ?? P, t = new U(), a = await R({
1666
+ const r = o?.client ?? P, t = new O(), a = await R({
1656
1667
  ...o,
1657
- markets: Object.values(M),
1658
- cacheTime: w
1659
- }), i = await ne(o);
1668
+ markets: Object.values(E),
1669
+ cacheTime: b
1670
+ }), s = await ne(o);
1660
1671
  for (let d of n) {
1661
- const f = await k({
1672
+ const y = await _({
1662
1673
  ...o,
1663
- cacheTime: w,
1674
+ cacheTime: b,
1664
1675
  market: d.market
1665
1676
  });
1666
1677
  t.moveCall({
1667
- target: `${f.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
1678
+ target: `${y.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
1668
1679
  arguments: [
1669
1680
  t.object("0x06"),
1670
1681
  // Clock object
1671
- t.object(f.storage),
1682
+ t.object(y.storage),
1672
1683
  // Protocol storage
1673
- t.object(f.incentiveV3),
1684
+ t.object(y.incentiveV3),
1674
1685
  // Incentive V3 contract
1675
1686
  t.pure.address(d.address)
1676
1687
  // User address
1677
1688
  ]
1678
1689
  });
1679
1690
  }
1680
- const c = await r.devInspectTransactionBlock({
1691
+ const i = await r.devInspectTransactionBlock({
1681
1692
  transactionBlock: t,
1682
1693
  sender: e
1683
- }), s = [];
1684
- c?.results?.forEach((d) => {
1685
- s.push(
1694
+ }), c = [];
1695
+ i?.results?.forEach((d) => {
1696
+ c.push(
1686
1697
  L(
1687
1698
  {
1688
1699
  results: [d]
@@ -1702,24 +1713,24 @@ async function De(e, n, o) {
1702
1713
  )
1703
1714
  );
1704
1715
  });
1705
- const l = [];
1706
- return s.forEach((d, f) => {
1707
- const v = n[f];
1716
+ const u = [];
1717
+ return c.forEach((d, y) => {
1718
+ const v = n[y];
1708
1719
  if (d.length === 5 && Array.isArray(d[0])) {
1709
- const y = d[0].length;
1710
- for (let u = 0; u < y; u++) {
1711
- const h = i.find(
1712
- (I) => b(I.coinType) === b(d[1][u])
1713
- ), j = a.find(
1714
- (I) => b(I.coinType) === b(d[0][u]) && I.market === v.market
1720
+ const g = d[0].length;
1721
+ for (let l = 0; l < g; l++) {
1722
+ const f = s.find(
1723
+ (T) => k(T.coinType) === k(d[1][l])
1724
+ ), w = a.find(
1725
+ (T) => k(T.coinType) === k(d[0][l]) && T.market === v.market
1715
1726
  );
1716
- !h || !j || l.push({
1717
- assetId: j.id,
1718
- assetCoinType: b(d[0][u]),
1719
- rewardCoinType: b(d[1][u]),
1720
- option: Number(d[2][u]),
1721
- userClaimableReward: Number(d[4][u]) / Math.pow(10, h.priceDecimal),
1722
- ruleIds: Array.isArray(d[3][u]) ? d[3][u] : [d[3][u]],
1727
+ !f || !w || u.push({
1728
+ assetId: w.id,
1729
+ assetCoinType: k(d[0][l]),
1730
+ rewardCoinType: k(d[1][l]),
1731
+ option: Number(d[2][l]),
1732
+ userClaimableReward: Number(d[4][l]) / Math.pow(10, f.priceDecimal),
1733
+ ruleIds: Array.isArray(d[3][l]) ? d[3][l] : [d[3][l]],
1723
1734
  market: v.market,
1724
1735
  owner: v.owner,
1725
1736
  address: v.address,
@@ -1727,10 +1738,10 @@ async function De(e, n, o) {
1727
1738
  });
1728
1739
  }
1729
1740
  }
1730
- }), l;
1741
+ }), u;
1731
1742
  }
1732
1743
  async function vt(e, n) {
1733
- const o = (n?.markets || [M.main]).map((a) => _(a));
1744
+ const o = (n?.markets || [E.main]).map((a) => j(a));
1734
1745
  let r = [];
1735
1746
  try {
1736
1747
  r = await x(e, n);
@@ -1742,12 +1753,12 @@ async function vt(e, n) {
1742
1753
  owner: e,
1743
1754
  market: a.key
1744
1755
  })).concat(
1745
- r.filter((a) => !!o.find((i) => i.id === a.marketId)).map((a) => {
1746
- const i = _(a.marketId);
1756
+ r.filter((a) => !!o.find((s) => s.id === a.marketId)).map((a) => {
1757
+ const s = j(a.marketId);
1747
1758
  return {
1748
1759
  address: a.accountCap,
1749
1760
  owner: e,
1750
- market: i.key,
1761
+ market: s.key,
1751
1762
  emodeId: a.emodeId
1752
1763
  };
1753
1764
  })
@@ -1757,8 +1768,8 @@ async function vt(e, n) {
1757
1768
  function wt(e) {
1758
1769
  const n = /* @__PURE__ */ new Map();
1759
1770
  e.forEach((r) => {
1760
- const t = r.assetId, a = r.option, i = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
1761
- n.has(i) ? n.get(i).total += r.userClaimableReward : n.set(i, {
1771
+ const t = r.assetId, a = r.option, s = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
1772
+ n.has(s) ? n.get(s).total += r.userClaimableReward : n.set(s, {
1762
1773
  assetId: t,
1763
1774
  rewardType: a,
1764
1775
  coinType: r.rewardCoinType,
@@ -1767,11 +1778,11 @@ function wt(e) {
1767
1778
  });
1768
1779
  });
1769
1780
  const o = /* @__PURE__ */ new Map();
1770
- for (const { assetId: r, rewardType: t, coinType: a, total: i, market: c } of n.values()) {
1771
- const s = `${r}-${t}-${c}`;
1772
- o.has(s) || o.set(s, { assetId: r, rewardType: t, market: c, rewards: /* @__PURE__ */ new Map() });
1773
- const l = o.get(s);
1774
- l.rewards.set(a, (l.rewards.get(a) || 0) + i);
1781
+ for (const { assetId: r, rewardType: t, coinType: a, total: s, market: i } of n.values()) {
1782
+ const c = `${r}-${t}-${i}`;
1783
+ o.has(c) || o.set(c, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
1784
+ const u = o.get(c);
1785
+ u.rewards.set(a, (u.rewards.get(a) || 0) + s);
1775
1786
  }
1776
1787
  return Array.from(o.values()).map((r) => ({
1777
1788
  assetId: r.assetId,
@@ -1786,229 +1797,229 @@ function wt(e) {
1786
1797
  const bt = B(
1787
1798
  async (e, n) => {
1788
1799
  const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${V.version}&market=${n?.market || N}`;
1789
- return (await fetch(o, { headers: E }).then((t) => t.json())).data;
1800
+ return (await fetch(o, { headers: M }).then((t) => t.json())).data;
1790
1801
  }
1791
1802
  ), kt = B(
1792
1803
  async (e, n) => {
1793
- const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${n?.page || 1}&pageSize=${n?.size || 400}&sdk=${V.version}&market=${n?.market || N}`, r = await fetch(o, { headers: E }).then((t) => t.json());
1804
+ const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${n?.page || 1}&pageSize=${n?.size || 400}&sdk=${V.version}&market=${n?.market || N}`, r = await fetch(o, { headers: M }).then((t) => t.json());
1794
1805
  return W({
1795
1806
  data: r.data.rewards
1796
1807
  });
1797
1808
  }
1798
1809
  );
1799
- async function Ct(e, n, o) {
1810
+ async function _t(e, n, o) {
1800
1811
  const r = await R({
1801
1812
  ...o,
1802
- markets: Object.values(M),
1803
- cacheTime: w
1813
+ markets: Object.values(E),
1814
+ cacheTime: b
1804
1815
  }), t = /* @__PURE__ */ new Map();
1805
- for (const i of n) {
1806
- const { rewardCoinType: c, ruleIds: s, market: l, owner: d, address: f, emodeId: v } = i, y = `${c}___${f}`;
1807
- for (const u of s) {
1808
- t.has(y) || t.set(y, {
1816
+ for (const s of n) {
1817
+ const { rewardCoinType: i, ruleIds: c, market: u, owner: d, address: y, emodeId: v } = s, g = `${i}___${y}`;
1818
+ for (const l of c) {
1819
+ t.has(g) || t.set(g, {
1809
1820
  assetIds: [],
1810
1821
  ruleIds: [],
1811
1822
  amount: 0,
1812
- market: l,
1823
+ market: u,
1813
1824
  owner: d,
1814
- address: f,
1825
+ address: y,
1815
1826
  isEMode: typeof v < "u"
1816
1827
  });
1817
- const h = t.get(y);
1818
- h.assetIds.push(i.assetCoinType.replace("0x", "")), h.ruleIds.push(u), h.amount += i.userClaimableReward;
1828
+ const f = t.get(g);
1829
+ f.assetIds.push(s.assetCoinType.replace("0x", "")), f.ruleIds.push(l), f.amount += s.userClaimableReward;
1819
1830
  }
1820
1831
  }
1821
1832
  const a = [];
1822
1833
  for (const [
1823
- i,
1824
- { assetIds: c, ruleIds: s, amount: l, market: d, owner: f, address: v, isEMode: y }
1834
+ s,
1835
+ { assetIds: i, ruleIds: c, amount: u, market: d, owner: y, address: v, isEMode: g }
1825
1836
  ] of t) {
1826
- const u = await k({
1837
+ const l = await _({
1827
1838
  ...o,
1828
- cacheTime: w,
1839
+ cacheTime: b,
1829
1840
  market: d
1830
- }), h = i.split("___")[0], j = r.find(
1831
- (S) => b(S.suiCoinType) === b(h) && S.market === d
1841
+ }), f = s.split("___")[0], w = r.find(
1842
+ (S) => k(S.suiCoinType) === k(f) && S.market === d
1832
1843
  );
1833
- if (!j || !j.contract.rewardFundId)
1834
- throw new Error(`No matching rewardFund found for reward coin: ${h} ${d}`);
1835
- const I = j.contract.rewardFundId;
1844
+ if (!w || !w.contract.rewardFundId)
1845
+ throw new Error(`No matching rewardFund found for reward coin: ${f} ${d}`);
1846
+ const T = w.contract.rewardFundId;
1836
1847
  if (o?.accountCap && !o.customCoinReceive)
1837
1848
  throw new Error("customCoinReceive is required when accountCap is provided");
1838
1849
  if (o?.customCoinReceive) {
1839
1850
  let S;
1840
1851
  o.accountCap ? S = e.moveCall({
1841
- target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1852
+ target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
1842
1853
  arguments: [
1843
1854
  e.object("0x06"),
1844
1855
  // Clock object
1845
- e.object(u.incentiveV3),
1856
+ e.object(l.incentiveV3),
1846
1857
  // Incentive V3 contract
1847
- e.object(u.storage),
1858
+ e.object(l.storage),
1848
1859
  // Protocol storage
1849
- e.object(I),
1860
+ e.object(T),
1850
1861
  // Reward fund
1851
- e.pure.vector("string", c),
1862
+ e.pure.vector("string", i),
1852
1863
  // Asset IDs
1853
- e.pure.vector("address", s),
1864
+ e.pure.vector("address", c),
1854
1865
  // Rule IDs
1855
- g(o.accountCap, e.object)
1866
+ h(o.accountCap, e.object)
1856
1867
  // Account capability
1857
1868
  ],
1858
- typeArguments: [h]
1859
- }) : y ? S = e.moveCall({
1860
- target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1869
+ typeArguments: [f]
1870
+ }) : g ? S = e.moveCall({
1871
+ target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
1861
1872
  arguments: [
1862
1873
  e.object("0x06"),
1863
1874
  // Clock object
1864
- e.object(u.incentiveV3),
1875
+ e.object(l.incentiveV3),
1865
1876
  // Incentive V3 contract
1866
- e.object(u.storage),
1877
+ e.object(l.storage),
1867
1878
  // Protocol storage
1868
- e.object(I),
1879
+ e.object(T),
1869
1880
  // Reward fund
1870
- e.pure.vector("string", c),
1881
+ e.pure.vector("string", i),
1871
1882
  // Asset IDs
1872
- e.pure.vector("address", s),
1883
+ e.pure.vector("address", c),
1873
1884
  // Rule IDs
1874
- g(v, e.object)
1885
+ h(v, e.object)
1875
1886
  // Account capability
1876
1887
  ],
1877
- typeArguments: [h]
1888
+ typeArguments: [f]
1878
1889
  }) : S = e.moveCall({
1879
- target: `${u.package}::incentive_v3::claim_reward`,
1890
+ target: `${l.package}::incentive_v3::claim_reward`,
1880
1891
  arguments: [
1881
1892
  e.object("0x06"),
1882
1893
  // Clock object
1883
- e.object(u.incentiveV3),
1894
+ e.object(l.incentiveV3),
1884
1895
  // Incentive V3 contract
1885
- e.object(u.storage),
1896
+ e.object(l.storage),
1886
1897
  // Protocol storage
1887
- e.object(I),
1898
+ e.object(T),
1888
1899
  // Reward fund
1889
- e.pure.vector("string", c),
1900
+ e.pure.vector("string", i),
1890
1901
  // Asset IDs
1891
- e.pure.vector("address", s)
1902
+ e.pure.vector("address", c)
1892
1903
  // Rule IDs
1893
1904
  ],
1894
- typeArguments: [h]
1905
+ typeArguments: [f]
1895
1906
  });
1896
1907
  const [D] = e.moveCall({
1897
1908
  target: "0x2::coin::from_balance",
1898
1909
  arguments: [S],
1899
- typeArguments: [h]
1910
+ typeArguments: [f]
1900
1911
  });
1901
1912
  if (o?.customCoinReceive.type === "transfer") {
1902
1913
  if (!o.customCoinReceive.transfer)
1903
1914
  throw new Error("customCoinReceive.transfer is required");
1904
1915
  e.transferObjects(
1905
1916
  [D],
1906
- g(o.customCoinReceive.transfer, e.pure.address)
1917
+ h(o.customCoinReceive.transfer, e.pure.address)
1907
1918
  );
1908
1919
  }
1909
1920
  if (o?.customCoinReceive.type === "depositNAVI") {
1910
- const re = p(j.totalSupplyAmount).shiftedBy(-9), ae = p(j.supplyCapCeiling).shiftedBy(-27);
1911
- re.plus(l).isGreaterThan(ae) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
1921
+ const re = p(w.totalSupplyAmount).shiftedBy(-9), ae = p(w.supplyCapCeiling).shiftedBy(-27);
1922
+ re.plus(u).isGreaterThan(ae) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
1912
1923
  [D],
1913
1924
  e.pure.address(o.customCoinReceive.depositNAVI.fallbackReceiveAddress)
1914
- ) : await Ce(e, j, D, o);
1925
+ ) : await _e(e, w, D, o);
1915
1926
  } else
1916
1927
  a.push({
1917
1928
  coin: D,
1918
- identifier: j,
1919
- owner: f,
1920
- isEMode: y
1929
+ identifier: w,
1930
+ owner: y,
1931
+ isEMode: g
1921
1932
  });
1922
- } else if (o?.accountCap || y) {
1933
+ } else if (o?.accountCap || g) {
1923
1934
  const S = e.moveCall({
1924
- target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1935
+ target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
1925
1936
  arguments: [
1926
1937
  e.object("0x06"),
1927
1938
  // Clock object
1928
- e.object(u.incentiveV3),
1939
+ e.object(l.incentiveV3),
1929
1940
  // Incentive V3 contract
1930
- e.object(u.storage),
1941
+ e.object(l.storage),
1931
1942
  // Protocol storage
1932
- e.object(I),
1943
+ e.object(T),
1933
1944
  // Reward fund
1934
- e.pure.vector("string", c),
1945
+ e.pure.vector("string", i),
1935
1946
  // Asset IDs
1936
- e.pure.vector("address", s),
1947
+ e.pure.vector("address", c),
1937
1948
  // Rule IDs
1938
- g(o?.accountCap || v, e.object)
1949
+ h(o?.accountCap || v, e.object)
1939
1950
  // Account capability
1940
1951
  ],
1941
- typeArguments: [h]
1952
+ typeArguments: [f]
1942
1953
  }), [D] = e.moveCall({
1943
1954
  target: "0x2::coin::from_balance",
1944
1955
  arguments: [S],
1945
- typeArguments: [h]
1956
+ typeArguments: [f]
1946
1957
  });
1947
1958
  e.transferObjects(
1948
1959
  [D],
1949
- g(o?.accountCap || f, e.pure.address)
1960
+ h(o?.accountCap || y, e.pure.address)
1950
1961
  );
1951
1962
  } else
1952
1963
  e.moveCall({
1953
- target: `${u.package}::incentive_v3::claim_reward_entry`,
1964
+ target: `${l.package}::incentive_v3::claim_reward_entry`,
1954
1965
  arguments: [
1955
1966
  e.object("0x06"),
1956
1967
  // Clock object
1957
- e.object(u.incentiveV3),
1968
+ e.object(l.incentiveV3),
1958
1969
  // Incentive V3 contract
1959
- e.object(u.storage),
1970
+ e.object(l.storage),
1960
1971
  // Protocol storage
1961
- e.object(I),
1972
+ e.object(T),
1962
1973
  // Reward fund
1963
- e.pure.vector("string", c),
1974
+ e.pure.vector("string", i),
1964
1975
  // Asset IDs
1965
- e.pure.vector("address", s)
1976
+ e.pure.vector("address", c)
1966
1977
  // Rule IDs
1967
1978
  ],
1968
- typeArguments: [h]
1979
+ typeArguments: [f]
1969
1980
  });
1970
1981
  }
1971
1982
  return a;
1972
1983
  }
1973
1984
  export {
1974
1985
  z as Address,
1975
- w as DEFAULT_CACHE_TIME,
1986
+ b as DEFAULT_CACHE_TIME,
1976
1987
  N as DEFAULT_MARKET_IDENTITY,
1977
1988
  Ke as FlashLoanAssetConfig,
1978
1989
  He as IncentiveAPYInfo,
1979
1990
  me as IncentivePoolInfo,
1980
1991
  Ge as IncentivePoolInfoByPhase,
1981
- M as MARKETS,
1982
- je as Market,
1992
+ E as MARKETS,
1993
+ Ce as Market,
1983
1994
  ze as OracleInfo,
1984
1995
  F as PoolOperator,
1985
1996
  Ye as ReserveDataInfo,
1986
- O as UserPositions,
1997
+ U as UserPositions,
1987
1998
  fe as UserStateInfo,
1988
1999
  Xe as borrowCoinPTB,
1989
- Ct as claimLendingRewardsPTB,
1990
- Ie as createAccountCapPTB,
2000
+ _t as claimLendingRewardsPTB,
2001
+ Te as createAccountCapPTB,
1991
2002
  nt as createEModeCapPTB,
1992
- Ce as depositCoinPTB,
2003
+ _e as depositCoinPTB,
1993
2004
  rt as emodeIdentityId,
1994
2005
  Be as enterEModePTB,
1995
2006
  ot as exitEModePTB,
1996
- Me as filterPriceFeeds,
2007
+ Ee as filterPriceFeeds,
1997
2008
  yt as flashloanPTB,
1998
- Te as getAccountCapOwnerPTB,
2009
+ Ie as getAccountCapOwnerPTB,
1999
2010
  G as getAllFlashLoanAssets,
2000
2011
  et as getBorrowFee,
2001
- ut as getCoins,
2002
- k as getConfig,
2012
+ lt as getCoins,
2013
+ _ as getConfig,
2003
2014
  Ze as getFees,
2004
2015
  ft as getFlashLoanAsset,
2005
- it as getHealthFactor,
2016
+ ct as getHealthFactor,
2006
2017
  Ae as getHealthFactorPTB,
2007
2018
  $e as getLendingPositions,
2008
- ct as getLendingState,
2019
+ it as getLendingState,
2009
2020
  tt as getMarket,
2010
- _ as getMarketConfig,
2011
- _e as getMarkets,
2021
+ j as getMarketConfig,
2022
+ je as getMarkets,
2012
2023
  A as getPool,
2013
2024
  R as getPools,
2014
2025
  ne as getPriceFeeds,
@@ -2017,21 +2028,21 @@ export {
2017
2028
  st as getSimulatedHealthFactor,
2018
2029
  ee as getSimulatedHealthFactorPTB,
2019
2030
  Je as getStats,
2020
- lt as getTransactions,
2031
+ ut as getTransactions,
2021
2032
  vt as getUserAvailableLendingRewards,
2022
2033
  kt as getUserClaimedRewardHistory,
2023
2034
  x as getUserEModeCaps,
2024
2035
  bt as getUserTotalClaimedReward,
2025
2036
  ht as liquidatePTB,
2026
2037
  at as mergeCoinsPTB,
2027
- b as normalizeCoinType,
2038
+ k as normalizeCoinType,
2028
2039
  ke as parsePoolUID,
2029
- g as parseTxValue,
2040
+ h as parseTxValue,
2030
2041
  xe as repayCoinPTB,
2031
2042
  gt as repayFlashLoanPTB,
2032
2043
  wt as summaryLendingRewards,
2033
2044
  mt as updateOraclePriceBeforeUserOperationPTB,
2034
- Ee as updateOraclePricesPTB,
2045
+ Me as updateOraclePricesPTB,
2035
2046
  Ve as updatePythPriceFeeds,
2036
2047
  pt as verifyHealthFactorPTB,
2037
2048
  $ as withCache,