binhachonCopy of User Bonding Behavior - #2
    Updated 2022-07-04
    with bonding_transactions as (
    select
    block_timestamp,
    tx_hash,
    origin_from_address,
    tokenflow_eth.hextoint(substr(data, 67, 64)) as bondid
    from ethereum.core.fact_event_logs
    where 1=1 --tx_hash in ('0xf4c5b77c2fe0291c18a7fb25fa4d6ed624ec5048aca8b53859c8d34c1c23e590')
    and origin_function_signature = '0x7c770aae' --Deposit
    and origin_to_address = '0xe1d71b60642d597e6e3dbf6d0cd106ac3cfa65fa' --BondDepo
    and topics[0]::string = '0x1f58724e9d5598976a9faf8e2e354dbc7d54ab2d81e09e0c682e2893881e1aa7'
    ),
    bonding_transfer as (
    select
    block_timestamp,
    tx_hash,
    raw_amount/1e9 as FLOOR_amount
    from ethereum.core.fact_token_transfers
    where tx_hash in (select tx_hash from bonding_transactions where bondid = 25)
    and contract_address = '0xf59257e961883636290411c11ec5ae622d19455e'
    and to_address = '0xe1d71b60642d597e6e3dbf6d0cd106ac3cfa65fa'
    ),
    bonding_transfer_1 as (
    select
    tx_hash,
    contract_address,
    raw_amount/1e18 as token_amount
    from ethereum.core.fact_token_transfers
    where tx_hash in (select tx_hash from bonding_transactions where bondid = 25)
    --and contract_address = '0xf59257e961883636290411c11ec5ae622d19455e'
    and to_address = '0x91e453f442d25523f42063e1695390e325076ca2'
    )
    select
    bonding_transfer.*,
    origin_from_address as user_address,
    contract_address as token_address,
    Run a query to Download Data