@tokemak/queries 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/functions/getAutopoolDayData.d.ts.map +1 -1
  2. package/dist/functions/getAutopoolHistory.d.ts.map +1 -1
  3. package/dist/functions/getAutopools.d.ts +3 -3
  4. package/dist/functions/getAutopools.d.ts.map +1 -1
  5. package/dist/functions/getAutopoolsRebalances.d.ts.map +1 -1
  6. package/dist/functions/getChainAutopools.d.ts +3 -3
  7. package/dist/functions/getChainAutopools.d.ts.map +1 -1
  8. package/dist/functions/getEthPriceAtBlock.d.ts +2 -2
  9. package/dist/functions/getEthPriceAtBlock.d.ts.map +1 -1
  10. package/dist/functions/getMultipleAutopoolRebalances.d.ts.map +1 -1
  11. package/dist/functions/getPoolsAndDestinations.d.ts +2 -2
  12. package/dist/functions/getPoolsAndDestinations.d.ts.map +1 -1
  13. package/dist/functions/getRebalanceStats.d.ts +7 -6
  14. package/dist/functions/getRebalanceStats.d.ts.map +1 -1
  15. package/dist/functions/getTokenPrices.d.ts +1 -1
  16. package/dist/functions/getTokenPrices.d.ts.map +1 -1
  17. package/dist/functions/getUserAutopoolBalanceChanges.d.ts.map +1 -1
  18. package/dist/functions/getUserAutopools.d.ts +1 -1
  19. package/dist/functions/getUserAutopools.d.ts.map +1 -1
  20. package/dist/functions/getUserSAuto.d.ts +1 -1
  21. package/dist/functions/getUserSAuto.d.ts.map +1 -1
  22. package/dist/functions/updateRebalanceStats.d.ts +2 -2
  23. package/dist/functions/updateRebalanceStats.d.ts.map +1 -1
  24. package/dist/index.js +290 -358
  25. package/dist/index.mjs +180 -251
  26. package/dist/safe.d.ts +9 -0
  27. package/dist/safe.d.ts.map +1 -0
  28. package/dist/safe.js +860 -0
  29. package/dist/safe.mjs +848 -0
  30. package/package.json +27 -16
  31. package/dist/functions/getBackupApr.d.ts +0 -2
  32. package/dist/functions/getBackupApr.d.ts.map +0 -1
  33. package/dist/functions/getBackupTokenPrices.d.ts +0 -6
  34. package/dist/functions/getBackupTokenPrices.d.ts.map +0 -1
  35. package/dist/functions/getPoolsAndDestinationsBackup.d.ts +0 -67
  36. package/dist/functions/getPoolsAndDestinationsBackup.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -274,6 +274,9 @@ var getTokePrice = async () => {
274
274
  }
275
275
  };
276
276
 
277
+ // functions/getAutopools.ts
278
+ var import_core = require("@wagmi/core");
279
+
277
280
  // utils/getExchangeNames.ts
