@naviprotocol/lending 1.4.0 → 1.4.1-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
@@ -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.0", V = {
132
+ }), ye = "1.4.1-beta.1", V = {
133
133
  version: ye
134
134
  }, ge = V.version, he = () => {
135
135
  if (typeof process < "u" && process.versions && process.versions.node)
@@ -151,8 +151,8 @@ function Q(e) {
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: s, cacheTime: i, ...c } = o;
155
- n.push(c);
154
+ const { client: a, disableCache: c, cacheTime: i, ...s } = o;
155
+ n.push(s);
156
156
  } else
157
157
  n.push(o);
158
158
  }), JSON.stringify(n);
@@ -170,10 +170,10 @@ 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((s) => (n[t] = {
174
- data: s,
173
+ return !r?.disableCache && typeof a?.data < "u" && (typeof r?.cacheTime > "u" || r.cacheTime > Date.now() - a.cacheAt) ? a.data : e(...o).then((c) => (n[t] = {
174
+ data: c,
175
175
  cacheAt: Date.now()
176
- }, s));
176
+ }, c));
177
177
  };
178
178
  }
179
179
  function W(e) {
@@ -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 w(e) {
203
203
  return pe(e);
204
204
  }
205
205
  function X(e) {
@@ -249,7 +249,7 @@ 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 || {});
@@ -260,16 +260,16 @@ const R = $(
260
260
  (t) => t.key
261
261
  )}`, r = await fetch(o, { headers: E }).then((t) => t.json());
262
262
  return r.data.forEach((t) => {
263
- const s = r.meta.emodes.filter((h) => {
263
+ const c = r.meta.emodes.filter((h) => {
264
264
  const j = _(h.marketId);
265
265
  return t.market === j.key && h.isActive;
266
266
  }).filter((h) => !!h.assets.find((j) => j.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(), f = p(t.supplyCapCeiling).shiftedBy(-27).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), v = p.max(
267
+ t.emodes = c;
268
+ const i = 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(), u = p(i).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(
269
269
  p(t.borrowedAmount),
270
270
  p(t.validBorrowAmount)
271
271
  ).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), y = p(f).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 = f, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = y, t.poolBorrowCapValue = l;
272
+ t.poolSupplyAmount = i, t.poolBorrowAmount = s, t.poolSupplyValue = u, t.poolBorrowValue = d, t.poolSupplyCapAmount = f, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = y, 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" ? w(a.suiCoinType) === w(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;
@@ -308,12 +308,12 @@ const Je = $(
308
308
  async function Ce(e, n, o, r) {
309
309
  const t = await k({
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 s = typeof o == "object" && o.$kind === "GasCoin";
316
- if (b(a.suiCoinType) === b("0x2::sui::SUI") && s) {
315
+ const c = typeof o == "object" && o.$kind === "GasCoin";
316
+ if (w(a.suiCoinType) === w("0x2::sui::SUI") && c) {
317
317
  if (!r?.amount)
318
318
  throw new Error("Amount is required for sui coin");
319
319
  o = e.splitCoins(o, [r.amount]);
@@ -357,8 +357,8 @@ async function Ce(e, n, o, r) {
357
357
  async function Qe(e, n, o, r) {
358
358
  const t = await k({
359
359
  ...r,
360
- cacheTime: w
361
- }), a = await A(n, r), s = g(o, e.pure.u64);
360
+ cacheTime: b
361
+ }), a = await A(n, r), c = g(o, e.pure.u64);
362
362
  let i;
363
363
  if (t.version === 1)
364
364
  if (r?.accountCap) {
@@ -370,7 +370,7 @@ 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
- s,
373
+ c,
374
374
  e.object(t.incentiveV2),
375
375
  e.object(t.incentiveV3),
376
376
  g(r.accountCap, e.object)
@@ -387,7 +387,7 @@ 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
- s,
390
+ c,
391
391
  e.object(t.incentiveV2),
392
392
  e.object(t.incentiveV3)
393
393
  ],
@@ -404,7 +404,7 @@ 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
- s,
407
+ c,
408
408
  e.object(t.incentiveV2),
409
409
  e.object(t.incentiveV3),
410
410
  g(r.accountCap, e.object),
@@ -422,7 +422,7 @@ 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
- s,
425
+ c,
426
426
  e.object(t.incentiveV2),
427
427
  e.object(t.incentiveV3),
428
428
  e.object("0x05")
@@ -440,11 +440,11 @@ async function Qe(e, n, o, r) {
440
440
  async function Xe(e, n, o, r) {
441
441
  const t = await k({
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 s = g(o, e.pure.u64);
447
+ const c = g(o, e.pure.u64);
448
448
  let i;
449
449
  if (t.version === 1)
450
450
  if (r?.accountCap) {
@@ -456,7 +456,7 @@ 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
- s,
459
+ c,
460
460
  e.object(t.incentiveV2),
461
461
  e.object(t.incentiveV3),
462
462
  g(r.accountCap, e.object)
@@ -473,7 +473,7 @@ 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
- s,
476
+ c,
477
477
  e.object(t.incentiveV2),
478
478
  e.object(t.incentiveV3)
479
479
  ],
@@ -490,7 +490,7 @@ 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
- s,
493
+ c,
494
494
  e.object(t.incentiveV2),
495
495
  e.object(t.incentiveV3),
496
496
  g(r.accountCap, e.object),
@@ -508,7 +508,7 @@ 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
- s,
511
+ c,
512
512
  e.object(t.incentiveV2),
513
513
  e.object(t.incentiveV3),
514
514
  e.object("0x05")
@@ -526,9 +526,9 @@ async function Xe(e, n, o, r) {
526
526
  async function xe(e, n, o, r) {
527
527
  const t = await k({
528
528
  ...r,
529
- cacheTime: w
530
- }), a = await A(n, r), s = typeof o == "object" && o.$kind === "GasCoin";
531
- if (b(a.suiCoinType) === b("0x2::sui::SUI") && s) {
529
+ cacheTime: b
530
+ }), a = await A(n, r), c = typeof o == "object" && o.$kind === "GasCoin";
531
+ if (w(a.suiCoinType) === w("0x2::sui::SUI") && c) {
532
532
  if (!r?.amount)
533
533
  throw new Error("Amount is required for sui coin");
534
534
  o = e.splitCoins(o, [r.amount]);
@@ -539,7 +539,7 @@ async function xe(e, n, o, r) {
539
539
  arguments: [g(o, e.object)],
540
540
  typeArguments: [a.suiCoinType]
541
541
  }), r?.accountCap) {
542
- const [c] = e.moveCall({
542
+ const [s] = e.moveCall({
543
543
  target: `${t.package}::incentive_v3::repay_with_account_cap`,
544
544
  arguments: [
545
545
  e.object("0x06"),
@@ -556,7 +556,7 @@ async function xe(e, n, o, r) {
556
556
  });
557
557
  return e.moveCall({
558
558
  target: "0x2::coin::from_balance",
559
- arguments: [c],
559
+ arguments: [s],
560
560
  typeArguments: [a.suiCoinType]
561
561
  });
562
562
  } else
@@ -584,22 +584,22 @@ const et = $(
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, s = new U();
588
- s.moveCall({
587
+ const t = await A(e.asset, e), a = e?.client ?? P, c = new U();
588
+ c.moveCall({
589
589
  target: `${n.package}::incentive_v3::get_borrow_fee_v2`,
590
590
  arguments: [
591
- s.object(n.incentiveV3),
592
- s.pure.address(e.address),
593
- s.pure.u8(t.id),
594
- s.pure.u64(1e4)
591
+ c.object(n.incentiveV3),
592
+ c.pure.address(e.address),
593
+ c.pure.u8(t.id),
594
+ c.pure.u64(1e4)
595
595
  ],
596
596
  typeArguments: []
597
597
  });
598
598
  const i = await a.devInspectTransactionBlock({
599
- transactionBlock: s,
599
+ transactionBlock: c,
600
600
  sender: e.address
601
- }), c = L(i, [C.u64()]);
602
- return (Number(c[0]) || 0) / 100;
601
+ }), s = L(i, [C.u64()]);
602
+ return (Number(s[0]) || 0) / 100;
603
603
  } catch (t) {
604
604
  console.error(t);
605
605
  }
@@ -615,6 +615,11 @@ const et = $(
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"
618
623
  }
619
624
  };
620
625
  class je {
@@ -629,42 +634,42 @@ class je {
629
634
  }
630
635
  initPools(n) {
631
636
  const o = H(this.pools), r = J(this.emodes), t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
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);
637
+ let c = p(0), i = p(0);
638
+ n.forEach((s) => {
639
+ if (!this.checkMarket(s.market)) {
640
+ console.warn(`Pool is not in market ${this.config.name}`, s);
636
641
  return;
637
642
  }
638
- o[c.uniqueId] || this.pools.push(c), c?.emodes?.forEach((d) => {
643
+ o[s.uniqueId] || this.pools.push(s), s?.emodes?.forEach((d) => {
639
644
  r[d.uniqueId] || this.emodes.push(d), d.assets.forEach((f) => {
640
645
  f.isDebt && d.assets.find(
641
- (y) => y.isCollateral && y.ltv > 0 && y.assetId !== c.id
642
- ) && t.add(c.uniqueId), f.isCollateral && d.assets.find((y) => y.isDebt && y.assetId !== c.id) && a.add(c.uniqueId);
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);
643
648
  });
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);
649
+ }), i = i.plus(s.poolBorrowValue), c = c.plus(s.poolSupplyValue);
650
+ }), this.poolMap = H(this.pools, "id"), this.emodeMap = J(this.emodes, "emodeId"), this.emodes.forEach((s) => {
651
+ const u = this.getEModePools(s.emodeId);
647
652
  this.emodePools.push(...u);
648
653
  }), this._overview = {
649
- marketTotalSupplyValue: s.toString(),
654
+ marketTotalSupplyValue: c.toString(),
650
655
  marketTotalBorrowValue: i.toString()
651
- }, this.emodeBorrowablePools = this.pools.filter((c) => t.has(c.uniqueId)), this.emodeSupplyablePools = this.pools.filter((c) => a.has(c.uniqueId));
656
+ }, this.emodeBorrowablePools = this.pools.filter((s) => t.has(s.uniqueId)), this.emodeSupplyablePools = this.pools.filter((s) => a.has(s.uniqueId));
652
657
  }
653
658
  getEMode(n) {
654
659
  return this.emodeMap[n] || null;
655
660
  }
656
661
  getEModeRelatePools(n, o) {
657
- const { collateral: r, debt: t, emodeId: a } = o || {}, s = [];
662
+ const { collateral: r, debt: t, emodeId: a } = o || {}, c = [];
658
663
  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]);
664
+ typeof a == "number" && a !== i.emodeId || i.assets.forEach((s) => {
665
+ typeof r == "boolean" && r && s.isCollateral && s.assetId === n.id && c.push(this.poolMap[s.assetId]), typeof t == "boolean" && t && s.isDebt && s.assetId === n.id && c.push(this.poolMap[s.assetId]);
661
666
  });
662
- }), s;
667
+ }), c;
663
668
  }
664
669
  getEModePools(n) {
665
670
  const o = this.getEMode(n);
666
671
  return o ? o.assets.map((t) => t.assetId).map((t) => this.poolMap[t]).filter((t) => !!t).map((t) => {
667
- const a = o.assets.find((s) => s.assetId === t.id);
672
+ const a = o.assets.find((c) => c.assetId === t.id);
668
673
  return {
669
674
  ...t,
670
675
  emode: {
@@ -694,7 +699,7 @@ const _ = (e) => {
694
699
  markets: e
695
700
  });
696
701
  return e.map((r) => {
697
- const t = _(r), a = o.filter((s) => s.market === t.key);
702
+ const t = _(r), a = o.filter((c) => c.market === t.key);
698
703
  return new je(r, a);
699
704
  });
700
705
  }
@@ -710,10 +715,10 @@ const _ = (e) => {
710
715
  return (await fetch(o, { headers: E }).then((t) => t.json())).data;
711
716
  }
712
717
  )
713
- ), w = 1e3 * 60 * 5;
714
- async function Ie(e, n) {
718
+ ), b = 1e3 * 60 * 5;
719
+ async function Te(e, n) {
715
720
  const o = await k({
716
- cacheTime: w,
721
+ cacheTime: b,
717
722
  ...n
718
723
  });
719
724
  return e.moveCall({
@@ -721,9 +726,9 @@ async function Ie(e, n) {
721
726
  arguments: []
722
727
  });
723
728
  }
724
- async function Te(e, n, o) {
729
+ async function Ie(e, n, o) {
725
730
  const r = await k({
726
- cacheTime: w,
731
+ cacheTime: b,
727
732
  ...o
728
733
  });
729
734
  return e.moveCall({
@@ -734,7 +739,7 @@ async function Te(e, n, o) {
734
739
  async function Be(e, n, o) {
735
740
  const r = await k({
736
741
  ...o,
737
- cacheTime: w
742
+ cacheTime: b
738
743
  });
739
744
  return o?.accountCap ? e.moveCall({
740
745
  target: `${r.package}::lending::enter_emode_with_account_cap`,
@@ -751,7 +756,7 @@ async function Be(e, n, o) {
751
756
  async function ot(e, n) {
752
757
  const o = await k({
753
758
  ...n,
754
- cacheTime: w
759
+ cacheTime: b
755
760
  });
756
761
  return n?.accountCap ? e.moveCall({
757
762
  target: `${o.package}::lending::exit_emode_with_account_cap`,
@@ -763,19 +768,19 @@ async function ot(e, n) {
763
768
  }
764
769
  async function nt(e, n, o) {
765
770
  const r = await k({
766
- cacheTime: w,
771
+ cacheTime: b,
767
772
  ...o
768
- }), t = await Ie(e, o);
773
+ }), t = await Te(e, o);
769
774
  await Be(e, n, {
770
775
  ...o,
771
776
  accountCap: t
772
777
  });
773
- const a = await _(o?.market || N), s = await Te(e, t, o);
778
+ const a = await _(o?.market || N), c = await Ie(e, t, o);
774
779
  return e.moveCall({
775
780
  target: `${r.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
776
781
  arguments: [
777
782
  e.object(r.emode.contract.registryObject),
778
- s,
783
+ c,
779
784
  g(a.id, e.pure.u64),
780
785
  g(n, e.pure.u64)
781
786
  ]
@@ -785,20 +790,20 @@ const x = $(
785
790
  B(
786
791
  async (e, n) => {
787
792
  const o = await k({
788
- cacheTime: w,
793
+ cacheTime: b,
789
794
  ...n
790
795
  }), r = new U(), t = n?.client ?? P;
791
796
  r.moveCall({
792
797
  target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
793
798
  arguments: [r.object(o.emode.contract.registryObject), r.pure.address(e)]
794
799
  });
795
- const s = (await t.devInspectTransactionBlock({
800
+ const c = (await t.devInspectTransactionBlock({
796
801
  transactionBlock: r,
797
802
  sender: e
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]));
803
+ })).results[0].returnValues, i = C.vector(C.u64()).parse(Uint8Array.from(c[0][0])), s = C.vector(C.u64()).parse(Uint8Array.from(c[1][0])), u = C.vector(C.Address).parse(Uint8Array.from(c[2][0]));
799
804
  return i.map((d, f) => ({
800
805
  marketId: Number(d),
801
- emodeId: Number(c[f]),
806
+ emodeId: Number(s[f]),
802
807
  accountCap: u[f].toString()
803
808
  }));
804
809
  }
@@ -810,41 +815,41 @@ function rt(e) {
810
815
  function at(e, n, o) {
811
816
  const r = typeof o?.balance == "number", t = r ? o.balance : 0;
812
817
  let a = 0;
813
- const s = [];
818
+ const c = [];
814
819
  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)
820
+ if (n.sort((s, u) => Number(u.balance) - Number(s.balance)).forEach((s) => {
821
+ if (!(r && a >= t) && Number(s.balance) !== 0) {
822
+ if (i || (i = s.coinType), i !== s.coinType)
818
823
  throw new Error("All coins must be of the same type");
819
- a += Number(c.balance), s.push(c.coinObjectId);
824
+ a += Number(s.balance), c.push(s.coinObjectId);
820
825
  }
821
- }), s.length === 0)
826
+ }), c.length === 0)
822
827
  throw new Error("No coins to merge");
823
828
  if (r && a < t)
824
829
  throw new Error(
825
830
  `Balance is less than the specified balance: ${a} < ${t}`
826
831
  );
827
- return b(i) === b("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]);
832
+ return w(i) === w("0x2::sui::SUI") && o?.useGasCoin ? r ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (c.length === 1 ? e.object(c[0]) : e.mergeCoins(c[0], c.slice(1)), r ? e.splitCoins(c[0], [e.pure.u64(t)]) : c[0]);
828
833
  }
829
- async function ee(e, n, o, r, t, a, s) {
834
+ async function ee(e, n, o, r, t, a, c) {
830
835
  const i = await k({
831
- ...s,
832
- cacheTime: w
833
- }), c = await A(o, s);
836
+ ...c,
837
+ cacheTime: b
838
+ }), s = await A(o, c);
834
839
  return e.moveCall({
835
840
  target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
836
841
  arguments: [
837
842
  e.object("0x06"),
838
843
  e.object(i.storage),
839
844
  e.object(i.oracle.priceOracle),
840
- we(e, c),
845
+ we(e, s),
841
846
  g(n, e.pure.address),
842
- g(c.id, e.pure.u8),
847
+ g(s.id, e.pure.u8),
843
848
  g(r, e.pure.u64),
844
849
  g(t, e.pure.u64),
845
850
  g(a, e.pure.bool)
846
851
  ],
847
- typeArguments: [c.suiCoinType]
852
+ typeArguments: [s.suiCoinType]
848
853
  });
849
854
  }
