diff --git a/src/helpers.ts b/src/helpers.ts index 56fa333..3088491 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -161,7 +161,8 @@ export async function getOrCreateUserData( export async function queryQuote( quoteParams: QueryWithAmountIn, context: Context, - blockNumber: bigint + blockNumber: bigint, + aggregatorAddress: `0x${string}` ): Promise { const { client, network, contracts } = context; @@ -171,7 +172,7 @@ export async function queryQuote( try { quote = await client.readContract({ abi: contracts.DexAggregator.abi, - address: addresses.DexAggregator![network.name] as `0x${string}`, + address: aggregatorAddress, functionName: "findBestPath", args: [ quoteParams.amountIn, diff --git a/src/index.ts b/src/index.ts index 07fb59f..1d1ad89 100644 --- a/src/index.ts +++ b/src/index.ts @@ -336,7 +336,8 @@ ponder.on("DexAggregator:RouterSwap", async ({ event, context }) => { const usdValueOfTrade = await queryQuote( { amountIn, tokenIn, tokenOut, maxSteps: BIGINT_THREE }, context, - blockNumber + blockNumber, + event.log.address ); let userData = await getOrCreateUserData(