Query editor
WITHnear_price as (selecttimestamp as dt,case when contract_address = 0x85f17cf997934a597031b2e18a9ab6ebd4b9f6a4 then price end as near_price_usd,case when contract_address = 0xdac17f958d2ee523a2206206994597c13d831ec7 then price end as usdt_price_usd,case when contract_address = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 then price end as usdc_price_usdfromprices.daywhereblockchain = 'ethereum'and contract_address in (0x85f17cf997934a597031b2e18a9ab6ebd4b9f6a4, 0xdac17f958d2ee523a2206206994597c13d831ec7, 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) --NEAR, USDT, USDC),trading_parsed as (selecttx_hash,tx_from as trader,b.block_time,block_date,casewhen json_extract(json_extract(json_extract(REPLACE(CAST(json_extract(action_function_call_args_parsed, '$.msg') AS varchar), ' ', ''), '$.actions'), cast(concat('$[', cast((ROW_NUMBER() OVER (PARTITION BY receipt_id ORDER BY index_in_execution_outcome_logs asc)) -1 as varchar), ']') as varchar)), '$.pool_id') is not nullthen CAST(json_extract(json_extract(json_extract(REPLACE(CAST(json_extract(action_function_call_args_parsed, '$.msg') AS varchar), ' ', ''), '$.actions'), cast(concat('$[', cast((ROW_NUMBER() OVER (PARTITION BY receipt_id ORDER BY index_in_execution_outcome_logs asc)) -1 as varchar), ']') as varchar)), '$.pool_id') as varchar)else CAST(json_extract(json_extract(json_extract(action_function_call_args_parsed, '$.actions'), cast(concat('$[', cast((ROW_NUMBER() OVER (PARTITION BY receipt_id ORDER BY index_in_execution_outcome_logs asc)) -1 as varchar), ']') as varchar)), '$.pool_id') as varchar)end as pool_id,regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 1) as amount_in_raw,replace(regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 2), ',', '') as token_in,regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 3) as amount_out_raw,replace(regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 4), ',', '') as token_out,casewhen regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 2) = 'wrap.near'then cast(regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 1) as double) / 1e24when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 4) = 'wrap.near'then cast(regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 3) as double) / 1e24when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 2) = 'usdt.tether-token.near'then cast(regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 1) as double) / 1e6when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 4) = 'usdt.tether-token.near'then cast(regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 3) as double) / 1e6when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 2) = '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1'then cast(regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 1) as double) / 1e6when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 4) = '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1'then cast(regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 3) as double) / 1e6end as normalized_amount,casewhen regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 2) = 'wrap.near'then 'NEAR'when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 4) = 'wrap.near'then 'NEAR'when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 2) = 'usdt.tether-token.near'then 'USDT'when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 4) = 'usdt.tether-token.near'then 'USDT'when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 2) = '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1'then 'USDC'when regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 4) = '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1'then 'USDC'end as normalized_token,casewhen regexp_extract(split(log, ',')[1], 'Swapped +([0-9]+) +([^ ]+) +for +([0-9]+) +([^ ]+)', 2) = 'cfi.consumer-fi.near'then 'Sell CFI'