freemartianPools on Ambient Finance copy
    Updated 2023-11-13
    -- forked from Pools on Ambient Finance @ https://flipsidecrypto.xyz/edit/queries/08121962-fdcd-4547-8312-06a087302b81

    -- ambient address: 0xaaaaaaaaa24eeeb8d57d431224f73832bc34f688
    -- pool signature: 0xa15112f9


    with
    -- eth AS(
    -- SELECT block_timestamp, tx_hash, origin_from_address, 'ETH' AS symbol,
    -- amount, amount_usd, 2 AS mark
    -- FROM ethereum.core.ez_eth_transfers
    -- WHERE eth_to_address = '0xaaaaaaaaa24eeeb8d57d431224f73832bc34f688'
    -- AND origin_function_signature = '0xa15112f9'
    -- ),
    -- tokens AS(
    -- SELECT block_timestamp, tx_hash, origin_from_address, symbol,
    -- amount, amount_usd, RANK() OVER(PARTITION BY tx_hash ORDER BY _log_id) AS mark
    -- FROM ethereum.core.ez_token_transfers
    -- WHERE to_address = '0xaaaaaaaaa24eeeb8d57d431224f73832bc34f688'
    -- AND origin_function_signature = '0xa15112f9'
    -- ),

    datas_add AS (
    SELECT block_timestamp, tx_hash, origin_from_address, 'ETH' AS symbol,
    amount, amount_usd, 2 AS mark
    FROM ethereum.core.ez_eth_transfers
    WHERE eth_to_address = '0xaaaaaaaaa24eeeb8d57d431224f73832bc34f688'
    AND origin_function_signature = '0xa15112f9'

    UNION

    SELECT block_timestamp, tx_hash, origin_from_address, symbol,
    amount, amount_usd, RANK() OVER(PARTITION BY tx_hash ORDER BY _log_id DESC) AS mark
    FROM ethereum.core.ez_token_transfers
    WHERE to_address = '0xaaaaaaaaa24eeeb8d57d431224f73832bc34f688'
    AND origin_function_signature = '0xa15112f9'
    Run a query to Download Data