Skip to content

Commit b1b2319

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

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

src/indexer/allo/v1/handleEvent.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,46 @@ export async function handleEvent(
797797
}
798798

799799
const strategyAddress = parseAddress(event.address);
800-
const rawDistribution = await ipfsGet(
800+
801+
const roundId = parseAddress(
802+
await readContract({
803+
contract: "AlloV1/MerklePayoutStrategyImplementation/V2",
804+
address: strategyAddress,
805+
functionName: "roundAddress",
806+
})
807+
);
808+
809+
const round = await db.getRoundById(
810+
chainId,
811+
roundId
812+
);
813+
814+
if (!round) {
815+
throw new Error("Round not found");
816+
}
817+
818+
const rawDistribution = (await ipfsGet(
801819
event.params.distributionMetaPtr.pointer
820+
)) as Record<string, unknown>;
821+
822+
const usdAmount = await convertToUSD(
823+
priceProvider,
824+
chainId,
825+
round?.matchTokenAddress,
826+
BigInt(1),
827+
event.blockNumber
802828
);
829+
830+
const blockTimestamp = getDateFromTimestamp(
831+
BigInt((await blockTimestampInMs(chainId, event.blockNumber)) / 1000)
832+
);
833+
rawDistribution["blockNumber"] = Number(event.blockNumber);
834+
if (blockTimestamp) {
835+
rawDistribution["blockTimestamp"] = blockTimestamp;
836+
}
837+
rawDistribution["usdPrice"] = usdAmount.price;
838+
rawDistribution["usdPriceTimestampAt"] = usdAmount.timestamp;
839+
803840
const distribution =
804841
MatchingDistributionSchema.safeParse(rawDistribution);
805842

@@ -817,7 +854,7 @@ export async function handleEvent(
817854
{
818855
type: "UpdateRoundByStrategyAddress",
819856
chainId,
820-
strategyAddress,
857+
strategyAddress: strategyAddress,
821858
round: {
822859
matchingDistribution: distribution.data,
823860
},

0 commit comments

Comments
 (0)