@1delta/margin-fetcher 0.0.88 → 0.0.91

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) {
@@ -10932,6 +10935,7 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
10932
10935
  let debt = 0;
10933
10936
  let collateral = 0;
10934
10937
  let borrowDiscountedCollateral = 0;
10938
+ let borrowDiscountedCollateralAllActive = 0;
10935
10939
  let rewardsPerAsset = {};
10936
10940
  for (let i = 0; i < assetKeys.length; i++) {
10937
10941
  const asset = assetKeys[i];
@@ -10942,7 +10946,8 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
10942
10946
  stakingYield,
10943
10947
  variableBorrowRate,
10944
10948
  stableBorrowRate,
10945
- rewards
10949
+ rewards,
10950
+ collateralActive
10946
10951
  } = lenderData[asset];
10947
10952
  deposits += depositsUSD;
10948
10953
  debt += debtStableUSD;
@@ -10961,9 +10966,12 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
10961
10966
  );
10962
10967
  stakingDepositAccrual += (stakingYield ?? 0) * depositsUSD;
10963
10968
  stakingBorrowAccrual += (stakingYield ?? 0) * (debtStableUSD + debtUSD);
10964
- if (collateralEnabled) {
10965
- collateral += (lenderData[asset].config[mode]?.collateralFactor ?? 1) * depositsUSD;
10966
- borrowDiscountedCollateral += (lenderData[asset].config[mode]?.borrowCollateralFactor ?? 1) * depositsUSD;
10969
+ if (collateralActive) {
10970
+ if (collateralEnabled) {
10971
+ collateral += (lenderData[asset].config[mode]?.collateralFactor ?? 1) * depositsUSD;
10972
+ borrowDiscountedCollateral += (lenderData[asset].config[mode]?.borrowCollateralFactor ?? 1) * depositsUSD;
10973
+ }
10974
+ borrowDiscountedCollateralAllActive += (lenderData[asset].config[mode]?.borrowCollateralFactor ?? 1) * depositsUSD;
10967
10975
  }
10968
10976
  depositInterest += depositRate * depositsUSD;
10969
10977
  borrowInterest += debtStableUSD * stableBorrowRate + debtUSD * variableBorrowRate;
@@ -10972,6 +10980,7 @@ function createBaseTypeUserState(payload, lenderData, totalDeposits24h = 0, tota
10972
10980
  const balanceData2 = {
10973
10981
  "0": {
10974
10982
  borrowDiscountedCollateral,
10983
+ borrowDiscountedCollateralAllActive,
10975
10984
  collateral,
10976
10985
  deposits,
10977
10986
  debt,
@@ -11058,6 +11067,7 @@ function createMultiAccountTypeUserState(payload, lenderData, histData) {
11058
11067
  const nav = deposits - debt;
11059
11068
  balanceData2[posId] = {
11060
11069
  borrowDiscountedCollateral,
11070
+ borrowDiscountedCollateralAllActive: borrowDiscountedCollateral,
11061
11071
  collateral,
11062
11072
  deposits,
11063
11073
  debt,
@@ -18052,6 +18062,7 @@ var CHUNK_SIZE = 100;
18052
18062
  var balanceData = {
18053
18063
  "0": {
18054
18064
  borrowDiscountedCollateral: 0,
18065
+ borrowDiscountedCollateralAllActive: 0,
18055
18066
  collateral: 0,
18056
18067
  deposits: 0,
18057
18068
  debt: 0,
@@ -19090,6 +19101,15 @@ var yobtc = "Yield Optimizer BTC::YOBTC";
19090
19101
  var yousd = "Yield Optimizer USD::YOUSD";
19091
19102
  var yoeur = "Yield Optimizer EUR::yoEUR";
19092
19103
  var hwhlp = "Hyperwave HLP::hwHLP";
19104
+ var weeths = "Super Symbiotic LRT::weETHs";
19105
+ var gmx_eth_usd = "GMX Market ETH/USD::GM [WETH-USDC]";
19106
+ var gmx_btc_usd = "GMX Market BTC/USD::GM [WBTC-USDC]";
19107
+ var glv_wbtc_usdc = "GMX Liquidity Vault [WBTC-USDC]::GLV [WBTC-USDC]";
19108
+ var glv_weth_usdc = "GMX Liquidity Vault [WETH-USDC]::GLV [WETH-USDC]";
19109
+ var gmx_eth_usd_address = "0x70d95587d40a2caf56bd97485ab3eec10bee6336";
19110
+ var gmx_btc_usd_address = "0x47c031236e19d024b42f8ae6780e44a573170703";
19111
+ var glv_wbtc_usdc_address = "0xdf03eed325b82bc1d4db8b49c30ecc9e05104b96";
19112
+ var glv_weth_usdc_address = "0x528a5bac7e746c9a509a1f4f6df58a03d44279f9";
19093
19113
  var FeedData = {
19094
19114
  WSTETH: "https://eth-api.lido.fi/v1/protocol/steth/apr/sma",
19095
19115
  STMATIC: "https://polygon.lido.fi/api/stats",
@@ -19100,6 +19120,7 @@ var FeedData = {
19100
19120
  EZETH: "https://app.renzoprotocol.com/api/stats?chainId=1",
19101
19121
  RETH: "https://api.rocketpool.net/api/mainnet/payload",
19102
19122
  WEETH: "https://www.ether.fi/api/apr",
19123
+ WEETHS: "https://api.sevenseas.capital/etherfi/ethereum/performance/0x917ceE801a67f933F2e6b33fC0cD1ED2d5909D88",
19103
19124
  SAVAX: "https://api.benqi.fi/liquidstaking/apr",
19104
19125
  RSETH: "https://universe.kelpdao.xyz/rseth/totalApy",
19105
19126
  TRUMATIC: "https://api.trufin.io/staker/apy?staker=MATIC",
@@ -19127,7 +19148,8 @@ var FeedData = {
19127
19148
  HBHYPE: "https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b",
19128
19149
  HLP: "https://api-ui.hyperliquid.xyz/info",
19129
19150
  HWHLP: "https://api.hyperwavefi.xyz/stats/latest?asset=hwhlp_999",
19130
- YO: "https://api.yo.xyz/api/v1/vault/stats"
19151
+ YO: "https://api.yo.xyz/api/v1/vault/stats",
19152
+ GMX: "https://arbitrum-api.gmxinfra.io/apy?period=1d"
19131
19153
  };
19132
19154
  function averageDataLastN(arr, n = 7) {
19133
19155
  const last = arr.slice(-n);
@@ -19189,6 +19211,10 @@ var fetchGeneralYields = async () => {
19189
19211
  const res = await fetch(FeedData.SAVAX).then((r) => r.json());
19190
19212
  return Number(res.apr) * 100;
19191
19213
  });
19214
+ const weethsPromise = safeFetch("WEETHS", async () => {
19215
+ const res = await fetch(FeedData.WEETHS).then((r) => r.json());
19216
+ return apyToApr(res.Response.apy) * 100;
19217
+ });
19192
19218
  const methPromise = safeFetch("METH", async () => {
19193
19219
  const res = await fetch(FeedData.METH).then((r) => r.json());
19194
19220
  return apyToApr(Number(res.data[0]?.OneDayAPY)) * 100;
@@ -19347,6 +19373,28 @@ var fetchGeneralYields = async () => {
19347
19373
  [yoeur]: apyToAprPercent(yoEUR)
19348
19374
  };
19349
19375
  });
19376
+ const gmxPromise = safeFetch("GMX", async () => {
19377
+ const res = await fetch(FeedData.GMX, {
19378
+ method: "GET",
19379
+ headers: { Accept: "application/json" }
19380
+ }).then((r) => r.json());
19381
+ let rData = {};
19382
+ const markets = res.markets;
19383
+ Object.entries(markets).forEach(([m, d]) => {
19384
+ if (m.toLowerCase() === gmx_eth_usd_address)
19385
+ rData[gmx_eth_usd] = apyToApr(d.apy) * 100;
19386
+ if (m.toLowerCase() === gmx_btc_usd_address)
19387
+ rData[gmx_btc_usd] = apyToApr(d.apy) * 100;
19388
+ });
19389
+ const glvs = res.glvs;
19390
+ Object.entries(glvs).forEach(([m, d]) => {
19391
+ if (m.toLowerCase() === glv_wbtc_usdc_address)
19392
+ rData[glv_wbtc_usdc] = apyToApr(d.apy) * 100;
19393
+ if (m.toLowerCase() === glv_weth_usdc_address)
19394
+ rData[glv_weth_usdc] = apyToApr(d.apy) * 100;
19395
+ });
19396
+ return rData;
19397
+ });
19350
19398
  const susdsPromise = safeFetch("SUSDS", async () => {
19351
19399
  const res = await fetch(FeedData.SUSDS, {
19352
19400
  method: "GET",
@@ -19538,7 +19586,9 @@ var fetchGeneralYields = async () => {
19538
19586
  pendleData,
19539
19587
  hlpData,
19540
19588
  yoData,
19541
- hwhlpData
19589
+ hwhlpData,
19590
+ gmxData,
19591
+ weethsData
19542
19592
  ] = await Promise.all([
19543
19593
  wstethPromise,
19544
19594
  ezethPromise,
@@ -19578,7 +19628,9 @@ var fetchGeneralYields = async () => {
19578
19628
  pendlePromise,
19579
19629
  hlpPromise,
19580
19630
  yoPromise,
19581
- hwhlpPromise
19631
+ hwhlpPromise,
19632
+ gmxPromise,
19633
+ weethsPromise
19582
19634
  ]);
19583
19635
  const data = {
19584
19636
  intrinsicYields: {
@@ -19617,12 +19669,14 @@ var fetchGeneralYields = async () => {
19617
19669
  [hbhype]: hbhypeData,
19618
19670
  [hlp]: hlpData,
19619
19671
  [hwhlp]: hwhlpData,
19672
+ [weeths]: weethsData,
19620
19673
  ...rtokensData,
19621
19674
  ...hypeData,
19622
19675
  ...angleData,
19623
19676
  ...yearnKatanaData,
19624
19677
  ...pendleData,
19625
- ...yoData
19678
+ ...yoData,
19679
+ ...gmxData
19626
19680
  },
19627
19681
  lenderRewards: {
19628
19682
  // '167000': {
@@ -21553,7 +21607,7 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21553
21607
  Promise.all(multicallPromises),
21554
21608
  ...otherDataPromises
21555
21609
  ]);
21556
- let allPrices = {};
21610
+ let allPrices = { ...otherResults[0], ...otherResults[1] };
21557
21611
  for (const {
21558
21612
  chainId,
21559
21613
  result,
@@ -21607,7 +21661,8 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21607
21661
  const compoundV2Data = parseCompoundV2Results(
21608
21662
  chainId,
21609
21663
  compoundV2Slice,
21610
- compoundV2.names
21664
+ compoundV2.names,
21665
+ allPrices
21611
21666
  );
21612
21667
  offset += comet.calls.length;
21613
21668
  allPrices = {
@@ -21622,7 +21677,6 @@ var fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
21622
21677
  ...compoundV2Data
21623
21678
  };
21624
21679
  }
21625
- allPrices = { ...otherResults[0], ...allPrices, ...otherResults[1] };
21626
21680
  for (const {
21627
21681
  chainId,
21628
21682
  result,
@@ -21749,9 +21803,9 @@ var getCompoundV2Calls = (chainId) => {
21749
21803
  switch (chainId) {
21750
21804
  case Chain.ARBITRUM_ONE: {
21751
21805
  const names = [
21752
- "GMX Market ETH/USD::GM [WETH-USDC]",
21806
+ ["GMX Market ETH/USD::GM [WETH-USDC]", 18],
21753
21807
  //
21754
- "GMX Market BTC/USD::GM [WBTC-USDC]"
21808
+ ["GMX Market BTC/USD::GM [WBTC-USDC]", 18]
21755
21809
  ];
21756
21810
  return [
21757
21811
  [
@@ -21776,18 +21830,87 @@ var getCompoundV2Calls = (chainId) => {
21776
21830
  names
21777
21831
  ];
21778
21832
  }
21833
+ case Chain.ETHEREUM_MAINNET: {
21834
+ const names = [
21835
+ ["SFRXETH", 18],
21836
+ //
21837
+ ["Super Symbiotic LRT::weETHs", 18],
21838
+ ["USDC-1 yVault::yvUSDC-1", 30],
21839
+ ["USDS-1 yVault::yvUSDS-1", 18],
21840
+ ["USDT-1 yVault::yvUSDT-1", 30],
21841
+ ["WETH-1 yVault::yvWETH-1", 18]
21842
+ ];
21843
+ return [
21844
+ [
21845
+ {
21846
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21847
+ // lens
21848
+ name: "vTokenUnderlyingPrice",
21849
+ params: [
21850
+ "0x17142a05fe678e9584FA1d88EfAC1bF181bF7ABe"
21851
+ //
21852
+ ]
21853
+ },
21854
+ {
21855
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21856
+ // lens
21857
+ name: "vTokenUnderlyingPrice",
21858
+ params: [
21859
+ "0xc42E4bfb996ED35235bda505430cBE404Eb49F77"
21860
+ //
21861
+ ]
21862
+ },
21863
+ {
21864
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21865
+ name: "vTokenUnderlyingPrice",
21866
+ params: [
21867
+ "0xf87c0a64dc3a8622D6c63265FA29137788163879"
21868
+ //
21869
+ ]
21870
+ },
21871
+ {
21872
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21873
+ name: "vTokenUnderlyingPrice",
21874
+ params: [
21875
+ "0x520d67226Bc904aC122dcE66ed2f8f61AA1ED764"
21876
+ //
21877
+ ]
21878
+ },
21879
+ {
21880
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21881
+ name: "vTokenUnderlyingPrice",
21882
+ params: [
21883
+ "0x475d0C68a8CD275c15D1F01F4f291804E445F677"
21884
+ //
21885
+ ]
21886
+ },
21887
+ {
21888
+ address: "0x277950603178BDD223eB53B9b7cF5D0053aa3473",
21889
+ name: "vTokenUnderlyingPrice",
21890
+ params: [
21891
+ "0xba3916302cBA4aBcB51a01e706fC6051AaF272A0"
21892
+ //
21893
+ ]
21894
+ }
21895
+ ],
21896
+ names
21897
+ ];
21898
+ }
21779
21899
  default:
21780
21900
  return [[], []];
21781
21901
  }
21782
21902
  };
21783
- var parseCompoundV2Results = (chainId, data, names) => {
21903
+ var parseCompoundV2Results = (chainId, data, names, other = {}) => {
21784
21904
  return Object.assign(
21785
21905
  {},
21786
21906
  ...data.map((entry, index) => {
21907
+ let price = Number(parseRawAmount(entry?.underlyingPrice ?? "0", names[index][1]));
21908
+ const name = names[index][0];
21909
+ if (name === "SFRXETH") {
21910
+ price = other["ETH"] * price;
21911
+ }
21787
21912
  return {
21788
- [names[index]]: Number(
21789
- parseRawAmount(entry?.underlyingPrice ?? "0", 18)
21790
- )
21913
+ [name]: price
21791
21914
  };
21792
21915
  })
21793
21916
  );