@naviprotocol/lending 1.4.6 → 1.4.7-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Transaction as F } from "@mysten/sui/transactions";
2
- import { bcs as d, toHex as ue, fromHex as pe } from "@mysten/bcs";
2
+ import { bcs as d, toHex as le, fromHex as pe } from "@mysten/bcs";
3
3
  import { SuiClient as de, getFullnodeUrl as me } from "@mysten/sui/client";
4
4
  import fe from "lodash.camelcase";
5
5
  import { normalizeStructTag as ye } from "@mysten/sui/utils";
@@ -9,7 +9,7 @@ import { bcs as C } from "@mysten/sui/bcs";
9
9
  const J = d.bytes(32).transform({
10
10
  // To change the input type, you need to provide a type definition for the input
11
11
  input: (e) => pe(e),
12
- output: (e) => ue(e)
12
+ output: (e) => le(e)
13
13
  }), Je = d.struct("IncentiveAPYInfo", {
14
14
  /** Asset identifier */
15
15
  asset_id: d.u8(),
@@ -129,7 +129,7 @@ const J = d.bytes(32).transform({
129
129
  borrow_balance: d.u256(),
130
130
  /** User's current supply balance */
131
131
  supply_balance: d.u256()
132
- }), be = "1.4.6", E = {
132
+ }), be = "1.4.7-beta.1", E = {
133
133
  version: be
134
134
  }, ke = E.version, _e = () => {
135
135
  if (typeof process < "u" && process.versions && process.versions.node)
@@ -157,7 +157,7 @@ function ee(e) {
157
157
  r.push(o);
158
158
  }), JSON.stringify(r);
159
159
  }
