Kruys-CollinsArbitrum Beefy Vaults TVL
    Updated 2024-11-12
    WITH
    base AS (
    SELECT
    block_timestamp,
    tx_hash,
    contract_address,
    decoded_log,
    event_name,
    event_index,
    l.address_name,
    l.address
    FROM
    arbitrum.core.fact_decoded_event_logs ct
    JOIN arbitrum.core.dim_labels l ON ct.contract_address = l.address
    WHERE contract_address IN (
    SELECT address
    FROM arbitrum.core.dim_labels
    WHERE project_name = 'beefy finance'
    AND label_subtype = 'vault'
    )
    AND event_name = 'Transfer'
    ),
    -- First, deduplicate the transfers by taking the first occurrence
    deduplicated_transfers AS (
    SELECT DISTINCT
    ct.block_timestamp as date,
    ct.tx_hash,
    decoded_log:from::string as frm_address,
    decoded_log:to::string as t_address,
    origin_function_signature as ofs,
    b.address_name,
    b.contract_address,
    FIRST_VALUE(amount_usd) OVER (
    PARTITION BY ct.tx_hash, b.contract_address, decoded_log:value::string
    ORDER BY ct.block_timestamp, b.event_index
    ) as amount_usd,
    QueryRunArchived: QueryRun has been archived