@stake-dao/reader 0.4.49 → 0.4.51

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 (41) hide show
  1. package/dist/esm/lockers/utils/getBribesRewardsData.js +1 -0
  2. package/dist/esm/lockers/utils/getBribesRewardsData.js.map +1 -1
  3. package/dist/esm/prices.js +7 -7
  4. package/dist/esm/prices.js.map +1 -1
  5. package/dist/esm/sdt/fetch.js +40 -40
  6. package/dist/esm/sdt/fetch.js.map +1 -1
  7. package/dist/esm/strategies/pancakeswap/fetch/pancakeswapMath.js +0 -3
  8. package/dist/esm/strategies/pancakeswap/fetch/pancakeswapMath.js.map +1 -1
  9. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  10. package/dist/esm/utils/etherscan.js +7 -0
  11. package/dist/esm/utils/etherscan.js.map +1 -0
  12. package/dist/esm/utils/getAverageYearlyRewards.js +38 -0
  13. package/dist/esm/utils/getAverageYearlyRewards.js.map +1 -0
  14. package/dist/esm/utils.js +7 -7
  15. package/dist/esm/utils.js.map +1 -1
  16. package/dist/esm/votemarket/curve/config.js +1 -0
  17. package/dist/esm/votemarket/curve/config.js.map +1 -1
  18. package/dist/esm/votemarket/fetchPendingRemoteCampaigns.js +1 -1
  19. package/dist/esm/votemarket/fetchPendingRemoteCampaigns.js.map +1 -1
  20. package/dist/types/lockers/utils/getBribesRewardsData.d.ts.map +1 -1
  21. package/dist/types/sdt/fetch.d.ts +4 -4
  22. package/dist/types/sdt/fetch.d.ts.map +1 -1
  23. package/dist/types/strategies/pancakeswap/fetch/pancakeswapMath.d.ts.map +1 -1
  24. package/dist/types/utils/etherscan.d.ts +14 -0
  25. package/dist/types/utils/etherscan.d.ts.map +1 -0
  26. package/dist/types/utils/getAverageYearlyRewards.d.ts +3 -0
  27. package/dist/types/utils/getAverageYearlyRewards.d.ts.map +1 -0
  28. package/dist/types/utils.d.ts +1 -1
  29. package/dist/types/utils.d.ts.map +1 -1
  30. package/dist/types/votemarket/curve/config.d.ts +1 -0
  31. package/dist/types/votemarket/curve/config.d.ts.map +1 -1
  32. package/package.json +2 -2
  33. package/src/lockers/utils/getBribesRewardsData.ts +1 -0
  34. package/src/prices.ts +7 -7
  35. package/src/sdt/fetch.ts +40 -51
  36. package/src/strategies/pancakeswap/fetch/pancakeswapMath.ts +0 -3
  37. package/src/utils/etherscan.ts +21 -0
  38. package/src/utils/getAverageYearlyRewards.ts +53 -0
  39. package/src/utils.ts +22 -18
  40. package/src/votemarket/curve/config.ts +1 -0
  41. package/src/votemarket/fetchPendingRemoteCampaigns.ts +1 -1
package/src/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RPC, tokens } from '@stake-dao/constants'
2
2
  import type { Token } from '@stake-dao/constants'
3
3
  import { request } from 'graphql-request'
4
- import { groupBy } from 'lodash-es'
4
+ import { chunk, groupBy } from 'lodash-es'
5
5
  import {
6
6
  http,
7
7
  type Address,
@@ -121,23 +121,27 @@ export const rpcCall = async (rpc: string, params: RpcCallArgs[]) => {
121
121
  return request
122
122
  }
123
123
 
124
- export const ethGetTxsReceipts = async (rpc: string, txHashes: string[]) => {
125
- const request = (
126
- await fetch(rpc, {
127
- method: 'POST',
128
- headers: { 'Content-Type': 'application/json' },
129
- body: JSON.stringify(
130
- txHashes.map((txHash, index) => ({
131
- id: index,
132
- jsonrpc: '2.0',
133
- method: 'eth_getTransactionReceipt',
134
- params: [txHash],
135
- })),
136
- ),
137
- })
138
- ).json()
124
+ export const ethGetTxsReceipts = async (rpc: string, txHashes: string[], maxSize: number = 100) => {
125
+ const chunkedTxHashes = chunk(txHashes, maxSize)
139
126
 
140
- return request
127
+ const receiptsRequests = await Promise.all(
128
+ chunkedTxHashes.map((txs) =>
129
+ fetch(rpc, {
130
+ method: 'POST',
131
+ headers: { 'Content-Type': 'application/json' },
132
+ body: JSON.stringify(
133
+ txs.map((txHash, index) => ({
134
+ id: index,
135
+ jsonrpc: '2.0',
136
+ method: 'eth_getTransactionReceipt',
137
+ params: [txHash],
138
+ })),
139
+ ),
140
+ }).then((res) => res.json()),
141
+ ),
142
+ )
143
+
144
+ return receiptsRequests.flat()
141
145
  }
142
146
 
143
147
  export const ethEstimateGas = async (rpc: string, from: string, to: string, data: string) => {
@@ -289,7 +293,7 @@ export const multichainMulticall = async (calls: MultiChainCall[], abi: readonly
289
293
  const callsPerChain = groupBy(calls, (call) => call.chainId)
290
294
 
291
295
  const chains = Object.keys(callsPerChain)
292
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
296
+
293
297
  const parsedCallsPerChain = chains.map((chainId) => callsPerChain[chainId]!.map(({ chainId, ...call }) => call))
294
298
 
295
299
  const promises = await Promise.allSettled(
@@ -40,6 +40,7 @@ export const NOT_LP_GAUGES = {
40
40
  427: '0xC91113B4Dd89dd20FDEECDAC82477Bc99A840355',
41
41
  428: '0x7ce8aF75A9180B602445bE230860DDcb4cAc3E42',
42
42
  473: '0x66EFd8E255B8B7Cf32961E90A5820f289402629e',
43
+ 670: '0x5A537a46D780B1C70138aB98eDce69e7a53177ba',
43
44
  }
44
45
 
45
46
  export const NOT_LP_GAUGES_INDEX = Object.keys(NOT_LP_GAUGES).map((x) => Number(x))
@@ -54,7 +54,7 @@ export const fetchPendingRemoteCampaigns = async ({
54
54
  const payload = decodeAbiParameters(
55
55
  parseAbiParameters([
56
56
  'Payload payload',
57
- 'struct Payload { uint256 actionType; address sender; bytes parameters }',
57
+ 'struct Payload { uint256 actionType; address sender; address votemarket; bytes parameters }',
58
58
  ]),
59
59
  decodedEvent.args.message.payload,
60
60
  )