850
855
  async function Ae(e, n, o) {
@@ -854,11 +859,11 @@ async function te(e, n, o) {
854
859
  const r = new U(), t = o?.client ?? P, a = await R({
855
860
  ...o,
856
861
  markets: Object.values(M)
857
- }), s = H(a);
862
+ }), c = H(a);
858
863
  for (let d of n) {
859
864
  const f = await k({
860
865
  ...o,
861
- cacheTime: w,
866
+ cacheTime: b,
862
867
  market: d.market
863
868
  });
864
869
  r.moveCall({
@@ -866,28 +871,28 @@ async function te(e, n, o) {
866
871
  arguments: [r.object(f.storage), r.pure.address(d.address)]
867
872
  });
868
873
  }
869
- const c = ((await t.devInspectTransactionBlock({
874
+ const s = ((await t.devInspectTransactionBlock({
870
875
  transactionBlock: r,
871
876
  sender: e
872
877
  })).results || []).map((d) => d.returnValues?.map((f) => C.vector(fe).parse(Uint8Array.from(f[0])))[0] || []), u = [];
873
- return c.forEach((d, f) => {
878
+ return s.forEach((d, f) => {
874
879
  const v = n[f], y = _(v.market);
875
880
  d.forEach((l) => {
876
881
  if (l.supply_balance === "0" && l.borrow_balance === "0" && (v.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
877
882
  return;
878
- const h = s[`${y.key}-${l.asset_id}`];
883
+ const h = c[`${y.key}-${l.asset_id}`];
879
884
  if (!h)
880
885
  return;
881
886
  const j = Y(
882
887
  l.supply_balance,
883
888
  h.currentSupplyIndex
884
- ).toString(), I = Y(
889
+ ).toString(), T = Y(
885
890
  l.borrow_balance,
886
891
  h.currentBorrowIndex
887
892
  ).toString();
888
893
  u.push({
889
894
  supplyBalance: j,
890
- borrowBalance: I,
895
+ borrowBalance: T,
891
896
  assetId: l.asset_id,
892
897
  market: y.key,
893
898
  pool: h,
@@ -916,18 +921,18 @@ async function ct(e, n) {
916
921
  }
917
922
  async function st(e, n, o, r) {
918
923
  const t = r?.client ?? P, a = new U();
919
- let s = 0, i = 0;
920
- const c = await A(n, r);
924
+ let c = 0, i = 0;
925
+ const s = await A(n, r);
921
926
  if (o.forEach((v) => {
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)
927
+ v.type === F.Supply ? c += v.amount : v.type === F.Withdraw ? c -= v.amount : v.type === F.Borrow ? i += v.amount : v.type === F.Repay && (i -= v.amount);
928
+ }), c * i < 0)
924
929
  throw new Error("Invalid operations");
925
- const u = s > 0 || i > 0;
930
+ const u = c > 0 || i > 0;
926
931
  await ee(
927
932
  a,
928
933
  e,
929
- c,
930
- Math.abs(s),
934
+ s,
935
+ Math.abs(c),
931
936
  Math.abs(i),
932
937
  u,
933
938
  r
@@ -979,36 +984,36 @@ const $e = $(
979
984
  address: e,
980
985
  market: i.key
981
986
  })).concat(
982
- t.filter((i) => !!r.find((c) => c.id === i.marketId)).map((i) => ({
987
+ t.filter((i) => !!r.find((s) => s.id === i.marketId)).map((i) => ({
983
988
  address: i.accountCap,
984
989
  market: _(i.marketId).key,
985
990
  emodeId: i.emodeId
986
991
  }))
987
992
  );
988
993
  return (await te(e, a, n)).forEach((i) => {
989
- const c = typeof i.emodeId == "number" ? t.find((u) => {
994
+ const s = typeof i.emodeId == "number" ? t.find((u) => {
990
995
  const d = _(i.market);
991
996
  return u.emodeId === i.emodeId && u.marketId === d.id;
992
997
  }) : void 0;
993
- if (c) {
994
- if (!i.pool.emodes.find((d) => d.emodeId === c.emodeId))
998
+ if (s) {
999
+ if (!i.pool.emodes.find((d) => d.emodeId === s.emodeId))
995
1000
  return;
996
1001
  if (p(i.supplyBalance).gte(0)) {
997
- const d = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), f = q(i.pool, c);
1002
+ const d = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), f = q(i.pool, s);
998
1003
  if (d.gt(0) || f.emode.isCollateral)
999
1004
  try {
1000
1005
  o.push({
1001
- id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${T()}`,
1006
+ id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${I()}`,
1002
1007
  wallet: e,
1003
1008
  protocol: "navi",
1004
1009
  market: i.market,
1005
1010
  type: "navi-lending-emode-supply",
1006
1011
  "navi-lending-emode-supply": {
1007
1012
  amount: d.toString(),
1008
- pool: q(i.pool, c),
1013
+ pool: q(i.pool, s),
1009
1014
  token: i.pool.token,
1010
1015
  valueUSD: d.multipliedBy(i.pool.oracle.price).toString(),
1011
- emodeCap: c
1016
+ emodeCap: s
1012
1017
  }
1013
1018
  });
1014
1019
  } catch (v) {
@@ -1016,21 +1021,21 @@ const $e = $(
1016
1021
  }
1017
1022
  }
1018
1023
  if (p(i.borrowBalance).gte(0)) {
1019
- const d = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), f = q(i.pool, c);
1024
+ const d = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), f = q(i.pool, s);
1020
1025
  if (d.gt(0) || f.emode.isDebt)
1021
1026
  try {
1022
1027
  o.push({
1023
- id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${T()}`,
1028
+ id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${I()}`,
1024
1029
  wallet: e,
1025
1030
  protocol: "navi",
1026
1031
  market: i.market,
1027
1032
  type: "navi-lending-emode-borrow",
1028
1033
  "navi-lending-emode-borrow": {
1029
1034
  amount: d.toString(),
1030
- pool: q(i.pool, c),
1035
+ pool: q(i.pool, s),
1031
1036
  token: i.pool.token,
1032
1037
  valueUSD: d.multipliedBy(i.pool.oracle.price).toString(),
1033
- emodeCap: c
1038
+ emodeCap: s
1034
1039
  }
1035
1040
  });
1036
1041
  } catch (v) {
@@ -1041,7 +1046,7 @@ const $e = $(
1041
1046
  if (p(i.supplyBalance).gt(0)) {
1042
1047
  const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1043
1048
  o.push({
1044
- id: `${i.pool.uniqueId}_navi-lending-supply-${T()}`,
1049
+ id: `${i.pool.uniqueId}_navi-lending-supply-${I()}`,
1045
1050
  wallet: e,
1046
1051
  protocol: "navi",
1047
1052
  type: "navi-lending-supply",
@@ -1057,7 +1062,7 @@ const $e = $(
1057
1062
  if (p(i.borrowBalance).gt(0)) {
1058
1063
  const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1059
1064
  o.push({
1060
- id: `${i.pool.uniqueId}_navi-lending-borrow-${T()}`,
1065
+ id: `${i.pool.uniqueId}_navi-lending-borrow-${I()}`,
1061
1066
  wallet: e,
1062
1067
  protocol: "navi",
1063
1068
  market: i.market,
@@ -1112,7 +1117,7 @@ class O {
1112
1117
  const r = !!n.isEMode;
1113
1118
  let t;
1114
1119
  return r ? t = {
1115
- id: T(),
1120
+ id: I(),
1116
1121
  wallet: "",
1117
1122
  protocol: "navi",
1118
1123
  market: "",
@@ -1125,7 +1130,7 @@ class O {
1125
1130
  emodeCap: {}
1126
1131
  }
1127
1132
  } : t = {
1128
- id: T(),
1133
+ id: I(),
1129
1134
  wallet: "",
1130
1135
  protocol: "navi",
1131
1136
  market: "",
@@ -1142,7 +1147,7 @@ class O {
1142
1147
  const r = !!n.isEMode;
1143
1148
  let t;
1144
1149
  return r ? t = {
1145
- id: T(),
1150
+ id: I(),
1146
1151
  wallet: "",
1147
1152
  protocol: "navi",
1148
1153
  market: "",
@@ -1155,7 +1160,7 @@ class O {
1155
1160
  emodeCap: {}
1156
1161
  }
1157
1162
  } : t = {
1158
- id: T(),
1163
+ id: I(),
1159
1164
  wallet: "",
1160
1165
  protocol: "navi",
1161
1166
  market: "",
@@ -1172,7 +1177,7 @@ class O {
1172
1177
  const r = !!n.isEMode;
1173
1178
  let t;
1174
1179
  return r ? t = {
1175
- id: T(),
1180
+ id: I(),
1176
1181
  wallet: "",
1177
1182
  protocol: "navi",
1178
1183
  market: "",
@@ -1185,7 +1190,7 @@ class O {
1185
1190
  emodeCap: {}
1186
1191
  }
1187
1192
  } : t = {
1188
- id: T(),
1193
+ id: I(),
1189
1194
  wallet: "",
1190
1195
  protocol: "navi",
1191
1196
  market: "",
@@ -1202,7 +1207,7 @@ class O {
1202
1207
  const r = !!n.isEMode;
1203
1208
  let t;
1204
1209
  return r ? t = {
1205
- id: T(),
1210
+ id: I(),
1206
1211
  wallet: "",
1207
1212
  protocol: "navi",
1208
1213
  market: "",
@@ -1215,7 +1220,7 @@ class O {
1215
1220
  emodeCap: {}
1216
1221
  }
1217
1222
  } : t = {
1218
- id: T(),
1223
+ id: I(),
1219
1224
  wallet: "",
1220
1225
  protocol: "navi",
1221
1226
  market: "",
@@ -1230,11 +1235,11 @@ class O {
1230
1235
  }
1231
1236
  getPositionsOverview(n) {
1232
1237
  const o = {}, r = {};
1233
- 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);
1238
+ let t = new p(0), a = new p(0), c = new p(0), i = new p(0), s = new p(0), u = new p(0);
1234
1239
  n.forEach((y) => {
1235
1240
  if (y.type === "navi-lending-supply") {
1236
1241
  const l = y["navi-lending-supply"];
1237
- t = t.plus(l.valueUSD), c = c.plus(
1242
+ t = t.plus(l.valueUSD), s = s.plus(
1238
1243
  new p(l.valueUSD).multipliedBy(l.pool.liquidationFactor.threshold)
1239
1244
  ), u = u.plus(
1240
1245
  new p(l.valueUSD).multipliedBy(l.pool.ltvValue)
@@ -1245,16 +1250,16 @@ class O {
1245
1250
  const l = y["navi-lending-emode-supply"];
1246
1251
  t = t.plus(l.valueUSD);
1247
1252
  const h = l.pool.emode;
1248
- c = c.plus(
1253
+ s = s.plus(
1249
1254
  new p(l.valueUSD).multipliedBy(h.lt)
1250
1255
  ), u = u.plus(
1251
1256
  new p(l.valueUSD).multipliedBy(h.ltv)
1252
1257
  );
1253
1258
  } else y.type === "navi-lending-emode-borrow" && (a = a.plus(y["navi-lending-emode-borrow"].valueUSD));
1254
- }), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0), u = p.max(u, 0), n.forEach((y) => {
1259
+ }), a = p.max(a, 0), t = p.max(t, 0), s = p.max(s, 0), u = p.max(u, 0), n.forEach((y) => {
1255
1260
  if (y.type === "navi-lending-supply") {
1256
1261
  const l = y["navi-lending-supply"], h = l.pool.supplyIncentiveApyInfo.apy;
1257
- t.gt(0) && (s = s.plus(
1262
+ t.gt(0) && (c = c.plus(
1258
1263
  new p(l.valueUSD).dividedBy(t).multipliedBy(new p(h).dividedBy(100))
1259
1264
  )), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1260
1265
  } else if (y.type === "navi-lending-borrow") {
@@ -1264,7 +1269,7 @@ class O {
1264
1269
  )), r[l.pool.suiCoinType] = p(r[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1265
1270
  } else if (y.type === "navi-lending-emode-supply") {
1266
1271
  const l = y["navi-lending-emode-supply"], h = l.pool.supplyIncentiveApyInfo.apy;
1267
- t.gt(0) && (s = s.plus(
1272
+ t.gt(0) && (c = c.plus(
1268
1273
  new p(l.valueUSD).dividedBy(t).multipliedBy(new p(h).dividedBy(100))
1269
1274
  )), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1270
1275
  } else if (y.type === "navi-lending-emode-borrow") {
@@ -1274,16 +1279,16 @@ class O {
1274
1279
  )), r[l.pool.suiCoinType] = p(r[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1275
1280
  }
1276
1281
  });
1277
- const d = t.minus(a), f = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(s).minus(a.multipliedBy(i)).div(t.minus(a));
1282
+ const d = t.minus(a), f = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(c).minus(a.multipliedBy(i)).div(t.minus(a));
1278
1283
  return {
1279
- hf: a.toNumber() !== 0 ? c.dividedBy(a).toNumber() : 1 / 0,
1284
+ hf: a.toNumber() !== 0 ? s.dividedBy(a).toNumber() : 1 / 0,
1280
1285
  netVaule: d.toString(),
1281
1286
  netWorthApr: f.toString(),
1282
1287
  totalSupplyValue: t.toString(),
1283
1288
  totalBorrowValue: a.toString(),
1284
- totalsupplyApy: s.toString(),
1289
+ totalsupplyApy: c.toString(),
1285
1290
  totalBorrowApy: i.toString(),
1286
- maxLiquidationValue: c.toString(),
1291
+ maxLiquidationValue: s.toString(),
1287
1292
  maxLoanToVaule: u.toString(),
1288
1293
  supply: o,
1289
1294
  borrow: r
@@ -1293,7 +1298,7 @@ class O {
1293
1298
  async function pt(e, n, o, r) {
1294
1299
  const t = await k({
1295
1300
  ...r,
1296
- cacheTime: w
1301
+ cacheTime: b
1297
1302
  });
1298
1303
  t.limter && e.moveCall({
1299
1304
  target: `${t.limter}::navi_adaptor::verify_navi_position_healthy`,
@@ -1333,29 +1338,29 @@ async function dt(e) {
1333
1338
  }
1334
1339
  async function Pe(e, n) {
1335
1340
  try {
1336
- const o = [], r = n?.client ?? P, t = e.map((s) => s.priceInfoObject), a = await r.multiGetObjects({
1341
+ const o = [], r = n?.client ?? P, t = e.map((c) => c.priceInfoObject), a = await r.multiGetObjects({
1337
1342
  ids: Array.from(new Set(t)),
1338
1343
  options: { showContent: !0 }
1339
1344
  });
1340
- for (const s of a) {
1341
- const i = s.data;
1345
+ for (const c of a) {
1346
+ const i = c.data;
1342
1347
  if (!i || !i.content || i.content.dataType !== "moveObject") {
1343
1348
  console.warn(`fetched object ${i?.objectId} datatype should be moveObject`);
1344
1349
  continue;
1345
1350
  }
1346
- const c = e.find((l) => l.priceInfoObject == i.objectId);
1347
- if (!c) {
1351
+ const s = e.find((l) => l.priceInfoObject == i.objectId);
1352
+ if (!s) {
1348
1353
  console.warn(`unable to find pyth info from array, priceInfoObject: ${i.objectId}`);
1349
1354
  continue;
1350
1355
  }
1351
1356
  const u = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: d, negative: f } = u.price.fields, v = u.conf, y = u.timestamp;
1352
1357
  o.push({
1353
- priceFeedId: c.priceFeedId,
1354
- priceInfoObject: c.priceInfoObject,
1358
+ priceFeedId: s.priceFeedId,
1359
+ priceInfoObject: s.priceInfoObject,
1355
1360
  price: f ? "-" + d : d,
1356
1361
  conf: v,
1357
1362
  publishTime: Number(y),
1358
- expiration: c.expiration
1363
+ expiration: s.expiration
1359
1364
  });
1360
1365
  }
1361
1366
  return o;
@@ -1376,8 +1381,8 @@ async function Se(e, n) {
1376
1381
  );
1377
1382
  continue;
1378
1383
  }
1379
- const s = a.expiration || 60;
1380
- t - a.publishTime > s && (console.info(
1384
+ const c = a.expiration || 60;
1385
+ t - a.publishTime > c && (console.info(
1381
1386
  `stale price feed, id: ${a.priceFeedId}, publish time: ${a.publishTime}, current timestamp: ${t}`
1382
1387
  ), o.push(a.priceFeedId));
1383
1388
  }
@@ -1389,7 +1394,7 @@ async function Se(e, n) {
1389
1394
  async function Ve(e, n, o) {
1390
1395
  const r = o?.client ?? P, t = await k({
1391
1396
  ...o,
1392
- cacheTime: w
1397
+ cacheTime: b
1393
1398
  });
1394
1399
  try {
1395
1400
  const a = await oe.getPriceFeedsUpdateData(n);
@@ -1405,7 +1410,7 @@ async function Ve(e, n, o) {
1405
1410
  async function Ee(e, n, o) {
1406
1411
  const r = await k({
1407
1412
  ...o,
1408
- cacheTime: w
1413
+ cacheTime: b
1409
1414
  });
1410
1415
  if (o?.updatePythPriceFeeds) {
1411
1416
  const t = n.filter((a) => !!a.pythPriceFeedId && !!a.pythPriceInfoObject).map((a) => ({
@@ -1460,16 +1465,21 @@ async function Ee(e, n, o) {
1460
1465
  async function ne(e) {
1461
1466
  return (await k({
1462
1467
  ...e,
1463
- cacheTime: w
1468
+ cacheTime: b
1464
1469
  })).oracle.feeds;
1465
1470
  }
1466
1471
  function Me(e, n) {
1467
- return e.filter((o) => !!(n?.lendingState && n.lendingState.find((t) => t.assetId === o.assetId) || n?.lendingPositions && n.lendingPositions.find((t) => [
1468
- "navi-lending-supply",
1469
- "navi-lending-borrow",
1470
- "navi-lending-emode-supply",
1471
- "navi-lending-emode-borrow"
1472
- ].includes(t.type) ? t[t.type]?.pool?.id === o.assetId : !1) || n?.pools && n.pools.find((t) => t.id === o.assetId)));
1472
+ return e.filter((o) => !!(n?.lendingState && n.lendingState.find((t) => w(t.pool.suiCoinType) === w(o.coinType)) || 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 c = t[t.type]?.pool;
1481
+ return w(c?.suiCoinType || "") === w(o.coinType);
1482
+ }) || n?.pools && n.pools.find((t) => w(t.suiCoinType) === w(o.coinType))));
1473
1483
  }
1474
1484
  async function mt(e, n, o, r) {
1475
1485
  try {
@@ -1479,11 +1489,11 @@ async function mt(e, n, o, r) {
1479
1489
  o.forEach((u) => {
1480
1490
  a.includes(u.market) || a.push(u.market);
1481
1491
  });
1482
- const s = await $e(n, {
1492
+ const c = await $e(n, {
1483
1493
  ...r,
1484
1494
  markets: a
1485
1495
  }), i = Me(t, {
1486
- lendingPositions: s,
1496
+ lendingPositions: c,
1487
1497
  pools: o
1488
1498
  });
1489
1499
  return await Ee(e, i, {
@@ -1508,22 +1518,22 @@ const G = $(
1508
1518
  )
1509
1519
  );
1510
1520
  async function ft(e, n) {
1511
- 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;
1521
+ return (await G(n)).find((r) => typeof e == "string" ? w(r.coinType) === w(e) : typeof e == "number" ? r.assetId === e : r.assetId === e.id) || null;
1512
1522
  }
1513
1523
  async function yt(e, n, o, r) {
1514
1524
  const t = await k({
1515
1525
  ...r,
1516
- cacheTime: w
1526
+ cacheTime: b
1517
1527
  }), a = await A(n, r);
1518
1528
  if (!(await G({
1519
1529
  ...r,
1520
- cacheTime: w
1530
+ cacheTime: b
1521
1531
  })).some(
1522
- (c) => b(c.coinType) === b(a.suiCoinType)
1532
+ (s) => w(s.coinType) === w(a.suiCoinType)
1523
1533
  ))
1524
1534
  throw new Error("Pool does not support flashloan");
1525
1535
  if (t.version === 1) {
1526
- const [c, u] = e.moveCall({
1536
+ const [s, u] = e.moveCall({
1527
1537
  target: `${t.package}::lending::flash_loan_with_ctx`,
1528
1538
  arguments: [
1529
1539
  e.object(t.flashloanConfig),
@@ -1532,9 +1542,9 @@ async function yt(e, n, o, r) {
1532
1542
  ],
1533
1543
  typeArguments: [a.suiCoinType]
1534
1544
  });
1535
- return [c, u];
1545
+ return [s, u];
1536
1546
  } else {
1537
- const [c, u] = e.moveCall({
1547
+ const [s, u] = e.moveCall({
1538
1548
  target: `${t.package}::lending::flash_loan_with_ctx_v2`,
1539
1549
  arguments: [
1540
1550
  e.object(t.flashloanConfig),
@@ -1544,19 +1554,19 @@ async function yt(e, n, o, r) {
1544
1554
  ],
1545
1555
  typeArguments: [a.suiCoinType]
1546
1556
  });
1547
- return [c, u];
1557
+ return [s, u];
1548
1558
  }
1549
1559
  }
1550
1560
  async function gt(e, n, o, r, t) {
1551
1561
  const a = await k({
1552
1562
  ...t,
1553
- cacheTime: w
1554
- }), s = await A(n, t);
1563
+ cacheTime: b
1564
+ }), c = await A(n, t);
1555
1565
  if (!(await G({
1556
1566
  ...t,
1557
- cacheTime: w
1567
+ cacheTime: b
1558
1568
  })).some(
1559
- (d) => b(d.coinType) === b(s.suiCoinType)
1569
+ (d) => w(d.coinType) === w(c.suiCoinType)
1560
1570
  ))
1561
1571
  throw new Error("Pool does not support flashloan");
1562
1572
  const [u] = e.moveCall({
@@ -1564,19 +1574,19 @@ async function gt(e, n, o, r, t) {
1564
1574
  arguments: [
1565
1575
  e.object("0x06"),
1566
1576
  e.object(a.storage),
1567
- e.object(s.contract.pool),
1577
+ e.object(c.contract.pool),
1568
1578
  g(o, e.object),
1569
1579
  g(r, e.object)
1570
1580
  ],
1571
- typeArguments: [s.suiCoinType]
1581
+ typeArguments: [c.suiCoinType]
1572
1582
  });
1573
1583
  return [u];
1574
1584
  }
1575
1585
  async function ht(e, n, o, r, t, a) {
1576
- const s = {
1586
+ const c = {
1577
1587
  ...a,
1578
- cacheTime: w
1579
- }, i = await k(s), c = await A(n, s), u = await A(r, s);
1588
+ cacheTime: b
1589
+ }, i = await k(c), s = await A(n, c), u = await A(r, c);
1580
1590
  if (i.version === 1) {
1581
1591
  const [d, f] = e.moveCall({
1582
1592
  target: `${i.package}::incentive_v3::liquidation`,
@@ -1587,9 +1597,9 @@ async function ht(e, n, o, r, t, a) {
1587
1597
  // Price oracle for asset pricing
1588
1598
  e.object(i.storage),
1589
1599
  // Protocol storage
1590
- e.pure.u8(c.id),
1600
+ e.pure.u8(s.id),
1591
1601
  // Pay asset ID
1592
- e.object(c.contract.pool),
1602
+ e.object(s.contract.pool),
1593
1603
  // Pay asset pool contract
1594
1604
  g(o, e.object),
1595
1605
  // Debt repayment amount
@@ -1604,7 +1614,7 @@ async function ht(e, n, o, r, t, a) {
1604
1614
  e.object(i.incentiveV3)
1605
1615
  // Incentive V3 contract
1606
1616
  ],
1607
- typeArguments: [c.suiCoinType, u.suiCoinType]
1617
+ typeArguments: [s.suiCoinType, u.suiCoinType]
1608
1618
  });
1609
1619
  return [d, f];
1610
1620
  } else {
@@ -1617,9 +1627,9 @@ async function ht(e, n, o, r, t, a) {
1617
1627
  // Price oracle for asset pricing
1618
1628
  e.object(i.storage),
1619
1629
  // Protocol storage
1620
- e.pure.u8(c.id),
1630
+ e.pure.u8(s.id),
1621
1631
  // Pay asset ID
1622
- e.object(c.contract.pool),
1632
+ e.object(s.contract.pool),
1623
1633
  // Pay asset pool contract
1624
1634
  g(o, e.object),
1625
1635
  // Debt repayment amount
@@ -1636,7 +1646,7 @@ async function ht(e, n, o, r, t, a) {
1636
1646
  e.object("0x05")
1637
1647
  // SuiSystemState object
1638
1648
  ],
1639
- typeArguments: [c.suiCoinType, u.suiCoinType]
1649
+ typeArguments: [s.suiCoinType, u.suiCoinType]
1640
1650
  });
1641
1651
  return [d, f];
1642
1652
  }
@@ -1645,12 +1655,12 @@ async function De(e, n, o) {
1645
1655
  const r = o?.client ?? P, t = new U(), a = await R({
1646
1656
  ...o,
1647
1657
  markets: Object.values(M),
1648
- cacheTime: w
1649
- }), s = await ne(o);
1658
+ cacheTime: b
1659
+ }), c = await ne(o);
1650
1660
  for (let d of n) {
1651
1661
  const f = await k({
1652
1662
  ...o,
1653
- cacheTime: w,
1663
+ cacheTime: b,
1654
1664
  market: d.market
1655
1665
  });
1656
1666
  t.moveCall({
@@ -1670,9 +1680,9 @@ async function De(e, n, o) {
1670
1680
  const i = await r.devInspectTransactionBlock({
1671
1681
  transactionBlock: t,
1672
1682
  sender: e
1673
- }), c = [];
1683
+ }), s = [];
1674
1684
  i?.results?.forEach((d) => {
1675
- c.push(
1685
+ s.push(
1676
1686
  L(
1677
1687
  {
1678
1688
  results: [d]
@@ -1693,20 +1703,20 @@ async function De(e, n, o) {
1693
1703
  );
1694
1704
  });
1695
1705
  const u = [];
1696
- return c.forEach((d, f) => {
1706
+ return s.forEach((d, f) => {
1697
1707
  const v = n[f];
1698
1708
  if (d.length === 5 && Array.isArray(d[0])) {
1699
1709
  const y = d[0].length;
1700
1710
  for (let l = 0; l < y; l++) {
1701
- const h = s.find(
1702
- (I) => b(I.coinType) === b(d[1][l])
1711
+ const h = c.find(
1712
+ (T) => w(T.coinType) === w(d[1][l])
1703
1713
  ), j = a.find(
1704
- (I) => b(I.coinType) === b(d[0][l]) && I.market === v.market
1714
+ (T) => w(T.coinType) === w(d[0][l]) && T.market === v.market
1705
1715
  );
1706
1716
  !h || !j || u.push({
1707
1717
  assetId: j.id,
1708
- assetCoinType: b(d[0][l]),
1709
- rewardCoinType: b(d[1][l]),
1718
+ assetCoinType: w(d[0][l]),
1719
+ rewardCoinType: w(d[1][l]),
1710
1720
  option: Number(d[2][l]),
1711
1721
  userClaimableReward: Number(d[4][l]) / Math.pow(10, h.priceDecimal),
1712
1722
  ruleIds: Array.isArray(d[3][l]) ? d[3][l] : [d[3][l]],
@@ -1732,12 +1742,12 @@ async function vt(e, n) {
1732
1742
  owner: e,
1733
1743
  market: a.key
1734
1744
  })).concat(
1735
- r.filter((a) => !!o.find((s) => s.id === a.marketId)).map((a) => {
1736
- const s = _(a.marketId);
1745
+ r.filter((a) => !!o.find((c) => c.id === a.marketId)).map((a) => {
1746
+ const c = _(a.marketId);
1737
1747
  return {
1738
1748
  address: a.accountCap,
1739
1749
  owner: e,
1740
- market: s.key,
1750
+ market: c.key,
1741
1751
  emodeId: a.emodeId
1742
1752
  };
1743
1753
  })
@@ -1747,8 +1757,8 @@ async function vt(e, n) {
1747
1757
  function wt(e) {
1748
1758
  const n = /* @__PURE__ */ new Map();
1749
1759
  e.forEach((r) => {
1750
- const t = r.assetId, a = r.option, s = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
1751
- n.has(s) ? n.get(s).total += r.userClaimableReward : n.set(s, {
1760
+ const t = r.assetId, a = r.option, c = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
1761
+ n.has(c) ? n.get(c).total += r.userClaimableReward : n.set(c, {
1752
1762
  assetId: t,
1753
1763
  rewardType: a,
1754
1764
  coinType: r.rewardCoinType,
@@ -1757,11 +1767,11 @@ function wt(e) {
1757
1767
  });
1758
1768
  });
1759
1769
  const o = /* @__PURE__ */ new Map();
1760
- for (const { assetId: r, rewardType: t, coinType: a, total: s, market: i } of n.values()) {
1761
- const c = `${r}-${t}-${i}`;
1762
- o.has(c) || o.set(c, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
1763
- const u = o.get(c);
1764
- u.rewards.set(a, (u.rewards.get(a) || 0) + s);
1770
+ for (const { assetId: r, rewardType: t, coinType: a, total: c, market: i } of n.values()) {
1771
+ const s = `${r}-${t}-${i}`;
1772
+ o.has(s) || o.set(s, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
1773
+ const u = o.get(s);
1774
+ u.rewards.set(a, (u.rewards.get(a) || 0) + c);
1765
1775
  }
1766
1776
  return Array.from(o.values()).map((r) => ({
1767
1777
  assetId: r.assetId,
@@ -1790,11 +1800,11 @@ async function Ct(e, n, o) {
1790
1800
  const r = await R({
1791
1801
  ...o,
1792
1802
  markets: Object.values(M),
1793
- cacheTime: w
1803
+ cacheTime: b
1794
1804
  }), t = /* @__PURE__ */ new Map();
1795
- for (const s of n) {
1796
- const { rewardCoinType: i, ruleIds: c, market: u, owner: d, address: f, emodeId: v } = s, y = `${i}___${f}`;
1797
- for (const l of c) {
1805
+ for (const c of n) {
1806
+ const { rewardCoinType: i, ruleIds: s, market: u, owner: d, address: f, emodeId: v } = c, y = `${i}___${f}`;
1807
+ for (const l of s) {
1798
1808
  t.has(y) || t.set(y, {
1799
1809
  assetIds: [],
1800
1810
  ruleIds: [],
@@ -1805,24 +1815,24 @@ async function Ct(e, n, o) {
1805
1815
  isEMode: typeof v < "u"
1806
1816
  });
1807
1817
  const h = t.get(y);
1808
- h.assetIds.push(s.assetCoinType.replace("0x", "")), h.ruleIds.push(l), h.amount += s.userClaimableReward;
1818
+ h.assetIds.push(c.assetCoinType.replace("0x", "")), h.ruleIds.push(l), h.amount += c.userClaimableReward;
1809
1819
  }
1810
1820
  }
1811
1821
  const a = [];
1812
1822
  for (const [
1813
- s,
1814
- { assetIds: i, ruleIds: c, amount: u, market: d, owner: f, address: v, isEMode: y }
1823
+ c,
1824
+ { assetIds: i, ruleIds: s, amount: u, market: d, owner: f, address: v, isEMode: y }
1815
1825
  ] of t) {
1816
1826
  const l = await k({
1817
1827
  ...o,
1818
- cacheTime: w,
1828
+ cacheTime: b,
1819
1829
  market: d
1820
- }), h = s.split("___")[0], j = r.find(
1821
- (S) => b(S.suiCoinType) === b(h) && S.market === d
1830
+ }), h = c.split("___")[0], j = r.find(
1831
+ (S) => w(S.suiCoinType) === w(h) && S.market === d
1822
1832
  );
1823
1833
  if (!j || !j.contract.rewardFundId)
1824
1834
  throw new Error(`No matching rewardFund found for reward coin: ${h} ${d}`);
1825
- const I = j.contract.rewardFundId;
1835
+ const T = j.contract.rewardFundId;
1826
1836
  if (o?.accountCap && !o.customCoinReceive)
1827
1837
  throw new Error("customCoinReceive is required when accountCap is provided");
1828
1838
  if (o?.customCoinReceive) {
@@ -1836,11 +1846,11 @@ async function Ct(e, n, o) {
1836
1846
  // Incentive V3 contract
1837
1847
  e.object(l.storage),
1838
1848
  // Protocol storage
1839
- e.object(I),
1849
+ e.object(T),
1840
1850
  // Reward fund
1841
1851
  e.pure.vector("string", i),
1842
1852
  // Asset IDs
1843
- e.pure.vector("address", c),
1853
+ e.pure.vector("address", s),
1844
1854
  // Rule IDs
1845
1855
  g(o.accountCap, e.object)
1846
1856
  // Account capability
@@ -1855,11 +1865,11 @@ async function Ct(e, n, o) {
1855
1865
  // Incentive V3 contract
1856
1866
  e.object(l.storage),
1857
1867
  // Protocol storage
1858
- e.object(I),
1868
+ e.object(T),
1859
1869
  // Reward fund
1860
1870
  e.pure.vector("string", i),
1861
1871
  // Asset IDs
1862
- e.pure.vector("address", c),
1872
+ e.pure.vector("address", s),
1863
1873
  // Rule IDs
1864
1874
  g(v, e.object)
1865
1875
  // Account capability
@@ -1874,11 +1884,11 @@ async function Ct(e, n, o) {
1874
1884
  // Incentive V3 contract
1875
1885
  e.object(l.storage),
1876
1886
  // Protocol storage
1877
- e.object(I),
1887
+ e.object(T),
1878
1888
  // Reward fund
1879
1889
  e.pure.vector("string", i),
1880
1890
  // Asset IDs
1881
- e.pure.vector("address", c)
1891
+ e.pure.vector("address", s)
1882
1892
  // Rule IDs
1883
1893
  ],
1884
1894
  typeArguments: [h]
@@ -1919,11 +1929,11 @@ async function Ct(e, n, o) {
1919
1929
  // Incentive V3 contract
1920
1930
  e.object(l.storage),
1921
1931
  // Protocol storage
1922
- e.object(I),
1932
+ e.object(T),
1923
1933
  // Reward fund
1924
1934
  e.pure.vector("string", i),
1925
1935
  // Asset IDs
1926
- e.pure.vector("address", c),
1936
+ e.pure.vector("address", s),
1927
1937
  // Rule IDs
1928
1938
  g(o?.accountCap || v, e.object)
1929
1939
  // Account capability
@@ -1948,11 +1958,11 @@ async function Ct(e, n, o) {
1948
1958
  // Incentive V3 contract
1949
1959
  e.object(l.storage),
1950
1960
  // Protocol storage
1951
- e.object(I),
1961
+ e.object(T),
1952
1962
  // Reward fund
1953
1963
  e.pure.vector("string", i),
1954
1964
  // Asset IDs
1955
- e.pure.vector("address", c)
1965
+ e.pure.vector("address", s)
1956
1966
  // Rule IDs
1957
1967
  ],
1958
1968
  typeArguments: [h]
@@ -1962,7 +1972,7 @@ async function Ct(e, n, o) {
1962
1972
  }
1963
1973
  export {
1964
1974
  z as Address,
1965
- w as DEFAULT_CACHE_TIME,
1975
+ b as DEFAULT_CACHE_TIME,
1966
1976
  N as DEFAULT_MARKET_IDENTITY,
1967
1977
  Ke as FlashLoanAssetConfig,
1968
1978
  He as IncentiveAPYInfo,
@@ -1977,7 +1987,7 @@ export {
1977
1987
  fe as UserStateInfo,
1978
1988
  Xe as borrowCoinPTB,
1979
1989
  Ct as claimLendingRewardsPTB,
1980
- Ie as createAccountCapPTB,
1990
+ Te as createAccountCapPTB,
1981
1991
  nt as createEModeCapPTB,
1982
1992
  Ce as depositCoinPTB,
1983
1993
  rt as emodeIdentityId,
@@ -1985,7 +1995,7 @@ export {
1985
1995
  ot as exitEModePTB,
1986
1996
  Me as filterPriceFeeds,
1987
1997
  yt as flashloanPTB,
1988
- Te as getAccountCapOwnerPTB,
1998
+ Ie as getAccountCapOwnerPTB,
1989
1999
  G as getAllFlashLoanAssets,
1990
2000
  et as getBorrowFee,
1991
2001
  lt as getCoins,
@@ -2014,7 +2024,7 @@ export {
2014
2024
  bt as getUserTotalClaimedReward,
2015
2025
  ht as liquidatePTB,
2016
2026
  at as mergeCoinsPTB,
2017
- b as normalizeCoinType,
2027
+ w as normalizeCoinType,
2018
2028
  ke as parsePoolUID,
2019
2029
  g as parseTxValue,
2020
2030
  xe as repayCoinPTB,