Skip to content

Commit

Permalink
use supplied timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
notdian committed May 24, 2024
1 parent f5a8b2e commit 28e02f5
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions adapters/xfai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ type ChangedLiquidity = {
owner: string;
token: string;
liquidity: number;
timestamp: number;
blockNumber: bigint;
};

export async function getUserTVLByBlock(
Expand All @@ -70,8 +68,6 @@ export async function getUserTVLByBlock(
text: `
SELECT owner,
token,
max("blockNumber") as "blockNumber",
(max("date") / 1000) as "timestamp",
sum(liquidity) as liquidity
FROM "LiquidityTrace"
WHERE "blockNumber" <= $1
Expand Down Expand Up @@ -132,14 +128,7 @@ export async function getUserTVLByBlock(
);

const result: OutputDataSchemaRow[] = liquiditiesRows.flatMap(
({
owner,
token,
pool: poolAddress,
liquidity,
blockNumber: block_number,
timestamp,
}) => {
({ owner, token, pool: poolAddress, liquidity }) => {
const poolSupply = poolSupplies[poolAddress];
const poolReserve = poolRes[poolAddress];
const tokenBalance =
Expand All @@ -150,7 +139,7 @@ export async function getUserTVLByBlock(
// Token reserve
{
block_number: Number(block.blockNumber),
timestamp,
timestamp: block.blockTimestamp,
user_address: owner,
token_address: token,
token_balance: tokenBalance,
Expand All @@ -160,7 +149,7 @@ export async function getUserTVLByBlock(
// WETH Reserve
{
block_number: Number(block.blockNumber),
timestamp,
timestamp: block.blockTimestamp,
user_address: owner,
token_address: WETH,
token_balance: ethBalance,
Expand Down

0 comments on commit 28e02f5

Please sign in to comment.