Skip to content

Commit 6522e61

Browse files
committed
Add Allo v1 Custom Fields
1 parent 43ff8de commit 6522e61

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/indexer/allo/v1/handleEvent.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,37 @@ export async function handleEvent(
797797
}
798798

799799
const strategyAddress = parseAddress(event.address);
800-
const rawDistribution = await ipfsGet(
800+
const round = await db.getRoundByStrategyAddress(
801+
chainId,
802+
strategyAddress
803+
);
804+
805+
if (!round) {
806+
throw new Error("Round not found");
807+
}
808+
809+
const rawDistribution = (await ipfsGet(
801810
event.params.distributionMetaPtr.pointer
811+
)) as Record<string, unknown>;
812+
813+
const usdAmount = await convertToUSD(
814+
priceProvider,
815+
chainId,
816+
round?.matchTokenAddress,
817+
BigInt(1),
818+
event.blockNumber
802819
);
820+
821+
const blockTimestamp = getDateFromTimestamp(
822+
BigInt((await blockTimestampInMs(chainId, event.blockNumber)) / 1000)
823+
);
824+
rawDistribution["blockNumber"] = Number(event.blockNumber);
825+
if (blockTimestamp) {
826+
rawDistribution["blockTimestamp"] = blockTimestamp;
827+
}
828+
rawDistribution["usdPrice"] = usdAmount.price;
829+
rawDistribution["usdPriceTimestampAt"] = usdAmount.timestamp;
830+
803831
const distribution =
804832
MatchingDistributionSchema.safeParse(rawDistribution);
805833

0 commit comments

Comments
 (0)