Yousefi_1994BendDAO Collateral by Collection
    Updated 2022-09-07
    with bend_loan_created as (
    select
    origin_from_address,
    substr(data, 27 + 0 * 64, 40) as nft_asset,
    ethereum.public.udf_hex_to_int(topics[3]) as loan_id
    from ethereum.core.fact_event_logs
    where contract_address = '0x5f6ac80cdb9e87f3cfa6a90e5140b9a16a361d5c'
    and topics[0] = '0xd08b40d1df4963a65ee43b1f9e7fabb01f24971fe4562cd297286e59606fb40e'
    and contract_name is null
    and event_name is null
    and event_inputs is null
    limit 50000
    ),
    bend_loan_repaid as (
    select
    ethereum.public.udf_hex_to_int(topics[2]) as loan_id
    from ethereum.core.fact_event_logs
    where contract_address = '0x5f6ac80cdb9e87f3cfa6a90e5140b9a16a361d5c'
    and topics[0] = '0xc75f1eaee157bc8a900f5c27364c2c4d99adfac7833e685565777342ef2172b1'
    and contract_name is null
    and event_name is null
    and event_inputs is null
    limit 50000
    ),
    bend_loan_created_cast as (
    select
    origin_from_address as depositor,
    concat('0x', cast(nft_asset as string)) as asset,
    cast(loan_id as string) as id
    from bend_loan_created
    ),
    bend_loan_repaid_cast as (
    select
    cast(loan_id as string) as id
    from bend_loan_repaid
    ),
    Run a query to Download Data