Skip to content

Commit

Permalink
Merge pull request #719 from balancer/v3-canary
Browse files Browse the repository at this point in the history
publish to prod
  • Loading branch information
gmbronco authored Aug 7, 2024
2 parents d38baaf + 0be3a6e commit f31c9eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 43 deletions.
28 changes: 3 additions & 25 deletions modules/controllers/event-query-controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
GqlPoolEventsDataRange,
GqlPoolAddRemoveEventV3,
GqlPoolSwapEventV3,
QueryPoolEventsArgs,
GqlPoolSwapEventCowAmm,
} from '../../schema';
import { GqlPoolEventsDataRange, GqlPoolAddRemoveEventV3, GqlPoolSwapEventV3, QueryPoolEventsArgs } from '../../schema';
import { prisma } from '../../prisma/prisma-client';
import { Chain, PoolEventType, Prisma } from '@prisma/client';
import { JoinExitEvent, SwapEvent } from '../../prisma/prisma-types';
Expand Down Expand Up @@ -44,18 +38,6 @@ const parseSwap = (event: SwapEvent): GqlPoolSwapEventV3 => {
};
};

const parseCowAmmSwap = (event: SwapEvent): GqlPoolSwapEventCowAmm => {
const regularSwap = parseSwap(event);
return {
...regularSwap,
__typename: 'GqlPoolSwapEventCowAmm',
surplus: (event.payload.surplus && {
...event.payload.surplus,
valueUSD: Number(event.payload.surplus.valueUSD),
}) || { address: '', amount: '0', valueUSD: 0 },
};
};

const rangeToTimestamp = (range: GqlPoolEventsDataRange): number => {
switch (range) {
case 'SEVEN_DAYS':
Expand All @@ -81,7 +63,7 @@ export function EventsQueryController(tracer?: any) {
first,
skip,
where,
}: QueryPoolEventsArgs): Promise<(GqlPoolSwapEventV3 | GqlPoolSwapEventCowAmm | GqlPoolAddRemoveEventV3)[]> => {
}: QueryPoolEventsArgs): Promise<(GqlPoolSwapEventV3 | GqlPoolAddRemoveEventV3)[]> => {
// Setting default values
first = Math.min(1000, first ?? 1000); // Limiting to 1000 items
skip = skip ?? 0;
Expand Down Expand Up @@ -144,11 +126,7 @@ export function EventsQueryController(tracer?: any) {
});

const results = dbEvents.map((event) =>
event.type === 'SWAP' && event.protocolVersion === 1
? parseCowAmmSwap(event as SwapEvent)
: event.type === 'SWAP'
? parseSwap(event as SwapEvent)
: parseJoinExit(event as JoinExitEvent),
event.type === 'SWAP' ? parseSwap(event as SwapEvent) : parseJoinExit(event as JoinExitEvent),
);

return results;
Expand Down
18 changes: 0 additions & 18 deletions modules/pool/pool.gql
Original file line number Diff line number Diff line change
Expand Up @@ -1537,21 +1537,3 @@ type GqlPoolSwapEventV3 implements GqlPoolEvent {
tokenIn: GqlPoolEventAmount!
tokenOut: GqlPoolEventAmount!
}

type GqlPoolSwapEventCowAmm implements GqlPoolEvent {
chain: GqlChain!
id: ID!
tx: String!
logIndex: Int!
blockNumber: Int!
blockTimestamp: Int!
type: GqlPoolEventType!
sender: String!
userAddress: String!
poolId: String!
timestamp: Int!
valueUSD: Float!
tokenIn: GqlPoolEventAmount!
tokenOut: GqlPoolEventAmount!
surplus: GqlPoolEventAmount!
}

0 comments on commit f31c9eb

Please sign in to comment.