Query editor
WITHavax_prices AS (--Prices here are delayed by ~10-15 minutesSELECTminute, priceFROM prices.usdWHERE symbol = 'AVAX'AND blockchain IS NULL),avax_tokens AS (SELECT *FROM tokens.erc20WHERE blockchain = 'avalanche_c'),listing_created_raw AS (SELECTlc.listingID, lc.isBuying, lc.token AS token_contract_address, t.symbol, lc.amount AS token_amount_raw, CAST(lc.amount / POWER(10, t.decimals) AS DOUBLE) AS token_amount, lc.price / 1e18 AS price, lc.price AS price_raw, lc.seller, lc.vault, tx.value / 1e18 AS tx_value, tx.value AS tx_value_raw, tx.hash AS tx_hash, tx."from" AS tx_from, tx.index AS tx_index, tx.block_number, tx.block_time, date_trunc('minute', tx.block_time) AS block_minute, tx.block_date, t.name, t.decimalsFROM labninety1_pass_otc_avalanche_c.pass_evt_listingcreated lcINNER JOIN avalanche_c.transactions txON lc.evt_block_number = tx.block_numberAND lc.evt_tx_hash = tx.hashINNER JOIN avax_tokens tON lc.token = t.contract_addressWHERE tx.block_number >= 63243103 --Block when Pass OTC was initially deployed),listing_created AS (SELECT*, IF(isBuying, 'Buying', 'Selling') AS listing_type/*Calculating listing price:When Buying: Price is total avax amount for purchaseWhen Selling: Price is avax amount per token*/, IF(isBuying, price, token_amount * price) AS price_total_amount_avax, IF(isBuying, price / token_amount, price ) AS price_per_token_avax/*