@stake-dao/reader 0.4.85 → 0.4.87

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 (48) hide show
  1. package/dist/esm/strategies/balancer/fetch.js +13 -4
  2. package/dist/esm/strategies/balancer/fetch.js.map +1 -1
  3. package/dist/esm/strategies/curve/endpoints.js +4 -2
  4. package/dist/esm/strategies/curve/endpoints.js.map +1 -1
  5. package/dist/esm/strategies/curve/fetch/index.js +2 -2
  6. package/dist/esm/strategies/curve/fetch/index.js.map +1 -1
  7. package/dist/esm/strategies/curve/httpCalls.js +23 -4
  8. package/dist/esm/strategies/curve/httpCalls.js.map +1 -1
  9. package/dist/esm/strategies/pancakeswap/fetch/index.js +13 -3
  10. package/dist/esm/strategies/pancakeswap/fetch/index.js.map +1 -1
  11. package/dist/esm/strategies/pendle/fetch.js +13 -3
  12. package/dist/esm/strategies/pendle/fetch.js.map +1 -1
  13. package/dist/esm/strategies/yearn/fetch/index.js +13 -3
  14. package/dist/esm/strategies/yearn/fetch/index.js.map +1 -1
  15. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  16. package/dist/esm/utils/etherscan.js +5 -1
  17. package/dist/esm/utils/etherscan.js.map +1 -1
  18. package/dist/esm/votemarket/fetchCampaigns/processRawCampaigns.js +1 -0
  19. package/dist/esm/votemarket/fetchCampaigns/processRawCampaigns.js.map +1 -1
  20. package/dist/types/strategies/balancer/fetch.d.ts +2 -3
  21. package/dist/types/strategies/balancer/fetch.d.ts.map +1 -1
  22. package/dist/types/strategies/curve/endpoints.d.ts +4 -2
  23. package/dist/types/strategies/curve/endpoints.d.ts.map +1 -1
  24. package/dist/types/strategies/curve/fetch/index.d.ts +2 -3
  25. package/dist/types/strategies/curve/fetch/index.d.ts.map +1 -1
  26. package/dist/types/strategies/curve/httpCalls.d.ts +1 -1
  27. package/dist/types/strategies/curve/httpCalls.d.ts.map +1 -1
  28. package/dist/types/strategies/pancakeswap/fetch/index.d.ts +2 -3
  29. package/dist/types/strategies/pancakeswap/fetch/index.d.ts.map +1 -1
  30. package/dist/types/strategies/pendle/fetch.d.ts +2 -3
  31. package/dist/types/strategies/pendle/fetch.d.ts.map +1 -1
  32. package/dist/types/strategies/types.d.ts +0 -1
  33. package/dist/types/strategies/types.d.ts.map +1 -1
  34. package/dist/types/strategies/yearn/fetch/index.d.ts +2 -3
  35. package/dist/types/strategies/yearn/fetch/index.d.ts.map +1 -1
  36. package/dist/types/utils/etherscan.d.ts.map +1 -1
  37. package/dist/types/votemarket/fetchCampaigns/processRawCampaigns.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/strategies/balancer/fetch.ts +13 -10
  40. package/src/strategies/curve/endpoints.ts +8 -4
  41. package/src/strategies/curve/fetch/index.ts +2 -11
  42. package/src/strategies/curve/httpCalls.ts +23 -25
  43. package/src/strategies/pancakeswap/fetch/index.ts +14 -22
  44. package/src/strategies/pendle/fetch.ts +14 -9
  45. package/src/strategies/types.ts +0 -1
  46. package/src/strategies/yearn/fetch/index.ts +13 -15
  47. package/src/utils/etherscan.ts +9 -1
  48. package/src/votemarket/fetchCampaigns/processRawCampaigns.ts +1 -0
@@ -4,14 +4,15 @@ import { formatUnits } from 'viem'
4
4
  import { ONE_YEAR, yearnStrats } from '@stake-dao/constants'
5
5
  import multicallYearnStratsAbi from '../../../abis/yearnVaultsMulticall.js'
6
6
  import { equalTlc, multicall } from '../../../utils.js'
7
- import { NEW_FACTORY_EXPLORER_EVENTS } from '../../curve/endpoints.js'
7
+ import { NEW_FACTORY_EVENT_TOPIC } from '../../curve/endpoints.js'
8
8
  import { getBoost } from '../../utils/boost.js'
