Query editor
WITH _ AS (SELECT 'custodial wallets detectormethodology:-- take all TON & Jetton transactions-- find wallets that sent tokens only to addressesof one organization which have a special tagmade by @okhlopkov'), POTENTIAL_CUSTODIAL_WALLETS AS (SELECT *FROM ton.accounts AWHERE 1=1-- only with wallet_ interfacesAND A.interfaces IS NOT NULL -- ??AND cardinality(FILTER(A.interfaces, i->regexp_like(i, 'wallet_.*') )) > 0 -- wallets & highload)-------------------------------------------------------------------------------------- TON & jetton transfers--------------------------------------------------------, TON_TRANSFERS AS (SELECTblock_date, block_time, source, destination,'0:0000000000000000000000000000000000000000000000000000000000000000' AS token_address,value AS amountFROM ton.messages MWHERE 1=1AND direction = 'in' AND bounced = FALSE-- AND value > POWER(10, 9 + 0) -- at least 1 ton transferAND COALESCE(opcode, 0) != 260734629), JETTON_TRANSFERS AS (SELECTblock_date, block_time, source, destination, jetton_master AS token_address, amountFROM ton.jetton_events JEWHERE 1=1AND tx_aborted = FALSE AND amount > 0AND source IS NOT NULL AND destination IS NOT NULL -- not sure about that), TRANSFERS AS (SELECT * FROM JETTON_TRANSFERSUNION ALLSELECT * FROM TON_TRANSFERS), TRANSFERS_FOR_CLASSIFICATION AS (SELECT *FROM TRANSFERSWHERE source IS NULL OR destination IS NULL OR source <> destination)------------------------------------------------------------------------------------