@1delta/margin-fetcher 0.0.87 → 0.0.90

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
@@ -7802,6 +7802,9 @@ var AAVE_V3_EMODES = (chain, lender) => {
7802
7802
  if (chain === Chain.BASE) {
7803
7803
  if (lender === Lender.AAVE_V3) return range(12);
7804
7804
  }
7805
+ if (chain === Chain.PLASMA_MAINNET) {
7806
+ if (lender === Lender.AAVE_V3) return range(12);
7807
+ }
7805
7808
  return [0, 1, 2, 3, 4, 5, 6];
7806
7809
  };
7807
7810
  function yldrBaseline(assetsToQuery, providerAddress) {
@@ -12001,7 +12004,9 @@ var getCompoundV2ReservesDataConverter = (lender, chainId, prices, additionalYie
12001
12004
  const price = prices[asset.assetGroup] ?? 0;
12002
12005
  const pausedActions = decodePausedActions(currentEntry.pausedActions);
12003
12006
  const allPaused = pausedActions[0 /* MINT */] && pausedActions[2 /* BORROW */] && pausedActions[1 /* REDEEM */] && pausedActions[3 /* REPAY */];
12004
- returnData.data[asset.address] = {
12007
+ const poolId = asset.address;
12008
+ returnData.data[poolId] = {
12009
+ poolId,
12005
12010
  asset,
12006
12011
  // interest rates
12007
12012
  depositRate: calculateRateForCompound(
@@ -19088,6 +19093,14 @@ var yobtc = "Yield Optimizer BTC::YOBTC";
19088
19093
  var yousd = "Yield Optimizer USD::YOUSD";
19089
19094
  var yoeur = "Yield Optimizer EUR::yoEUR";
19090
19095
  var hwhlp = "Hyperwave HLP::hwHLP";
19096
+ var gmx_eth_usd = "GMX Market ETH/USD::GM [WETH-USDC]";
19097
+ var gmx_btc_usd = "GMX Market BTC/USD::GM [WBTC-USDC]";
19098
+ var glv_wbtc_usdc = "GMX Liquidity Vault [WBTC-USDC]::GLV [WBTC-USDC]";
19099
+ var glv_weth_usdc = "GMX Liquidity Vault [WETH-USDC]::GLV [WETH-USDC]";
19100
+ var gmx_eth_usd_address = "0x70d95587d40a2caf56bd97485ab3eec10bee6336";
19101
+ var gmx_btc_usd_address = "0x47c031236e19d024b42f8ae6780e44a573170703";
19102
+ var glv_wbtc_usdc_address = "0xdf03eed325b82bc1d4db8b49c30ecc9e05104b96";
19103
+ var glv_weth_usdc_address = "0x528a5bac7e746c9a509a1f4f6df58a03d44279f9";
19091
19104
  var FeedData = {
19092
19105
  WSTETH: "https://eth-api.lido.fi/v1/protocol/steth/apr/sma",
19093
19106
  STMATIC: "https://polygon.lido.fi/api/stats",
@@ -19125,7 +19138,8 @@ var FeedData = {
19125
19138
  HBHYPE: "https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b",
19126
19139
  HLP: "https://api-ui.hyperliquid.xyz/info",
19127
19140
  HWHLP: "https://api.hyperwavefi.xyz/stats/latest?asset=hwhlp_999",
19128
- YO: "https://api.yo.xyz/api/v1/vault/stats"
19141
+ YO: "https://api.yo.xyz/api/v1/vault/stats",
19142
+ GMX: "https://arbitrum-api.gmxinfra.io/apy?period=1d"
19129
19143
  };
19130
19144
  function averageDataLastN(arr, n = 7) {
19131
19145
  const last = arr.slice(-n);
@@ -19345,6 +19359,28 @@ var fetchGeneralYields = async () => {
19345
19359
  [yoeur]: apyToAprPercent(yoEUR)
19346
19360
  };
19347
19361
  });
19362
+ const gmxPromise = safeFetch("GMX", async () => {
19363
+ const res = await fetch(FeedData.GMX, {
19364
+ method: "GET",
19365
+ headers: { Accept: "application/json" }
19366
+ }).then((r) => r.json());
19367
+ let rData = {};
19368
+ const markets = res.markets;
19369
+ Object.entries(markets).forEach(([m, d]) => {
19370
+ if (m.toLowerCase() === gmx_eth_usd_address)
19371
+ rData[gmx_eth_usd] = apyToApr(d.apy) * 100;
19372
+ if (m.toLowerCase() === gmx_btc_usd_address)
19373
+ rData[gmx_btc_usd] = apyToApr(d.apy) * 100;
19374
+ });
19375
+ const glvs = res.glvs;
19376
+ Object.entries(glvs).forEach(([m, d]) => {
19377
+ if (m.toLowerCase() === glv_wbtc_usdc_address)
19378
+ rData[glv_wbtc_usdc] = apyToApr(d.apy) * 100;
19379
+ if (m.toLowerCase() === glv_weth_usdc_address)
19380
+ rData[glv_weth_usdc] = apyToApr(d.apy) * 100;
19381
+ });
19382
+ return rData;
19383
+ });
19348
19384
  const susdsPromise = safeFetch("SUSDS", async () => {
19349
19385
  const res = await fetch(FeedData.SUSDS, {
19350
19386
  method: "GET",
@@ -19536,7 +19572,8 @@ var fetchGeneralYields = async () => {
19536
19572
  pendleData,
19537
19573
  hlpData,
19538
19574
  yoData,
19539
- hwhlpData
19575
+ hwhlpData,
19576
+ gmxData
19540
19577
  ] = await Promise.all([
19541
19578
  wstethPromise,
19542
19579
  ezethPromise,
@@ -19576,7 +19613,8 @@ var fetchGeneralYields = async () => {
19576
19613
  pendlePromise,
19577
19614
  hlpPromise,
19578
19615
  yoPromise,
19579
- hwhlpPromise
19616
+ hwhlpPromise,
19617
+ gmxPromise
19580
19618
  ]);
19581
19619
  const data = {
19582
19620
  intrinsicYields: {
@@ -19620,7 +19658,8 @@ var fetchGeneralYields = async () => {
19620
19658
  ...angleData,
19621
19659
  ...yearnKatanaData,
19622
19660
  ...pendleData,
19623
- ...yoData
19661
+ ...yoData,
19662
+ ...gmxData
19624
19663
  },
19625
19664
  lenderRewards: {
19626
19665
  // '167000': {
@@ -21551,7 +21590,7 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21551
21590
  Promise.all(multicallPromises),
21552
21591
  ...otherDataPromises
21553
21592
  ]);
21554
- let allPrices = {};
21593
+ let allPrices = { ...otherResults[0], ...otherResults[1] };
21555
21594
  for (const {
21556
21595
  chainId,
21557
21596
  result,
@@ -21605,7 +21644,8 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21605
21644
  const compoundV2Data = parseCompoundV2Results(
21606
21645
  chainId,
21607
21646
  compoundV2Slice,
21608
- compoundV2.names
21647
+ compoundV2.names,
21648
+ allPrices
21609
21649
  );
21610
21650
  offset += comet.calls.length;
21611
21651
  allPrices = {
@@ -21620,7 +21660,6 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21620
21660
  ...compoundV2Data
21621
21661
  };
21622
21662
  }
21623
- allPrices = { ...otherResults[0], ...allPrices, ...otherResults[1] };
21624
21663
  for (const {
21625
21664
  chainId,
21626
21665
  result,
@@ -21632,10 +21671,11 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21632
21671
  uniswapV3Calls,
21633
21672
  api3,
21634
21673
  rwa,
21635
- comet
21674
+ comet,
21675
+ compoundV2
21636
21676
  }
21637
21677
  } of chainResults) {
21638
- const morphoOffset = chainlink.calls.length + aaveCalls.length + uniswapCalls.length + uniswapV3Calls.length + api3.calls.length + comet.calls.length + rwa.calls.length;
21678
+ const morphoOffset = chainlink.calls.length + aaveCalls.length + uniswapCalls.length + uniswapV3Calls.length + api3.calls.length + comet.calls.length + compoundV2.calls.length + rwa.calls.length;
21639
21679
  const morphoResult = result.slice(morphoOffset);
21640
21680
  const morphoData = parseMorphoResults(
21641
21681
  chainId,
@@ -21746,9 +21786,9 @@ var getCompoundV2Calls = (chainId) => {
21746
21786
  switch (chainId) {
21747
21787
  case Chain.ARBITRUM_ONE: {
21748
21788
  const names = [
21749
- "GMX Market ETH/USD::GM [WETH-USDC]",
21789
+ ["GMX Market ETH/USD::GM [WETH-USDC]", 18],
21750
21790
  //
21751
- "GMX Market BTC/USD::GM [WBTC-USDC]"
21791
+ ["GMX Market BTC/USD::GM [WBTC-USDC]", 18]
21752
21792
  ];
21753
21793
  return [
21754
21794
  [
@@ -21773,18 +21813,87 @@ var getCompoundV2Calls = (chainId) => {
21773
21813
  names
21774
21814
  ];
21775
21815
  }
21816
+ case Chain.ETHEREUM_MAINNET: {
21817
+ const names = [
21818
+ ["SFRXETH", 18],
21819
+ //
21820
+ ["Super Symbiotic LRT::weETHs", 18],
21821
+ ["USDC-1 yVault::yvUSDC-1", 30],
21822
+ ["USDS-1 yVault::yvUSDS-1", 18],
21823
+ ["USDT-1 yVault::yvUSDT-1", 30],
21824
+ ["WETH-1 yVault::yvWETH-1", 18]
21825
+ ];
21826
+ return [
21827
+ [
21828
+ {
21829
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21830
+ // lens
21831
+ name: "vTokenUnderlyingPrice",
21832
+ params: [
21833
+ "0x17142a05fe678e9584FA1d88EfAC1bF181bF7ABe"
21834
+ //
21835
+ ]
21836
+ },
21837
+ {
21838
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21839
+ // lens
21840
+ name: "vTokenUnderlyingPrice",
21841
+ params: [
21842
+ "0xc42E4bfb996ED35235bda505430cBE404Eb49F77"
21843
+ //
21844
+ ]
21845
+ },
21846
+ {
21847
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21848
+ name: "vTokenUnderlyingPrice",
21849
+ params: [
21850
+ "0xf87c0a64dc3a8622D6c63265FA29137788163879"
21851
+ //
21852
+ ]
21853
+ },
21854
+ {
21855
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21856
+ name: "vTokenUnderlyingPrice",
21857
+ params: [
21858
+ "0x520d67226Bc904aC122dcE66ed2f8f61AA1ED764"
21859
+ //
21860
+ ]
21861
+ },
21862
+ {
21863
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21864
+ name: "vTokenUnderlyingPrice",
21865
+ params: [
21866
+ "0x475d0C68a8CD275c15D1F01F4f291804E445F677"
21867
+ //
21868
+ ]
21869
+ },
21870
+ {
21871
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21872
+ name: "vTokenUnderlyingPrice",
21873
+ params: [
21874
+ "0xba3916302cBA4aBcB51a01e706fC6051AaF272A0"
21875
+ //
21876
+ ]
21877
+ }
21878
+ ],
21879
+ names
21880
+ ];
21881
+ }
21776
21882
  default:
21777
21883
  return [[], []];
21778
21884
  }
21779
21885
  };
21780
- var parseCompoundV2Results = (chainId, data, names) => {
21886
+ var parseCompoundV2Results = (chainId, data, names, other = {}) => {
21781
21887
  return Object.assign(
21782
21888
  {},
21783
21889
  ...data.map((entry, index) => {
21890
+ let price = Number(parseRawAmount(entry?.underlyingPrice ?? "0", names[index][1]));
21891
+ const name = names[index][0];
21892
+ if (name === "SFRXETH") {
21893
+ price = other["ETH"] * price;
21894
+ }
21784
21895
  return {
21785
- [names[index]]: Number(
21786
- parseRawAmount(entry?.underlyingPrice ?? "0", 18)
21787
- )
21896
+ [name]: price
21788
21897
  };
21789
21898
  })
21790
21899
  );
@@ -21914,6 +22023,7 @@ function getExponentForOracle(chainId, fork) {
21914
22023
  if (chainId === Chain.XDC_NETWORK) return 0n;
21915
22024
  if (chainId === Chain.TELOS_EVM_MAINNET) return 10n;
21916
22025
  if (chainId === Chain.SONIC_MAINNET && fork === Lender.POLTER) return 10n;
22026
+ if (chainId === Chain.ARBITRUM_ONE && fork === Lender.RADIANT_V2) return 10n;
21917
22027
  return AAVE_V2_LENDERS.includes(fork) ? 0n : 10n;
21918
22028
  }
21919
22029
  var parseAaveResults = (chainId, data, queries, list = {}) => {