Query editor
with token_contracts(contract_address, symbol_name, decimals) as (values(0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 'USDC', 6),(0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, 'WETH', 18),(0x6b175474e89094c44da98b954eedeac495271d0f, 'DAI', 18),(0x514910771af9ca656af840dff83e8264ecf986ca, 'LINK', 18),(0xdac17f958d2ee523a2206206994597c13d831ec7, 'USDT', 6),(0x1f9840a85d5af5bf1d1762f925bdaddc4201f984, 'UNI', 18),(0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3, 'MIM', 18),(0x853d955acef822db058eb8505911ed77f175b99e, 'FRAX', 18),(0x2260fac5e5542a773aa44fbcfedf7c193bc2c599, 'WBTC', 8)), token_prices as (SELECT date_trunc('day', minute) as day,symbol,avg(price) as avg_price,max(token_contracts.contract_address) as contract_address,max(token_contracts.decimals) as decimalsFROM prices.usd as usd join token_contracts on (usd.symbol = token_contracts.symbol_name)WHERE symbol IN ('WETH', 'WBTC', 'USDC', 'USDT', 'MIM', 'FRAX', 'UNI', 'DAI', 'LINK', 'AVAX')and minute >= (now() - INTERVAL '30' DAY)GROUP BY 1, 2ORDER BY 1 DESC), usdc_deposit AS (selecttx.contract_address as deposit_token_contract_address,ccd.call_tx_hash,cast(ccd.depositAmount as int256) as depositAmount,DATE_TRUNC('day',ccd.call_block_time) as day,tx."from" as wallet_addressfrom dydx_ethereum.CurrencyConvertor_call_deposit ccdleft join erc20_ethereum.evt_Transfer tx on (ccd.call_tx_hash = tx.evt_tx_hash)where tx."to" = 0x8e8bd01b5a9eb272cc3892a2e40e64a716aa2a40and tx.evt_block_time >= (now() - INTERVAL '30' DAY)and ccd.call_block_time >= (now() - INTERVAL '30' DAY)), usdc_deposit_with_price AS (selectusdc_deposit.*,(usdc_deposit.depositAmount * token_prices.avg_price)/POW(10, token_prices.decimals) as deposit_usdcfrom usdc_depositjoin token_priceson (usdc_deposit.day = token_prices.day and usdc_deposit.deposit_token_contract_address = token_prices.contract_address)), erc20_deposti AS (selecttx.contract_address as deposit_token_contract_address,ccd.call_tx_hash,cast(ccd.tokenFromAmount as int256) as depositAmount,DATE_TRUNC('day',ccd.call_block_time) as day,tx."from" as wallet_addressfrom dydx_ethereum.CurrencyConvertor_call_depositERC20 ccdleft join erc20_ethereum.evt_Transfer tx on (ccd.call_tx_hash = tx.evt_tx_hash)where tx."to" = ccd.exchangeProxy and tx.contract_address=ccd.tokenFromand tx.evt_block_time >= (now() - INTERVAL '30' DAY)and ccd.call_block_time >= (now() - INTERVAL '30' DAY)), erc20_deposti_with_price AS (selecterc20_deposti.*,(erc20_deposti.depositAmount * token_prices.avg_price)/POW(10, token_prices.decimals) as deposit_usdcfrom erc20_depostijoin token_priceson (erc20_deposti.day = token_prices.day and erc20_deposti.deposit_token_contract_address = token_prices.contract_address)