160
- function P(e) {
160
+ function $(e) {
161
161
  const r = {};
162
162
  return (...o) => {
163
163
  const n = ee(o);
@@ -213,7 +213,7 @@ const Ie = 27, Q = (e, r) => {
213
213
  if (!Number(e) || !Number(r)) return new p(0);
214
214
  const o = new p(1).shiftedBy(1 * Ie), n = o.multipliedBy(new p(0.5));
215
215
  return new p(e).multipliedBy(new p(r)).plus(n).dividedBy(o).integerValue(p.ROUND_DOWN);
216
- }, D = Z ? {
216
+ }, U = Z ? {
217
217
  "User-Agent": Z
218
218
  } : {};
219
219
  function z(e, r = "uniqueId") {
@@ -249,32 +249,32 @@ function Te(e) {
249
249
  poolId: parseInt(o)
250
250
  };
251
251
  }
252
- function $() {
252
+ function S() {
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 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
256
  const q = M(
257
- P(
257
+ $(
258
258
  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(
259
+ const r = (e?.markets || [D.main]).map((t) => j(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.map(
260
260
  (t) => t.key
261
- )}`, n = await fetch(o, { headers: D }).then((t) => t.json());
261
+ )}`, n = await fetch(o, { headers: U }).then((t) => t.json());
262
262
  return n.data.forEach((t) => {
263
263
  const s = n.meta.emodes.filter((f) => {
264
- const w = T(f.marketId);
264
+ const w = j(f.marketId);
265
265
  return t.market === w.key && f.isActive;
266
266
  }).filter((f) => !!f.assets.find((w) => w.assetId === t.id));
267
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(
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(), l = 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
269
  p(t.borrowedAmount),
270
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;
271
+ ).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), y = p(h).multipliedBy(t.oracle.price).toString(), u = p(v).multipliedBy(t.oracle.price).toString();
272
+ t.poolSupplyAmount = i, t.poolBorrowAmount = c, t.poolSupplyValue = l, t.poolBorrowValue = m, t.poolSupplyCapAmount = h, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = y, t.poolBorrowCapValue = u;
273
273
  }), n.data;
274
274
  }
275
275
  )
276
276
  );
277
- async function S(e, r) {
277
+ async function P(e, r) {
278
278
  let o = r?.market;
279
279
  if (typeof e == "string") {
280
280
  const a = Te(e);
@@ -293,15 +293,15 @@ async function S(e, r) {
293
293
  return t.isDeprecated && console.log(`The lending pool for coinType ${t.suiCoinType} is going to be deprecated.`), t;
294
294
  }
295
295
  const xe = M(
296
- P(async (e) => {
296
+ $(async (e) => {
297
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;
298
+ return (await fetch(r, { headers: U }).then((n) => n.json())).data;
299
299
  })
300
300
  ), et = M(
301
- P(
301
+ $(
302
302
  async (e) => {
303
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());
304
+ return await fetch(r, { headers: U }).then((n) => n.json());
305
305
  }
306
306
  )
307
307
  );
@@ -309,7 +309,7 @@ async function Be(e, r, o, n) {
309
309
  const t = await _({
310
310
  ...n,
311
311
  cacheTime: b
312
- }), a = await S(r, n), s = n?.market || O, i = n?.env || "prod";
312
+ }), a = await P(r, n), s = j(n?.market || O), i = n?.env || "prod";
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
315
  const c = typeof o == "object" && o.$kind === "GasCoin";
@@ -318,8 +318,8 @@ async function Be(e, r, o, n) {
318
318
  throw new Error("Amount is required for sui coin");
319
319
  o = e.splitCoins(o, [n.amount]);
320
320
  }
321
- let u;
322
- return typeof n?.amount < "u" ? u = g(n.amount, e.pure.u64) : u = e.moveCall({
321
+ let l;
322
+ return typeof n?.amount < "u" ? l = g(n.amount, e.pure.u64) : l = e.moveCall({
323
323
  target: "0x2::coin::value",
324
324
  arguments: [g(o, e.object)],
325
325
  typeArguments: [a.suiCoinType]
@@ -344,12 +344,12 @@ async function Be(e, r, o, n) {
344
344
  e.object(a.contract.pool),
345
345
  e.pure.u8(a.id),
346
346
  g(o, e.object),
347
- u,
347
+ l,
348
348
  e.object(t.incentiveV2),
349
349
  e.object(t.incentiveV3)
350
350
  ],
351
351
  typeArguments: [a.suiCoinType]
352
- }), t.version === 2 && a.token.symbol === "SUI" && i === "prod" && s === "main" && e.moveCall({
352
+ }), t.version === 2 && a.token.symbol === "SUI" && i === "prod" && s.key === "main" && e.moveCall({
353
353
  target: `${t.package}::pool::refresh_stake`,
354
354
  arguments: [e.object(a.contract.pool), e.object("0x05")]
355
355
  }), e;
@@ -358,11 +358,11 @@ async function tt(e, r, o, n) {
358
358
  const t = await _({
359
359
  ...n,
360
360
  cacheTime: b
361
- }), a = await S(r, n), s = g(o, e.pure.u64);
361
+ }), a = await P(r, n), s = g(o, e.pure.u64);
362
362
  let i;
363
363
  if (t.version === 1)
364
364
  if (n?.accountCap) {
365
- const [u] = e.moveCall({
365
+ const [l] = e.moveCall({
366
366
  target: `${t.package}::incentive_v3::withdraw_with_account_cap`,
367
367
  arguments: [
368
368
  e.object("0x06"),
@@ -377,9 +377,9 @@ async function tt(e, r, o, n) {
377
377
  ],
378
378
  typeArguments: [a.suiCoinType]
379
379
  });
380
- i = u;
380
+ i = l;
381
381
  } else {
382
- const [u] = e.moveCall({
382
+ const [l] = e.moveCall({
383
383
  target: `${t.package}::incentive_v3::withdraw`,
384
384
  arguments: [
385
385
  e.object("0x06"),
@@ -393,10 +393,10 @@ async function tt(e, r, o, n) {
393
393
  ],
394
394
  typeArguments: [a.suiCoinType]
395
395
  });
396
- i = u;
396
+ i = l;
397
397
  }
398
398
  else if (n?.accountCap) {
399
- const [u] = e.moveCall({
399
+ const [l] = e.moveCall({
400
400
  target: `${t.package}::incentive_v3::withdraw_with_account_cap_v2`,
401
401
  arguments: [
402
402
  e.object("0x06"),
@@ -412,9 +412,9 @@ async function tt(e, r, o, n) {
412
412
  ],
413
413
  typeArguments: [a.suiCoinType]
414
414
  });
415
- i = u;
415
+ i = l;
416
416
  } else {
417
- const [u] = e.moveCall({
417
+ const [l] = e.moveCall({
418
418
  target: `${t.package}::incentive_v3::withdraw_v2`,
419
419
  arguments: [
420
420
  e.object("0x06"),
@@ -429,7 +429,7 @@ async function tt(e, r, o, n) {
429
429
  ],
430
430
  typeArguments: [a.suiCoinType]
431
431
  });
432
- i = u;
432
+ i = l;
433
433
  }
434
434
  return e.moveCall({
435
435
  target: "0x2::coin::from_balance",
@@ -441,14 +441,14 @@ async function ot(e, r, o, n) {
441
441
  const t = await _({
442
442
  ...n,
443
443
  cacheTime: b
444
- }), a = await S(r, n);
444
+ }), a = await P(r, n);
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
447
  const s = g(o, e.pure.u64);
448
448
  let i;
449
449
  if (t.version === 1)
450
450
  if (n?.accountCap) {
451
- const [u] = e.moveCall({
451
+ const [l] = e.moveCall({
452
452
  target: `${t.package}::incentive_v3::borrow_with_account_cap`,
453
453
  arguments: [
454
454
  e.object("0x06"),
@@ -463,9 +463,9 @@ async function ot(e, r, o, n) {
463
463
  ],
464
464
  typeArguments: [a.suiCoinType]
465
465
  });
466
- i = u;
466
+ i = l;
467
467
  } else {
468
- const [u] = e.moveCall({
468
+ const [l] = e.moveCall({
469
469
  target: `${t.package}::incentive_v3::borrow`,
470
470
  arguments: [
471
471
  e.object("0x06"),
@@ -479,10 +479,10 @@ async function ot(e, r, o, n) {
479
479
  ],
480
480
  typeArguments: [a.suiCoinType]
481
481
  });
482
- i = u;
482
+ i = l;
483
483
  }
484
484
  else if (n?.accountCap) {
485
- const [u] = e.moveCall({
485
+ const [l] = e.moveCall({
486
486
  target: `${t.package}::incentive_v3::borrow_with_account_cap_v2`,
487
487
  arguments: [
488
488
  e.object("0x06"),
@@ -498,9 +498,9 @@ async function ot(e, r, o, n) {
498
498
  ],
499
499
  typeArguments: [a.suiCoinType]
500
500
  });
501
- i = u;
501
+ i = l;
502
502
  } else {
503
- const [u] = e.moveCall({
503
+ const [l] = e.moveCall({
504
504
  target: `${t.package}::incentive_v3::borrow_v2`,
505
505
  arguments: [
506
506
  e.object("0x06"),
@@ -515,7 +515,7 @@ async function ot(e, r, o, n) {
515
515
  ],
516
516
  typeArguments: [a.suiCoinType]
517
517
  });
518
- i = u;
518
+ i = l;
519
519
  }
520
520
  return e.moveCall({
521
521
  target: "0x2::coin::from_balance",
@@ -527,7 +527,7 @@ async function rt(e, r, o, n) {
527
527
  const t = await _({
528
528
  ...n,
529
529
  cacheTime: b
530
- }), a = await S(r, n), s = typeof o == "object" && o.$kind === "GasCoin";
530
+ }), a = await P(r, n), s = typeof o == "object" && o.$kind === "GasCoin";
531
531
  if (k(a.suiCoinType) === k("0x2::sui::SUI") && s) {
532
532
  if (!n?.amount)
533
533
  throw new Error("Amount is required for sui coin");
@@ -577,14 +577,14 @@ async function rt(e, r, o, n) {
577
577
  }), e;
578
578
  }
579
579
  const nt = M(
580
- P(
580
+ $(
581
581
  async (e) => {
582
582
  const r = await _({
583
583
  ...e
584
584
  });
585
585
  if (e?.address && typeof e?.asset < "u")
586
586
  try {
587
- const t = await S(e.asset, e), a = e?.client ?? V, s = new F();
587
+ const t = await P(e.asset, e), a = e?.client ?? V, s = new F();
588
588
  s.moveCall({
589
589
  target: `${r.package}::incentive_v3::get_borrow_fee_v2`,
590
590
  arguments: [
@@ -610,7 +610,7 @@ const nt = M(
610
610
  return Number(n) / 100;
611
611
  }
612
612
  )
613
- ), O = "main", U = {
613
+ ), O = "main", D = {
614
614
  main: {
615
615
  id: 0,
616
616
  key: "main",
@@ -630,6 +630,36 @@ const nt = M(
630
630
  id: 3,
631
631
  key: "sui-eco",
632
632
  name: "Sui Eco Market"
633
+ },
634
+ "vsui-usdc": {
635
+ id: 4,
636
+ key: "vsui-usdc",
637
+ name: "vSUI/USDC Market"
638
+ },
639
+ "sui-usdc": {
640
+ id: 5,
641
+ key: "sui-usdc",
642
+ name: "SUI/USDC Market"
643
+ },
644
+ "hasui-sui": {
645
+ id: 6,
646
+ key: "hasui-sui",
647
+ name: "haSUI/SUI Market"
648
+ },
649
+ "wbtc-usdc": {
650
+ id: 7,
651
+ key: "wbtc-usdc",
652
+ name: "WBTC/USDC Market"
653
+ },
654
+ "vsui-sui": {
655
+ id: 8,
656
+ key: "vsui-sui",
657
+ name: "vSUI/SUI Market"
658
+ },
659
+ "xbtc-usdc": {
660
+ id: 9,
661
+ key: "xbtc-usdc",
662
+ name: "xBTC/USDC Market"
633
663
  }
634
664
  };
635
665
  class Ae {
@@ -637,7 +667,7 @@ class Ae {
637
667
  this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
638
668
  marketTotalSupplyValue: "0",
639
669
  marketTotalBorrowValue: "0"
640
- }, this.config = T(r), this.initPools(o);
670
+ }, this.config = j(r), this.initPools(o);
641
671
  }
642
672
  get overview() {
643
673
  return this._overview;
@@ -658,8 +688,8 @@ class Ae {
658
688
  });
659
689
  }), i = i.plus(c.poolBorrowValue), s = s.plus(c.poolSupplyValue);
660
690
  }), 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);
691
+ const l = this.getEModePools(c.emodeId);
692
+ this.emodePools.push(...l);
663
693
  }), this._overview = {
664
694
  marketTotalSupplyValue: s.toString(),
665
695
  marketTotalBorrowValue: i.toString()
@@ -695,13 +725,13 @@ class Ae {
695
725
  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;
696
726
  }
697
727
  }
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);
728
+ const j = (e) => {
729
+ const o = Object.values(D).find((n) => typeof e == "number" ? n.id === e : typeof e == "string" ? n.key === e : n.id === e.id);
700
730
  if (!o)
701
731
  throw new Error("Market not found");
702
732
  return o;
703
- }, $e = M(
704
- P(
733
+ }, Se = M(
734
+ $(
705
735
  async (e, r) => {
706
736
  const o = await q({
707
737
  cacheTime: 6e4,
@@ -709,24 +739,24 @@ const T = (e) => {
709
739
  markets: e
710
740
  });
711
741
  return e.map((n) => {
712
- const t = T(n), a = o.filter((s) => s.market === t.key);
742
+ const t = j(n), a = o.filter((s) => s.market === t.key);
713
743
  return new Ae(n, a);
714
744
  });
715
745
  }
716
746
  )
717
747
  ), at = M(
718
- P(
719
- async (e, r) => (await $e([e], r))[0]
748
+ $(
749
+ async (e, r) => (await Se([e], r))[0]
720
750
  )
721
751
  ), _ = M(
722
- P(
752
+ $(
723
753
  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;
754
+ const r = j(e?.market || O), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.key}`;
755
+ return (await fetch(o, { headers: U }).then((t) => t.json())).data;
726
756
  }
727
757
  )
728
758
  ), b = 1e3 * 60 * 5;
729
- async function Pe(e, r) {
759
+ async function $e(e, r) {
730
760
  const o = await _({
731
761
  cacheTime: b,
732
762
  ...r
@@ -736,7 +766,7 @@ async function Pe(e, r) {
736
766
  arguments: []
737
767
  });
738
768
  }
739
- async function Se(e, r, o) {
769
+ async function Pe(e, r, o) {
740
770
  const n = await _({
741
771
  cacheTime: b,
742
772
  ...o
@@ -780,12 +810,12 @@ async function ct(e, r, o) {
780
810
  const n = await _({
781
811
  cacheTime: b,
782
812
  ...o
783
- }), t = await Pe(e, o);
813
+ }), t = await $e(e, o);
784
814
  await Me(e, r, {
785
815
  ...o,
786
816
  accountCap: t
787
817
  });
788
- const a = await T(o?.market || O), s = await Se(e, t, o);
818
+ const a = await j(o?.market || O), s = await Pe(e, t, o);
789
819
  return e.moveCall({
790
820
  target: `${n.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
791
821
  arguments: [
@@ -797,7 +827,7 @@ async function ct(e, r, o) {
797
827
  }), t;
798
828
  }
799
829
  const oe = M(
800
- P(
830
+ $(
801
831
  async (e, r) => {
802
832
  const o = await _({
803
833
  cacheTime: b,
@@ -810,24 +840,24 @@ const oe = M(
810
840
  const s = (await t.devInspectTransactionBlock({
811
841
  transactionBlock: n,
812
842
  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]));
843
+ })).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])), l = C.vector(C.Address).parse(Uint8Array.from(s[2][0]));
814
844
  return i.map((m, h) => ({
815
845
  marketId: Number(m),
816
846
  emodeId: Number(c[h]),
817
- accountCap: u[h].toString()
847
+ accountCap: l[h].toString()
818
848
  }));
819
849
  }
820
850
  )
821
851
  );
822
852
  function st(e) {
823
- return `${T(e.marketId).key}-${e.emodeId}`;
853
+ return `${j(e.marketId).key}-${e.emodeId}`;
824
854
  }
825
- function lt(e, r, o) {
855
+ function ut(e, r, o) {
826
856
  const n = typeof o?.balance == "number", t = n ? o.balance : 0;
827
857
  let a = 0;
828
858
  const s = [];
829
859
  let i = "";
830
- if (r.sort((c, u) => Number(u.balance) - Number(c.balance)).forEach((c) => {
860
+ if (r.sort((c, l) => Number(l.balance) - Number(c.balance)).forEach((c) => {
831
861
  if (!(n && a >= t) && Number(c.balance) !== 0) {
832
862
  if (i || (i = c.coinType), i !== c.coinType)
833
863
  throw new Error("All coins must be of the same type");
@@ -845,7 +875,7 @@ async function re(e, r, o, n, t, a, s) {
845
875
  const i = await _({
846
876
  ...s,
847
877
  cacheTime: b
848
- }), c = await S(o, s);
878
+ }), c = await P(o, s);
849
879
  return e.moveCall({
850
880
  target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
851
881
  arguments: [
@@ -868,74 +898,74 @@ async function Ve(e, r, o) {
868
898
  async function ne(e, r, o) {
869
899
  const n = new F(), t = o?.client ?? V, a = await q({
870
900
  ...o,
871
- markets: Object.values(U)
872
- }), s = z(a), c = Array.from(new Set(r.map((l) => l.market))).map((l) => T(l));
873
- for (const l of c) {
901
+ markets: Object.values(D)
902
+ }), s = z(a), c = Array.from(new Set(r.map((u) => u.market))).map((u) => j(u));
903
+ for (const u of c) {
874
904
  const f = await _({
875
905
  ...o,
876
906
  cacheTime: b,
877
- market: l.key
907
+ market: u.key
878
908
  });
879
909
  n.moveCall({
880
910
  target: `${f.uiGetter}::getter::get_reserve_data`,
881
911
  arguments: [n.object(f.storage)]
882
912
  });
883
913
  }
884
- for (let l of r) {
914
+ for (let u of r) {
885
915
  const f = await _({
886
916
  ...o,
887
917
  cacheTime: b,
888
- market: l.market
918
+ market: u.market
889
919
  });
890
920
  n.moveCall({
891
921
  target: `${f.uiGetter}::getter_unchecked::get_user_state`,
892
- arguments: [n.object(f.storage), n.pure.address(l.address)]
922
+ arguments: [n.object(f.storage), n.pure.address(u.address)]
893
923
  });
894
924
  }
895
925
  const m = (await t.devInspectTransactionBlock({
896
926
  transactionBlock: n,
897
927
  sender: e
898
928
  })).results || [], h = {};
899
- c.forEach((l, f) => {
929
+ c.forEach((u, f) => {
900
930
  try {
901
- const w = m[f]?.returnValues?.map((B) => C.vector(ve).parse(Uint8Array.from(B[0])))[0] || [], I = {};
931
+ const w = m[f]?.returnValues?.map((B) => C.vector(ve).parse(Uint8Array.from(B[0])))[0] || [], T = {};
902
932
  for (const B of w)
903
- I[B.id] = {
933
+ T[B.id] = {
904
934
  supplyIndex: B.supply_index,
905
935
  borrowIndex: B.borrow_index
906
936
  };
907
- h[l.key] = I;
937
+ h[u.key] = T;
908
938
  } catch (w) {
909
939
  console.warn(
910
- `[@naviprotocol/lending] Failed to decode reserve data for market "${l.key}", falling back to open-api pool indices`,
940
+ `[@naviprotocol/lending] Failed to decode reserve data for market "${u.key}", falling back to open-api pool indices`,
911
941
  w
912
942
  );
913
943
  }
914
944
  });
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))
945
+ const v = m.slice(c.length).map((u) => u.returnValues?.map((f) => C.vector(we).parse(Uint8Array.from(f[0])))[0] || []), y = [];
946
+ return v.forEach((u, f) => {
947
+ const w = r[f], T = j(w.market), B = h[T.key] || {};
948
+ u.forEach((I) => {
949
+ if (I.supply_balance === "0" && I.borrow_balance === "0" && (w.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
920
950
  return;
921
- const A = s[`${I.key}-${j.asset_id}`];
951
+ const A = s[`${T.key}-${I.asset_id}`];
922
952
  if (!A)
923
953
  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();
954
+ const L = B[I.asset_id], G = L?.supplyIndex ?? A.currentSupplyIndex, ce = L?.borrowIndex ?? A.currentBorrowIndex, se = Q(I.supply_balance, G).toString(), ue = Q(I.borrow_balance, ce).toString();
925
955
  y.push({
926
956
  supplyBalance: se,
927
- borrowBalance: le,
928
- assetId: j.asset_id,
929
- market: I.key,
957
+ borrowBalance: ue,
958
+ assetId: I.asset_id,
959
+ market: T.key,
930
960
  pool: A,
931
961
  emodeId: w.emodeId
932
962
  });
933
963
  });
934
964
  }), y;
935
965
  }
936
- const ut = M(
966
+ const lt = M(
937
967
  async (e, r) => {
938
- const n = (r?.markets || Object.keys(U)).map((t) => T(t)).map((t) => ({
968
+ const n = (r?.markets || Object.keys(D)).map((t) => j(t)).map((t) => ({
939
969
  address: e,
940
970
  market: t.key
941
971
  }));
@@ -954,19 +984,19 @@ async function pt(e, r) {
954
984
  async function dt(e, r, o, n) {
955
985
  const t = n?.client ?? V, a = new F();
956
986
  let s = 0, i = 0;
957
- const c = await S(r, n);
987
+ const c = await P(r, n);
958
988
  if (o.forEach((v) => {
959
989
  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
990
  }), s * i < 0)
961
991
  throw new Error("Invalid operations");
962
- const u = s > 0 || i > 0;
992
+ const l = s > 0 || i > 0;
963
993
  await re(
964
994
  a,
965
995
  e,
966
996
  c,
967
997
  Math.abs(s),
968
998
  Math.abs(i),
969
- u,
999
+ l,
970
1000
  n
971
1001
  );
972
1002
  const m = await t.devInspectTransactionBlock({
@@ -975,12 +1005,12 @@ async function dt(e, r, o, n) {
975
1005
  }), h = H(m, [C.u256()]);
976
1006
  return te(Number(h[0]) || 0);
977
1007
  }
978
- const mt = P(
1008
+ const mt = $(
979
1009
  async (e, r) => {
980
1010
  const o = new URLSearchParams();
981
1011
  r?.cursor && o.set("cursor", r.cursor), o.set("userAddress", e);
982
1012
  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;
1013
+ return (await fetch(n, { headers: U }).then((a) => a.json())).data;
984
1014
  }
985
1015
  );
986
1016
  async function ft(e, r) {
@@ -1005,7 +1035,7 @@ async function ft(e, r) {
1005
1035
  }
1006
1036
  const Ee = M(
1007
1037
  async (e, r) => {
1008
- const o = [], n = (r?.markets || Object.keys(U)).map((i) => T(i));
1038
+ const o = [], n = (r?.markets || Object.keys(D)).map((i) => j(i));
1009
1039
  let t = [];
1010
1040
  try {
1011
1041
  t = await oe(e, r);
@@ -1018,14 +1048,14 @@ const Ee = M(
1018
1048
  })).concat(
1019
1049
  t.filter((i) => !!n.find((c) => c.id === i.marketId)).map((i) => ({
1020
1050
  address: i.accountCap,
1021
- market: T(i.marketId).key,
1051
+ market: j(i.marketId).key,
1022
1052
  emodeId: i.emodeId
1023
1053
  }))
1024
1054
  );
1025
1055
  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;
1056
+ const c = typeof i.emodeId == "number" ? t.find((l) => {
1057
+ const m = j(i.market);
1058
+ return l.emodeId === i.emodeId && l.marketId === m.id;
1029
1059
  }) : void 0;
1030
1060
  if (c) {
1031
1061
  if (!i.pool.emodes.find((m) => m.emodeId === c.emodeId))
@@ -1035,7 +1065,7 @@ const Ee = M(
1035
1065
  if (m.gt(0) || h.emode.isCollateral)
1036
1066
  try {
1037
1067
  o.push({
1038
- id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${$()}`,
1068
+ id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${S()}`,
1039
1069
  wallet: e,
1040
1070
  protocol: "navi",
1041
1071
  market: i.market,
@@ -1057,7 +1087,7 @@ const Ee = M(
1057
1087
  if (m.gt(0) || h.emode.isDebt)
1058
1088
  try {
1059
1089
  o.push({
1060
- id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${$()}`,
1090
+ id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${S()}`,
1061
1091
  wallet: e,
1062
1092
  protocol: "navi",
1063
1093
  market: i.market,
@@ -1076,34 +1106,34 @@ const Ee = M(
1076
1106
  }
1077
1107
  } else {
1078
1108
  if (p(i.supplyBalance).gt(0)) {
1079
- const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1109
+ const l = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1080
1110
  o.push({
1081
- id: `${i.pool.uniqueId}_navi-lending-supply-${$()}`,
1111
+ id: `${i.pool.uniqueId}_navi-lending-supply-${S()}`,
1082
1112
  wallet: e,
1083
1113
  protocol: "navi",
1084
1114
  type: "navi-lending-supply",
1085
1115
  market: i.market,
1086
1116
  "navi-lending-supply": {
1087
- amount: u.toString(),
1117
+ amount: l.toString(),
1088
1118
  pool: i.pool,
1089
1119
  token: i.pool.token,
1090
- valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
1120
+ valueUSD: l.multipliedBy(i.pool.oracle.price).toString()
1091
1121
  }
1092
1122
  });
1093
1123
  }
1094
1124
  if (p(i.borrowBalance).gt(0)) {
1095
- const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1125
+ const l = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1096
1126
  o.push({
1097
- id: `${i.pool.uniqueId}_navi-lending-borrow-${$()}`,
1127
+ id: `${i.pool.uniqueId}_navi-lending-borrow-${S()}`,
1098
1128
  wallet: e,
1099
1129
  protocol: "navi",
1100
1130
  market: i.market,
1101
1131
  type: "navi-lending-borrow",
1102
1132
  "navi-lending-borrow": {
1103
- amount: u.toString(),
1133
+ amount: l.toString(),
1104
1134
  pool: i.pool,
1105
1135
  token: i.pool.token,
1106
- valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
1136
+ valueUSD: l.multipliedBy(i.pool.oracle.price).toString()
1107
1137
  }
1108
1138
  });
1109
1139
  }
@@ -1163,7 +1193,7 @@ class N {
1163
1193
  const n = !!r.isEMode, t = this.getPrice(r);
1164
1194
  let a;
1165
1195
  return n ? a = {
1166
- id: $(),
1196
+ id: S(),
1167
1197
  wallet: "",
1168
1198
  protocol: "navi",
1169
1199
  market: "",
@@ -1176,7 +1206,7 @@ class N {
1176
1206
  emodeCap: {}
1177
1207
  }
1178
1208
  } : a = {
1179
- id: $(),
1209
+ id: S(),
1180
1210
  wallet: "",
1181
1211
  protocol: "navi",
1182
1212
  market: "",
@@ -1193,7 +1223,7 @@ class N {
1193
1223
  const n = !!r.isEMode, t = this.getPrice(r);
1194
1224
  let a;
1195
1225
  return n ? a = {
1196
- id: $(),
1226
+ id: S(),
1197
1227
  wallet: "",
1198
1228
  protocol: "navi",
1199
1229
  market: "",
@@ -1206,7 +1236,7 @@ class N {
1206
1236
  emodeCap: {}
1207
1237
  }
1208
1238
  } : a = {
1209
- id: $(),
1239
+ id: S(),
1210
1240
  wallet: "",
1211
1241
  protocol: "navi",
1212
1242
  market: "",
@@ -1223,7 +1253,7 @@ class N {
1223
1253
  const n = !!r.isEMode, t = this.getPrice(r);
1224
1254
  let a;
1225
1255
  return n ? a = {
1226
- id: $(),
1256
+ id: S(),
1227
1257
  wallet: "",
1228
1258
  protocol: "navi",
1229
1259
  market: "",
@@ -1236,7 +1266,7 @@ class N {
1236
1266
  emodeCap: {}
1237
1267
  }
1238
1268
  } : a = {
1239
- id: $(),
1269
+ id: S(),
1240
1270
  wallet: "",
1241
1271
  protocol: "navi",
1242
1272
  market: "",
@@ -1253,7 +1283,7 @@ class N {
1253
1283
  const n = !!r.isEMode, t = this.getPrice(r);
1254
1284
  let a;
1255
1285
  return n ? a = {
1256
- id: $(),
1286
+ id: S(),
1257
1287
  wallet: "",
1258
1288
  protocol: "navi",
1259
1289
  market: "",
@@ -1266,7 +1296,7 @@ class N {
1266
1296
  emodeCap: {}
1267
1297
  }
1268
1298
  } : a = {
1269
- id: $(),
1299
+ id: S(),
1270
1300
  wallet: "",
1271
1301
  protocol: "navi",
1272
1302
  market: "",
@@ -1284,52 +1314,52 @@ class N {
1284
1314
  }
1285
1315
  getPositionsOverview(r) {
1286
1316
  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);
1317
+ let t = new p(0), a = new p(0), s = new p(0), i = new p(0), c = new p(0), l = new p(0);
1288
1318
  r.forEach((y) => {
1289
1319
  if (y.type === "navi-lending-supply") {
1290
- const l = y["navi-lending-supply"], f = this.resolveValueUSD(l);
1320
+ const u = y["navi-lending-supply"], f = this.resolveValueUSD(u);
1291
1321
  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)
1322
+ new p(f).multipliedBy(u.pool.liquidationFactor.threshold)
1323
+ ), l = l.plus(
1324
+ new p(f).multipliedBy(u.pool.ltvValue)
1295
1325
  );
1296
1326
  } else if (y.type === "navi-lending-borrow") {
1297
- const l = y["navi-lending-borrow"];
1298
- a = a.plus(this.resolveValueUSD(l));
1327
+ const u = y["navi-lending-borrow"];
1328
+ a = a.plus(this.resolveValueUSD(u));
1299
1329
  } else if (y.type === "navi-lending-emode-supply") {
1300
- const l = y["navi-lending-emode-supply"], f = this.resolveValueUSD(l);
1330
+ const u = y["navi-lending-emode-supply"], f = this.resolveValueUSD(u);
1301
1331
  t = t.plus(f);
1302
- const w = l.pool.emode;
1332
+ const w = u.pool.emode;
1303
1333
  c = c.plus(
1304
1334
  new p(f).multipliedBy(w.lt)
1305
- ), u = u.plus(
1335
+ ), l = l.plus(
1306
1336
  new p(f).multipliedBy(w.ltv)
1307
1337
  );
1308
1338
  } else if (y.type === "navi-lending-emode-borrow") {
1309
- const l = y["navi-lending-emode-borrow"];
1310
- a = a.plus(this.resolveValueUSD(l));
1339
+ const u = y["navi-lending-emode-borrow"];
1340
+ a = a.plus(this.resolveValueUSD(u));
1311
1341
  }
1312
- }), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0), u = p.max(u, 0), r.forEach((y) => {
1342
+ }), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0), l = p.max(l, 0), r.forEach((y) => {
1313
1343
  if (y.type === "navi-lending-supply") {
1314
- const l = y["navi-lending-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
1344
+ const u = y["navi-lending-supply"], f = this.resolveValueUSD(u), w = u.pool.supplyIncentiveApyInfo.apy;
1315
1345
  t.gt(0) && (s = s.plus(
1316
1346
  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();
1347
+ )), o[u.pool.suiCoinType] = p(o[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1318
1348
  } else if (y.type === "navi-lending-borrow") {
1319
- const l = y["navi-lending-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
1349
+ const u = y["navi-lending-borrow"], f = this.resolveValueUSD(u), w = u.pool.borrowIncentiveApyInfo.apy;
1320
1350
  a.gt(0) && (i = i.plus(
1321
1351
  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();
1352
+ )), n[u.pool.suiCoinType] = p(n[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1323
1353
  } 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;
1354
+ const u = y["navi-lending-emode-supply"], f = this.resolveValueUSD(u), w = u.pool.supplyIncentiveApyInfo.apy;
1325
1355
  t.gt(0) && (s = s.plus(
1326
1356
  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();
1357
+ )), o[u.pool.suiCoinType] = p(o[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1328
1358
  } 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;
1359
+ const u = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(u), w = u.pool.borrowIncentiveApyInfo.apy;
1330
1360
  a.gt(0) && (i = i.plus(
1331
1361
  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();
1362
+ )), n[u.pool.suiCoinType] = p(n[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1333
1363
  }
1334
1364
  });
1335
1365
  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));
@@ -1342,7 +1372,7 @@ class N {
1342
1372
  totalsupplyApy: s.toString(),
1343
1373
  totalBorrowApy: i.toString(),
1344
1374
  maxLiquidationValue: c.toString(),
1345
- maxLoanToVaule: u.toString(),
1375
+ maxLoanToVaule: l.toString(),
1346
1376
  supply: o,
1347
1377
  borrow: n
1348
1378
  };
@@ -1389,7 +1419,7 @@ async function gt(e) {
1389
1419
  throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
1390
1420
  }
1391
1421
  }
1392
- async function De(e, r) {
1422
+ async function Ue(e, r) {
1393
1423
  try {
1394
1424
  const o = [], n = r?.client ?? V, t = e.map((s) => s.priceInfoObject), a = await n.multiGetObjects({
1395
1425
  ids: Array.from(new Set(t)),
@@ -1401,12 +1431,12 @@ async function De(e, r) {
1401
1431
  console.warn(`fetched object ${i?.objectId} datatype should be moveObject`);
1402
1432
  continue;
1403
1433
  }
1404
- const c = e.find((l) => l.priceInfoObject == i.objectId);
1434
+ const c = e.find((u) => u.priceInfoObject == i.objectId);
1405
1435
  if (!c) {
1406
1436
  console.warn(`unable to find pyth info from array, priceInfoObject: ${i.objectId}`);
1407
1437
  continue;
1408
1438
  }
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;
1439
+ const l = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: m, negative: h } = l.price.fields, v = l.conf, y = l.timestamp;
1410
1440
  o.push({
1411
1441
  priceFeedId: c.priceFeedId,
1412
1442
  priceInfoObject: c.priceInfoObject,
@@ -1422,9 +1452,9 @@ async function De(e, r) {
1422
1452
  return;
1423
1453
  }
1424
1454
  }
1425
- async function Ue(e, r) {
1455
+ async function De(e, r) {
1426
1456
  try {
1427
- const o = [], n = await De(e, r);
1457
+ const o = [], n = await Ue(e, r);
1428
1458
  if (!n) return o;
1429
1459
  const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
1430
1460
  for (const a of n) {
@@ -1472,7 +1502,7 @@ async function Ne(e, r, o) {
1472
1502
  expiration: 30
1473
1503
  }));
1474
1504
  try {
1475
- const a = await Ue(t, o);
1505
+ const a = await De(t, o);
1476
1506
  a.length > 0 && await Oe(e, a, o);
1477
1507
  } catch {
1478
1508
  console.error("Failed to update Pyth price feeds");
@@ -1539,8 +1569,8 @@ async function ht(e, r, o, n) {
1539
1569
  const t = await ie({
1540
1570
  ...n
1541
1571
  }), a = [];
1542
- o.forEach((u) => {
1543
- a.includes(u.market) || a.push(u.market);
1572
+ o.forEach((l) => {
1573
+ a.includes(l.market) || a.push(l.market);
1544
1574
  });
1545
1575
  const s = await Ee(r, {
1546
1576
  ...n,
@@ -1560,12 +1590,12 @@ async function ht(e, r, o, n) {
1560
1590
  }
1561
1591
  }
1562
1592
  const Y = M(
1563
- P(
1593
+ $(
1564
1594
  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],
1568
- coinType: n
1595
+ const r = j(e?.market || O), o = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.key}`, n = await fetch(o, { headers: U }).then((t) => t.json());
1596
+ return Object.keys(n.data).map((t) => ({
1597
+ ...n.data[t],
1598
+ coinType: t
1569
1599
  }));
1570
1600
  }
1571
1601
  )
@@ -1577,7 +1607,7 @@ async function wt(e, r, o, n) {
1577
1607
  const t = await _({
1578
1608
  ...n,
1579
1609
  cacheTime: b
1580
- }), a = await S(r, n);
1610
+ }), a = await P(r, n);
1581
1611
  if (!(await Y({
1582
1612
  ...n,
1583
1613
  cacheTime: b
@@ -1586,7 +1616,7 @@ async function wt(e, r, o, n) {
1586
1616
  ))
1587
1617
  throw new Error("Pool does not support flashloan");
1588
1618
  if (t.version === 1) {
1589
- const [c, u] = e.moveCall({
1619
+ const [c, l] = e.moveCall({
1590
1620
  target: `${t.package}::lending::flash_loan_with_ctx`,
1591
1621
  arguments: [
1592
1622
  e.object(t.flashloanConfig),
@@ -1595,9 +1625,9 @@ async function wt(e, r, o, n) {
1595
1625
  ],
1596
1626
  typeArguments: [a.suiCoinType]
1597
1627
  });
1598
- return [c, u];
1628
+ return [c, l];
1599
1629
  } else {
1600
- const [c, u] = e.moveCall({
1630
+ const [c, l] = e.moveCall({
1601
1631
  target: `${t.package}::lending::flash_loan_with_ctx_v2`,
1602
1632
  arguments: [
1603
1633
  e.object(t.flashloanConfig),
@@ -1607,14 +1637,14 @@ async function wt(e, r, o, n) {
1607
1637
  ],
1608
1638
  typeArguments: [a.suiCoinType]
1609
1639
  });
1610
- return [c, u];
1640
+ return [c, l];
1611
1641
  }
1612
1642
  }
1613
1643
  async function bt(e, r, o, n, t) {
1614
1644
  const a = await _({
1615
1645
  ...t,
1616
1646
  cacheTime: b
1617
- }), s = await S(r, t);
1647
+ }), s = await P(r, t);
1618
1648
  if (!(await Y({
1619
1649
  ...t,
1620
1650
  cacheTime: b
@@ -1622,7 +1652,7 @@ async function bt(e, r, o, n, t) {
1622
1652
  (m) => k(m.coinType) === k(s.suiCoinType)
1623
1653
  ))
1624
1654
  throw new Error("Pool does not support flashloan");
1625
- const [u] = e.moveCall({
1655
+ const [l] = e.moveCall({
1626
1656
  target: `${a.package}::lending::flash_repay_with_ctx`,
1627
1657
  arguments: [
1628
1658
  e.object("0x06"),
@@ -1633,13 +1663,13 @@ async function bt(e, r, o, n, t) {
1633
1663
  ],
1634
1664
  typeArguments: [s.suiCoinType]
1635
1665
  });
1636
- return [u];
1666
+ return [l];
1637
1667
  }
1638
1668
  async function kt(e, r, o, n, t, a) {
1639
1669
  const s = {
1640
1670
  ...a,
1641
1671
  cacheTime: b
1642
- }, i = await _(s), c = await S(r, s), u = await S(n, s);
1672
+ }, i = await _(s), c = await P(r, s), l = await P(n, s);
1643
1673
  if (i.version === 1) {
1644
1674
  const [m, h] = e.moveCall({
1645
1675
  target: `${i.package}::incentive_v3::liquidation`,
@@ -1656,9 +1686,9 @@ async function kt(e, r, o, n, t, a) {
1656
1686
  // Pay asset pool contract
1657
1687
  g(o, e.object),
1658
1688
  // Debt repayment amount
1659
- e.pure.u8(u.id),
1689
+ e.pure.u8(l.id),
1660
1690
  // Collateral asset ID
1661
- e.object(u.contract.pool),
1691
+ e.object(l.contract.pool),
1662
1692
  // Collateral asset pool contract
1663
1693
  g(t, e.pure.address),
1664
1694
  // Borrower address
@@ -1667,7 +1697,7 @@ async function kt(e, r, o, n, t, a) {
1667
1697
  e.object(i.incentiveV3)
1668
1698
  // Incentive V3 contract
1669
1699
  ],
1670
- typeArguments: [c.suiCoinType, u.suiCoinType]
1700
+ typeArguments: [c.suiCoinType, l.suiCoinType]
1671
1701
  });
1672
1702
  return [m, h];
1673
1703
  } else {
@@ -1686,9 +1716,9 @@ async function kt(e, r, o, n, t, a) {
1686
1716
  // Pay asset pool contract
1687
1717
  g(o, e.object),
1688
1718
  // Debt repayment amount
1689
- e.pure.u8(u.id),
1719
+ e.pure.u8(l.id),
1690
1720
  // Collateral asset ID
1691
- e.object(u.contract.pool),
1721
+ e.object(l.contract.pool),
1692
1722
  // Collateral asset pool contract
1693
1723
  g(t, e.pure.address),
1694
1724
  // Borrower address
@@ -1699,7 +1729,7 @@ async function kt(e, r, o, n, t, a) {
1699
1729
  e.object("0x05")
1700
1730
  // SuiSystemState object
1701
1731
  ],
1702
- typeArguments: [c.suiCoinType, u.suiCoinType]
1732
+ typeArguments: [c.suiCoinType, l.suiCoinType]
1703
1733
  });
1704
1734
  return [m, h];
1705
1735
  }
@@ -1707,7 +1737,7 @@ async function kt(e, r, o, n, t, a) {
1707
1737
  async function Re(e, r, o) {
1708
1738
  const n = o?.client ?? V, t = new F(), a = await q({
1709
1739
  ...o,
1710
- markets: Object.values(U),
1740
+ markets: Object.values(D),
1711
1741
  cacheTime: b
1712
1742
  }), s = await ie(o);
1713
1743
  for (let m of r) {
@@ -1755,24 +1785,24 @@ async function Re(e, r, o) {
1755
1785
  )
1756
1786
  );
1757
1787
  });
1758
- const u = [];
1788
+ const l = [];
1759
1789
  return c.forEach((m, h) => {
1760
1790
  const v = r[h];
1761
1791
  if (m.length === 5 && Array.isArray(m[0])) {
1762
1792
  const y = m[0].length;
1763
- for (let l = 0; l < y; l++) {
1793
+ for (let u = 0; u < y; u++) {
1764
1794
  const f = s.find(
1765
- (I) => k(I.coinType) === k(m[1][l])
1795
+ (T) => k(T.coinType) === k(m[1][u])
1766
1796
  ), w = a.find(
1767
- (I) => k(I.coinType) === k(m[0][l]) && I.market === v.market
1797
+ (T) => k(T.coinType) === k(m[0][u]) && T.market === v.market
1768
1798
  );
1769
- !f || !w || u.push({
1799
+ !f || !w || l.push({
1770
1800
  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]],
1801
+ assetCoinType: k(m[0][u]),
1802
+ rewardCoinType: k(m[1][u]),
1803
+ option: Number(m[2][u]),
1804
+ userClaimableReward: Number(m[4][u]) / Math.pow(10, f.priceDecimal),
1805
+ ruleIds: Array.isArray(m[3][u]) ? m[3][u] : [m[3][u]],
1776
1806
  market: v.market,
1777
1807
  owner: v.owner,
1778
1808
  address: v.address,
@@ -1780,10 +1810,10 @@ async function Re(e, r, o) {
1780
1810
  });
1781
1811
  }
1782
1812
  }
1783
- }), u;
1813
+ }), l;
1784
1814
  }
1785
1815
  async function _t(e, r) {
1786
- const o = (r?.markets || [U.main]).map((a) => T(a));
1816
+ const o = (r?.markets || [D.main]).map((a) => j(a));
1787
1817
  let n = [];
1788
1818
  try {
1789
1819
  n = await oe(e, r);
@@ -1796,7 +1826,7 @@ async function _t(e, r) {
1796
1826
  market: a.key
1797
1827
  })).concat(
1798
1828
  n.filter((a) => !!o.find((s) => s.id === a.marketId)).map((a) => {
1799
- const s = T(a.marketId);
1829
+ const s = j(a.marketId);
1800
1830
  return {
1801
1831
  address: a.accountCap,
1802
1832
  owner: e,
@@ -1823,8 +1853,8 @@ function Ct(e) {
1823
1853
  for (const { assetId: n, rewardType: t, coinType: a, total: s, market: i } of r.values()) {
1824
1854
  const c = `${n}-${t}-${i}`;
1825
1855
  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);
1856
+ const l = o.get(c);
1857
+ l.rewards.set(a, (l.rewards.get(a) || 0) + s);
1828
1858
  }
1829
1859
  return Array.from(o.values()).map((n) => ({
1830
1860
  assetId: n.assetId,
@@ -1836,69 +1866,69 @@ function Ct(e) {
1836
1866
  }))
1837
1867
  }));
1838
1868
  }
1839
- const jt = P(
1869
+ const jt = $(
1840
1870
  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;
1871
+ const o = j(r?.market || O), n = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${E.version}&market=${o.key}`;
1872
+ return (await fetch(n, { headers: U }).then((a) => a.json())).data;
1843
1873
  }
1844
- ), It = P(
1874
+ ), It = $(
1845
1875
  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());
1876
+ const o = j(r?.market || O), n = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${r?.page || 1}&pageSize=${r?.size || 400}&sdk=${E.version}&market=${o.key}`, t = await fetch(n, { headers: U }).then((a) => a.json());
1847
1877
  return K({
1848
- data: n.data.rewards
1878
+ data: t.data.rewards
1849
1879
  });
1850
1880
  }
1851
1881
  );
1852
1882
  async function Tt(e, r, o) {
1853
1883
  const n = await q({
1854
1884
  ...o,
1855
- markets: Object.values(U),
1885
+ markets: Object.values(D),
1856
1886
  cacheTime: b
1857
1887
  }), t = /* @__PURE__ */ new Map();
1858
1888
  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) {
1889
+ const { rewardCoinType: i, ruleIds: c, market: l, owner: m, address: h, emodeId: v } = s, y = `${i}___${h}__${l}`;
1890
+ for (const u of c) {
1861
1891
  t.has(y) || t.set(y, {
1862
1892
  assetIds: [],
1863
1893
  ruleIds: [],
1864
1894
  amount: 0,
1865
- market: u,
1895
+ market: l,
1866
1896
  owner: m,
1867
1897
  address: h,
1868
1898
  isEMode: typeof v < "u"
1869
1899
  });
1870
1900
  const f = t.get(y);
1871
- f.assetIds.push(s.assetCoinType.replace("0x", "")), f.ruleIds.push(l), f.amount += s.userClaimableReward;
1901
+ f.assetIds.push(s.assetCoinType.replace("0x", "")), f.ruleIds.push(u), f.amount += s.userClaimableReward;
1872
1902
  }
1873
1903
  }
1874
1904
  const a = [];
1875
1905
  for (const [
1876
1906
  s,
1877
- { assetIds: i, ruleIds: c, amount: u, market: m, owner: h, address: v, isEMode: y }
1907
+ { assetIds: i, ruleIds: c, amount: l, market: m, owner: h, address: v, isEMode: y }
1878
1908
  ] of t) {
1879
- const l = await _({
1909
+ const u = await _({
1880
1910
  ...o,
1881
1911
  cacheTime: b,
1882
1912
  market: m
1883
1913
  }), f = s.split("___")[0], w = n.filter(
1884
- (j) => k(j.suiCoinType) === k(f)
1914
+ (I) => k(I.suiCoinType) === k(f)
1885
1915
  );
1886
- w.sort((j, A) => j.market === m ? -1 : 1);
1887
- const I = w[0], B = l.rewardFunds[k(f)];
1916
+ w.sort((I, A) => I.market === m ? -1 : 1);
1917
+ const T = w[0], B = u.rewardFunds[k(f)];
1888
1918
  if (!B)
1889
1919
  throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
1890
1920
  if (o?.accountCap && !o.customCoinReceive)
1891
1921
  throw new Error("customCoinReceive is required when accountCap is provided");
1892
1922
  if (o?.customCoinReceive) {
1893
- let j;
1894
- o.accountCap ? j = e.moveCall({
1895
- target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
1923
+ let I;
1924
+ o.accountCap ? I = e.moveCall({
1925
+ target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1896
1926
  arguments: [
1897
1927
  e.object("0x06"),
1898
1928
  // Clock object
1899
- e.object(l.incentiveV3),
1929
+ e.object(u.incentiveV3),
1900
1930
  // Incentive V3 contract
1901
- e.object(l.storage),
1931
+ e.object(u.storage),
1902
1932
  // Protocol storage
1903
1933
  e.object(B),
1904
1934
  // Reward fund
@@ -1910,14 +1940,14 @@ async function Tt(e, r, o) {
1910
1940
  // Account capability
1911
1941
  ],
1912
1942
  typeArguments: [f]
1913
- }) : y ? j = e.moveCall({
1914
- target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
1943
+ }) : y ? I = e.moveCall({
1944
+ target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1915
1945
  arguments: [
1916
1946
  e.object("0x06"),
1917
1947
  // Clock object
1918
- e.object(l.incentiveV3),
1948
+ e.object(u.incentiveV3),
1919
1949
  // Incentive V3 contract
1920
- e.object(l.storage),
1950
+ e.object(u.storage),
1921
1951
  // Protocol storage
1922
1952
  e.object(B),
1923
1953
  // Reward fund
@@ -1929,14 +1959,14 @@ async function Tt(e, r, o) {
1929
1959
  // Account capability
1930
1960
  ],
1931
1961
  typeArguments: [f]
1932
- }) : j = e.moveCall({
1933
- target: `${l.package}::incentive_v3::claim_reward`,
1962
+ }) : I = e.moveCall({
1963
+ target: `${u.package}::incentive_v3::claim_reward`,
1934
1964
  arguments: [
1935
1965
  e.object("0x06"),
1936
1966
  // Clock object
1937
- e.object(l.incentiveV3),
1967
+ e.object(u.incentiveV3),
1938
1968
  // Incentive V3 contract
1939
- e.object(l.storage),
1969
+ e.object(u.storage),
1940
1970
  // Protocol storage
1941
1971
  e.object(B),
1942
1972
  // Reward fund
@@ -1949,7 +1979,7 @@ async function Tt(e, r, o) {
1949
1979
  });
1950
1980
  const [A] = e.moveCall({
1951
1981
  target: "0x2::coin::from_balance",
1952
- arguments: [j],
1982
+ arguments: [I],
1953
1983
  typeArguments: [f]
1954
1984
  });
1955
1985
  if (o?.customCoinReceive.type === "transfer") {
@@ -1961,30 +1991,30 @@ async function Tt(e, r, o) {
1961
1991
  );
1962
1992
  }
1963
1993
  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(
1994
+ const L = p(T.totalSupplyAmount).shiftedBy(-9), G = p(T.supplyCapCeiling).shiftedBy(-27);
1995
+ L.plus(l).isGreaterThan(G) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
1966
1996
  [A],
1967
1997
  e.pure.address(o.customCoinReceive.depositNAVI.fallbackReceiveAddress)
1968
- ) : await Be(e, I, A, {
1998
+ ) : await Be(e, T, A, {
1969
1999
  ...o,
1970
- market: I.market
2000
+ market: T.market
1971
2001
  });
1972
2002
  } else
1973
2003
  a.push({
1974
2004
  coin: A,
1975
- identifier: I,
2005
+ identifier: T,
1976
2006
  owner: h,
1977
2007
  isEMode: y
1978
2008
  });
1979
2009
  } else if (o?.accountCap || y) {
1980
- const j = e.moveCall({
1981
- target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
2010
+ const I = e.moveCall({
2011
+ target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1982
2012
  arguments: [
1983
2013
  e.object("0x06"),
1984
2014
  // Clock object
1985
- e.object(l.incentiveV3),
2015
+ e.object(u.incentiveV3),
1986
2016
  // Incentive V3 contract
1987
- e.object(l.storage),
2017
+ e.object(u.storage),
1988
2018
  // Protocol storage
1989
2019
  e.object(B),
1990
2020
  // Reward fund
@@ -1998,7 +2028,7 @@ async function Tt(e, r, o) {
1998
2028
  typeArguments: [f]
1999
2029
  }), [A] = e.moveCall({
2000
2030
  target: "0x2::coin::from_balance",
2001
- arguments: [j],
2031
+ arguments: [I],
2002
2032
  typeArguments: [f]
2003
2033
  });
2004
2034
  e.transferObjects(
@@ -2007,13 +2037,13 @@ async function Tt(e, r, o) {
2007
2037
  );
2008
2038
  } else
2009
2039
  e.moveCall({
2010
- target: `${l.package}::incentive_v3::claim_reward_entry`,
2040
+ target: `${u.package}::incentive_v3::claim_reward_entry`,
2011
2041
  arguments: [
2012
2042
  e.object("0x06"),
2013
2043
  // Clock object
2014
- e.object(l.incentiveV3),
2044
+ e.object(u.incentiveV3),
2015
2045
  // Incentive V3 contract
2016
- e.object(l.storage),
2046
+ e.object(u.storage),
2017
2047
  // Protocol storage
2018
2048
  e.object(B),
2019
2049
  // Reward fund
@@ -2035,7 +2065,7 @@ export {
2035
2065
  Je as IncentiveAPYInfo,
2036
2066
  he as IncentivePoolInfo,
2037
2067
  Ze as IncentivePoolInfoByPhase,
2038
- U as MARKETS,
2068
+ D as MARKETS,
2039
2069
  Ae as Market,
2040
2070
  Qe as OracleInfo,
2041
2071
  R as PoolOperator,
@@ -2044,7 +2074,7 @@ export {
2044
2074
  we as UserStateInfo,
2045
2075
  ot as borrowCoinPTB,
2046
2076
  Tt as claimLendingRewardsPTB,
2047
- Pe as createAccountCapPTB,
2077
+ $e as createAccountCapPTB,
2048
2078
  ct as createEModeCapPTB,
2049
2079
  Be as depositCoinPTB,
2050
2080
  st as emodeIdentityId,
@@ -2052,7 +2082,7 @@ export {
2052
2082
  it as exitEModePTB,
2053
2083
  Fe as filterPriceFeeds,
2054
2084
  wt as flashloanPTB,
2055
- Se as getAccountCapOwnerPTB,
2085
+ Pe as getAccountCapOwnerPTB,
2056
2086
  Y as getAllFlashLoanAssets,
2057
2087
  nt as getBorrowFee,
2058
2088
  ft as getCoins,
@@ -2062,15 +2092,15 @@ export {
2062
2092
  pt as getHealthFactor,
2063
2093
  Ve as getHealthFactorPTB,
2064
2094
  Ee as getLendingPositions,
2065
- ut as getLendingState,
2095
+ lt as getLendingState,
2066
2096
  at as getMarket,
2067
- T as getMarketConfig,
2068
- $e as getMarkets,
2069
- S as getPool,
2097
+ j as getMarketConfig,
2098
+ Se as getMarkets,
2099
+ P as getPool,
2070
2100
  q as getPools,
2071
2101
  ie as getPriceFeeds,
2072
2102
  gt as getPythStalePriceFeedId,
2073
- Ue as getPythStalePriceFeedIdV2,
2103
+ De as getPythStalePriceFeedIdV2,
2074
2104
  dt as getSimulatedHealthFactor,
2075
2105
  re as getSimulatedHealthFactorPTB,
2076
2106
  xe as getStats,
@@ -2080,7 +2110,7 @@ export {
2080
2110
  oe as getUserEModeCaps,
2081
2111
  jt as getUserTotalClaimedReward,
2082
2112
  kt as liquidatePTB,
2083
- lt as mergeCoinsPTB,
2113
+ ut as mergeCoinsPTB,
2084
2114
  k as normalizeCoinType,
2085
2115
  Te as parsePoolUID,
2086
2116
  g as parseTxValue,
@@ -2092,7 +2122,7 @@ export {
2092
2122
  Oe as updatePythPriceFeeds,
2093
2123
  yt as verifyHealthFactorPTB,
2094
2124
  M as withCache,
2095
- P as withSingleton,
2125
+ $ as withSingleton,
2096
2126
  tt as withdrawCoinPTB
2097
2127
  };
2098
2128
  //# sourceMappingURL=index.esm.js.map