From c19d6d1bd3e24c690e75f52e0695453770dc6c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20P=C3=A9rez?= Date: Wed, 19 Jul 2023 13:30:29 +0200 Subject: [PATCH] Add Uni v2 Pair Created Event migration BSC (#134) --- docker-compose.yml | 4 ++- ...00-CreateUniswapV2PairCreatedEventTable.ts | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 migrations/bsc/1666641601000-CreateUniswapV2PairCreatedEventTable.ts diff --git a/docker-compose.yml b/docker-compose.yml index 69c06a2c..5e2b6a05 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/migrations/bsc/1666641601000-CreateUniswapV2PairCreatedEventTable.ts b/migrations/bsc/1666641601000-CreateUniswapV2PairCreatedEventTable.ts new file mode 100644 index 00000000..cb8e5f3d --- /dev/null +++ b/migrations/bsc/1666641601000-CreateUniswapV2PairCreatedEventTable.ts @@ -0,0 +1,36 @@ +import { MigrationInterface, QueryRunner, getConnection } from 'typeorm'; + +export class CreateUniswapV2PairCreatedEventTable1666641601000 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + 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 { + const connection = getConnection(); + const { schema } = connection.options as any; + await queryRunner.query(`DROP TABLE ${schema}.uniswap_v2_pair_created_event;`); + } +}