9
9
  import { buildYearnStrategies } from '../build.js'
10
10
  import { computeYearnApr } from './computeYearnApr.js'
11
11
 
12
12
  import { contracts } from '@stake-dao/constants'
13
13
  import type { Price } from '../../../prices.js'
14
- import type { RewardsData, SdtApr, StrategyData, ValidChainId, ValidExplorer } from '../../types.js'
14
+ import { getLogsFromEtherscan } from '../../../utils/etherscan.js'
15
+ import type { RewardsData, SdtApr, StrategyData, ValidChainId } from '../../types.js'
15
16
  import { getAprBreakdown } from '../../utils/getAprBreakdown.js'
16
17
  import { decodeNewFactoryEvent } from '../../utils/index.js'
17
18
  import { fetchAllYearnGauges } from './fetchAllYearnGauges.js'
@@ -49,7 +50,6 @@ interface TFetchYearn {
49
50
  provider: any
50
51
  rpc: string
51
52
  explorerApiKey: string
52
- explorer: ValidExplorer
53
53
  chainId: ValidChainId
54
54
  }
55
55
 
@@ -58,7 +58,6 @@ export const fetchYearn = async ({
58
58
  provider,
59
59
  rpc,
60
60
  explorerApiKey,
61
- explorer,
62
61
  chainId,
63
62
  }: TFetchYearn): Promise<StrategyData> => {
64
63
  const fromBlock = yearnStrats.meta.lastSyncBlock[chainId]! + 1
@@ -70,17 +69,16 @@ export const fetchYearn = async ({
70
69
 
71
70
  const httpCalls = [
72
71
  // Etherscan Events
73
- (
74
- await fetch(
75
- NEW_FACTORY_EXPLORER_EVENTS(
76
- explorerApiKey,
77
- explorer,
78
- contracts.yearnVaultFactory![chainId]!,
79
- fromBlock,
80
- toBlock,
81
- ),
82
- )
83
- ).json(),
72
+ getLogsFromEtherscan({
73
+ chainId,
74
+ address: contracts.yearnVaultFactory![chainId]!,
75
+ apikey: explorerApiKey,
76
+ extraQueryParams: {
77
+ topic0: NEW_FACTORY_EVENT_TOPIC,
78
+ fromBlock: `${fromBlock}`,
79
+ toBlock: `${toBlock}`,
80
+ },
81
+ }),
84
82
  // Yearn Api
85
83
  (
86
84
  await fetch(
@@ -17,5 +17,13 @@ export const getLogsFromEtherscan = async ({
17
17
  ? rawQueryParams
18
18
  : { chainid: `${chainId}`, module: 'logs', action: 'getLogs', address, apikey, ...extraQueryParams }
19
19
 
20
- return fetch(`https://api.etherscan.io/v2/api?${new URLSearchParams(queryParams)}`).then((res) => res.json())
20
+ const data = await fetch(`https://api.etherscan.io/v2/api?${new URLSearchParams(queryParams)}`).then((res) =>
21
+ res.json(),
22
+ )
23
+
24
+ if (data.status !== '1') {
25
+ console.error(`🟥 - error on etherscan api call - ${data.message} - ${data.result}`)
26
+ }
27
+
28
+ return data
21
29
  }
@@ -121,6 +121,7 @@ export const processRawCampaigns = async ({
121
121
  ...(fetchedTokens.length > 0 ? await getPrices(fetchedTokens as any, chainId) : []),
122
122
  ...(nativeFetchedTokens.length > 0 ? await getPrices(nativeFetchedTokens as any, mainnet.id) : []),
123
123
  ...(underlyingTokens.length > 0 ? await getPrices(underlyingTokens as any, chainId) : []),
124
+ { address: '0x4DF454443D6e9A888e9B1571B2375e8Ab4118d9d', symbol: 'TAC IOU', usdPrice: 0.0375 }, // tmp rEYWA price
124
125
  // { address: '0x9E49A0314AE61e9C9E34e4Af62a73FBFfB6DE95A', symbol: 'ARR', usdPrice: 10 }, // For test purpose
125
126
  // { address: '0x0Cc20784f790805537D4eE33B41f1aC4eC55446B', symbol: 'USDC', usdPrice: 1 }, // For test purpose
126
127
  // { address: '0x59c9a01163e685719FAbE5De34779F563f49D4a3', symbol: 'CRV', usdPrice: 30 }, // For test purpose