From 923ed2156f07b97240272b0f1ee1ace8a284f404 Mon Sep 17 00:00:00 2001 From: Ajeet Goyal Date: Mon, 19 Aug 2024 14:49:32 +0530 Subject: [PATCH] update balance sql query --- adapters/renzo/src/index.ts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/adapters/renzo/src/index.ts b/adapters/renzo/src/index.ts index e3f659c3..350eba75 100644 --- a/adapters/renzo/src/index.ts +++ b/adapters/renzo/src/index.ts @@ -19,22 +19,11 @@ const API_KEY = process.env.RENZO_API_KEY || '' const QUERY_SIZE = 500000 const getSQLQuery = (blockNumber: number) => ` SELECT - id, ezETHBalance -FROM - AccountSnapshot t1 - JOIN ( - SELECT - id, - max(__genBlockNumber__) as block - FROM - AccountSnapshot - WHERE - __genBlockNumber__ <= ${blockNumber} - GROUP BY id - ) t2 - ON - t1.id = t2.id AND - t1.__genBlockNumber__ = t2.block + id, + argMax(ezETHBalance, __genBlockNumber__) as ezETHBalance +FROM AccountSnapshot_raw +WHERE __genBlockNumber__ <= ${blockNumber} +GROUP BY id ` export const getUserTVLByBlock = async (block: BlockData): Promise => {