CryptoIcicleAave - 3. AAVE positions in Euro stablecoins around July 13th.
    Updated 2023-04-13
    -- Aave - 3. AAVE positions in Euro stablecoins around July 13th.
    -- On July 13th, for the first time in 20 years the Euro reached 1:1 parity with the U.S. Dollar.
    -- Show daily or hourly positions (supply and borrow) of Euro stablecoins on AAVE before and after July 13th.
    -- If appropriate, you may set your data to refresh daily.

    -- Function signature credit https://app.flipsidecrypto.com/velocity/queries/9fd237e9-45a2-4840-9e89-e48c765c7d56
    with txns as (
    select
    iff(origin_function_signature = '0x617ba037', 'supply', 'borrow') as position,
    iff(block_timestamp::date < '2022-07-13', 'before', 'after') as type,
    event_inputs:value/1e18 as amount,
    CASE contract_address
    WHEN '0xe0b52e49357fd4daf2c15e02058dce6bc0057db4' THEN 'AGEUR'
    WHEN '0xe111178a87a3bff0c8d18decba5798827539ae99' THEN 'ERUS'
    WHEN '0x4e3decbb3645551b8a19f0ea1678079fcb33fb4c' THEN 'JEUR'
    END as token,
    *
    from polygon.core.fact_event_logs e
    join flipside_prod_db.crosschain.address_labels l on e.contract_address = l.address
    where
    -- https://docs.aave.com/developers/deployed-contracts/v3-mainnet/polygon
    contract_address in
    (
    '0xe0b52e49357fd4daf2c15e02058dce6bc0057db4', -- AGEUR
    '0xe111178a87a3bff0c8d18decba5798827539ae99', -- ERUS
    '0x4e3decbb3645551b8a19f0ea1678079fcb33fb4c' -- JEUR
    )
    and ( origin_function_signature = '0x617ba037' -- Supply
    or origin_function_signature = '0xa415bcad' -- Borrow
    )
    and event_name = 'Transfer'
    )

    select
    date_trunc('{{date_range}}',block_timestamp) as date,
    concat(position,':', type) as type,
    Run a query to Download Data