Skip to content

Commit

Permalink
Merge pull request #28 from galacticcouncil/fix-xyk-partitioning
Browse files Browse the repository at this point in the history
fix xyk volumes
  • Loading branch information
green-jay authored Mar 27, 2024
2 parents 2ae77af + 495232b commit 68670c7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions queries/coingecko/v1/tickers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 68670c7

Please sign in to comment.