--主要从bnb.logs表取明细,需要根据具体的log来做灵活处理
--Stepn官方钱包转入转出GST
select
      stat_date
      ,sum(value) as gst_deposit_amount
      ,sum(value) as gst_withdraw_amount
 from 
 (
     select
            concat('0x',substr(topic2,27,40)) as from_wallet
            ,concat('0x',substr(topic3,27,40)) as to_wallet
            ,tx_hash
            ,conv(substr(data,3,64),16,10)/pow(10,{{decimals}})  as value
            ,block_time
            ,substr(block_time,1,10) as stat_date
            ,'deposit' as cate
        from bnb.logs
        where block_time >=  '2022-05-01 00:00'
        and contract_address = '0x4a2c860cec6471b9f5f5a336eb4f38bb21683c98'--GST合约地址
        and topic3 = '0x0000000000000000000000006238872a0bd9f0e19073695532a7ed77ce93c69e'--Stepn官方钱包
        
        union all
        
        select
            concat('0x',substr(topic2,27,40)) as from_wallet
            ,concat('0x',substr(topic3,27,40)) as to_wallet
            ,tx_hash
            ,conv(substr(data,3,64),16,10)/pow(10,{{decimals}})  as value
            ,block_time
            ,substr(block_time,1,10) as stat_date
            ,'withdraw' as cate
        from bnb.logs
        where block_time >=  '2022-05-01 00:00'
        and contract_address = '0x4a2c860cec6471b9f5f5a336eb4f38bb21683c98'
        and topic2 = '0x0000000000000000000000006238872a0bd9f0e19073695532a7ed77ce93c69e'
        
) a
group by 
    stat_date