diff --git a/.sqlx/query-c4a8b0ebbad2dff414a26c5bb92f50c3a4a481e7d1f839459798236cbffd25fe.json b/.sqlx/query-c4a8b0ebbad2dff414a26c5bb92f50c3a4a481e7d1f839459798236cbffd25fe.json deleted file mode 100644 index 9b4fcec..0000000 --- a/.sqlx/query-c4a8b0ebbad2dff414a26c5bb92f50c3a4a481e7d1f839459798236cbffd25fe.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT AVG(bid_wei)::TEXT\n FROM mev_blocks\n WHERE timestamp > NOW() - INTERVAL '6 months'\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "avg", - "type_info": "Text" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - null - ] - }, - "hash": "c4a8b0ebbad2dff414a26c5bb92f50c3a4a481e7d1f839459798236cbffd25fe" -} diff --git a/.sqlx/query-d8e2b668a36e6272aa9a6da3da4f3aa3ec234de3b4051ae7765b32770ed1c6eb.json b/.sqlx/query-d8e2b668a36e6272aa9a6da3da4f3aa3ec234de3b4051ae7765b32770ed1c6eb.json new file mode 100644 index 0000000..a9e1acd --- /dev/null +++ b/.sqlx/query-d8e2b668a36e6272aa9a6da3da4f3aa3ec234de3b4051ae7765b32770ed1c6eb.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY bid_wei)::TEXT AS median_bid_wei\n FROM mev_blocks\n WHERE timestamp > NOW() - INTERVAL '6 months'\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "median_bid_wei", + "type_info": "Text" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "d8e2b668a36e6272aa9a6da3da4f3aa3ec234de3b4051ae7765b32770ed1c6eb" +} diff --git a/src/bin/update-validator-rewards/mev_blocks.rs b/src/bin/update-validator-rewards/mev_blocks.rs index 3bd0024..802d9d9 100644 --- a/src/bin/update-validator-rewards/mev_blocks.rs +++ b/src/bin/update-validator-rewards/mev_blocks.rs @@ -47,7 +47,7 @@ pub async fn calc_mev_reward( ) -> Result { let mev_per_slot: EthNewtype = sqlx::query!( " - SELECT AVG(bid_wei)::TEXT + SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY bid_wei)::TEXT AS median_bid_wei FROM mev_blocks WHERE timestamp > NOW() - INTERVAL '6 months' " @@ -55,7 +55,7 @@ pub async fn calc_mev_reward( .fetch_one(executor) .await .unwrap() - .avg + .median_bid_wei .context("expect at least one block in mev_blocks table before computing MEV reward")? .parse::() .context("failed to parse MEV per slot as Wei")?