Skip to content

Commit

Permalink
add fixes for factory
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed May 20, 2024
1 parent 92790c2 commit 327180e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/dex/uniswap-v3/uniswap-v3-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class UniswapV3Factory extends StatefulEventSubscriber<FactoryState> {
parentName: string,
protected readonly factoryAddress: Address,
logger: Logger,
protected readonly onPoolCreated: OnPoolCreatedCallback,
public readonly onPoolCreated: OnPoolCreatedCallback,
mapKey: string = '',
) {
super(
Expand Down
28 changes: 16 additions & 12 deletions src/dex/uniswap-v3/uniswap-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,7 @@ export class UniswapV3
this.notExistingPoolSetKey =
`${CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();

const factoryImplementation =
this.config.factoryImplementation !== undefined
? this.config.factoryImplementation
: UniswapV3Factory;

this.factory = new factoryImplementation(
dexHelper,
dexKey,
this.config.factory,
this.logger,
this.onPoolCreatedDeleteFromNonExistingSet,
);
this.factory = this.getFactoryInstance();
}

get supportedFees() {
Expand Down Expand Up @@ -401,6 +390,21 @@ export class UniswapV3
);
}

protected getFactoryInstance(): UniswapV3Factory {
const factoryImplementation =
this.config.factoryImplementation !== undefined
? this.config.factoryImplementation
: UniswapV3Factory;

return new factoryImplementation(
this.dexHelper,
this.dexKey,
this.config.factory,
this.logger,
this.onPoolCreatedDeleteFromNonExistingSet.bind(this),
);
}

async addMasterPool(poolKey: string, blockNumber: number): Promise<boolean> {
const _pairs = await this.dexHelper.cache.hget(
PoolsRegistryHashKey,
Expand Down

0 comments on commit 327180e

Please sign in to comment.