From a2ca736361817ea0f7b1c87121d2e223f70e0e58 Mon Sep 17 00:00:00 2001 From: gmbronco <83549293+gmbronco@users.noreply.github.com> Date: Tue, 29 Oct 2024 04:46:11 +0100 Subject: [PATCH] fixes --- modules/actions/pool/v2/sync-swaps.ts | 7 ++----- modules/sources/transformers/swap-v2-transformer.ts | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/actions/pool/v2/sync-swaps.ts b/modules/actions/pool/v2/sync-swaps.ts index 322e7b5b..d3094c54 100644 --- a/modules/actions/pool/v2/sync-swaps.ts +++ b/modules/actions/pool/v2/sync-swaps.ts @@ -47,11 +47,8 @@ export async function syncSwaps(subgraphClient: V2SubgraphClient, chain: Chain): console.time('BalancerSwaps'); const { swaps } = await subgraphClient.BalancerSwaps({ first: 1000, - where: { - ...where, - poolId_in: ['0x32cc63ffeccb7c0508d64e4d37145313cc053b27000200000000000000000cb4'], - }, - orderBy: Swap_OrderBy.Block, + where: where, + orderBy: chain === Chain.FANTOM ? Swap_OrderBy.Timestamp : Swap_OrderBy.Block, orderDirection: OrderDirection.Asc, }); console.timeEnd('BalancerSwaps'); diff --git a/modules/sources/transformers/swap-v2-transformer.ts b/modules/sources/transformers/swap-v2-transformer.ts index 7f2830b0..0afe0085 100644 --- a/modules/sources/transformers/swap-v2-transformer.ts +++ b/modules/sources/transformers/swap-v2-transformer.ts @@ -18,11 +18,13 @@ export function swapV2Transformer(swap: BalancerSwapFragment, chain: Chain): Swa let feeUSD = feeFloatUSD < 1e6 ? feeFloatUSD.toFixed(18).replace(/0+$/, '').replace(/\.$/, '') : String(feeFloatUSD); + // FX pools have a different fee calculation + // Replica of the subgraph logic: + // https://github.com/balancer/balancer-subgraph-v2/blob/60453224453bd07a0a3a22a8ad6cc26e65fd809f/src/mappings/vault.ts#L551-L564 if (swap.poolId.poolType === 'FX') { + const USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; const tokenOutAddress = swap.tokenOut; const tokenInAddress = swap.tokenIn; - // FX pools have a different fee calculation - const USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; let isTokenInBase = tokenOutAddress == USDC_ADDRESS; let baseTokenAddress = isTokenInBase ? tokenInAddress : tokenOutAddress; let quoteTokenAddress = isTokenInBase ? tokenOutAddress : tokenInAddress;