@1delta/margin-fetcher 0.0.110 → 0.0.112

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.js CHANGED
@@ -10819,8 +10819,9 @@ var MORPHO_LENS = {
10819
10819
  [Chain.ETHEREUM_MAINNET]: "0x4b5458BB47dCBC1a41B31b41e1a8773dE312BE9d",
10820
10820
  [Chain.PLASMA_MAINNET]: "0xcB6Eb8df68153cebF60E1872273Ef52075a5C297",
10821
10821
  [Chain.BERACHAIN]: "0x7a59ddbB76521E8982Fa3A08598C9a83b14A6C07",
10822
- [Chain.BNB_SMART_CHAIN_MAINNET]: "0xFc98b3157f0447DfbB9FdBE7d072F7DdacA1E27C"
10822
+ [Chain.BNB_SMART_CHAIN_MAINNET]: "0xFc98b3157f0447DfbB9FdBE7d072F7DdacA1E27C",
10823
10823
  // lista lens
10824
+ [Chain.UNICHAIN]: "0xA453ba397c61B0c292EA3959A858821145B2707F"
10824
10825
  };
10825
10826
  var LISTA_LENS = {
10826
10827
  [Chain.BNB_SMART_CHAIN_MAINNET]: "0xFc98b3157f0447DfbB9FdBE7d072F7DdacA1E27C"
@@ -12109,7 +12110,7 @@ var MOONWELL_LENS = {
12109
12110
  [Chain.BASE]: "0x6834770aba6c2028f448e3259ddee4bcb879d459",
12110
12111
  [Chain.MOONBEAM]: "0xe76C8B8706faC85a8Fbdcac3C42e3E7823c73994"
12111
12112
  };
12112
- var CONMPOUND_V2_LENS = {
12113
+ var COMPOUND_V2_LENS = {
12113
12114
  [Lender.VENUS]: VENUS_LENS,
12114
12115
  [Lender.MOONWELL]: MOONWELL_LENS
12115
12116
  };
@@ -12124,7 +12125,7 @@ function getCompoundV2Reserves(chainId, lender = Lender.VENUS) {
12124
12125
  }
12125
12126
  function getCompoundV2Lens(chainId, lender) {
12126
12127
  if (isVenusType(lender)) return VENUS_LENS[chainId];
12127
- return CONMPOUND_V2_LENS[lender]?.[chainId];
12128
+ return COMPOUND_V2_LENS[lender]?.[chainId];
12128
12129
  }
12129
12130
 
12130
12131
  // src/abis/compound-v2/VenusLensLegacy.ts
@@ -20132,7 +20133,7 @@ var fetchGeneralYields = async () => {
20132
20133
  method: "GET",
20133
20134
  headers: { Accept: "application/json" }
20134
20135
  }).then((r) => r.json());
20135
- return Number(res.data?.last_annualized_apr ?? 0);
20136
+ return Number(res.data?.apr_1d ?? 0);
20136
20137
  });
20137
20138
  const csusdlPromise = safeFetch("CSUSDL", async () => {
20138
20139
  const res = await fetch(FeedData.MORPHO_VAULTS, {
@@ -20161,8 +20162,16 @@ var fetchGeneralYields = async () => {
20161
20162
  vaultAddress: "0xdfc24b077bc1425ad1dea75bcb6f8158e10df303"
20162
20163
  })
20163
20164
  }).then((r) => r.json());
20164
- const apr = (res?.apr ?? 0) * 100;
20165
- return apr;
20165
+ let calculated;
20166
+ try {
20167
+ const p = res.portfolio[0][1];
20168
+ const val = p.accountValueHistory[p.accountValueHistory.length - 1][1];
20169
+ const pnl = p.pnlHistory[p.pnlHistory.length - 1][1];
20170
+ calculated = pnl / val * 100;
20171
+ } catch {
20172
+ calculated = (res?.apr ?? 0) * 100;
20173
+ }
20174
+ return calculated;
20166
20175
  });
20167
20176
  const rtokensPromise = safeFetch("RTOKENS", async () => {
20168
20177
  const res = await fetch(FeedData.RTOKENS).then((r) => r.json());
@@ -21915,7 +21924,7 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21915
21924
  const multicallPromises = chainIds.map(async (chainId) => {
21916
21925
  let aaveForks = aaves?.[chainId];
21917
21926
  if (chainId === Chain.KAIA_MAINNET)
21918
- aaveForks = aaveForks?.filter((a) => a !== Lender.KLAYBANK);
21927
+ aaveForks = aaveForks?.filter((a) => a !== Lender.KLAP);
21919
21928
  if (chainId === Chain.GNOSIS)
21920
21929
  aaveForks = aaveForks?.filter((a) => a !== Lender.AGAVE);
21921
21930
  if (chainId === Chain.ETHEREUM_MAINNET)
@@ -22068,7 +22077,8 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
22068
22077
  chainId,
22069
22078
  aaveSlice,
22070
22079
  queries,
22071
- lists[chainId]?.list
22080
+ lists[chainId]?.list,
22081
+ allPrices
22072
22082
  );
22073
22083
  offset += aaveCalls.length;
22074
22084
  const uniswapSlice = result.slice(offset, offset + uniswapCalls.length);
@@ -22828,16 +22838,27 @@ function getExponentForOracle(chainId, fork) {
22828
22838
  if (chainId === Chain.ARBITRUM_ONE && fork === Lender.RADIANT_V2) return 10n;
22829
22839
  return AAVE_V2_LENDERS.includes(fork) ? 0n : 10n;
22830
22840
  }
22831
- var parseAaveResults = (chainId, data, queries, list = {}) => {
22841
+ var parseAaveResults = (chainId, data, queries, list = {}, otherPrices = {}) => {
22832
22842
  let prices = {};
22843
+ function scaler() {
22844
+ if (chainId !== Chain.KAIA_MAINNET) return (p, l) => p;
22845
+ return (p, l) => {
22846
+ const scale = l === Lender.KLAYBANK ? otherPrices["KAIA"] ?? prices["KAIA"] : 1;
22847
+ return p * scale;
22848
+ };
22849
+ }
22850
+ const getScale = scaler();
22833
22851
  data.forEach((d, i) => {
22834
22852
  if (d !== "0x") {
22835
22853
  const details = queries[i];
22836
22854
  details.assets.forEach((a, j) => {
22837
22855
  const oracleId = list[a]?.assetGroup ?? chainId + "-" + a;
22838
- prices[oracleId] = formatAavePrice(
22839
- d[j].toString(),
22840
- getExponentForOracle(chainId, details.fork)
22856
+ prices[oracleId] = getScale(
22857
+ formatAavePrice(
22858
+ d[j].toString(),
22859
+ getExponentForOracle(chainId, details.fork)
22860
+ ),
22861
+ details.fork
22841
22862
  );
22842
22863
  });
22843
22864
  }