@1delta/margin-fetcher 0.0.88 → 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) {
@@ -19090,6 +19093,14 @@ var yobtc = "Yield Optimizer BTC::YOBTC";
19090
19093
  var yousd = "Yield Optimizer USD::YOUSD";
19091
19094
  var yoeur = "Yield Optimizer EUR::yoEUR";
19092
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";
19093
19104
  var FeedData = {
19094
19105
  WSTETH: "https://eth-api.lido.fi/v1/protocol/steth/apr/sma",
19095
19106
  STMATIC: "https://polygon.lido.fi/api/stats",
@@ -19127,7 +19138,8 @@ var FeedData = {
19127
19138
  HBHYPE: "https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b",
19128
19139
  HLP: "https://api-ui.hyperliquid.xyz/info",
19129
19140
  HWHLP: "https://api.hyperwavefi.xyz/stats/latest?asset=hwhlp_999",
19130
- 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"
19131
19143
  };
19132
19144
  function averageDataLastN(arr, n = 7) {
19133
19145
  const last = arr.slice(-n);
@@ -19347,6 +19359,28 @@ var fetchGeneralYields = async () => {
19347
19359
  [yoeur]: apyToAprPercent(yoEUR)
19348
19360
  };
19349
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
+ });
19350
19384
  const susdsPromise = safeFetch("SUSDS", async () => {
19351
19385
  const res = await fetch(FeedData.SUSDS, {
19352
19386
  method: "GET",
@@ -19538,7 +19572,8 @@ var fetchGeneralYields = async () => {
19538
19572
  pendleData,
19539
19573
  hlpData,
19540
19574
  yoData,
19541
- hwhlpData
19575
+ hwhlpData,
19576
+ gmxData
19542
19577
  ] = await Promise.all([
19543
19578
  wstethPromise,
19544
19579
  ezethPromise,
@@ -19578,7 +19613,8 @@ var fetchGeneralYields = async () => {
19578
19613
  pendlePromise,
19579
19614
  hlpPromise,
19580
19615
  yoPromise,
19581
- hwhlpPromise
19616
+ hwhlpPromise,
19617
+ gmxPromise
19582
19618
  ]);
19583
19619
  const data = {
19584
19620
  intrinsicYields: {
@@ -19622,7 +19658,8 @@ var fetchGeneralYields = async () => {
19622
19658
  ...angleData,
19623
19659
  ...yearnKatanaData,
19624
19660
  ...pendleData,
19625
- ...yoData
19661
+ ...yoData,
19662
+ ...gmxData
19626
19663
  },
19627
19664
  lenderRewards: {
19628
19665
  // '167000': {
@@ -21553,7 +21590,7 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21553
21590
  Promise.all(multicallPromises),
21554
21591
  ...otherDataPromises
21555
21592
  ]);
21556
- let allPrices = {};
21593
+ let allPrices = { ...otherResults[0], ...otherResults[1] };
21557
21594
  for (const {
21558
21595
  chainId,
21559
21596
  result,
@@ -21607,7 +21644,8 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21607
21644
  const compoundV2Data = parseCompoundV2Results(
21608
21645
  chainId,
21609
21646
  compoundV2Slice,
21610
- compoundV2.names
21647
+ compoundV2.names,
21648
+ allPrices
21611
21649
  );
21612
21650
  offset += comet.calls.length;
21613
21651
  allPrices = {
@@ -21622,7 +21660,6 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21622
21660
  ...compoundV2Data
21623
21661
  };
21624
21662
  }
21625
- allPrices = { ...otherResults[0], ...allPrices, ...otherResults[1] };
21626
21663
  for (const {
21627
21664
  chainId,
21628
21665
  result,
@@ -21749,9 +21786,9 @@ var getCompoundV2Calls = (chainId) => {
21749
21786
  switch (chainId) {
21750
21787
  case Chain.ARBITRUM_ONE: {
21751
21788
  const names = [
21752
- "GMX Market ETH/USD::GM [WETH-USDC]",
21789
+ ["GMX Market ETH/USD::GM [WETH-USDC]", 18],
21753
21790
  //
21754
- "GMX Market BTC/USD::GM [WBTC-USDC]"
21791
+ ["GMX Market BTC/USD::GM [WBTC-USDC]", 18]
21755
21792
  ];
21756
21793
  return [
21757
21794
  [
@@ -21776,18 +21813,87 @@ var getCompoundV2Calls = (chainId) => {
21776
21813
  names
21777
21814
  ];
21778
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
+ }
21779
21882
  default:
21780
21883
  return [[], []];
21781
21884
  }
21782
21885
  };
21783
- var parseCompoundV2Results = (chainId, data, names) => {
21886
+ var parseCompoundV2Results = (chainId, data, names, other = {}) => {
21784
21887
  return Object.assign(
21785
21888
  {},
21786
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
+ }
21787
21895
  return {
21788
- [names[index]]: Number(
21789
- parseRawAmount(entry?.underlyingPrice ?? "0", 18)
21790
- )
21896
+ [name]: price
21791
21897
  };
21792
21898
  })
21793
21899
  );