278
281
  function getExchangeNames(destinationVaults) {
279
282
  const uniqueNamesSet = /* @__PURE__ */ new Set();
@@ -624,22 +627,8 @@ async function paginateQuery(queryFn, arrayKey, options = {}) {
624
627
  return results;
625
628
  }
626
629
 
627
- // functions/getPoolsAndDestinationsBackup.ts
628
- var import_utils2 = require("@tokemak/utils");
629
- var getPoolsAndDestinationsBackup = async (chainId) => {
630
- try {
631
- const networkName = (0, import_utils2.getNetwork)(chainId)?.name.toLowerCase();
632
- const backupData = await getBlobData(
633
- `${networkName}-getPoolsAndDestinations-latest-success.json`
634
- );
635
- return backupData?.data;
636
- } catch (e) {
637
- console.error(e);
638
- }
639
- };
640
-
641
630
  // functions/getChainAutopools.ts
642
- var import_utils6 = require("@tokemak/utils");
631
+ var import_utils4 = require("@tokemak/utils");
643
632
  var import_viem2 = require("viem");
644
633
 
645
634
  // constants/tokenOrders.ts
@@ -741,16 +730,14 @@ var import_chains2 = require("viem/chains");
741
730
 
742
731
  // functions/getPoolsAndDestinations.ts
743
732
  var import_config = require("@tokemak/config");
744
- var import_core = require("@wagmi/core");
745
733
  var import_abis = require("@tokemak/abis");
746
- var getPoolsAndDestinations = async (wagmiConfig, { chainId }) => {
734
+ var getPoolsAndDestinations = async (client, { chainId }) => {
747
735
  try {
748
736
  const { lens } = (0, import_config.getCoreConfig)(chainId);
749
- const { autoPools, destinations } = await (0, import_core.readContract)(wagmiConfig, {
737
+ const { autoPools, destinations } = await client.readContract({
750
738
  address: lens,
751
739
  abi: import_abis.lensAbi,
752
- functionName: "getPoolsAndDestinations",
753
- chainId
740
+ functionName: "getPoolsAndDestinations"
754
741
  });
755
742
  const autopoolsAndDestinations = mergeArraysWithKey(
756
743
  autoPools,
@@ -763,30 +750,9 @@ var getPoolsAndDestinations = async (wagmiConfig, { chainId }) => {
763
750
  }
764
751
  };
765
752
 
766
- // functions/getBackupApr.ts
767
- var import_utils4 = require("@tokemak/utils");
768
- var getBackupApr = async (chainId, poolAddress) => {
769
- try {
770
- const networkName = (0, import_utils4.getNetwork)(chainId)?.name.toLowerCase();
771
- const backupData = await getBlobData(
772
- `${networkName}-getChainAutopools-latest-success.json`
773
- );
774
- if (backupData) {
775
- const backupApr = backupData.data.find(
776
- (item) => item.poolAddress.toLowerCase() === poolAddress.toLowerCase()
777
- )?.apr.base;
778
- return backupApr || 0;
779
- }
780
- } catch (e) {
781
- console.error(e);
782
- return 0;
783
- }
784
- return null;
785
- };
786
-
787
753
  // functions/getChainAutopools.ts
788
754
  var import_constants6 = require("@tokemak/constants");
789
- var getChainAutopools = async (wagmiConfig, {
755
+ var getChainAutopools = async (client, {
790
756
  chainId,
791
757
  prices
792
758
  }) => {
@@ -800,24 +766,22 @@ var getChainAutopools = async (wagmiConfig, {
800
766
  const genStratAprs = await getGenStratAprs({
801
767
  chainId
802
768
  });
803
- let autopoolsAndDestinations = await getPoolsAndDestinations(wagmiConfig, {
769
+ const autopoolsAndDestinations = await getPoolsAndDestinations(client, {
804
770
  chainId
805
771
  });
806
772
  if (!autopoolsAndDestinations) {
807
- const backupData = await getPoolsAndDestinationsBackup(chainId);
808
- if (backupData) {
809
- autopoolsAndDestinations = backupData;
810
- } else {
811
- throw new Error(`No autopools and destinations found for ${chainId}`);
812
- }
773
+ throw new Error(`No autopools and destinations found for ${chainId}`);
813
774
  }
814
- const vaultAddedMapping = vaultAddeds.reduce((acc, vaultAdded) => {
815
- acc[vaultAdded.vault.toLowerCase()] = Number(vaultAdded.blockTimestamp);
816
- return acc;
817
- }, {});
775
+ const vaultAddedMapping = vaultAddeds.reduce(
776
+ (acc, vaultAdded) => {
777
+ acc[vaultAdded.vault.toLowerCase()] = Number(vaultAdded.blockTimestamp);
778
+ return acc;
779
+ },
780
+ {}
781
+ );
818
782
  const autopools = await Promise.all(
819
783
  autopoolsAndDestinations.map(async (autopool) => {
820
- let baseAsset = (0, import_utils6.getToken)(autopool.baseAsset);
784
+ let baseAsset = (0, import_utils4.getToken)(autopool.baseAsset);
821
785
  if (!baseAsset?.symbol) {
822
786
  console.error(
823
787
  "FIX THIS BEFORE PROD: base asset not found",
@@ -832,18 +796,18 @@ var getChainAutopools = async (wagmiConfig, {
832
796
  }) || 0;
833
797
  }
834
798
  const timestamp = vaultAddedMapping[autopool.poolAddress.toLowerCase()];
835
- const totalAssets = (0, import_utils6.formatUnitsNum)(
799
+ const totalAssets = (0, import_utils4.formatUnitsNum)(
836
800
  autopool.totalAssets,
837
801
  baseAsset.decimals
838
802
  );
839
803
  const tvl = totalAssets * baseAssetPrice;
840
- const totalIdleAssets = (0, import_utils6.formatUnitsNum)(
804
+ const totalIdleAssets = (0, import_utils4.formatUnitsNum)(
841
805
  autopool.totalIdle,
842
806
  baseAsset.decimals
843
807
  );
844
808
  const exchangeValues = {};
845
809
  const destinations = autopool.destinations.map((destination) => {
846
- const debtValueHeldByVaultEth = (0, import_utils6.formatUnitsNum)(
810
+ const debtValueHeldByVaultEth = (0, import_utils4.formatUnitsNum)(
847
811
  destination.debtValueHeldByVault,
848
812
  baseAsset.decimals
849
813
  );
@@ -856,8 +820,8 @@ var getChainAutopools = async (wagmiConfig, {
856
820
  destination.underlyingTokenValueHeld
857
821
  );
858
822
  let underlyingTokens = tokensWithValue.map((token) => {
859
- const tokenDetails = (0, import_utils6.getToken)(token.tokenAddress);
860
- let value = (0, import_utils6.formatUnitsNum)(
823
+ const tokenDetails = (0, import_utils4.getToken)(token.tokenAddress);
824
+ let value = (0, import_utils4.formatUnitsNum)(
861
825
  token.valueHeldInEth,
862
826
  baseAsset.decimals
863
827
  );
@@ -873,7 +837,7 @@ var getChainAutopools = async (wagmiConfig, {
873
837
  if (underlyingTokenAddress) {
874
838
  underlyingTokens = [
875
839
  {
876
- ...(0, import_utils6.getToken)(underlyingTokenAddress, chainId),
840
+ ...(0, import_utils4.getToken)(underlyingTokenAddress, chainId),
877
841
  valueUsd: debtValueHeldByVaultEth * baseAssetPrice,
878
842
  value: debtValueHeldByVaultEth
879
843
  }
@@ -885,11 +849,11 @@ var getChainAutopools = async (wagmiConfig, {
885
849
  ...destination,
886
850
  debtValueHeldByVaultUsd: debtValueHeldByVaultEth * baseAssetPrice,
887
851
  debtValueHeldByVaultEth,
888
- compositeReturn: isGenStrat ? genStratAprs?.[autopool.poolAddress]?.[destination.vaultAddress]?.apr || 0 : (0, import_utils6.formatEtherNum)(destination.compositeReturn),
852
+ compositeReturn: isGenStrat ? genStratAprs?.[autopool.poolAddress]?.[destination.vaultAddress]?.apr || 0 : (0, import_utils4.formatEtherNum)(destination.compositeReturn),
889
853
  debtValueHeldByVaultAllocation: debtValueHeldByVaultEth / totalAssets,
890
854
  underlyingTokens,
891
- poolName: (0, import_utils6.formatPoolName)(destination.lpTokenName),
892
- exchange: (0, import_utils6.getProtocol)(destination.exchangeName)
855
+ poolName: (0, import_utils4.formatPoolName)(destination.lpTokenName),
856
+ exchange: (0, import_utils4.getProtocol)(destination.exchangeName)
893
857
  };
894
858
  });
895
859
  const HIDDEN_DESTINATION_SYMBOLS = ["USR", "WSTUSR"];
@@ -900,7 +864,7 @@ var getChainAutopools = async (wagmiConfig, {
900
864
  );
901
865
  const uniqueExchanges = Array.from(
902
866
  new Set(
903
- filteredDestinations.map((d) => (0, import_utils6.getProtocol)(d.exchangeName)).filter(Boolean)
867
+ filteredDestinations.map((d) => (0, import_utils4.getProtocol)(d.exchangeName)).filter(Boolean)
904
868
  )
905
869
  );
906
870
  const uniqueExchangesWithValueHeld = uniqueExchanges.map((exchange) => {
@@ -936,15 +900,18 @@ var getChainAutopools = async (wagmiConfig, {
936
900
  },
937
901
  []
938
902
  );
939
- const uniqueTokensWithValueHeldMap = filteredDestinations.flatMap((d) => d.underlyingTokens).reduce((acc, token) => {
940
- if (acc[token.address]) {
941
- acc[token.address].valueUsd += token.valueUsd;
942
- acc[token.address].value += token.value;
943
- } else {
944
- acc[token.address] = { ...token };
945
- }
946
- return acc;
947
- }, {});
903
+ const uniqueTokensWithValueHeldMap = filteredDestinations.flatMap((d) => d.underlyingTokens).reduce(
904
+ (acc, token) => {
905
+ if (acc[token.address]) {
906
+ acc[token.address].valueUsd += token.valueUsd;
907
+ acc[token.address].value += token.value;
908
+ } else {
909
+ acc[token.address] = { ...token };
910
+ }
911
+ return acc;
912
+ },
913
+ {}
914
+ );
948
915
  const HIDDEN_TOKEN_SYMBOLS = ["USR", "WSTUSR"];
949
916
  const uniqueTokens = Object.values(uniqueTokensWithValueHeldMap).filter(
950
917
  (token) => !HIDDEN_TOKEN_SYMBOLS.includes(token.symbol?.toUpperCase())
@@ -973,24 +940,12 @@ var getChainAutopools = async (wagmiConfig, {
973
940
  const aprs = autopoolsApr.find(
974
941
  (autopoolApr) => (0, import_viem2.getAddress)(autopoolApr.id) === (0, import_viem2.getAddress)(autopool.poolAddress)
975
942
  );
976
- let baseApr = aprs?.baseApy !== void 0 ? aprs.baseApy / 100 : void 0;
943
+ const baseApr = aprs?.baseApy !== void 0 ? aprs.baseApy / 100 : void 0;
977
944
  let extraApr = 0;
978
- if (baseApr === void 0) {
979
- try {
980
- const backupApr = await getBackupApr(chainId, autopool.poolAddress);
981
- if (backupApr) {
982
- baseApr = backupApr;
983
- console.log("using backup apr", backupApr);
984
- }
985
- } catch (e) {
986
- console.error(e);
987
- console.log("unable to retrieve backup apr");
988
- }
989
- }
990
945
  let extraRewards = [];
991
946
  if (aprs?.rewards && aprs.rewards.length > 0) {
992
947
  extraRewards = aprs.rewards.map((reward) => {
993
- const token = (0, import_utils6.getToken)(reward.rewardToken, chainId);
948
+ const token = (0, import_utils4.getToken)(reward.rewardToken, chainId);
994
949
  return {
995
950
  ...token,
996
951
  apr: reward.rewardApy / 100
@@ -998,8 +953,8 @@ var getChainAutopools = async (wagmiConfig, {
998
953
  });
999
954
  }
1000
955
  extraApr = extraRewards.reduce((acc, reward) => acc + reward.apr, 0);
1001
- if (baseApr === void 0) baseApr = 0;
1002
- const combinedApr = baseApr + extraApr;
956
+ const baseForMath = baseApr ?? 0;
957
+ const combinedApr = baseForMath + extraApr;
1003
958
  let denominatedToken = import_tokenlist3.ETH_TOKEN;
1004
959
  let useDenominatedValues = false;
1005
960
  const denominationData = autopoolsDenomination.find(
@@ -1009,7 +964,7 @@ var getChainAutopools = async (wagmiConfig, {
1009
964
  if (denominatedIn?.symbol?.toLowerCase() === "weth") {
1010
965
  denominatedToken = import_tokenlist3.ETH_TOKEN;
1011
966
  } else {
1012
- denominatedToken = (0, import_utils6.getToken)(denominatedIn?.id);
967
+ denominatedToken = (0, import_utils4.getToken)(denominatedIn?.id);
1013
968
  if (denominatedToken) {
1014
969
  useDenominatedValues = true;
1015
970
  }
@@ -1024,12 +979,12 @@ var getChainAutopools = async (wagmiConfig, {
1024
979
  tokenAddress: denominatedToken.address
1025
980
  }) || 0;
1026
981
  }
1027
- const navPerShareBaseAsset = (0, import_utils6.formatUnitsNum)(
982
+ const navPerShareBaseAsset = (0, import_utils4.formatUnitsNum)(
1028
983
  autopool.navPerShare,
1029
984
  baseAsset.decimals
1030
985
  );
1031
986
  const assets = convertBaseAssetToTokenPricesAndDenom(
1032
- (0, import_utils6.formatUnitsNum)(autopool.totalAssets, baseAsset.decimals),
987
+ (0, import_utils4.formatUnitsNum)(autopool.totalAssets, baseAsset.decimals),
1033
988
  baseAssetPrice,
1034
989
  denominatedTokenPrice,
1035
990
  prices
@@ -1054,7 +1009,7 @@ var getChainAutopools = async (wagmiConfig, {
1054
1009
  prices
1055
1010
  );
1056
1011
  const baseDailyEarnings = convertBaseAssetToTokenPricesAndDenom(
1057
- totalAssets * baseApr / import_constants6.DAYS_PER_YEAR,
1012
+ totalAssets * baseForMath / import_constants6.DAYS_PER_YEAR,
1058
1013
  baseAssetPrice,
1059
1014
  denominatedTokenPrice,
1060
1015
  prices
@@ -1062,36 +1017,39 @@ var getChainAutopools = async (wagmiConfig, {
1062
1017
  const tokenOrder = [UIBaseAsset.symbol, ...UITokenOrder].filter(
1063
1018
  (value, index, array) => array.indexOf(value) === index
1064
1019
  );
1065
- const UITokens = uniqueTokens.reduce((acc, token) => {
1066
- try {
1067
- const parentAsset = token.extensions?.parentAsset;
1068
- if (parentAsset) {
1069
- const parentToken = import_tokenlist3.ALL_TOKENS.find(
1070
- (t) => t.symbol.toLowerCase() === parentAsset.toLowerCase()
1071
- );
1072
- if (parentToken && !acc.some(
1073
- (t) => t?.address?.toLowerCase() === parentToken?.address?.toLowerCase()
1020
+ const UITokens = uniqueTokens.reduce(
1021
+ (acc, token) => {
1022
+ try {
1023
+ const parentAsset = token.extensions?.parentAsset;
1024
+ if (parentAsset) {
1025
+ const parentToken = import_tokenlist3.ALL_TOKENS.find(
1026
+ (t) => t.symbol.toLowerCase() === parentAsset.toLowerCase()
1027
+ );
1028
+ if (parentToken && !acc.some(
1029
+ (t) => t?.address?.toLowerCase() === parentToken?.address?.toLowerCase()
1030
+ )) {
1031
+ acc.push({
1032
+ ...parentToken,
1033
+ valueUsd: 0,
1034
+ value: 0,
1035
+ allocation: 0
1036
+ });
1037
+ }
1038
+ } else if (!acc.some(
1039
+ (t) => t?.address?.toLowerCase() === token?.address?.toLowerCase()
1074
1040
  )) {
1075
- acc.push({
1076
- ...parentToken,
1077
- valueUsd: 0,
1078
- value: 0,
1079
- allocation: 0
1080
- });
1041
+ acc.push(token);
1081
1042
  }
1082
- } else if (!acc.some(
1083
- (t) => t?.address?.toLowerCase() === token?.address?.toLowerCase()
1084
- )) {
1085
- acc.push(token);
1043
+ } catch (error) {
1044
+ console.warn(
1045
+ `Error processing token: ${token?.symbol || "unknown"}`,
1046
+ error
1047
+ );
1086
1048
  }
1087
- } catch (error) {
1088
- console.warn(
1089
- `Error processing token: ${token?.symbol || "unknown"}`,
1090
- error
1091
- );
1092
- }
1093
- return acc;
1094
- }, []).sort((a, b) => {
1049
+ return acc;
1050
+ },
1051
+ []
1052
+ ).sort((a, b) => {
1095
1053
  try {
1096
1054
  const aIndex = tokenOrder.indexOf(a.symbol.toUpperCase());
1097
1055
  const bIndex = tokenOrder.indexOf(b.symbol.toUpperCase());
@@ -1134,7 +1092,7 @@ var getChainAutopools = async (wagmiConfig, {
1134
1092
  });
1135
1093
  const autopoolInfo = getAutopoolInfo(autopool.symbol);
1136
1094
  if (autopoolInfo && !autopoolInfo.description) {
1137
- autopoolInfo.description = `Autopool featuring ${UIBaseAsset.symbol} deployed across integrated DEXs and lending protocols on ${(0, import_utils6.getNetwork)(chainId)?.name}.`;
1095
+ autopoolInfo.description = `Autopool featuring ${UIBaseAsset.symbol} deployed across integrated DEXs and lending protocols on ${(0, import_utils4.getNetwork)(chainId)?.name}.`;
1138
1096
  }
1139
1097
  return {
1140
1098
  ...autopool,
@@ -1160,9 +1118,9 @@ var getChainAutopools = async (wagmiConfig, {
1160
1118
  UITokens,
1161
1119
  UIExchanges: finalUIExchanges,
1162
1120
  tokens: uniqueTokens,
1163
- chain: (0, import_utils6.getNetwork)(chainId),
1121
+ chain: (0, import_utils4.getNetwork)(chainId),
1164
1122
  apr: {
1165
- base: baseApr,
1123
+ base: baseApr ?? null,
1166
1124
  extraAprs: extraRewards,
1167
1125
  combined: combinedApr,
1168
1126
  hasExtraAprs: extraRewards.length > 0
@@ -1200,12 +1158,13 @@ var getAutopools = async (wagmiConfig, {
1200
1158
  try {
1201
1159
  const chains = getChainsForEnv({ includeTestnet });
1202
1160
  const autopools = (await Promise.all(
1203
- chains.map(
1204
- (chain) => getChainAutopools(wagmiConfig, {
1161
+ chains.map((chain) => {
1162
+ const chainId = chain?.chainId;
1163
+ return getChainAutopools((0, import_core.getPublicClient)(wagmiConfig, { chainId }), {
1205
1164
  prices,
1206
- chainId: chain?.chainId
1207
- })
1208
- )
1165
+ chainId
1166
+ });
1167
+ })
1209
1168
  )).flat();
1210
1169
  const sortedAutopoolsByTimestamp = autopools.sort(
1211
1170
  (a, b) => b.timestamp - a.timestamp
@@ -1252,7 +1211,7 @@ var getAutopoolsRebalances = async (chainId = 1) => {
1252
1211
 
1253
1212
  // functions/getAutopoolDayData.ts
1254
1213
  var import_viem4 = require("viem");
1255
- var import_utils10 = require("@tokemak/utils");
1214
+ var import_utils8 = require("@tokemak/utils");
1256
1215
  var import_constants7 = require("@tokemak/constants");
1257
1216
  var import_graph_cli4 = require("@tokemak/graph-cli");
1258
1217
  var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_constants7.TOKEMAK_LAUNCH_TIMESTAMP) => {
@@ -1267,10 +1226,10 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_co
1267
1226
  const navPerShare = Number(autoPoolDayData.nav) / Number(autoPoolDayData.totalSupply) * Math.pow(10, 18 - baseDecimals);
1268
1227
  let baseApy = autoPoolDayData.autopoolApy;
1269
1228
  let rewarderApy = 0;
1270
- const formattedRewarder7DayMAApy = (0, import_utils10.formatEtherNum)(
1229
+ const formattedRewarder7DayMAApy = (0, import_utils8.formatEtherNum)(
1271
1230
  BigInt(Number(autoPoolDayData.rewarderDay7MAApy) || 0)
1272
1231
  );
1273
- const formattedRewarder30DayMAApy = (0, import_utils10.formatEtherNum)(
1232
+ const formattedRewarder30DayMAApy = (0, import_utils8.formatEtherNum)(
1274
1233
  BigInt(Number(autoPoolDayData.rewarderDay30MAApy) || 0)
1275
1234
  );
1276
1235
  if (formattedRewarder7DayMAApy) {
@@ -1398,7 +1357,7 @@ var getAutopoolsHistory = async (autopools, days, includeTestnet = false) => {
1398
1357
  var import_viem6 = require("viem");
1399
1358
  var import_core2 = require("@wagmi/core");
1400
1359
  var import_abis2 = require("@tokemak/abis");
1401
- var import_utils12 = require("@tokemak/utils");
1360
+ var import_utils10 = require("@tokemak/utils");
1402
1361
  var getAutopoolUser = async (config, {
1403
1362
  autopool,
1404
1363
  address,
@@ -1440,14 +1399,14 @@ var getAutopoolUser = async (config, {
1440
1399
  args: [address],
1441
1400
  chainId: autopool?.chain?.chainId
1442
1401
  });
1443
- const stakedShares = (0, import_utils12.formatEtherNum)(stakedPoolShares);
1402
+ const stakedShares = (0, import_utils10.formatEtherNum)(stakedPoolShares);
1444
1403
  const staked = convertBaseAssetToTokenPricesAndDenom(
1445
1404
  stakedShares * (autopool?.navPerShare.baseAsset || 0),
1446
1405
  autopool?.baseAsset.price,
1447
1406
  autopool?.denomination.price,
1448
1407
  prices
1449
1408
  );
1450
- const unstakedShares = (0, import_utils12.formatEtherNum)(unstakedPoolShares || 0n);
1409
+ const unstakedShares = (0, import_utils10.formatEtherNum)(unstakedPoolShares || 0n);
1451
1410
  const unstaked = convertBaseAssetToTokenPricesAndDenom(
1452
1411
  unstakedShares * (autopool?.navPerShare.baseAsset || 0),
1453
1412
  autopool?.baseAsset.price,
@@ -1462,7 +1421,7 @@ var getAutopoolUser = async (config, {
1462
1421
  prices
1463
1422
  );
1464
1423
  const totalDeposits = convertBaseAssetToTokenPricesAndDenom(
1465
- (0, import_utils12.formatUnitsNum)(
1424
+ (0, import_utils10.formatUnitsNum)(
1466
1425
  userActivity?.totals[autopool?.poolAddress]?.totalDeposits || 0n,
1467
1426
  autopool?.baseAsset.decimals
1468
1427
  ),
@@ -1471,7 +1430,7 @@ var getAutopoolUser = async (config, {
1471
1430
  prices
1472
1431
  );
1473
1432
  const totalWithdrawals = convertBaseAssetToTokenPricesAndDenom(
1474
- (0, import_utils12.formatUnitsNum)(
1433
+ (0, import_utils10.formatUnitsNum)(
1475
1434
  userActivity?.totals[autopool?.poolAddress]?.totalWithdrawals || 0n,
1476
1435
  autopool?.baseAsset.decimals
1477
1436
  ),
@@ -1496,7 +1455,7 @@ var getAutopoolUser = async (config, {
1496
1455
  );
1497
1456
  let lastDeposit;
1498
1457
  if (poolEvents && poolEvents?.length > 0) {
1499
- lastDeposit = (0, import_utils12.convertTimestampToDate)(
1458
+ lastDeposit = (0, import_utils10.convertTimestampToDate)(
1500
1459
  poolEvents[poolEvents.length - 1].timestamp
1501
1460
  ).toLocaleDateString("en-US", {
1502
1461
  day: "2-digit",
@@ -1530,7 +1489,7 @@ var getAutopoolUser = async (config, {
1530
1489
 
1531
1490
  // functions/getAutopoolUserActivity.ts
1532
1491
  var import_graph_cli6 = require("@tokemak/graph-cli");
1533
- var import_utils15 = require("@tokemak/utils");
1492
+ var import_utils13 = require("@tokemak/utils");
1534
1493
  var getAutopoolUserActivity = async ({
1535
1494
  autopool,
1536
1495
  userAddress
@@ -1592,7 +1551,7 @@ var getAutopoolUserActivity = async ({
1592
1551
  } else {
1593
1552
  eventType = "Unknown";
1594
1553
  }
1595
- const netDeposits = (0, import_utils15.formatUnitsNum)(
1554
+ const netDeposits = (0, import_utils13.formatUnitsNum)(
1596
1555
  userActivityTotals[activity.vaultAddress].totalDeposits - userActivityTotals[activity.vaultAddress].totalWithdrawals,
1597
1556
  autopool.baseAsset.decimals
1598
1557
  );
@@ -1620,7 +1579,7 @@ var getAutopoolUserActivity = async ({
1620
1579
  var import_graph_cli7 = require("@tokemak/graph-cli");
1621
1580
  var import_constants8 = require("@tokemak/constants");
1622
1581
  var import_chains3 = require("viem/chains");
1623
- var import_utils17 = require("@tokemak/utils");
1582
+ var import_utils15 = require("@tokemak/utils");
1624
1583
  var getAutopoolUserHistory = async ({
1625
1584
  userAddress,
1626
1585
  autopool,
@@ -1671,8 +1630,8 @@ var getAutopoolUserHistory = async ({
1671
1630
  const matchingAutopoolDayData = autopoolDayData.find(
1672
1631
  (autopoolDay) => autopoolDay.date.toDateString() === userVaultDayData.date.toDateString()
1673
1632
  );
1674
- const userPortionOfVault = (0, import_utils17.formatEtherNum)(userVaultDayData.totalShares) / (0, import_utils17.formatEtherNum)(matchingAutopoolDayData?.totalSupply);
1675
- const userNav = userPortionOfVault * (0, import_utils17.formatUnitsNum)(
1633
+ const userPortionOfVault = (0, import_utils15.formatEtherNum)(userVaultDayData.totalShares) / (0, import_utils15.formatEtherNum)(matchingAutopoolDayData?.totalSupply);
1634
+ const userNav = userPortionOfVault * (0, import_utils15.formatUnitsNum)(
1676
1635
  BigInt(matchingAutopoolDayData?.nav || 0),
1677
1636
  autopool?.baseAsset.decimals
1678
1637
  );
@@ -2852,7 +2811,7 @@ var getRewardsPayloadV1 = async (cycleHash, account, rewardsV1Url) => {
2852
2811
  // functions/getUserAutoEthRewards.ts
2853
2812
  var import_abis4 = require("@tokemak/abis");
2854
2813
  var import_core6 = require("@wagmi/core");
2855
- var import_utils19 = require("@tokemak/utils");
2814
+ var import_utils17 = require("@tokemak/utils");
2856
2815
  var getAutoEthRewards = async (wagmiConfig, {
2857
2816
  account,
2858
2817
  currentCycleIndex,
@@ -2890,7 +2849,7 @@ var getAutoEthRewards = async (wagmiConfig, {
2890
2849
  const currentAmount = Number(drippingHashPayload?.summary?.currentAmount);
2891
2850
  const previousAmount = Number(drippingHashPayload?.summary?.previousAmount);
2892
2851
  const cycleDuration = 604800;
2893
- const lastCycleStart = (0, import_utils19.convertChainCycleToUnix)(Number(currentCycleIndex));
2852
+ const lastCycleStart = (0, import_utils17.convertChainCycleToUnix)(Number(currentCycleIndex));
2894
2853
  const timeSinceCycleStart = Date.now() / 1e3 - lastCycleStart;
2895
2854
  const currentUserRewards = currentAmount * Math.min(timeSinceCycleStart, cycleDuration) / cycleDuration + previousAmount;
2896
2855
  const lastWeekRewards = Number(lastWeekHashPayload?.summary?.currentAmount);
@@ -2911,7 +2870,7 @@ var getUserAutoEthRewards = async (wagmiConfig, rewardsV1Url, rewardsHash, addre
2911
2870
  rewardsHash,
2912
2871
  chainId
2913
2872
  });
2914
- const currentUserRewardsUsd = (0, import_utils19.formatCurrency)(
2873
+ const currentUserRewardsUsd = (0, import_utils17.formatCurrency)(
2915
2874
  ethPrice * (autoETHRewards?.currentUserRewards || 0)
2916
2875
  );
2917
2876
  return { ...autoETHRewards, currentUserRewardsUsd };
@@ -3099,11 +3058,11 @@ var getChainUserAutopoolsHistory = async ({
3099
3058
  };
3100
3059
 
3101
3060
  // functions/getUserAutopoolsHistory.ts
3102
- var import_utils23 = require("@tokemak/utils");
3061
+ var import_utils21 = require("@tokemak/utils");
3103
3062
 
3104
3063
  // functions/getTokenValueDayDatas.ts
3105
3064
  var import_chains10 = require("viem/chains");
3106
- var import_utils20 = require("@tokemak/utils");
3065
+ var import_utils18 = require("@tokemak/utils");
3107
3066
  var import_viem10 = require("viem");
3108
3067
  var import_graph_cli10 = require("@tokemak/graph-cli");
3109
3068
  var getTokenValueDayDatas = async (tokenAddress, chainId = import_chains10.mainnet.id) => {
@@ -3113,7 +3072,7 @@ var getTokenValueDayDatas = async (tokenAddress, chainId = import_chains10.mainn
3113
3072
  tokenAddress: tokenAddress.toLowerCase()
3114
3073
  });
3115
3074
  const historicalPrice = tokenValueDayDatas.map((tokenValueDayData) => {
3116
- const date = (0, import_utils20.convertTimestampToDate)(
3075
+ const date = (0, import_utils18.convertTimestampToDate)(
3117
3076
  tokenValueDayData.lastSnapshotTimestamp
3118
3077
  );
3119
3078
  const usdPrice = (0, import_viem10.formatUnits)(tokenValueDayData.priceInUsd, 8);
@@ -3273,7 +3232,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
3273
3232
  Math.floor(sharesRatio * Number(SCALE))
3274
3233
  );
3275
3234
  const navBigInt = sharesRatioBigInt * BigInt(dayData.nav) / SCALE;
3276
- const navNum = (0, import_utils23.formatUnitsNum)(
3235
+ const navNum = (0, import_utils21.formatUnitsNum)(
3277
3236
  navBigInt,
3278
3237
  dayData.baseAsset.decimals
3279
3238
  );
@@ -3344,7 +3303,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
3344
3303
  let finalAggregatedHistoryArray = Object.keys(aggregatedHistoryArray).map(
3345
3304
  (dateKey) => ({
3346
3305
  date: aggregatedHistoryArray[dateKey].date,
3347
- formattedDate: (0, import_utils23.formatDateToReadable)(aggregatedHistoryArray[dateKey].date),
3306
+ formattedDate: (0, import_utils21.formatDateToReadable)(aggregatedHistoryArray[dateKey].date),
3348
3307
  nav: {
3349
3308
  ETH: aggregatedHistoryArray[dateKey].nav.ETH,
3350
3309
  USD: aggregatedHistoryArray[dateKey].nav.USD,
@@ -3392,7 +3351,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
3392
3351
  return sum;
3393
3352
  }
3394
3353
  const decimals = vault.baseAsset.decimals;
3395
- const assetChangeNum = (0, import_utils23.formatUnitsNum)(
3354
+ const assetChangeNum = (0, import_utils21.formatUnitsNum)(
3396
3355
  BigInt(event.assetChange || 0n),
3397
3356
  decimals
3398
3357
  );
@@ -3636,13 +3595,13 @@ var getChainUserAutopools = async ({
3636
3595
  };
3637
3596
 
3638
3597
  // functions/getUserAutopools.ts
3639
- var import_utils25 = require("@tokemak/utils");
3598
+ var import_utils23 = require("@tokemak/utils");
3640
3599
  var import_tokenlist7 = require("@tokemak/tokenlist");
3641
3600
 
3642
3601
  // functions/getUserAutopool.tsx
3643
3602
  var import_viem11 = require("viem");
3644
3603
  var import_core12 = require("@wagmi/core");
3645
- var import_utils24 = require("@tokemak/utils");
3604
+ var import_utils22 = require("@tokemak/utils");
3646
3605
  var import_abis10 = require("@tokemak/abis");
3647
3606
  var getUserAutopool = async (wagmiConfig, {
3648
3607
  address,
@@ -3691,10 +3650,10 @@ var getUserAutopool = async (wagmiConfig, {
3691
3650
  args: [address],
3692
3651
  chainId: autopool?.chain?.chainId
3693
3652
  });
3694
- const stakedShares = (0, import_utils24.formatEtherNum)(stakedPoolShares);
3653
+ const stakedShares = (0, import_utils22.formatEtherNum)(stakedPoolShares);
3695
3654
  const stakedNav = stakedShares * (autopool?.navPerShare.baseAsset || 0);
3696
3655
  const stakedNavUsd = stakedShares * (autopool?.navPerShare.USD || 0);
3697
- const unstakedShares = (0, import_utils24.formatEtherNum)(unstakedPoolShares || 0n);
3656
+ const unstakedShares = (0, import_utils22.formatEtherNum)(unstakedPoolShares || 0n);
3698
3657
  const unstakedNav = unstakedShares * (autopool?.navPerShare.USD || 0);
3699
3658
  const unstakedNavUsd = unstakedShares * (autopool?.navPerShare.USD || 0);
3700
3659
  const totalShares = unstakedShares + stakedShares;
@@ -3715,7 +3674,7 @@ var getUserAutopool = async (wagmiConfig, {
3715
3674
  });
3716
3675
  pastRewarderBalances = pastRewards.map(({ result }, index) => {
3717
3676
  const balance = result;
3718
- const shares = (0, import_utils24.formatEtherNum)(result);
3677
+ const shares = (0, import_utils22.formatEtherNum)(result);
3719
3678
  const nav = shares * (autopool?.navPerShare.baseAsset || 0);
3720
3679
  const navUsd = shares * (autopool?.navPerShare.USD || 0);
3721
3680
  return {
@@ -3833,14 +3792,14 @@ var getUserAutopools = async ({
3833
3792
  );
3834
3793
  if (autopoolData) {
3835
3794
  const isDOLA = autopoolData.symbol === "autoDOLA" && userAutoDOLA;
3836
- const userShares = isDOLA ? userAutoDOLA?.totalShares : (0, import_utils25.formatEtherNum)(userAutopool?.totalShares);
3837
- const totalVaultShares = (0, import_utils25.formatEtherNum)(autopoolData?.totalSupply);
3795
+ const userShares = isDOLA ? userAutoDOLA?.totalShares : (0, import_utils23.formatEtherNum)(userAutopool?.totalShares);
3796
+ const totalVaultShares = (0, import_utils23.formatEtherNum)(autopoolData?.totalSupply);
3838
3797
  const userShareOfVault = userShares / totalVaultShares;
3839
- const totalDeposits = (0, import_utils25.formatUnitsNum)(
3798
+ const totalDeposits = (0, import_utils23.formatUnitsNum)(
3840
3799
  userActivity?.totals[userAutopool.vaultAddress]?.totalDeposits || 0n,
3841
3800
  autopoolData?.baseAsset.decimals
3842
3801
  );
3843
- const totalWithdrawals = (0, import_utils25.formatUnitsNum)(
3802
+ const totalWithdrawals = (0, import_utils23.formatUnitsNum)(
3844
3803
  userActivity?.totals[userAutopool.vaultAddress]?.totalWithdrawals || 0n,
3845
3804
  autopoolData?.baseAsset.decimals
3846
3805
  );
@@ -3849,7 +3808,7 @@ var getUserAutopools = async ({
3849
3808
  );
3850
3809
  let lastDeposit;
3851
3810
  if (poolEvents && poolEvents?.length > 0) {
3852
- lastDeposit = (0, import_utils25.convertTimestampToDate)(
3811
+ lastDeposit = (0, import_utils23.convertTimestampToDate)(
3853
3812
  poolEvents[poolEvents.length - 1].timestamp
3854
3813
  ).toLocaleDateString("en-US", {
3855
3814
  day: "2-digit",
@@ -3949,7 +3908,7 @@ var getUserAutopools = async ({
3949
3908
  totalWithdrawals: prev.totalWithdrawals + totalWithdrawals
3950
3909
  };
3951
3910
  const stakedBalance = isDOLA ? userAutoDOLA?.staked.balance : BigInt(userAutopool?.stakedShares);
3952
- const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : (0, import_utils25.formatEtherNum)(stakedBalance);
3911
+ const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : (0, import_utils23.formatEtherNum)(stakedBalance);
3953
3912
  const stakedNav = stakedShares * (autopoolData?.navPerShare.baseAsset || 0);
3954
3913
  const staked = convertBaseAssetToTokenPrices(
3955
3914
  stakedNav,
@@ -3957,7 +3916,7 @@ var getUserAutopools = async ({
3957
3916
  prices
3958
3917
  );
3959
3918
  const unstakedBalance = isDOLA ? userAutoDOLA?.unstaked.balance : BigInt(userAutopool?.walletShares);
3960
- const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : (0, import_utils25.formatEtherNum)(unstakedBalance);
3919
+ const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : (0, import_utils23.formatEtherNum)(unstakedBalance);
3961
3920
  const unstakedNav = unstakedShares * (autopoolData?.navPerShare.baseAsset || 0);
3962
3921
  const unstaked = convertBaseAssetToTokenPrices(
3963
3922
  unstakedNav,
@@ -3966,7 +3925,7 @@ var getUserAutopools = async ({
3966
3925
  );
3967
3926
  const stakedRatio = stakedShares / userShares;
3968
3927
  const unstakedRatio = 1 - stakedRatio;
3969
- const blendedApr = stakedRatio * autopoolData?.apr?.combined + unstakedRatio * autopoolData?.apr?.base;
3928
+ const blendedApr = stakedRatio * autopoolData?.apr?.combined + unstakedRatio * (autopoolData?.apr?.base ?? 0);
3970
3929
  return {
3971
3930
  name: autopoolData?.name,
3972
3931
  symbol: autopoolData?.symbol,
@@ -4008,13 +3967,16 @@ var getUserAutopools = async ({
4008
3967
  denominatedToken = autopoolWithDenomination?.denomination;
4009
3968
  }
4010
3969
  }
4011
- const nav = Object.values(categories).reduce((acc, { nav: nav2 }) => {
4012
- return Object.keys(nav2).reduce((sumAcc, key) => {
4013
- const typedKey = key;
4014
- sumAcc[typedKey] = (sumAcc[typedKey] || 0) + nav2[typedKey];
4015
- return sumAcc;
4016
- }, acc);
4017
- }, {});
3970
+ const nav = Object.values(categories).reduce(
3971
+ (acc, { nav: nav2 }) => {
3972
+ return Object.keys(nav2).reduce((sumAcc, key) => {
3973
+ const typedKey = key;
3974
+ sumAcc[typedKey] = (sumAcc[typedKey] || 0) + nav2[typedKey];
3975
+ return sumAcc;
3976
+ }, acc);
3977
+ },
3978
+ {}
3979
+ );
4018
3980
  const idleWithTokenPrices = userAutopoolsWithData.reduce(
4019
3981
  (acc, userAutopool) => {
4020
3982
  if (!userAutopool) return acc;
@@ -4042,20 +4004,26 @@ var getUserAutopools = async ({
4042
4004
  ...idle2,
4043
4005
  allocation: idle2.USD / nav.USD
4044
4006
  }));
4045
- const returns = Object.values(categories).reduce((acc, { returns: returns2 }) => {
4046
- return Object.keys(returns2).reduce((sumAcc, key) => {
4047
- const typedKey = key;
4048
- sumAcc[typedKey] = (sumAcc[typedKey] || 0) + returns2[typedKey];
4049
- return sumAcc;
4050
- }, acc);
4051
- }, {});
4052
- const supplied = Object.values(categories).reduce((acc, { supplied: supplied2 }) => {
4053
- return Object.keys(supplied2).reduce((sumAcc, key) => {
4054
- const typedKey = key;
4055
- sumAcc[typedKey] = (sumAcc[typedKey] || 0) + supplied2[typedKey];
4056
- return sumAcc;
4057
- }, acc);
4058
- }, {});
4007
+ const returns = Object.values(categories).reduce(
4008
+ (acc, { returns: returns2 }) => {
4009
+ return Object.keys(returns2).reduce((sumAcc, key) => {
4010
+ const typedKey = key;
4011
+ sumAcc[typedKey] = (sumAcc[typedKey] || 0) + returns2[typedKey];
4012
+ return sumAcc;
4013
+ }, acc);
4014
+ },
4015
+ {}
4016
+ );
4017
+ const supplied = Object.values(categories).reduce(
4018
+ (acc, { supplied: supplied2 }) => {
4019
+ return Object.keys(supplied2).reduce((sumAcc, key) => {
4020
+ const typedKey = key;
4021
+ sumAcc[typedKey] = (sumAcc[typedKey] || 0) + supplied2[typedKey];
4022
+ return sumAcc;
4023
+ }, acc);
4024
+ },
4025
+ {}
4026
+ );
4059
4027
  const userExchangesWithAllocations = Object.values(userExchanges).map(
4060
4028
  (userExchange) => {
4061
4029
  return {
@@ -4117,11 +4085,14 @@ var getUserAutopools = async ({
4117
4085
  categories[categoryKey] = {
4118
4086
  ...categoryData,
4119
4087
  apr,
4120
- avgDailyReturns: Object.keys(categoryData.nav).reduce((acc, key) => {
4121
- const typedKey = key;
4122
- acc[typedKey] = dailyRate * categoryData.nav[typedKey];
4123
- return acc;
4124
- }, {})
4088
+ avgDailyReturns: Object.keys(categoryData.nav).reduce(
4089
+ (acc, key) => {
4090
+ const typedKey = key;
4091
+ acc[typedKey] = dailyRate * categoryData.nav[typedKey];
4092
+ return acc;
4093
+ },
4094
+ {}
4095
+ )
4125
4096
  };
4126
4097
  });
4127
4098
  return {
@@ -4314,7 +4285,7 @@ var getChainUserAutopoolsRewards = async (wagmiConfig, {
4314
4285
  };
4315
4286
 
4316
4287
  // functions/getUserAutopoolsRewards.ts
4317
- var import_utils29 = require("@tokemak/utils");
4288
+ var import_utils27 = require("@tokemak/utils");
4318
4289
  var import_tokenlist9 = require("@tokemak/tokenlist");
4319
4290
  var import_chains11 = require("viem/chains");
4320
4291
  var getUserAutopoolsRewards = async (wagmiConfig, {
@@ -4345,7 +4316,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
4345
4316
  return [];
4346
4317
  }
4347
4318
  return autopool.extraRewarders.map((extraRewards2) => {
4348
- const rewarderToken = (0, import_utils29.getToken)(
4319
+ const rewarderToken = (0, import_utils27.getToken)(
4349
4320
  extraRewards2.rewardToken?.id,
4350
4321
  autopool.chain?.chainId
4351
4322
  );
@@ -4354,7 +4325,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
4354
4325
  if (rewarderToken.symbol === "XSILO") {
4355
4326
  price = tokenPrices[import_tokenlist9.SILO_TOKEN.symbol] || 0;
4356
4327
  }
4357
- const formattedAmount = (0, import_utils29.formatUnitsNum)(
4328
+ const formattedAmount = (0, import_utils27.formatUnitsNum)(
4358
4329
  claimableAmount,
4359
4330
  rewarderToken.decimals || 18
4360
4331
  );
@@ -4372,7 +4343,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
4372
4343
  const tokenRewards = {};
4373
4344
  Object.values(chainUserRewards).forEach((autopoolRewards) => {
4374
4345
  Object.entries(autopoolRewards).forEach(([tokenAddress, amount]) => {
4375
- const token = (0, import_utils29.getToken)(tokenAddress, chainId);
4346
+ const token = (0, import_utils27.getToken)(tokenAddress, chainId);
4376
4347
  const tokenSymbol = token.symbol;
4377
4348
  if (!tokenRewards[tokenSymbol]) {
4378
4349
  tokenRewards[tokenSymbol] = {
@@ -4392,7 +4363,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
4392
4363
  if (tokenSymbol === "XSILO") {
4393
4364
  price = tokenPrices[import_tokenlist9.SILO_TOKEN.symbol] || 0;
4394
4365
  }
4395
- const formattedAmount = (0, import_utils29.formatUnitsNum)(amount, decimals || 18);
4366
+ const formattedAmount = (0, import_utils27.formatUnitsNum)(amount, decimals || 18);
4396
4367
  tokenRewards[tokenSymbol] = {
4397
4368
  amount,
4398
4369
  formattedAmount,
@@ -4463,7 +4434,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
4463
4434
 
4464
4435
  // functions/getAmountWithdrawn.ts
4465
4436
  var import_viem16 = require("viem");
4466
- var import_utils31 = require("@tokemak/utils");
4437
+ var import_utils29 = require("@tokemak/utils");
4467
4438
 
4468
4439
  // functions/getSwapQuote.ts
4469
4440
  var import_constants16 = require("@tokemak/constants");
@@ -4677,7 +4648,7 @@ var getAmountWithdrawn = async ({
4677
4648
  let quote;
4678
4649
  let convertedAssets;
4679
4650
  if (!!dynamicSwap?.previewRedeem) {
4680
- const minAmountWithSlippage = (0, import_utils31.calculateMinAmountWithSlippage)(
4651
+ const minAmountWithSlippage = (0, import_utils29.calculateMinAmountWithSlippage)(
4681
4652
  dynamicSwap?.previewRedeem,
4682
4653
  slippage
4683
4654
  );
@@ -4701,7 +4672,7 @@ var getAmountWithdrawn = async ({
4701
4672
  buyToken,
4702
4673
  sellToken,
4703
4674
  sellAmount: dynamicSwap?.previewRedeem,
4704
- slippageBps: (0, import_utils31.convertNumToBps)(slippage),
4675
+ slippageBps: (0, import_utils29.convertNumToBps)(slippage),
4705
4676
  chainId,
4706
4677
  includeSources: "0xV2",
4707
4678
  sellAll: true
@@ -4729,7 +4700,7 @@ var getAmountWithdrawn = async ({
4729
4700
  // functions/getAmountDeposited.ts
4730
4701
  var import_core18 = require("@wagmi/core");
4731
4702
  var import_abis15 = require("@tokemak/abis");
4732
- var import_utils32 = require("@tokemak/utils");
4703
+ var import_utils30 = require("@tokemak/utils");
4733
4704
  var getAmountDeposited = async ({
4734
4705
  address,
4735
4706
  chainId,
@@ -4750,13 +4721,13 @@ var getAmountDeposited = async ({
4750
4721
  chainId
4751
4722
  });
4752
4723
  if (!isSwap) {
4753
- let minAmountWithSlippage = (0, import_utils32.calculateMinAmountWithSlippage)(
4724
+ let minAmountWithSlippage = (0, import_utils30.calculateMinAmountWithSlippage)(
4754
4725
  previewDeposit,
4755
4726
  slippage
4756
4727
  );
4757
- return (0, import_utils32.formatEtherNum)(minAmountWithSlippage);
4728
+ return (0, import_utils30.formatEtherNum)(minAmountWithSlippage);
4758
4729
  } else {
4759
- return (0, import_utils32.formatEtherNum)(previewDeposit);
4730
+ return (0, import_utils30.formatEtherNum)(previewDeposit);
4760
4731
  }
4761
4732
  } catch (e) {
4762
4733
  console.error(e);
@@ -4874,7 +4845,7 @@ var waitForMessageReceived = async ({
4874
4845
  // functions/getChainUserSToke.ts
4875
4846
  var import_abis18 = require("@tokemak/abis");
4876
4847
  var import_config13 = require("@tokemak/config");
4877
- var import_utils33 = require("@tokemak/utils");
4848
+ var import_utils31 = require("@tokemak/utils");
4878
4849
  var import_core21 = require("@wagmi/core");
4879
4850
  var import_viem18 = require("viem");
4880
4851
  var import_chains13 = require("viem/chains");
@@ -4950,8 +4921,8 @@ var getChainUserSToke = async (wagmiConfig, {
4950
4921
  if (withdrawalAmount > 0n && cycleIndex >= withdrawalMinCycle) {
4951
4922
  balanceExcludingWithdrawal = balanceExcludingWithdrawal - withdrawalAmount;
4952
4923
  }
4953
- const withdrawalAmountUsd = (0, import_utils33.formatCurrency)(
4954
- (0, import_utils33.formatEtherNum)(withdrawalAmount) * tokePrice
4924
+ const withdrawalAmountUsd = (0, import_utils31.formatCurrency)(
4925
+ (0, import_utils31.formatEtherNum)(withdrawalAmount) * tokePrice
4955
4926
  );
4956
4927
  const lockDuration = Number(depositLockDuration);
4957
4928
  const lockCycle = Number(depositLockCycle);
@@ -4972,16 +4943,16 @@ var getChainUserSToke = async (wagmiConfig, {
4972
4943
  const withdrawAvailable = lockRenew - 1;
4973
4944
  const hasAddedLockedToke = depositAmount > 0n && depositAmount > rolloverDepositAmount;
4974
4945
  const addedLockedToke = depositAmount - rolloverDepositAmount;
4975
- const balanceUSD = (0, import_utils33.formatCurrency)(
4946
+ const balanceUSD = (0, import_utils31.formatCurrency)(
4976
4947
  Number((0, import_viem18.formatEther)(balanceExcludingWithdrawal)) * tokePrice
4977
4948
  );
4978
- const balanceExcludingWithdrawalUsd = (0, import_utils33.formatCurrency)(
4979
- (0, import_utils33.formatEtherNum)(balanceExcludingWithdrawal) * tokePrice
4949
+ const balanceExcludingWithdrawalUsd = (0, import_utils31.formatCurrency)(
4950
+ (0, import_utils31.formatEtherNum)(balanceExcludingWithdrawal) * tokePrice
4980
4951
  );
4981
4952
  const isUnlockRequestAvailable = currentCycle === withdrawAvailable;
4982
4953
  const hasRequestedUnlock = withdrawalAmount > 0n;
4983
- const unlockRequestPeriodStartUnix = (0, import_utils33.convertChainCycleToUnix)(withdrawAvailable, chainId) - Date.now() / 1e3;
4984
- const unlockRequestPeriodEndUnix = (0, import_utils33.convertChainCycleToUnix)(lockRenew, chainId) - Date.now() / 1e3;
4954
+ const unlockRequestPeriodStartUnix = (0, import_utils31.convertChainCycleToUnix)(withdrawAvailable, chainId) - Date.now() / 1e3;
4955
+ const unlockRequestPeriodEndUnix = (0, import_utils31.convertChainCycleToUnix)(lockRenew, chainId) - Date.now() / 1e3;
4985
4956
  const hasBalance = balance > 0n;
4986
4957
  const hasBalanceExcludingWithdrawal = balanceExcludingWithdrawal > 0n;
4987
4958
  const hasUnlockableBalance = withdrawalMinCycle <= currentCycle && withdrawalAmount > 0n;
@@ -4991,8 +4962,8 @@ var getChainUserSToke = async (wagmiConfig, {
4991
4962
  lockDurationInMonths = lockDuration - 1;
4992
4963
  }
4993
4964
  const unlockPeriodDateRangeArray = [
4994
- new Date((0, import_utils33.convertChainCycleToUnix)(withdrawAvailable, chainId) * 1e3),
4995
- new Date((0, import_utils33.convertChainCycleToUnix)(lockRenew, chainId) * 1e3)
4965
+ new Date((0, import_utils31.convertChainCycleToUnix)(withdrawAvailable, chainId) * 1e3),
4966
+ new Date((0, import_utils31.convertChainCycleToUnix)(lockRenew, chainId) * 1e3)
4996
4967
  ];
4997
4968
  const {
4998
4969
  unlockPeriodDateRange,
@@ -5004,18 +4975,18 @@ var getChainUserSToke = async (wagmiConfig, {
5004
4975
  unlockPeriodDateRangeArray,
5005
4976
  chainId === import_chains13.sepolia.id ? "time" : "date"
5006
4977
  );
5007
- const totalActiveUserCredits = (0, import_utils33.formatEtherNum)(balanceExcludingWithdrawal) * lockDurationInMonths;
5008
- const totalUserCredits = (0, import_utils33.formatEtherNum)(balance) * lockDurationInMonths;
4978
+ const totalActiveUserCredits = (0, import_utils31.formatEtherNum)(balanceExcludingWithdrawal) * lockDurationInMonths;
4979
+ const totalUserCredits = (0, import_utils31.formatEtherNum)(balance) * lockDurationInMonths;
5009
4980
  return {
5010
4981
  balance,
5011
4982
  balanceUSD,
5012
4983
  balanceExcludingWithdrawal: hasBalance ? (0, import_viem18.formatEther)(balanceExcludingWithdrawal) : "0.00",
5013
4984
  balanceExcludingWithdrawalUsd,
5014
4985
  hasBalanceExcludingWithdrawal,
5015
- timeLeftBeforeUnlockRequestAvailable: (0, import_utils33.convertSecondsToRemainingTime)(
4986
+ timeLeftBeforeUnlockRequestAvailable: (0, import_utils31.convertSecondsToRemainingTime)(
5016
4987
  unlockRequestPeriodStartUnix
5017
4988
  ),
5018
- timeLeftBeforeUnlockRequestUnavailable: (0, import_utils33.convertSecondsToRemainingTime)(
4989
+ timeLeftBeforeUnlockRequestUnavailable: (0, import_utils31.convertSecondsToRemainingTime)(
5019
4990
  unlockRequestPeriodEndUnix
5020
4991
  ),
5021
4992
  withdrawalAmount,
@@ -5032,7 +5003,7 @@ var getChainUserSToke = async (wagmiConfig, {
5032
5003
  unlockRenewalDate,
5033
5004
  lockDurationInMonths,
5034
5005
  boost: lockDuration,
5035
- points: (0, import_utils33.formatEtherNum)(balanceExcludingWithdrawal) * lockDuration,
5006
+ points: (0, import_utils31.formatEtherNum)(balanceExcludingWithdrawal) * lockDuration,
5036
5007
  totalActiveCredits: totalActiveUserCredits,
5037
5008
  totalCredits: totalUserCredits
5038
5009
  };
@@ -5044,7 +5015,7 @@ var getChainUserSToke = async (wagmiConfig, {
5044
5015
  };
5045
5016
 
5046
5017
  // functions/getUserSToke.ts
5047
- var import_utils35 = require("@tokemak/utils");
5018
+ var import_utils33 = require("@tokemak/utils");
5048
5019
  var getUserSToke = async (wagmiConfig, {
5049
5020
  address,
5050
5021
  tokePrice,
@@ -5071,8 +5042,8 @@ var getUserSToke = async (wagmiConfig, {
5071
5042
  }
5072
5043
  return acc;
5073
5044
  }, 0n);
5074
- const totalBalance = (0, import_utils35.formatEtherNum)(totalBalanceRaw || 0n);
5075
- const totalBalanceUsd = (0, import_utils35.formatCurrency)(totalBalance * tokePrice);
5045
+ const totalBalance = (0, import_utils33.formatEtherNum)(totalBalanceRaw || 0n);
5046
+ const totalBalanceUsd = (0, import_utils33.formatCurrency)(totalBalance * tokePrice);
5076
5047
  const hasBalance = totalBalance > 0;
5077
5048
  return {
5078
5049
  chains: { ...userSToke },
@@ -5089,9 +5060,9 @@ var getUserSToke = async (wagmiConfig, {
5089
5060
  var import_viem19 = require("viem");
5090
5061
  var import_core22 = require("@wagmi/core");
5091
5062
  var import_abis19 = require("@tokemak/abis");
5092
- var import_utils37 = require("@tokemak/utils");
5063
+ var import_utils35 = require("@tokemak/utils");
5093
5064
  var import_config14 = require("@tokemak/config");
5094
- var import_utils38 = require("@tokemak/utils");
5065
+ var import_utils36 = require("@tokemak/utils");
5095
5066
  var getChainSToke = async (wagmiConfig, {
5096
5067
  tokePrice,
5097
5068
  chainId
@@ -5117,15 +5088,15 @@ var getChainSToke = async (wagmiConfig, {
5117
5088
  ]
5118
5089
  });
5119
5090
  const tvl = Number((0, import_viem19.formatEther)(totalSupply || 0n)) * tokePrice;
5120
- const secondsLeftBeforeNextCycle = (0, import_utils37.convertChainCycleToUnix)(Number(currentCycle) + 1, chainId) - Date.now() / 1e3;
5091
+ const secondsLeftBeforeNextCycle = (0, import_utils35.convertChainCycleToUnix)(Number(currentCycle) + 1, chainId) - Date.now() / 1e3;
5121
5092
  return {
5122
5093
  rawTotalSupply: totalSupply,
5123
- totalSupply: (0, import_utils37.formatLargeNumber)((0, import_viem19.formatEther)(totalSupply || 0n)),
5124
- tvl: (0, import_utils37.formatTVL)(tvl),
5094
+ totalSupply: (0, import_utils35.formatLargeNumber)((0, import_viem19.formatEther)(totalSupply || 0n)),
5095
+ tvl: (0, import_utils35.formatTVL)(tvl),
5125
5096
  rawTVL: tvl,
5126
5097
  currentCycle,
5127
- chain: (0, import_utils38.getNetwork)(chainId),
5128
- timeBeforeNextCycle: (0, import_utils37.convertSecondsToRemainingTime)(
5098
+ chain: (0, import_utils36.getNetwork)(chainId),
5099
+ timeBeforeNextCycle: (0, import_utils35.convertSecondsToRemainingTime)(
5129
5100
  secondsLeftBeforeNextCycle
5130
5101
  )
5131
5102
  };
@@ -5136,7 +5107,7 @@ var getChainSToke = async (wagmiConfig, {
5136
5107
  };
5137
5108
 
5138
5109
  // functions/getSToke.ts
5139
- var import_utils39 = require("@tokemak/utils");
5110
+ var import_utils37 = require("@tokemak/utils");
5140
5111
  var import_viem20 = require("viem");
5141
5112
  var getSToke = async (wagmiConfig, {
5142
5113
  tokePrice,
@@ -5156,14 +5127,14 @@ var getSToke = async (wagmiConfig, {
5156
5127
  }
5157
5128
  return acc;
5158
5129
  }, 0n);
5159
- const totalSupply = (0, import_utils39.formatLargeNumber)((0, import_viem20.formatEther)(totalSupplyBigInt || 0n));
5130
+ const totalSupply = (0, import_utils37.formatLargeNumber)((0, import_viem20.formatEther)(totalSupplyBigInt || 0n));
5160
5131
  let tvlNum = Object.values(sToke).reduce((acc, item) => {
5161
5132
  if (item && item.rawTVL) {
5162
5133
  return acc + item.rawTVL;
5163
5134
  }
5164
5135
  return acc;
5165
5136
  }, 0);
5166
- const tvl = (0, import_utils39.formatTVL)(tvlNum);
5137
+ const tvl = (0, import_utils37.formatTVL)(tvlNum);
5167
5138
  return { totalSupply, rawTotalSupply: totalSupplyBigInt, tvl, rawTVL: tvlNum, chains: { ...sToke } };
5168
5139
  } catch (e) {
5169
5140
  console.error(e);
@@ -5217,7 +5188,7 @@ var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
5217
5188
  // functions/getChainSTokeRewards.ts
5218
5189
  var import_config15 = require("@tokemak/config");
5219
5190
  var import_viem21 = require("viem");
5220
- var import_utils41 = require("@tokemak/utils");
5191
+ var import_utils39 = require("@tokemak/utils");
5221
5192
  var import_graph_cli15 = require("@tokemak/graph-cli");
5222
5193
  var getChainSTokeRewards = async ({
5223
5194
  chainId
@@ -5241,9 +5212,9 @@ var getChainSTokeRewards = async ({
5241
5212
  if (!whitelistedPools.includes(pool.id.toLowerCase())) {
5242
5213
  continue;
5243
5214
  }
5244
- const convertedBalance = (0, import_utils41.formatEtherNum)(pool.balance);
5215
+ const convertedBalance = (0, import_utils39.formatEtherNum)(pool.balance);
5245
5216
  const convertedBalanceUSD = Number((0, import_viem21.formatUnits)(pool.balanceUSD, 8));
5246
- const convertedApr = (0, import_utils41.formatEtherNum)(pool.currentAprPerCredit);
5217
+ const convertedApr = (0, import_utils39.formatEtherNum)(pool.currentAprPerCredit);
5247
5218
  if (minApr === null || convertedApr < minApr) {
5248
5219
  minApr = convertedApr;
5249
5220
  }
@@ -5317,7 +5288,7 @@ var getSTokeRewards = async ({
5317
5288
 
5318
5289
  // functions/getChainUserSTokeRewards.ts
5319
5290
  var import_config16 = require("@tokemak/config");
5320
- var import_utils44 = require("@tokemak/utils");
5291
+ var import_utils42 = require("@tokemak/utils");
5321
5292
  var getChainUserSTokeRewards = async (wagmiConfig, {
5322
5293
  address,
5323
5294
  chainId,
@@ -5368,14 +5339,14 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
5368
5339
  throw fallbackError;
5369
5340
  }
5370
5341
  }
5371
- const claimableNum = (0, import_utils44.formatEtherNum)(tokeRewards?.claimable || 0n);
5342
+ const claimableNum = (0, import_utils42.formatEtherNum)(tokeRewards?.claimable || 0n);
5372
5343
  const claimableUsd = tokePrice * claimableNum;
5373
5344
  const hasClaimable = claimableNum > 0n;
5374
- const pendingRewards = (0, import_utils44.formatEtherNum)(
5345
+ const pendingRewards = (0, import_utils42.formatEtherNum)(
5375
5346
  tokeRewards?.rewardsPayload.breakdown?.totalRewardAmount || 0n
5376
5347
  );
5377
5348
  const pendingRewardsUsd = tokePrice * pendingRewards;
5378
- const totalRewardsReceived = (0, import_utils44.formatEtherNum)(
5349
+ const totalRewardsReceived = (0, import_utils42.formatEtherNum)(
5379
5350
  tokeRewards.rewardsPayload.payload.amount || 0n
5380
5351
  );
5381
5352
  const totalRewardsReceivedUsd = tokePrice * totalRewardsReceived;
@@ -5394,26 +5365,7 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
5394
5365
  // functions/getTokenPrices.ts
5395
5366
  var import_tokenlist12 = require("@tokemak/tokenlist");
5396
5367
  var import_constants18 = require("@tokemak/constants");
5397
-
5398
- // functions/getBackupTokenPrices.ts
5399
- var getBackupTokenPrices = async () => {
5400
- try {
5401
- const backupData = await getBlobData(`getTokenPrices-latest-success.json`);
5402
- if (backupData) {
5403
- return backupData;
5404
- }
5405
- } catch (e) {
5406
- console.error(e);
5407
- return void 0;
5408
- }
5409
- return void 0;
5410
- };
5411
-
5412
- // functions/getTokenPrices.ts
5413
- var isStale = (timestamp) => {
5414
- return timestamp - Math.floor(Date.now() / 1e3) > 5 * 60;
5415
- };
5416
- var getTokenPrices = async (isCronJob = false) => {
5368
+ var getTokenPrices = async () => {
5417
5369
  try {
5418
5370
  const body = {
5419
5371
  tokens: import_tokenlist12.PRICED_TOKENS.map((asset) => ({
@@ -5451,27 +5403,12 @@ var getTokenPrices = async (isCronJob = false) => {
5451
5403
  }
5452
5404
  };
5453
5405
  } catch (e) {
5454
- if (isCronJob) {
5455
- return {
5456
- prices: void 0,
5457
- timestamp: void 0,
5458
- isStale: false
5459
- };
5460
- } else {
5461
- const backupPrices = await getBackupTokenPrices();
5462
- if (backupPrices) {
5463
- return {
5464
- prices: backupPrices.prices,
5465
- timestamp: backupPrices.timestamp,
5466
- isStale: isStale(backupPrices.timestamp)
5467
- };
5468
- }
5469
- return {
5470
- prices: void 0,
5471
- timestamp: void 0,
5472
- isStale: false
5473
- };
5474
- }
5406
+ console.error("getTokenPrices failed:", e);
5407
+ return {
5408
+ prices: void 0,
5409
+ timestamp: void 0,
5410
+ isStale: false
5411
+ };
5475
5412
  }
5476
5413
  };
5477
5414
 
@@ -5535,7 +5472,7 @@ var getSubgraphStatus = async (includeTestnet = false) => {
5535
5472
  var import_core24 = require("@wagmi/core");
5536
5473
  var import_abis21 = require("@tokemak/abis");
5537
5474
  var import_viem22 = require("viem");
5538
- var import_utils46 = require("@tokemak/utils");
5475
+ var import_utils44 = require("@tokemak/utils");
5539
5476
  var import_config17 = require("@tokemak/config");
5540
5477
  var import_chains14 = require("viem/chains");
5541
5478
  var publicClient = (0, import_viem22.createPublicClient)({
@@ -5569,11 +5506,11 @@ var getCycleV1 = async (wagmiConfig, {
5569
5506
  });
5570
5507
  const rolloverEvents = await publicClient.getFilterLogs({ filter });
5571
5508
  const cycleRolloverBlockNumber = chainId === 1 ? rolloverEvents[rolloverEvents.length - 1]?.blockNumber : rolloverEvents[rolloverEvents.length - 1]?.blockNumber || currentBlockNumber;
5572
- const secondsLeftBeforeNextCycle = (0, import_utils46.convertChainCycleToUnix)(Number(currentCycleIndex) + 1) - Date.now() / 1e3;
5509
+ const secondsLeftBeforeNextCycle = (0, import_utils44.convertChainCycleToUnix)(Number(currentCycleIndex) + 1) - Date.now() / 1e3;
5573
5510
  return {
5574
5511
  currentCycleIndex,
5575
5512
  cycleRolloverBlockNumber,
5576
- timeBeforeNextCycle: (0, import_utils46.convertSecondsToRemainingTime)(
5513
+ timeBeforeNextCycle: (0, import_utils44.convertSecondsToRemainingTime)(
5577
5514
  secondsLeftBeforeNextCycle
5578
5515
  )
5579
5516
  };
@@ -5584,7 +5521,7 @@ var getCycleV1 = async (wagmiConfig, {
5584
5521
  };
5585
5522
 
5586
5523
  // functions/getProtocolStats.ts
5587
- var import_utils47 = require("@tokemak/utils");
5524
+ var import_utils45 = require("@tokemak/utils");
5588
5525
  var getProtocolStats = async (autopools, stoke, sushiLP, sauto, EthAutoLP) => {
5589
5526
  try {
5590
5527
  if (!autopools || !stoke || !sushiLP) {
@@ -5614,12 +5551,12 @@ var getProtocolStats = async (autopools, stoke, sushiLP, sauto, EthAutoLP) => {
5614
5551
  Object.entries(categories).map(([key, value]) => [
5615
5552
  key,
5616
5553
  {
5617
- tvl: (0, import_utils47.formatTVL)(value.tvl),
5618
- supply: (0, import_utils47.formatLargeNumber)(value.supply || 0)
5554
+ tvl: (0, import_utils45.formatTVL)(value.tvl),
5555
+ supply: (0, import_utils45.formatLargeNumber)(value.supply || 0)
5619
5556
  }
5620
5557
  ])
5621
5558
  );
5622
- const tvl = (0, import_utils47.formatTVL)(
5559
+ const tvl = (0, import_utils45.formatTVL)(
5623
5560
  autopoolTVL + stoke.rawTVL + (sushiLP?.tvl || 0) + (EthAutoLP?.tvlUsd || 0) + (sauto?.rawTVL || 0)
5624
5561
  );
5625
5562
  const vaultAddresses = autopools?.flatMap(
@@ -5628,33 +5565,33 @@ var getProtocolStats = async (autopools, stoke, sushiLP, sauto, EthAutoLP) => {
5628
5565
  const uniqueVaultAddresses = [...new Set(vaultAddresses)];
5629
5566
  const totalDestinations = uniqueVaultAddresses.length;
5630
5567
  const stakedTVL = {
5631
- totalSupply: (0, import_utils47.formatLargeNumber)(
5632
- (0, import_utils47.formatEtherNum)(
5568
+ totalSupply: (0, import_utils45.formatLargeNumber)(
5569
+ (0, import_utils45.formatEtherNum)(
5633
5570
  (sauto?.rawTotalSupply || 0n) + (stoke.rawTotalSupply || 0n)
5634
5571
  )
5635
5572
  ),
5636
- tvl: (0, import_utils47.formatTVL)((sauto?.rawTVL || 0) + stoke.rawTVL)
5573
+ tvl: (0, import_utils45.formatTVL)((sauto?.rawTVL || 0) + stoke.rawTVL)
5637
5574
  };
5638
5575
  return {
5639
5576
  autopools: {
5640
- tvl: (0, import_utils47.formatTVL)(autopoolTVL),
5577
+ tvl: (0, import_utils45.formatTVL)(autopoolTVL),
5641
5578
  tvlNum: autopoolTVL,
5642
5579
  categories: formattedCategories
5643
5580
  },
5644
5581
  stoke: {
5645
- tvl: (0, import_utils47.formatTVL)(stoke.rawTVL),
5582
+ tvl: (0, import_utils45.formatTVL)(stoke.rawTVL),
5646
5583
  tvlNum: stoke.rawTVL,
5647
5584
  totalSupply: `${stoke.totalSupply} TOKE`
5648
5585
  },
5649
5586
  sushiLP: {
5650
- tvl: (0, import_utils47.formatTVL)(sushiLP?.tvl || 0),
5587
+ tvl: (0, import_utils45.formatTVL)(sushiLP?.tvl || 0),
5651
5588
  totalSupply: sushiLP?.totalSupply || 0
5652
5589
  },
5653
5590
  EthAutoLP: {
5654
- tvl: (0, import_utils47.formatTVL)(EthAutoLP?.tvlUsd || 0)
5591
+ tvl: (0, import_utils45.formatTVL)(EthAutoLP?.tvlUsd || 0)
5655
5592
  },
5656
5593
  sauto: {
5657
- tvl: (0, import_utils47.formatTVL)(sauto?.rawTVL || 0),
5594
+ tvl: (0, import_utils45.formatTVL)(sauto?.rawTVL || 0),
5658
5595
  tvlNum: sauto?.rawTVL || 0,
5659
5596
  totalSupply: `${sauto?.totalSupply} AUTO`
5660
5597
  },
@@ -5673,27 +5610,25 @@ var import_graph_cli17 = require("@tokemak/graph-cli");
5673
5610
 
5674
5611
  // functions/getEthPriceAtBlock.ts
5675
5612
  var import_config18 = require("@tokemak/config");
5676
- var import_core25 = require("@wagmi/core");
5677
5613
  var import_abis22 = require("@tokemak/abis");
5678
5614
  var import_tokenlist13 = require("@tokemak/tokenlist");
5679
- var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
5615
+ var getEthPriceAtBlock = async (client, blockNumber, chainId) => {
5680
5616
  const config = (0, import_config18.getCoreConfig)(chainId);
5681
5617
  const rootPriceOracle = config.rootPriceOracle;
5682
5618
  const weth = config.weth;
5683
5619
  const usdc = import_tokenlist13.USDC_TOKEN.extensions?.bridgeInfo?.[chainId]?.tokenAddress || import_tokenlist13.USDC_TOKEN.address;
5684
- const priceAtBlock = await (0, import_core25.readContract)(wagmiConfig, {
5620
+ const priceAtBlock = await client.readContract({
5685
5621
  address: rootPriceOracle,
5686
5622
  abi: import_abis22.rootPriceOracleAbi,
5687
5623
  functionName: "getPriceInQuote",
5688
5624
  args: [weth, usdc],
5689
- blockNumber,
5690
- chainId
5625
+ blockNumber
5691
5626
  });
5692
5627
  return priceAtBlock;
5693
5628
  };
5694
5629
 
5695
5630
  // functions/getRebalanceStats.ts
5696
- var import_utils49 = require("@tokemak/utils");
5631
+ var import_utils47 = require("@tokemak/utils");
5697
5632
  var import_tokenlist14 = require("@tokemak/tokenlist");
5698
5633
  var import_chains15 = require("viem/chains");
5699
5634
  var BATCH_SIZE = 500;
@@ -5717,17 +5652,17 @@ function inferBaseAssetDecimals(rebalance, chainId) {
5717
5652
  }
5718
5653
  return import_tokenlist14.USDC_TOKEN.decimals;
5719
5654
  }
5720
- var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
5655
+ var getRebalanceValueUsd = async (rebalance, chainId, client) => {
5721
5656
  const ethWei = BigInt(rebalance.tokenOutValueInEth || "0");
5722
5657
  if (ethWei === 0n) return null;
5723
5658
  try {
5724
5659
  const price = await getEthPriceAtBlock(
5725
- wagmiConfig,
5660
+ client,
5726
5661
  BigInt(rebalance.blockNumber),
5727
5662
  chainId
5728
5663
  );
5729
- const ethUsd = Number((0, import_utils49.formatUnitsNum)(price, import_tokenlist14.USDC_TOKEN.decimals));
5730
- const ethAmt = Number((0, import_utils49.formatEtherNum)(ethWei));
5664
+ const ethUsd = Number((0, import_utils47.formatUnitsNum)(price, import_tokenlist14.USDC_TOKEN.decimals));
5665
+ const ethAmt = Number((0, import_utils47.formatEtherNum)(ethWei));
5731
5666
  const usd = ethAmt * ethUsd;
5732
5667
  return usd;
5733
5668
  } catch (e) {
@@ -5735,19 +5670,15 @@ var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
5735
5670
  return null;
5736
5671
  }
5737
5672
  };
5738
- var processRebalance = async (rebalance, chainId, wagmiConfig) => {
5673
+ var processRebalance = async (rebalance, chainId, client) => {
5739
5674
  const baseDecimals = inferBaseAssetDecimals(rebalance, chainId);
5740
5675
  const baseAssetAmount = Number(
5741
- (0, import_utils49.formatUnitsNum)(
5676
+ (0, import_utils47.formatUnitsNum)(
5742
5677
  BigInt(rebalance.tokenOutValueBaseAsset || "0"),
5743
5678
  baseDecimals
5744
5679
  )
5745
5680
  );
5746
- const ethPathUsd = await getRebalanceValueUsd(
5747
- rebalance,
5748
- chainId,
5749
- wagmiConfig
5750
- );
5681
+ const ethPathUsd = await getRebalanceValueUsd(rebalance, chainId, client);
5751
5682
  if (ethPathUsd != null) {
5752
5683
  return {
5753
5684
  autopool: rebalance.autopool,
@@ -5767,12 +5698,12 @@ var processRebalance = async (rebalance, chainId, wagmiConfig) => {
5767
5698
  valueInAsset: baseAssetAmount
5768
5699
  };
5769
5700
  };
5770
- var processRebalancesInBatches = async (rebalances, chainId, wagmiConfig) => {
5701
+ var processRebalancesInBatches = async (rebalances, chainId, client) => {
5771
5702
  const processedRebalances = [];
5772
5703
  for (let i = 0; i < rebalances.length; i += BATCH_SIZE) {
5773
5704
  const batch = rebalances.slice(i, i + BATCH_SIZE);
5774
5705
  const batchPromises = batch.map(
5775
- async (rebalance) => processRebalance(rebalance, chainId, wagmiConfig)
5706
+ async (rebalance) => processRebalance(rebalance, chainId, client)
5776
5707
  );
5777
5708
  const batchResults = await Promise.all(batchPromises);
5778
5709
  processedRebalances.push(...batchResults);
@@ -5797,18 +5728,15 @@ var calculateRebalanceStats = (rebalances) => {
5797
5728
  rebalances
5798
5729
  };
5799
5730
  };
5800
- var getRebalanceStats = async (wagmiConfig, {
5731
+ var getRebalanceStats = async (getClient, {
5801
5732
  includeTestnet = false
5802
5733
  }) => {
5803
5734
  const chains = getChainsForEnv({ includeTestnet });
5804
5735
  const rebalances = await Promise.all(
5805
5736
  chains.map(async (chain) => {
5806
5737
  const rawRebalances = await fetchChainRebalances(chain.chainId);
5807
- return processRebalancesInBatches(
5808
- rawRebalances,
5809
- chain.chainId,
5810
- wagmiConfig
5811
- );
5738
+ const client = getClient(chain.chainId);
5739
+ return processRebalancesInBatches(rawRebalances, chain.chainId, client);
5812
5740
  })
5813
5741
  );
5814
5742
  const allRebalances = rebalances.flat();
@@ -5816,6 +5744,7 @@ var getRebalanceStats = async (wagmiConfig, {
5816
5744
  };
5817
5745
 
5818
5746
  // functions/updateRebalanceStats.ts
5747
+ var import_core25 = require("@wagmi/core");
5819
5748
  var updateRebalanceStats = async (wagmiConfig, {
5820
5749
  currentRebalances,
5821
5750
  includeTestnet = false
@@ -5830,10 +5759,13 @@ var updateRebalanceStats = async (wagmiConfig, {
5830
5759
  )
5831
5760
  );
5832
5761
  if (newRawRebalances.length > 0) {
5762
+ const client = (0, import_core25.getPublicClient)(wagmiConfig, {
5763
+ chainId: chain.chainId
5764
+ });
5833
5765
  return processRebalancesInBatches(
5834
5766
  newRawRebalances,
5835
5767
  chain.chainId,
5836
- wagmiConfig
5768
+ client
5837
5769
  );
5838
5770
  }
5839
5771
  return [];
@@ -5847,7 +5779,7 @@ var updateRebalanceStats = async (wagmiConfig, {
5847
5779
  // functions/getUserSAuto.ts
5848
5780
  var import_abis23 = require("@tokemak/abis");
5849
5781
  var import_config19 = require("@tokemak/config");
5850
- var import_utils51 = require("@tokemak/utils");
5782
+ var import_utils49 = require("@tokemak/utils");
5851
5783
  var import_core26 = require("@wagmi/core");
5852
5784
  var import_viem23 = require("viem");
5853
5785
  var import_chains16 = require("viem/chains");
@@ -5909,8 +5841,8 @@ var getUserSAuto = async (wagmiConfig, {
5909
5841
  if (withdrawalAmount > 0n && cycleIndex >= withdrawalMinCycle) {
5910
5842
  balanceExcludingWithdrawal = balanceExcludingWithdrawal - withdrawalAmount;
5911
5843
  }
5912
- const withdrawalAmountUsd = (0, import_utils51.formatCurrency)(
5913
- (0, import_utils51.formatEtherNum)(withdrawalAmount) * autoPrice
5844
+ const withdrawalAmountUsd = (0, import_utils49.formatCurrency)(
5845
+ (0, import_utils49.formatEtherNum)(withdrawalAmount) * autoPrice
5914
5846
  );
5915
5847
  const lockDuration = Number(depositLockDuration);
5916
5848
  const lockCycle = Number(depositLockCycle);
@@ -5920,24 +5852,24 @@ var getUserSAuto = async (wagmiConfig, {
5920
5852
  const nextCycleRenewIncrement = Math.ceil((currentCycle - lockStart) / lockDuration) * lockDuration;
5921
5853
  const lockRenew = currentCycle - lockStart > lockDuration ? currentCycle === lockStart + nextCycleRenewIncrement ? lockStart + nextCycleRenewIncrement + lockDuration : lockStart + nextCycleRenewIncrement : currentCycle === lockStart + nextCycleRenewIncrement ? lockStart + nextCycleRenewIncrement + lockDuration : firstLockEnd;
5922
5854
  const withdrawAvailable = lockRenew - 1;
5923
- const balanceUSD = (0, import_utils51.formatCurrency)(
5855
+ const balanceUSD = (0, import_utils49.formatCurrency)(
5924
5856
  Number((0, import_viem23.formatEther)(balanceExcludingWithdrawal)) * autoPrice
5925
5857
  );
5926
- const balanceExcludingWithdrawalUsd = (0, import_utils51.formatCurrency)(
5927
- (0, import_utils51.formatEtherNum)(balanceExcludingWithdrawal) * autoPrice
5858
+ const balanceExcludingWithdrawalUsd = (0, import_utils49.formatCurrency)(
5859
+ (0, import_utils49.formatEtherNum)(balanceExcludingWithdrawal) * autoPrice
5928
5860
  );
5929
5861
  const isUnlockRequestAvailable = currentCycle === withdrawAvailable;
5930
5862
  const hasRequestedUnlock = withdrawalAmount > 0n;
5931
- const unlockRequestPeriodStartUnix = (0, import_utils51.convertAutoCycleToUnix)(withdrawAvailable) - Date.now() / 1e3;
5932
- const unlockRequestPeriodEndUnix = (0, import_utils51.convertAutoCycleToUnix)(lockRenew) - Date.now() / 1e3;
5863
+ const unlockRequestPeriodStartUnix = (0, import_utils49.convertAutoCycleToUnix)(withdrawAvailable) - Date.now() / 1e3;
5864
+ const unlockRequestPeriodEndUnix = (0, import_utils49.convertAutoCycleToUnix)(lockRenew) - Date.now() / 1e3;
5933
5865
  const hasBalance = balance > 0n;
5934
5866
  const hasBalanceExcludingWithdrawal = balanceExcludingWithdrawal > 0n;
5935
5867
  const hasUnlockableBalance = withdrawalMinCycle <= BigInt(currentCycle) && withdrawalAmount > 0n;
5936
5868
  const cyclesInAMonth = 4;
5937
5869
  const lockDurationInMonths = lockDuration / cyclesInAMonth;
5938
5870
  const unlockPeriodDateRangeArray = [
5939
- new Date((0, import_utils51.convertAutoCycleToUnix)(withdrawAvailable) * 1e3),
5940
- new Date((0, import_utils51.convertAutoCycleToUnix)(lockRenew) * 1e3)
5871
+ new Date((0, import_utils49.convertAutoCycleToUnix)(withdrawAvailable) * 1e3),
5872
+ new Date((0, import_utils49.convertAutoCycleToUnix)(lockRenew) * 1e3)
5941
5873
  ];
5942
5874
  const {
5943
5875
  unlockPeriodDateRange,
@@ -5946,20 +5878,20 @@ var getUserSAuto = async (wagmiConfig, {
5946
5878
  unlockPeriodStartDate,
5947
5879
  unlockRenewalDate
5948
5880
  } = formatDateRange(unlockPeriodDateRangeArray, "date");
5949
- const totalActiveUserCredits = (0, import_utils51.formatEtherNum)(balanceExcludingWithdrawal) * lockDurationInMonths;
5950
- const totalUserCredits = (0, import_utils51.formatEtherNum)(balance) * lockDurationInMonths;
5881
+ const totalActiveUserCredits = (0, import_utils49.formatEtherNum)(balanceExcludingWithdrawal) * lockDurationInMonths;
5882
+ const totalUserCredits = (0, import_utils49.formatEtherNum)(balance) * lockDurationInMonths;
5951
5883
  const hasAddedLockedAuto = depositAmount > 0n;
5952
5884
  const addedLockedAuto = depositAmount;
5953
5885
  return {
5954
5886
  balance,
5955
5887
  balanceUSD,
5956
- balanceExcludingWithdrawal: hasBalance ? (0, import_utils51.formatAmount)((0, import_viem23.formatEther)(balanceExcludingWithdrawal)) : "0.00",
5888
+ balanceExcludingWithdrawal: hasBalance ? (0, import_viem23.formatEther)(balanceExcludingWithdrawal) : "0.00",
5957
5889
  balanceExcludingWithdrawalUsd,
5958
5890
  hasBalanceExcludingWithdrawal,
5959
- timeLeftBeforeUnlockRequestAvailable: (0, import_utils51.convertSecondsToRemainingTime)(
5891
+ timeLeftBeforeUnlockRequestAvailable: (0, import_utils49.convertSecondsToRemainingTime)(
5960
5892
  unlockRequestPeriodStartUnix
5961
5893
  ),
5962
- timeLeftBeforeUnlockRequestUnavailable: (0, import_utils51.convertSecondsToRemainingTime)(
5894
+ timeLeftBeforeUnlockRequestUnavailable: (0, import_utils49.convertSecondsToRemainingTime)(
5963
5895
  unlockRequestPeriodEndUnix
5964
5896
  ),
5965
5897
  withdrawalAmount,
@@ -5976,7 +5908,7 @@ var getUserSAuto = async (wagmiConfig, {
5976
5908
  unlockRenewalDate,
5977
5909
  lockDurationInMonths,
5978
5910
  boost: lockDuration,
5979
- points: (0, import_utils51.formatEtherNum)(balanceExcludingWithdrawal) * lockDuration,
5911
+ points: (0, import_utils49.formatEtherNum)(balanceExcludingWithdrawal) * lockDuration,
5980
5912
  totalActiveCredits: totalActiveUserCredits,
5981
5913
  totalCredits: totalUserCredits,
5982
5914
  hasBalance
@@ -5991,7 +5923,7 @@ var getUserSAuto = async (wagmiConfig, {
5991
5923
  var import_viem24 = require("viem");
5992
5924
  var import_core27 = require("@wagmi/core");
5993
5925
  var import_abis24 = require("@tokemak/abis");
5994
- var import_utils53 = require("@tokemak/utils");
5926
+ var import_utils51 = require("@tokemak/utils");
5995
5927
  var import_config20 = require("@tokemak/config");
5996
5928
  var import_chains17 = require("viem/chains");
5997
5929
  var getSAuto = async (wagmiConfig, {
@@ -6019,14 +5951,14 @@ var getSAuto = async (wagmiConfig, {
6019
5951
  ]
6020
5952
  });
6021
5953
  const tvl = Number((0, import_viem24.formatEther)(totalSupply || 0n)) * autoPrice;
6022
- const secondsLeftBeforeNextCycle = (0, import_utils53.convertAutoCycleToUnix)(Number(currentCycle) + 1) - Date.now() / 1e3;
5954
+ const secondsLeftBeforeNextCycle = (0, import_utils51.convertAutoCycleToUnix)(Number(currentCycle) + 1) - Date.now() / 1e3;
6023
5955
  return {
6024
5956
  rawTotalSupply: totalSupply,
6025
- totalSupply: (0, import_utils53.formatLargeNumber)((0, import_viem24.formatEther)(totalSupply || 0n)),
6026
- tvl: (0, import_utils53.formatTVL)(tvl),
5957
+ totalSupply: (0, import_utils51.formatLargeNumber)((0, import_viem24.formatEther)(totalSupply || 0n)),
5958
+ tvl: (0, import_utils51.formatTVL)(tvl),
6027
5959
  rawTVL: tvl,
6028
5960
  currentCycle,
6029
- timeBeforeNextCycle: (0, import_utils53.convertSecondsToRemainingTime)(
5961
+ timeBeforeNextCycle: (0, import_utils51.convertSecondsToRemainingTime)(
6030
5962
  secondsLeftBeforeNextCycle
6031
5963
  )
6032
5964
  };
@@ -6038,7 +5970,7 @@ var getSAuto = async (wagmiConfig, {
6038
5970
 
6039
5971
  // functions/getSAutoRewards.ts
6040
5972
  var import_viem25 = require("viem");
6041
- var import_utils54 = require("@tokemak/utils");
5973
+ var import_utils52 = require("@tokemak/utils");
6042
5974
  var import_graph_cli18 = require("@tokemak/graph-cli");
6043
5975
  var import_chains18 = require("viem/chains");
6044
5976
  var getSAutoRewards = async () => {
@@ -6050,7 +5982,7 @@ var getSAutoRewards = async () => {
6050
5982
  "globalRewardsBalanceDayDatas"
6051
5983
  );
6052
5984
  const totalEarnings = globalRewardsBalances.reduce((acc, balance) => {
6053
- return acc + (0, import_utils54.formatEtherNum)(balance.balance);
5985
+ return acc + (0, import_utils52.formatEtherNum)(balance.balance);
6054
5986
  }, 0);
6055
5987
  const totalEarningsUsd = globalRewardsBalances.reduce((acc, balance) => {
6056
5988
  return acc + Number((0, import_viem25.formatUnits)(balance.balanceUSD, 8));
@@ -6058,13 +5990,13 @@ var getSAutoRewards = async () => {
6058
5990
  const historicalRewards = allGlobalRewardsBalanceDayDatas.map(
6059
5991
  (dayData) => ({
6060
5992
  timestamp: String(dayData.timestamp),
6061
- balance: (0, import_utils54.formatEtherNum)(dayData.balance),
5993
+ balance: (0, import_utils52.formatEtherNum)(dayData.balance),
6062
5994
  balanceUSD: Number((0, import_viem25.formatUnits)(dayData.balanceUSD, 8)),
6063
- earned: (0, import_utils54.formatEtherNum)(dayData.earned),
5995
+ earned: (0, import_utils52.formatEtherNum)(dayData.earned),
6064
5996
  earnedUSD: Number((0, import_viem25.formatUnits)(dayData.earnedUSD, 8)),
6065
- dayAprPerCredit: (0, import_utils54.formatEtherNum)(dayData.dayAprPerCredit),
6066
- formattedDate: (0, import_utils54.formatDateToReadable)(
6067
- (0, import_utils54.convertTimestampToDate)(Number(dayData.timestamp))
5997
+ dayAprPerCredit: (0, import_utils52.formatEtherNum)(dayData.dayAprPerCredit),
5998
+ formattedDate: (0, import_utils52.formatDateToReadable)(
5999
+ (0, import_utils52.convertTimestampToDate)(Number(dayData.timestamp))
6068
6000
  )
6069
6001
  })
6070
6002
  );
@@ -6081,7 +6013,7 @@ var getSAutoRewards = async () => {
6081
6013
 
6082
6014
  // functions/getUserSAutoRewards.ts
6083
6015
  var import_config21 = require("@tokemak/config");
6084
- var import_utils56 = require("@tokemak/utils");
6016
+ var import_utils54 = require("@tokemak/utils");
6085
6017
  var getUserSAutoRewards = async (wagmiConfig, { address, autoPrice }) => {
6086
6018
  const { rewardsV1Url, sAutoRewardsHash, sAutoRewards, sAuto } = (0, import_config21.getMainnetConfig)();
6087
6019
  const currentCycle = await getCurrentCycleId(wagmiConfig, {
@@ -6127,19 +6059,19 @@ var getUserSAutoRewards = async (wagmiConfig, { address, autoPrice }) => {
6127
6059
  return null;
6128
6060
  }
6129
6061
  }
6130
- const claimableNum = (0, import_utils56.formatEtherNum)(autoRewards?.claimable || 0n);
6062
+ const claimableNum = (0, import_utils54.formatEtherNum)(autoRewards?.claimable || 0n);
6131
6063
  const claimableUsd = autoPrice * claimableNum;
6132
6064
  const hasClaimable = claimableNum > 0;
6133
- let pendingRewards = (0, import_utils56.formatEtherNum)(
6065
+ let pendingRewards = (0, import_utils54.formatEtherNum)(
6134
6066
  autoRewards?.rewardsPayload.breakdown?.totalRewardAmount || 0n
6135
6067
  );
6136
6068
  if (currentCycle === 4242n) {
6137
- pendingRewards = (0, import_utils56.formatEtherNum)(
6069
+ pendingRewards = (0, import_utils54.formatEtherNum)(
6138
6070
  autoRewards?.rewardsPayload.payload.amount || 0n
6139
6071
  );
6140
6072
  }
6141
6073
  const pendingRewardsUsd = autoPrice * pendingRewards;
6142
- const totalRewardsReceived = (0, import_utils56.formatEtherNum)(
6074
+ const totalRewardsReceived = (0, import_utils54.formatEtherNum)(
6143
6075
  autoRewards.rewardsPayload.payload.amount || 0n
6144
6076
  );
6145
6077
  const totalRewardsReceivedUsd = autoPrice * totalRewardsReceived;
@@ -6174,7 +6106,7 @@ var getUserMerklRewards = async (address) => {
6174
6106
 
6175
6107
  // functions/getUserEthAutoLPRewards.ts
6176
6108
  var import_viem26 = require("viem");
6177
- var import_utils57 = require("@tokemak/utils");
6109
+ var import_utils55 = require("@tokemak/utils");
6178
6110
  var import_tokenlist15 = require("@tokemak/tokenlist");
6179
6111
  var getUserEthAutoLPRewards = async (address) => {
6180
6112
  const rewards = await getUserMerklRewards(address);
@@ -6185,8 +6117,8 @@ var getUserEthAutoLPRewards = async (address) => {
6185
6117
  const amount = autoRewards?.amount;
6186
6118
  const claimed = autoRewards?.claimed;
6187
6119
  const claimable = Number(amount) - Number(claimed);
6188
- const formattedClaimable = (0, import_utils57.formatAmount)(
6189
- (0, import_utils57.formatUnitsNum)(BigInt(claimable || 0), 18)
6120
+ const formattedClaimable = (0, import_utils55.formatAmount)(
6121
+ (0, import_utils55.formatUnitsNum)(BigInt(claimable || 0), 18)
6190
6122
  );
6191
6123
  const users = [];
6192
6124
  const tokens = [];
@@ -6240,7 +6172,7 @@ async function getMerklPoolApr({
6240
6172
  // functions/getSAutoApr.ts
6241
6173
  var import_graph_cli19 = require("@tokemak/graph-cli");
6242
6174
  var import_chains19 = require("viem/chains");
6243
- var import_utils58 = require("@tokemak/utils");
6175
+ var import_utils56 = require("@tokemak/utils");
6244
6176
  var getSAutoApr = async () => {
6245
6177
  try {
6246
6178
  const { GetSAutoApr } = (0, import_graph_cli19.getSdkByChainId)(import_chains19.mainnet.id);
@@ -6259,12 +6191,12 @@ var getSAutoApr = async () => {
6259
6191
  aprFormatted: void 0
6260
6192
  };
6261
6193
  }
6262
- const aprPerCredit = (0, import_utils58.formatEtherNum)(rawApr);
6194
+ const aprPerCredit = (0, import_utils56.formatEtherNum)(rawApr);
6263
6195
  const lockDuration = 16;
6264
6196
  const apr = aprPerCredit * lockDuration;
6265
6197
  return {
6266
6198
  apr,
6267
- aprFormatted: (0, import_utils58.formatPercent)(apr)
6199
+ aprFormatted: (0, import_utils56.formatPercent)(apr)
6268
6200
  };
6269
6201
  } catch (error) {
6270
6202
  console.error("Error fetching sAUTO APR:", error);