Skip to content

Commit f6bda6b

Browse files
committed
pool event types
1 parent a158a42 commit f6bda6b

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

modules/controllers/pool-events-query-controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const parseSwap = (event: SwapEvent): GqlPoolSwapEvent => {
2828
return {
2929
__typename: 'GqlPoolSwapEventV3',
3030
...event,
31+
valueUSD: event.valueUSD || 0,
3132
sender: event.userAddress,
3233
timestamp: event.blockTimestamp,
3334
tokenIn: {

modules/pool/lib/pool-swap.service.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,7 @@ export class PoolSwapService {
4141
for (const chain of args.where.chainIn) {
4242
const balancerSubgraphService = AllNetworkConfigsKeyedOnChain[chain].services.balancerSubgraphService;
4343

44-
const getterFn =
45-
chain === Chain.FANTOM
46-
? balancerSubgraphService.getFantomPoolJoinExits.bind(balancerSubgraphService)
47-
: balancerSubgraphService.getPoolJoinExits.bind(balancerSubgraphService);
48-
49-
const { joinExits } = await getterFn({
44+
const { joinExits } = await balancerSubgraphService.getPoolJoinExits({
5045
where: { pool_in: args.where?.poolIdIn },
5146
first,
5247
skip: args.skip,
@@ -81,12 +76,7 @@ export class PoolSwapService {
8176
): Promise<GqlPoolJoinExit[]> {
8277
const balancerSubgraphService = AllNetworkConfigsKeyedOnChain[chain].services.balancerSubgraphService;
8378

84-
const getterFn =
85-
chain === Chain.FANTOM
86-
? balancerSubgraphService.getFantomPoolJoinExits.bind(balancerSubgraphService)
87-
: balancerSubgraphService.getPoolJoinExits.bind(balancerSubgraphService);
88-
89-
const { joinExits } = await getterFn({
79+
const { joinExits } = await balancerSubgraphService.getPoolJoinExits({
9080
where: { pool: poolId, user: userAddress },
9181
first,
9282
skip: skip,

modules/sources/enrichers/swaps-usd.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,24 @@ export async function swapsUsd(swaps: SwapEvent[], chain: Chain): Promise<SwapEv
4343
const payload = {
4444
fee: {
4545
...swap.payload.fee,
46-
valueUSD: (tokenOut?.price || 0) * parseFloat(swap.payload.fee.amount),
46+
valueUSD: String((tokenOut?.price || 0) * parseFloat(swap.payload.fee.amount)),
4747
},
4848
tokenIn: {
4949
...swap.payload.tokenIn,
50-
valueUSD: (tokenIn?.price || 0) * parseFloat(swap.payload.tokenIn.amount),
5150
},
5251
tokenOut: {
5352
...swap.payload.tokenOut,
54-
valueUSD: (tokenOut?.price || 0) * parseFloat(swap.payload.tokenOut.amount),
5553
},
5654
};
5755

56+
const valueUSD =
57+
(tokenIn?.price || 0) * parseFloat(swap.payload.tokenIn.amount) ||
58+
(tokenOut?.price || 0) * parseFloat(swap.payload.tokenOut.amount);
59+
5860
dbEntries.push({
5961
...swap,
6062
// Taking all the chances to get the token price
61-
valueUSD: payload.tokenIn.valueUSD || payload.tokenOut.valueUSD || 0,
63+
valueUSD,
6264
payload,
6365
});
6466
}

0 commit comments

Comments
 (0)