Query editor
select * from dune.blocklytics.result_pendle_trades-- WITH-- topic_hashes as (-- SELECT-- topic0,-- label-- FROM (-- VALUES-- (0x5258a3c624debb1cc84b0f5f66c73eef048832eeebe7178e63e95a53cf28dc94, 'remove_liquidity_single_token'),-- (0x387bf301bf673df0120e2d57e639f0e05e5e03d5336577c4cd83c1bff96e8dee, 'add_liquidity_single_token'),-- (0xa3a2846538c60e47775faa60c6ae79b67dee6d97bb70e386ebbaf4c3a38e8b81, 'swap_yt_token'),-- (0xd3c1d9b397236779b29ee5b5b150c1110fc8221b6b6ec0be49c9f4860ceb2036, 'swap_pt_token')-- ) as temp_table (topic0, label)-- ),-- all_trades as (-- SELECT-- 'ethereum' as blockchain,-- el.contract_address,-- el.tx_hash,-- el.index as tx_index,-- el.block_number,-- el.block_time,-- bytearray_substring(topic2, 13, 20) as market_address,-- CASE-- WHEN th.label = 'swap_yt_token' THEN 'YT'-- WHEN th.label = 'swap_pt_token' THEN 'PT'-- WHEN th.label = 'remove_liquidity_single_token' THEN 'LP'-- WHEN th.label = 'add_liquidity_single_token' THEN 'LP'-- END as token_type,-- CASE-- WHEN th.label = 'swap_yt_token' THEN ABS(bytearray_to_int256(bytearray_substring(data,33,32))/1e18)-- WHEN th.label = 'swap_pt_token' THEN ABS(bytearray_to_int256(bytearray_substring(data,33,32))/1e18)-- WHEN th.label = 'remove_liquidity_single_token' THEN ABS(bytearray_to_int256(bytearray_substring(data,33,32))/1e18)-- WHEN th.label = 'add_liquidity_single_token' THEN ABS(bytearray_to_int256(bytearray_substring(data,65,32))/1e18)-- END as token_amount,-- bytearray_substring(topic3, 13, 20) as opposite_side_token_address,-- CASE-- WHEN th.label = 'swap_yt_token' THEN ABS(bytearray_to_int256(bytearray_substring(data,65,32)))-- WHEN th.label = 'swap_pt_token' THEN ABS(bytearray_to_int256(bytearray_substring(data,65,32)))-- WHEN th.label = 'remove_liquidity_single_token' THEN ABS(bytearray_to_int256(bytearray_substring(data,65,32)))-- WHEN th.label = 'add_liquidity_single_token' THEN ABS(bytearray_to_int256(bytearray_substring(data,33,32)))-- END as opposite_side_token_amount-- FROM-- ethereum.logs el-- INNER JOIN-- topic_hashes th-- ON el.topic0 = th.topic0-- WHERE el.block_time >= DATE '2024-01-01'-- AND el.contract_address IN (0x00000000005BBB0EF59571E58418F9a4357b68A0, 0x888888888889758F76e7103c6CbF23ABbF58F946) -- pendle routers-- UNION ALL-- SELECT-- 'arbitrum' as blockchain,-- el.contract_address,-- el.tx_hash,-- el.index as tx_index,