Skip to content

Commit

Permalink
solve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed Dec 10, 2024
2 parents d533882 + 6d0b9d5 commit 3d9a4c0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 81 deletions.
30 changes: 0 additions & 30 deletions src/dex/pancakeswap-v3/pancakeswap-v3-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,36 +250,6 @@ export class PancakeSwapV3EventPool extends StatefulEventSubscriber<PoolState> {
return TICK_BITMAP_TO_USE + TICK_BITMAP_BUFFER;
}

async getOrGenerateState(
blockNumber: number,
): Promise<DeepReadonly<PoolState> | null> {
const state = this.getState(blockNumber);
if (state) {
return state;
}

this.logger.error(
`PancakeV3: No state found for ${this.name} ${this.addressesSubscribed[0]}, generating new one`,
);
try {
const newState = await this.generateState(blockNumber);

if (!newState) {
this.logger.error(
`PancakeV3: Could not generate state for ${this.name} ${this.addressesSubscribed[0]}`,
);
return null;
}
this.setState(newState, blockNumber);
return newState;
} catch (error) {
this.logger.error(
`PancakeV3: Failed to generate state for ${this.name} ${this.addressesSubscribed[0]}`,
);
return null;
}
}

async generateState(blockNumber: number): Promise<Readonly<PoolState>> {
const callData = this._getStateRequestCallData();

Expand Down
10 changes: 0 additions & 10 deletions src/dex/pancakeswap-v3/pancakeswap-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,6 @@ export class PancakeswapV3

if (selectedPools.length === 0) return null;

await Promise.all(
selectedPools.map(pool => pool.getOrGenerateState(blockNumber)),
);

const poolsToUse = selectedPools.reduce(
(acc, pool) => {
let state = pool.getState(blockNumber);
Expand All @@ -636,12 +632,6 @@ export class PancakeswapV3
},
);

poolsToUse.poolWithoutState.forEach(pool => {
this.logger.warn(
`PancakeV3: Pool ${pool.name} on ${this.dexKey} has no state. Fallback to rpc`,
);
});

const rpcResultsPromise = this.getPricingFromRpc(
_srcToken,
_destToken,
Expand Down
30 changes: 0 additions & 30 deletions src/dex/uniswap-v3/uniswap-v3-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,36 +254,6 @@ export class UniswapV3EventPool extends StatefulEventSubscriber<PoolState> {
return TICK_BITMAP_TO_USE + TICK_BITMAP_BUFFER;
}

async getOrGenerateState(
blockNumber: number,
): Promise<DeepReadonly<PoolState> | null> {
const state = this.getState(blockNumber);
if (state) {
return state;
}

this.logger.error(
`UniV3: No state found for ${this.name} ${this.addressesSubscribed[0]}, generating new one`,
);
try {
const newState = await this.generateState(blockNumber);

if (!newState) {
this.logger.error(
`UniV3: Could not generate state for ${this.name} ${this.addressesSubscribed[0]}`,
);
return null;
}
this.setState(newState, blockNumber);
return newState;
} catch (error) {
this.logger.error(
`UniV3: Failed to generate state for ${this.name} ${this.addressesSubscribed[0]}`,
);
return null;
}
}

async generateState(blockNumber: number): Promise<Readonly<PoolState>> {
const callData = this._getStateRequestCallData();

Expand Down
11 changes: 0 additions & 11 deletions src/dex/uniswap-v3/uniswap-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,18 +715,13 @@ export class UniswapV3

if (selectedPools.length === 0) return null;

await Promise.all(
selectedPools.map(pool => pool.getOrGenerateState(blockNumber)),
);

const poolsToUse = selectedPools.reduce(
(acc, pool) => {
let state = pool.getState(blockNumber);
if (state === null) {
this.logger.trace(
`${this.dexKey}: State === null. Fallback to rpc ${pool.name}`,
);
// as we generate state (if nullified) in previous Promise.all, here should only be pools with failed initialization
acc.poolWithoutState.push(pool);
} else {
acc.poolWithState.push(pool);
Expand All @@ -739,12 +734,6 @@ export class UniswapV3
},
);

poolsToUse.poolWithoutState.forEach(pool => {
this.logger.warn(
`UniV3: Pool ${pool.name} on ${this.dexKey} has no state. Fallback to rpc`,
);
});

const states = poolsToUse.poolWithState.map(
p => p.getState(blockNumber)!,
);
Expand Down

0 comments on commit 3d9a4c0

Please sign in to comment.