watcher-ts/packages/uni-watcher
nikugogoi cfd293f11b
Fix job-runner stop and restart in uni-watcher (#319)
* Fix job-runner stop and restart in uni-watcher

* Fix blocks processed twice after processing missing parent block
2021-12-17 11:57:09 +05:30
..
environments Process events in singe job and avoid block progress query to improve performance (#306) 2021-12-10 10:44:10 +05:30
src Fix job-runner stop and restart in uni-watcher (#319) 2021-12-17 11:57:09 +05:30
test Changes to improve performance for event processing job (#304) 2021-12-08 11:11:29 +05:30
.eslintignore Uniswap watcher package with event schema (#113) 2021-07-01 16:42:37 +05:30
.eslintrc.json Test for entities after TransferEvent (#196) 2021-08-10 12:09:00 +05:30
.gitignore uni-watcher smoke test (#172) 2021-07-30 19:50:56 +05:30
.mocharc.yml Smoke test for entities after Mint event (#185) 2021-08-05 17:12:11 +05:30
package.json Use node v16 and pprof to generate profile data for watchers (#299) 2021-12-09 10:39:35 +05:30
README.md Run services from transpiled ES5 (#239) 2021-09-02 10:27:56 +05:30
tsconfig.json Enable source maps for transpiled files (#242) 2021-09-07 16:01:15 +05:30

Uniswap Watcher

Setup

Create a postgres12 database for the job queue:

sudo su - postgres
createdb uni-watcher-job-queue

Enable the pgcrypto extension on the job queue database (https://github.com/timgit/pg-boss/blob/master/docs/usage.md#intro).

Example:

postgres@tesla:~$ psql -U postgres -h localhost uni-watcher-job-queue
Password for user postgres:
psql (12.7 (Ubuntu 12.7-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

uni-watcher-job-queue=# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
uni-watcher-job-queue=# exit

Create a postgres12 database for the address watcher:

sudo su - postgres
createdb uni-watcher

Update environments/local.toml with database connection settings for both the databases.

Run

Build files:

$ yarn build

Run the server:

$ yarn server

# For development.
$ yarn server:dev

# For specifying config file.
$ yarn server -f environments/local.toml

Start the job runner:

$ yarn job-runner

# For development.
$ yarn job-runner:dev

# For specifying config file.
$ yarn job-runner -f environments/local.toml

Start watching the factory contract:

$ yarn watch:contract --address 0xContractAddress --kind <contract-kind> --startingBlock <start-block>

# For specifying config file.
$ yarn watch:contract -f environments/local.toml --address 0xContractAddress --kind <contract-kind> --startingBlock <start-block>

Example:

$ yarn watch:contract --address 0xfE0034a874c2707c23F91D7409E9036F5e08ac34 --kind factory --startingBlock 100

Start watching the NonFungiblePositionManager contract:

Example:

$ yarn watch:contract --address 0xB171168C0df9457Ff3E3D795aE25Bf4f41e2FFE3 --kind nfpm --startingBlock 100

To fill a block range:

yarn fill --startBlock <from-block> --endBlock <to-block>

# For specifying config file.
$ yarn fill -f environments/local.toml --startBlock <from-block> --endBlock <to-block>

Example:

$ yarn fill --startBlock 1000 --endBlock 2000

Test

To test the watchers locally:

  • Deploy the Uniswap contracts
  • Watch the Factory and NonFungiblePositionManager contracts
  • Send transactions to trigger events

See https://github.com/vulcanize/uniswap-v3-periphery/blob/watcher-ts/demo.md for instructions.

Smoke test

To run a smoke test:

  • Start the server and the job-runner.

  • To build contracts for tests, run the command below in root of the repository:

    $ yarn build:contracts
    
  • Run:

    $ yarn smoke-test