From 495232b1d1a3cb4f405ac74b229095a83af1bb5b Mon Sep 17 00:00:00 2001 From: green-jay Date: Wed, 27 Mar 2024 10:04:08 +0100 Subject: [PATCH] fix xyk volumes --- queries/coingecko/v1/tickers.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/queries/coingecko/v1/tickers.sql b/queries/coingecko/v1/tickers.sql index a6d6d6e..1b51209 100644 --- a/queries/coingecko/v1/tickers.sql +++ b/queries/coingecko/v1/tickers.sql @@ -519,17 +519,17 @@ xyk_pools AS ( tm.symbol as base_currency, tme.symbol as target_currency, (amount_in / 10^tm.decimals) / (amount_out / 10^tme.decimals) as last_price, - SUM(amount_in / 10^tm.decimals) OVER (PARTITION BY asset_in) as base_volume, - SUM(amount_out / 10^tme.decimals) OVER (PARTITION BY asset_out) as target_volume, + SUM(amount_in / 10^tm.decimals) OVER (PARTITION BY asset_in, asset_out) as base_volume, + SUM(amount_out / 10^tme.decimals) OVER (PARTITION BY asset_in, asset_out) as target_volume, CONCAT(tm.symbol, '_', tme.symbol) as pool_id, 0 as liquidity_in_usd, - MAX((amount_in / 10^tm.decimals) / (amount_out / 10^tme.decimals)) OVER (PARTITION BY asset_in) as high, - MIN((amount_in / 10^tm.decimals) / (amount_out / 10^tme.decimals)) OVER (PARTITION BY asset_in) as low, + MAX((amount_in / 10^tm.decimals) / (amount_out / 10^tme.decimals)) OVER (PARTITION BY asset_in, asset_out) as high, + MIN((amount_in / 10^tm.decimals) / (amount_out / 10^tme.decimals)) OVER (PARTITION BY asset_in, asset_out) as low, ROW_NUMBER() OVER (PARTITION BY tm.id, tme.id ORDER BY timestamp DESC) as rn FROM xyk_ranking xr JOIN token_metadata tm ON xr.asset_in = tm.id::text JOIN token_metadata tme ON xr.asset_out = tme.id::text - WHERE tm.id NOT BETWEEN 100 AND 199 AND tme.id NOT BETWEEN 100 AND 199 -- filter out unreportable assets + WHERE tm.type = 'token' AND tme.type = 'token' ORDER BY timestamp DESC ) SELECT