Updated 2025-03-09
    with

    main as (
    select
    tx_hash,
    block_timestamp,
    decoded_log:beneficiary::string as user,
    decoded_log:collateral_amount / 1e6 as collateral_amount_usd,
    decoded_log:avusd_amount / 1e18 as amount_usd,
    event_name
    from
    avalanche.core.ez_decoded_event_logs
    where
    tx_succeeded
    and origin_to_address = '0x1499cb3197427b78dc0e2d356a1e0e4149e0ed51'
    and origin_to_address = contract_address
    and event_name in ('Redeem', 'Mint')
    )

    select
    count(distinct iff(event_name = 'Mint', tx_hash, null)) as mints,
    count(distinct iff(event_name = 'Redeem', tx_hash, null)) as redeems,
    count(distinct iff(event_name = 'Mint', user, null)) as minters,
    count(distinct iff(event_name = 'Redeem', user, null)) as redeemers,
    sum(iff(event_name = 'Mint', amount_usd, 0)) as mint_volume_usd,
    sum(iff(event_name = 'Redeem', amount_usd, 0)) as redeem_volume_usd,
    mint_volume_usd - redeem_volume_usd as tvl_usd
    from
    main


    QueryRunArchived: QueryRun has been archived