@naviprotocol/lending 1.4.0-emode.19 → 1.4.0-emode.20

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,9 +129,9 @@ const W = d.bytes(32).transform({
129
129
  borrow_balance: d.u256(),
130
130
  /** User's current supply balance */
131
131
  supply_balance: d.u256()
132
- }), me = "1.4.0-emode.19", $ = {
132
+ }), me = "1.4.0-emode.20", S = {
133
133
  version: me
134
- }, ye = $.version, ge = () => {
134
+ }, ye = S.version, ge = () => {
135
135
  if (typeof process < "u" && process.versions && process.versions.node)
136
136
  try {
137
137
  const e = require("os"), o = process.version, n = e.type(), r = e.arch();
@@ -143,7 +143,7 @@ const W = d.bytes(32).transform({
143
143
  }, fe = () => {
144
144
  let e = "";
145
145
  return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ye} (${ge()})`), e;
146
- }, H = fe(), S = new ce({
146
+ }, H = fe(), $ = new ce({
147
147
  url: ie("mainnet")
148
148
  });
149
149
  function J(e) {
@@ -256,7 +256,7 @@ var N = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] =
256
256
  const R = A(
257
257
  I(
258
258
  async (e) => {
259
- const o = (e?.markets || [E.main]).map((t) => j(t)), n = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${$.version}&market=${o.map(
259
+ const o = (e?.markets || [E.main]).map((t) => j(t)), n = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${S.version}&market=${o.map(
260
260
  (t) => t.key
261
261
  )}`, r = await fetch(n, { headers: V }).then((t) => t.json());
262
262
  return r.data.forEach((t) => {
@@ -294,13 +294,13 @@ async function B(e, o) {
294
294
  }
295
295
  const ze = A(
296
296
  I(async (e) => {
297
- const o = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${$.version}`;
297
+ const o = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${S.version}`;
298
298
  return (await fetch(o, { headers: V }).then((r) => r.json())).data;
299
299
  })
300
300
  ), Ke = A(
301
301
  I(
302
302
  async (e) => {
303
- const o = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${$.version}`;
303
+ const o = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${S.version}`;
304
304
  return await fetch(o, { headers: V }).then((r) => r.json());
305
305
  }
306
306
  )
@@ -584,7 +584,7 @@ const Xe = A(
584
584
  });
585
585
  if (e?.address && typeof e?.asset < "u")
586
586
  try {
587
- const t = await B(e.asset, e), a = e?.client ?? S, i = new U();
587
+ const t = await B(e.asset, e), a = e?.client ?? $, i = new U();
588
588
  i.moveCall({
589
589
  target: `${o.package}::incentive_v3::get_borrow_fee_v2`,
590
590
  arguments: [
@@ -603,7 +603,7 @@ const Xe = A(
603
603
  } catch (t) {
604
604
  console.error(t);
605
605
  }
606
- const r = (await S.getObject({
606
+ const r = (await $.getObject({
607
607
  id: o.incentiveV3,
608
608
  options: { showType: !0, showOwner: !0, showContent: !0 }
609
609
  })).data.content.fields.borrow_fee_rate;
@@ -704,7 +704,7 @@ const j = (e) => {
704
704
  ), k = A(
705
705
  I(
706
706
  async (e) => {
707
- const o = j(e?.market || D), n = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${$.version}&market=${o.key}`;
707
+ const o = j(e?.market || D), n = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${S.version}&market=${o.key}`;
708
708
  return (await fetch(n, { headers: V }).then((t) => t.json())).data;
709
709
  }
710
710
  )
@@ -785,7 +785,7 @@ const X = A(
785
785
  const n = await k({
786
786
  cacheTime: h,
787
787
  ...o
788
- }), r = new U(), t = o?.client ?? S;
788
+ }), r = new U(), t = o?.client ?? $;
789
789
  r.moveCall({
790
790
  target: `${n.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
791
791
  arguments: [r.object(n.emode.contract.registryObject), r.pure.address(e)]
@@ -849,7 +849,7 @@ async function Ie(e, o, n) {
849
849
  return Z(e, o, 0, 0, 0, !1, n);
850
850
  }
851
851
  async function x(e, o, n) {
852
- const r = new U(), t = n?.client ?? S, a = await R({
852
+ const r = new U(), t = n?.client ?? $, a = await R({
853
853
  ...n,
854
854
  markets: Object.values(E)
855
855
  }), i = q(a);
@@ -904,7 +904,7 @@ const nt = A(
904
904
  }
905
905
  );
906
906
  async function rt(e, o) {
907
- const n = o?.client ?? S, r = new U();
907
+ const n = o?.client ?? $, r = new U();
908
908
  await Ie(r, e, o);
909
909
  const t = await n.devInspectTransactionBlock({
910
910
  transactionBlock: r,
@@ -913,7 +913,7 @@ async function rt(e, o) {
913
913
  return Q(Number(a[0]) || 0);
914
914
  }
915
915
  async function at(e, o, n, r) {
916
- const t = r?.client ?? S, a = new U();
916
+ const t = r?.client ?? $, a = new U();
917
917
  let i = 0, c = 0;
918
918
  const s = await B(o, r);
919
919
  if (n.forEach((v) => {
@@ -940,13 +940,13 @@ const ct = I(
940
940
  async (e, o) => {
941
941
  const n = new URLSearchParams();
942
942
  o?.cursor && n.set("cursor", o.cursor), n.set("userAddress", e);
943
- const r = `https://open-api.naviprotocol.io/api/navi/user/transactions?${n.toString()}&sdk=${$.version}`;
943
+ const r = `https://open-api.naviprotocol.io/api/navi/user/transactions?${n.toString()}&sdk=${S.version}`;
944
944
  return (await fetch(r, { headers: V }).then((a) => a.json())).data;
945
945
  }
946
946
  );
947
947
  async function it(e, o) {
948
948
  let n = null;
949
- const r = [], t = o?.client ?? S;
949
+ const r = [], t = o?.client ?? $;
950
950
  do {
951
951
  let a;
952
952
  if (o?.coinType ? a = await t.getCoins({
@@ -966,7 +966,14 @@ async function it(e, o) {
966
966
  }
967
967
  const Be = A(
968
968
  async (e, o) => {
969
- const n = [], r = (o?.markets || Object.keys(E)).map((c) => j(c)), t = await X(e, o), a = r.map((c) => ({
969
+ const n = [], r = (o?.markets || Object.keys(E)).map((c) => j(c));
970
+ let t = [];
971
+ try {
972
+ t = await X(e, o);
973
+ } catch (c) {
974
+ console.error(c);
975
+ }
976
+ const a = r.map((c) => ({
970
977
  address: e,
971
978
  market: c.key
972
979
  })).concat(
@@ -985,7 +992,7 @@ const Be = A(
985
992
  if (l(c.supplyBalance).gt(0)) {
986
993
  const u = l(c.supplyBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, l.ROUND_DOWN);
987
994
  n.push({
988
- id: `${c.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply`,
995
+ id: `${e}_${c.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply`,
989
996
  wallet: e,
990
997
  protocol: "navi",
991
998
  market: c.market,
@@ -1020,7 +1027,7 @@ const Be = A(
1020
1027
  if (l(c.supplyBalance).gt(0)) {
1021
1028
  const u = l(c.supplyBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, l.ROUND_DOWN);
1022
1029
  n.push({
1023
- id: `${c.pool.uniqueId}_navi-lending-supply`,
1030
+ id: `${e}_${c.pool.uniqueId}_navi-lending-supply`,
1024
1031
  wallet: e,
1025
1032
  protocol: "navi",
1026
1033
  type: "navi-lending-supply",
@@ -1294,8 +1301,8 @@ async function Ae(e) {
1294
1301
  throw new Error(`failed to get pyth stale price feed id, msg: ${o.message}`);
1295
1302
  }
1296
1303
  }
1297
- async function Se(e, o, n) {
1298
- const r = n?.client ?? S, t = await k({
1304
+ async function $e(e, o, n) {
1305
+ const r = n?.client ?? $, t = await k({
1299
1306
  ...n,
1300
1307
  cacheTime: h
1301
1308
  });
@@ -1310,7 +1317,7 @@ async function Se(e, o, n) {
1310
1317
  throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
1311
1318
  }
1312
1319
  }
1313
- async function $e(e, o, n) {
1320
+ async function Se(e, o, n) {
1314
1321
  const r = await k({
1315
1322
  ...n,
1316
1323
  cacheTime: h
@@ -1319,7 +1326,7 @@ async function $e(e, o, n) {
1319
1326
  const t = o.filter((a) => !!a.pythPriceFeedId).map((a) => a.pythPriceFeedId);
1320
1327
  try {
1321
1328
  const a = await Ae(t);
1322
- a.length > 0 && await Se(e, a, n);
1329
+ a.length > 0 && await $e(e, a, n);
1323
1330
  } catch {
1324
1331
  }
1325
1332
  }
@@ -1373,7 +1380,7 @@ async function st(e, o, n, r) {
1373
1380
  lendingPositions: i,
1374
1381
  pools: n
1375
1382
  });
1376
- return await $e(e, c, {
1383
+ return await Se(e, c, {
1377
1384
  updatePythPriceFeeds: !0,
1378
1385
  ...r
1379
1386
  });
@@ -1386,7 +1393,7 @@ async function st(e, o, n, r) {
1386
1393
  const L = A(
1387
1394
  I(
1388
1395
  async (e) => {
1389
- const o = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${$.version}&market=${e?.market || D}`, n = await fetch(o, { headers: V }).then((r) => r.json());
1396
+ const o = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${S.version}&market=${e?.market || D}`, n = await fetch(o, { headers: V }).then((r) => r.json());
1390
1397
  return Object.keys(n.data).map((r) => ({
1391
1398
  ...n.data[r],
1392
1399
  coinType: r
@@ -1529,7 +1536,7 @@ async function dt(e, o, n, r, t, a) {
1529
1536
  }
1530
1537
  }
1531
1538
  async function Ve(e, o, n) {
1532
- const r = n?.client ?? S, t = new U(), a = await R({
1539
+ const r = n?.client ?? $, t = new U(), a = await R({
1533
1540
  ...n,
1534
1541
  markets: Object.values(E),
1535
1542
  cacheTime: h
@@ -1652,12 +1659,12 @@ function yt(e) {
1652
1659
  }
1653
1660
  const gt = I(
1654
1661
  async (e, o) => {
1655
- const n = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${$.version}&market=${o?.market || D}`;
1662
+ const n = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${S.version}&market=${o?.market || D}`;
1656
1663
  return (await fetch(n, { headers: V }).then((t) => t.json())).data;
1657
1664
  }
1658
1665
  ), ft = I(
1659
1666
  async (e, o) => {
1660
- const n = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${o?.page || 1}&pageSize=${o?.size || 400}&sdk=${$.version}&market=${o?.market || D}`, r = await fetch(n, { headers: V }).then((t) => t.json());
1667
+ const n = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${o?.page || 1}&pageSize=${o?.size || 400}&sdk=${S.version}&market=${o?.market || D}`, r = await fetch(n, { headers: V }).then((t) => t.json());
1661
1668
  return F({
1662
1669
  data: r.data.rewards
1663
1670
  });
@@ -1892,8 +1899,8 @@ export {
1892
1899
  pt as repayFlashLoanPTB,
1893
1900
  yt as summaryLendingRewards,
1894
1901
  st as updateOraclePriceBeforeUserOperationPTB,
1895
- $e as updateOraclePricesPTB,
1896
- Se as updatePythPriceFeeds,
1902
+ Se as updateOraclePricesPTB,
1903
+ $e as updatePythPriceFeeds,
1897
1904
  A as withCache,
1898
1905
  I as withSingleton,
1899
1906
  Ye as withdrawCoinPTB