Sbhn_NPinitial-silver
    Updated 2025-02-15
    with price as (
    select hour::date as datee,
    case when token_address = 'So11111111111111111111111111111111111111112' then 'BeRUj3h7BqkbdfFU7FBNYbodgf8GCHodzKvF9aVjNNfL'
    when token_address = '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs' then 'So11111111111111111111111111111111111111112'
    when token_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' then 'AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE' end as token,
    avg(price) as usdprice
    from solana.price.ez_prices_hourly
    group by 1,2
    ),

    deposit as (select
    sum(amount/pow(10,decimal)) as deposited,
    sum((amount/pow(10,decimal))*usdprice) as deposited_usd
    from eclipse.core.fact_transfers
    join price on block_timestamp::date=datee and mint=token
    where tx_to in ('JBUYTVaQAvp61GKnbgooEEzyTsevG1x5fYDnGoDD2soT','tyvjvUtLxNFQXWxQSerSzZdhTe1YCzq1odtmouLbtXx','DeRTnD4sgiPzNQaiximquqD5yZAhu3Aws2g4n2e8tNuR')
    and tx_id in (select DISTINCT tx_id
    from eclipse.core.fact_transactions
    join lateral flatten(input=>log_messages) f
    where f.value = 'Program log: Instruction: LendingAccountDeposit')
    ),

    borrow as (select

    sum(amount/pow(10,decimal)) as borrowed,
    sum((amount/pow(10,decimal))*usdprice) as borrowed_usd
    from eclipse.core.fact_transfers
    join price on block_timestamp::date=datee and mint=token
    where tx_from in ('JBUYTVaQAvp61GKnbgooEEzyTsevG1x5fYDnGoDD2soT','tyvjvUtLxNFQXWxQSerSzZdhTe1YCzq1odtmouLbtXx','DeRTnD4sgiPzNQaiximquqD5yZAhu3Aws2g4n2e8tNuR')
    and tx_id in (select DISTINCT tx_id
    from eclipse.core.fact_transactions
    join lateral flatten(input=>log_messages) f
    where f.value = 'Program log: Instruction: LendingAccountBorrow')
    ),

    repay as (select
    Last run: about 2 months ago
    INFLOW
    OUTFLOW
    NETFLOW
    1
    52536558.085972944636284.09155757900273.99441545
    1
    54B
    686s