Skip to content

Commit

Permalink
Add Uni v2 Pair Created Event migration BSC (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ktl-XV committed Jul 19, 2023
1 parent d44af8e commit c19d6d1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ services:
MAX_BLOCKS_TO_PULL: 5000
SECONDS_BETWEEN_RUNS: 1
FEAT_UNISWAP_V2_VIP_SWAP_EVENT: "true"
UNISWAP_V2_VIP_SWAP_SOURCES: "PancakeSwap,BakerySwap,SushiSwap"
UNISWAP_V2_VIP_SWAP_SOURCES: "PancakeSwap,BakerySwap,SushiSwap,CafeSwap,SwapLiquidity,ApeSwapFinance,CheeseSwap,Swap"
FEAT_UNISWAP_V2_PAIR_CREATED_EVENT: "true"
UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS: "PancakeSwap:0xca143ce32fe78f1f7019d7d551a6402fc5350c73:6809737,BakerySwap:0x01bf7c66c6bd861915cdaae475042d3c4bae16a7:470617,SushiSwap:0xc35dadb65012ec5796536bd9864ed8773abc74c4:5205069,CafeSwap:0x3e708fdbe3ada63fc94f8f61811196f1302137ad:5865260,SwapLiquidity:0x553990f2cba90272390f62c5bdb1681ffc899675:784352,ApeSwapFinance:0x0841bd0b734e4f5853f0dd8d7ea041c241fb0da6:4855901,CheeseSwap:0xdd538e4fd1b69b7863e1f741213276a6cf1efb3b:1569172"
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 15860129

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner, getConnection } from 'typeorm';

export class CreateUniswapV2PairCreatedEventTable1666641601000 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`
CREATE TABLE ${schema}.uniswap_v2_pair_created_events (
observed_timestamp NUMERIC NOT NULL,
contract_address VARCHAR NOT NULL,
transaction_hash VARCHAR NOT NULL,
transaction_index NUMERIC NOT NULL,
log_index NUMERIC NOT NULL,
block_hash VARCHAR NOT NULL,
block_number NUMERIC NOT NULL,
token0 VARCHAR NOT NULL,
token1 VARCHAR NOT NULL,
pair VARCHAR NOT NULL,
pair_factory_counter NUMERIC NULL,
protocol VARCHAR NOT NULL,
PRIMARY KEY (transaction_hash, log_index)
);
CREATE INDEX uniswap_v2_pair_created_events_block_number_idx ON ${schema}.uniswap_v2_pair_created_events (block_number);
CREATE INDEX uniswap_v2_pair_created_events_token0_idx ON ${schema}.uniswap_v2_pair_created_events (token0);
CREATE INDEX uniswap_v2_pair_created_events_token1_idx ON ${schema}.uniswap_v2_pair_created_events (token1);
CREATE INDEX uniswap_v2_pair_created_events_protocol_idx ON ${schema}.uniswap_v2_pair_created_events (protocol);
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
const connection = getConnection();
const { schema } = connection.options as any;
await queryRunner.query(`DROP TABLE ${schema}.uniswap_v2_pair_created_event;`);
}
}

0 comments on commit c19d6d1

Please sign in to comment.