diff --git a/src/constants/index.ts b/src/constants/index.ts index 0346b6b..1e26fa2 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -27,7 +27,7 @@ type ChainTokenList = { // Staking Yearly Rate export const YEARLY_RATE = JSBI.divide(JSBI.BigInt(365), JSBI.BigInt(REWARDS_DURATION_DAYS_180)); // Block time here is slightly higher (~1s) than average in order to avoid ongoing proposals past the displayed time -export const AVERAGE_BLOCK_TIME_IN_SECS = 3; +export const AVERAGE_BLOCK_TIME_IN_SECS = 5; export const PROPOSAL_LENGTH_IN_BLOCKS = 40_320; export const PROPOSAL_LENGTH_IN_SECS = AVERAGE_BLOCK_TIME_IN_SECS * PROPOSAL_LENGTH_IN_BLOCKS; // export const GOVERNANCE_ADDRESS = '0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F'; diff --git a/src/state/multicall/updater.tsx b/src/state/multicall/updater.tsx index b777254..b636383 100644 --- a/src/state/multicall/updater.tsx +++ b/src/state/multicall/updater.tsx @@ -15,13 +15,10 @@ import { parseCallKey, updateMulticallResults, } from './actions'; -import axios from 'axios'; -import rateLimit from 'axios-rate-limit'; // chunk calls so we do not exceed the gas limit const CALL_CHUNK_SIZE = 25; const BACKOFF_TIMEOUT = 5000; -const http = rateLimit(axios.create(), { maxRequests: 2, perMilliseconds: 1000 }); /** * Fetches a chunk of calls, enforcing a minimum block number constraint @@ -38,25 +35,18 @@ async function fetchChunk( let resultsBlockNumber, returnData; try { - // Use rate-limited axios instance here - const response = await http.post( - 'https://mainnet.tron.tronql.com/uo5c40py0q8udu7qje2nyo6ti8fue4/wallet/triggerconstantcontract', - { - multicallContract: multicallContract.address, - chunk: chunk.map((obj) => [obj.address, obj.callData]), - }, + [resultsBlockNumber, returnData] = await multicallContract.aggregate( + chunk.map((obj) => [obj.address, obj.callData]), ); - resultsBlockNumber = response.data.resultsBlockNumber; - returnData = response.data.returnData; } catch (error) { console.debug('Failed to fetch chunk inside retry', error); throw error; } - if (resultsBlockNumber < minBlockNumber) { - console.debug(`Fetched results for old block number: ${resultsBlockNumber} vs. ${minBlockNumber}`); + if (resultsBlockNumber.toNumber() < minBlockNumber) { + console.debug(`Fetched results for old block number: ${resultsBlockNumber.toString()} vs. ${minBlockNumber}`); throw new RetryableError('Fetched for old block number'); } - return { results: returnData, blockNumber: resultsBlockNumber }; + return { results: returnData, blockNumber: resultsBlockNumber.toNumber() }; } /** @@ -213,8 +203,9 @@ export default function Updater(): null { ); }); - // Add a delay between chunks to avoid rate limit issues - return () => setTimeout(cancel, BACKOFF_TIMEOUT); + setTimeout(() => {}, BACKOFF_TIMEOUT); + + return cancel; }), }; }, [chainId, multicallContract, dispatch, serializedOutdatedCallKeys, latestBlockNumber]);