From f2ce697175a9fe5717261254b08ddf4055c58eaa Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Thu, 23 Sep 2021 12:04:27 -0400 Subject: [PATCH] Add instructions on connecting to Postgres --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README.md b/README.md index af1e40c..27beabc 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,38 @@ And stop the listener with kubectl exec deploy/mev-inspect-deployment -- /app/listener stop ``` +## Exploring + +All inspect output data is stored in Postgres. + +To connect to the local Postgres database for querying, launch a client container with: +``` +kubectl run -i --rm --tty postgres-client --env="PGPASSWORD=password" --image=jbergknoff/postgresql-client -- mev_inspect --host=postgresql --user=postgres +``` + +When you see the prompt +``` +mev_inspect=# +``` + +You're ready to query! + +Try finding the total number of swaps decoded with UniswapV3Pool +``` +SELECT COUNT(*) FROM swaps WHERE abi_name='UniswapV3Pool'; +``` + +or top 10 arbs by gross profit that took profit in WETH +``` +SELECT * +FROM arbitrages +WHERE profit_token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' +ORDER BY profit_amount DESC +LIMIT 10; +``` + +Postgres tip: Enter `\x` to enter "Explanded display" mode which looks nicer for results with many columns + ## Contributing ### Guide @@ -150,3 +182,13 @@ docker compose down ``` Then go through the steps in the current README for kube setup + +### Error from server (AlreadyExists): pods "postgres-client" already exists +This means the postgres client container didn't shut down correctly + +Delete this one with +``` +kubectl delete pod/postgres-client +``` + +Then start it back up again