From d23c2eb74360229773049c0804c5b07dcf021c4b Mon Sep 17 00:00:00 2001 From: Spacebean Date: Mon, 21 Oct 2024 11:34:32 -0400 Subject: [PATCH] feat: remove multicall for supply + bean --- projects/ui/src/state/bean/pools/updater.ts | 34 +++++++-------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/projects/ui/src/state/bean/pools/updater.ts b/projects/ui/src/state/bean/pools/updater.ts index 9ea1a42e2..e6929149c 100644 --- a/projects/ui/src/state/bean/pools/updater.ts +++ b/projects/ui/src/state/bean/pools/updater.ts @@ -42,12 +42,10 @@ export const useFetchPools = () => { ]; const lpMulticall = makeLPMulticall(beanstalk.address, poolsArr); - const [priceResult, poolsResult, _lpResults] = await Promise.all([ + const [priceResult, beanTotalSupply, totalDeltaB, _lpResults] = await Promise.all([ beanstalkPrice.price(), - multicall(config, { - contracts: priceAndBeanCalls, - allowFailure: true, - }), + BEAN.getContract().totalSupply().then(tokenResult(BEAN)), + beanstalk.totalDeltaB().then(tokenResult(BEAN)), // fetch [poolDeltaB, totalSupply] for each pool, in chunks of 20 Promise.all( lpMulticall.calls.map((lpCall) => @@ -59,18 +57,19 @@ export const useFetchPools = () => { ).then((result) => chunkArray(result.flat(), lpMulticall.chunkSize)), ]); - console.debug(`${pageContext} MULTICALL RESULTS: `, { + console.debug(`${pageContext} FETCH: `, { lpMulticall, priceResult, priceAndBeanCalls, _lpResults, - poolsResult, + beanTotalSupply, + totalDeltaB, }); - const [beanTotalSupply, totalDeltaB] = [ - extract(poolsResult[0], 'bean.totalSupply'), - extract(poolsResult[1], 'totalDeltaB'), - ]; + // const [beanTotalSupply, totalDeltaB] = [ + // extract(poolsResult[0], 'bean.totalSupply'), + // extract(poolsResult[1], 'totalDeltaB'), + // ]; const lpResults = _lpResults.reduce>( (prev, [_deltaB, _supply], i) => { @@ -137,7 +136,7 @@ export const useFetchPools = () => { } if (beanTotalSupply) { - dispatch(updateSupply(transform(beanTotalSupply, 'bnjs', BEAN))); + dispatch(updateSupply(beanTotalSupply)); } if (totalDeltaB) { @@ -215,17 +214,6 @@ function makeTotalDeltaBMulticall( }; } -function makePriceMulticall( - address: string -): ContractFunctionParameters { - return { - address: address as `0x${string}`, - abi: BEANSTALK_ABI_SNIPPETS.price, - functionName: 'price', - args: [], - }; -} - function makeLPMulticall( beanstalkAddress: string, pools: Pool[]