Query editor
-- I need you to analyze our locked depositors and figure out who amongst them came over from Pendle-- and who amongst them currently holds PTs or has held PTs in the pastwith transactions as (select * from query_5206930), locks as (selectamount, duration,min(block_time) over (partition by address) as first_time, block_time,address as user, tx_hashfrom transactionswhere mode='lock'), pendlers_raw as (selectvarbinary_substring(data,13,20) as user, block_time, block_number,min(block_time) over (partition by varbinary_substring(data,13,20)) as first_time,cast(varbinary_to_int256(varbinary_substring(data,33,32)) as double) as amount_pt,cast(varbinary_to_int256(varbinary_substring(data,65,32)) as double) as amount_token,varbinary_substring(topic2,13,20) as market,varbinary_substring(topic3,13,20) as token,tx_hashfrom ethereum.logswhereblock_number >= 19759272 andcontract_address=0x888888888889758F76e7103c6CbF23ABbF58F946 andtopic0=0xd3c1d9b397236779b29ee5b5b150c1110fc8221b6b6ec0be49c9f4860ceb2036 andvarbinary_substring(data,13,20) in (select user from locks)), pairs as (select distinct token, marketfrom pendlers_raw), tokens as (selectp.token, t1.decimals as decimals_token,p.market, t2.decimals as decimals_marketfrom pairs pleft join tokens.erc20 t1 on t1.contract_address = p.tokenleft join tokens.erc20 t2 on t2.contract_address = p.market), pendlers as (selectp.user, p.block_time, p.block_number, p.first_time,p.amount_pt/pow(10,coalesce(t.decimals_market,18)) as amount_pt,p.amount_token/pow(10,t.decimals_token) as amount_token,p.market, p.token, tx_hash, decimals_market, decimals_tokenfrom pendlers_raw pjoin tokens t on p.token=t.token and p.market=t.market)select distinct * from pendlers