Skip to content

Commit

Permalink
change hook filter to bool (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
franzns authored Oct 9, 2024
1 parent 33bac59 commit f613949
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-dolls-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

change hook filter to bool
2 changes: 1 addition & 1 deletion graphql_schema_generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ export const schema = gql`
createTime: GqlPoolTimePeriod
filterIn: [String!]
filterNotIn: [String!]
hookAddressIn: [String!]
hasHook: Boolean
idIn: [String!]
idNotIn: [String!]
minTvl: Float
Expand Down
8 changes: 5 additions & 3 deletions modules/pool/lib/pool-gql-loader.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,11 @@ export class PoolGqlLoaderService {
}
: {}),
},
hook: {
address: { in: where?.hookAddressIn || undefined },
},
...(where?.hasHook && where.hasHook
? { hook: { isNot: null } }
: where?.hasHook && !where.hasHook
? { hook: { is: null } }
: {}),
};

if (!textSearch) {
Expand Down
35 changes: 32 additions & 3 deletions modules/pool/pool-debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,40 @@ describe('pool debugging', () => {
// await poolService.syncAllPoolsFromSubgraph();
// await poolService.syncChangedPools();
// await tokenService.updateTokenPrices(['MAINNET']);
await PoolController().reloadPoolsV3('SEPOLIA');
// await PoolController().reloadPoolsV3('SEPOLIA');

const poolAfterNewSync = await poolService.getGqlPool('0x8fc07bcf9b88ace84c7523248dc4a85f638c9536', 'SEPOLIA');
const poolsUndefinedArr = await prisma.prismaPool.findMany({
where: { chain: 'SEPOLIA', protocolVersion: 3, hook: { address: { in: undefined } } },
});

const poolsWithHooks = await prisma.prismaPool.findMany({
where: { chain: 'SEPOLIA', protocolVersion: 3, hook: { isNot: null } },
});

const poolsEmptyArr = await prisma.prismaPool.findMany({
where: { chain: 'SEPOLIA', protocolVersion: 3, hook: { address: { in: [''] } } },
});

const poolsWithoutHooks = await prisma.prismaPool.findMany({
where: { chain: 'SEPOLIA', protocolVersion: 3, hook: { is: null } },
});

const poolsAll = await prisma.prismaPool.findMany({
where: { chain: 'SEPOLIA', protocolVersion: 3 },
});

const allPools = await poolService.getGqlPools({ where: { chainIn: ['SEPOLIA'], protocolVersionIn: [3] } });
const allPoolsHooks = await poolService.getGqlPools({
where: { chainIn: ['SEPOLIA'], protocolVersionIn: [3], hasHook: true },
});
const allPoolsNoHooks = await poolService.getGqlPools({
where: { chainIn: ['SEPOLIA'], protocolVersionIn: [3], hasHook: false },
});
console.log(poolsAll.length);

// const poolAfterNewSync = await poolService.getGqlPool('0x8fc07bcf9b88ace84c7523248dc4a85f638c9536', 'SEPOLIA');

expect(poolAfterNewSync.dynamicData.isPaused).toBe(true);
// expect(poolAfterNewSync.dynamicData.isPaused).toBe(true);
}, 5000000);

it('sync aprs', async () => {
Expand Down
2 changes: 1 addition & 1 deletion modules/pool/pool.gql
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ input GqlPoolFilter {
userAddress: String
protocolVersionIn: [Int!]
minTvl: Float
hookAddressIn: [String!]
hasHook: Boolean
}

type GqlPoolTokenExpanded {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ export type Scalars = {
BigInt: string;
Bytes: string;
Int8: any;
Timestamp: any;
};

export enum Aggregation_Interval {
day = 'day',
hour = 'hour',
}

export type BlockChangedFilter = {
number_gte: Scalars['Int'];
};
Expand Down Expand Up @@ -829,8 +823,6 @@ export type _Block_ = {
hash?: Maybe<Scalars['Bytes']>;
/** The block number */
number: Scalars['Int'];
/** The hash of the parent block */
parentHash?: Maybe<Scalars['Bytes']>;
/** Integer representation of the timestamp stored in blocks for the chain */
timestamp?: Maybe<Scalars['Int']>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ export type Scalars = {
BigInt: string;
Bytes: string;
Int8: any;
Timestamp: any;
};

export enum Aggregation_Interval {
Day = 'day',
Hour = 'hour',
}

export type Bar = {
__typename?: 'Bar';
address: Scalars['Bytes'];
Expand Down Expand Up @@ -465,8 +459,6 @@ export type _Block_ = {
hash?: Maybe<Scalars['Bytes']>;
/** The block number */
number: Scalars['Int'];
/** The hash of the parent block */
parentHash?: Maybe<Scalars['Bytes']>;
/** Integer representation of the timestamp stored in blocks for the chain */
timestamp?: Maybe<Scalars['Int']>;
};
Expand Down
2 changes: 1 addition & 1 deletion schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ export interface GqlPoolFilter {
createTime?: InputMaybe<GqlPoolTimePeriod>;
filterIn?: InputMaybe<Array<Scalars['String']>>;
filterNotIn?: InputMaybe<Array<Scalars['String']>>;
hookAddressIn?: InputMaybe<Array<Scalars['String']>>;
hasHook?: InputMaybe<Scalars['Boolean']>;
idIn?: InputMaybe<Array<Scalars['String']>>;
idNotIn?: InputMaybe<Array<Scalars['String']>>;
minTvl?: InputMaybe<Scalars['Float']>;
Expand Down

0 comments on commit f613949

Please sign in to comment.