Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunk size #399

Merged
merged 6 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ yarn-error.log
.DS_Store
.env
dist/
cache/
cache/
.idea/
10 changes: 8 additions & 2 deletions src/poolCacher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ export class PoolCacher {
* @param {GraphQLArgs} queryArgs - Optional query arguments to pass to pool data service.
* @returns {boolean} True if pools fetched successfully, False if not.
*/
public async fetchPools(queryArgs?: GraphQLArgs): Promise<boolean> {
public async fetchPools(
queryArgs?: GraphQLArgs,
chunkSize?: number
): Promise<boolean> {
try {
this.pools = await this.poolDataService.getPools(queryArgs);
this.pools = await this.poolDataService.getPools(
queryArgs,
chunkSize
);
this._finishedFetching = true;
return true;
} catch (err) {
Expand Down
5 changes: 4 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ export interface TokenPriceService {
}

export interface PoolDataService {
getPools(query?: GraphQLArgs): Promise<SubgraphPoolBase[]>;
getPools(
query?: GraphQLArgs,
chunkSize?: number
): Promise<SubgraphPoolBase[]>;
}

export type FundManagement = {
Expand Down
8 changes: 6 additions & 2 deletions src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
TokenPriceService,
PoolDataService,
SorConfig,
GraphQLArgs,
} from './types';
import { Zero } from '@ethersproject/constants';

Expand Down Expand Up @@ -69,8 +70,11 @@ export class SOR {
* fetchPools Retrieves pools information and saves to internal pools cache.
* @returns {boolean} True if pools fetched successfully, False if not.
*/
async fetchPools(): Promise<boolean> {
return this.poolCacher.fetchPools();
async fetchPools(
queryArgs?: GraphQLArgs,
chunkSize?: number
): Promise<boolean> {
return this.poolCacher.fetchPools(queryArgs, chunkSize);
}

/**
Expand Down