Query editor
with gas_table as (select'txs' as tag,casewhen bytearray_substring(data, 1, 4) = 0xa9059cbb then 'transfer'when bytearray_substring(data, 1, 4) = 0x23b872dd then 'transferFrom'when bytearray_substring(data, 1, 4) = 0x095ea7b3 then 'approve'end as selector,gas_usedfrom {{chain}}.transactionswhere block_time > now() - interval '{{dt}}' dayand to = 0xdac17f958d2ee523a2206206994597c13d831ec7 -- USDTand bytearray_substring(data, 1, 4) in (0xa9059cbb, -- transfer(address _to, uint256 _value)0x23b872dd, -- transferFrom(address _from, address _to, uint256 _value)0x095ea7b3 -- approve(address _spender, uint256 _value)) and success = trueunion allselect'trace' as tag,casewhen bytearray_substring(input, 1, 4) = 0xa9059cbb then 'transfer'when bytearray_substring(input, 1, 4) = 0x23b872dd then 'transferFrom'when bytearray_substring(input, 1, 4) = 0x095ea7b3 then 'approve'end as selector,gas_usedfrom {{chain}}.traceswhere block_time > now() - interval '{{dt}}' dayand to = 0xdac17f958d2ee523a2206206994597c13d831ec7 -- USDTand bytearray_substring(input, 1, 4) in (0xa9059cbb, -- transfer(address _to, uint256 _value)0x23b872dd, -- transferFrom(address _from, address _to, uint256 _value)0x095ea7b3 -- approve(address _spender, uint256 _value)) and success = true)selecttag,selector,avg(gas_used) as avg_gas_used,max(gas_used) as max_gas_used,min(gas_used) as min_gas_used,count(if(gas_used < 10000, 1, null))*100/count(1) as "<10000",count(if(gas_used >= 10000 and gas_used < 20000, 1, null))*100/count(1) as "<20000",count(if(gas_used >= 20000 and gas_used < 30000, 1, null))*100/count(1) as "<30000",count(if(gas_used >= 30000 and gas_used < 40000, 1, null))*100/count(1) as "<40000",count(if(gas_used >= 40000 and gas_used < 50000, 1, null))*100/count(1) as "<50000",count(if(gas_used >= 50000 and gas_used < 60000, 1, null))*100/count(1) as "<60000",count(if(gas_used >= 60000, 1, null))*100/count(1) as ">60000"fromgas_tablegroup bytag,selector