Query editor
WITH comptrollers(project, chain, rpc, comptroller) AS (SELECT DISTINCT project, chain,CASE chain WHEN 'ethereum' THEN 'https://ethereum-rpc.publicnode.com' WHEN 'optimism' THEN 'https://optimism-rpc.publicnode.com' WHEN 'base' THEN 'https://base-rpc.publicnode.com' WHEN 'linea' THEN 'https://rpc.linea.build' END AS rpc,comptrollerFROM query_7410589WHERE project IN ('bao_markets')UNION ALL SELECT 'hundred_finance','optimism','https://optimism-rpc.publicnode.com','0x0f390559f258eb8591c8e31cf0905e97cf36ace2'UNION ALL SELECT 'unfederalreserve_v1','ethereum','https://ethereum-rpc.publicnode.com','0x3105d328c66d8d55092358cf595d54608178e9b5'UNION ALL SELECT 'mendi','linea','https://rpc.linea.build','0x1b4d3b0421ddc1eb216d230bc01527422fb93103'UNION ALL SELECT 'moonwell','base','https://base-rpc.publicnode.com', concat('0x', to_hex(contract_address)) FROM moonwell_base.comptroller_evt_marketlisted GROUP BY 1,2,3,4),sel AS (SELECTconcat('0x', substr(to_hex(keccak(to_utf8('admin()'))),1,8)) AS admin_sel,concat('0x', substr(to_hex(keccak(to_utf8('pendingAdmin()'))),1,8)) AS pending_admin_sel,concat('0x', substr(to_hex(keccak(to_utf8('pauseGuardian()'))),1,8)) AS pause_guardian_sel,concat('0x', substr(to_hex(keccak(to_utf8('comptrollerImplementation()'))),1,8)) AS implementation_sel,concat('0x', substr(to_hex(keccak(to_utf8('oracle()'))),1,8)) AS oracle_sel,concat('0x', substr(to_hex(keccak(to_utf8('closeFactorMantissa()'))),1,8)) AS close_factor_sel,concat('0x', substr(to_hex(keccak(to_utf8('liquidationIncentiveMantissa()'))),1,8)) AS liq_incentive_sel),calls AS (SELECT c.*,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', comptroller, '","data":"', (SELECT admin_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') AS admin_hex,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', comptroller, '","data":"', (SELECT pending_admin_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') AS pending_admin_hex,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', comptroller, '","data":"', (SELECT pause_guardian_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') AS pause_guardian_hex,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', comptroller, '","data":"', (SELECT implementation_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') AS implementation_hex,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', comptroller, '","data":"', (SELECT oracle_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') AS oracle_hex,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', comptroller, '","data":"', (SELECT close_factor_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') AS close_factor_hex,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', comptroller, '","data":"', (SELECT liq_incentive_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') AS liq_incentive_hexFROM comptrollers c)SELECT project, chain, comptroller,CASE WHEN admin_hex IS NOT NULL AND length(admin_hex)>=66 THEN concat('0x', substr(admin_hex,27,40)) END AS admin,CASE WHEN pending_admin_hex IS NOT NULL AND length(pending_admin_hex)>=66 THEN concat('0x', substr(pending_admin_hex,27,40)) END AS pending_admin,CASE WHEN pause_guardian_hex IS NOT NULL AND length(pause_guardian_hex)>=66 THEN concat('0x', substr(pause_guardian_hex,27,40)) END AS pause_guardian,CASE WHEN implementation_hex IS NOT NULL AND length(implementation_hex)>=66 THEN concat('0x', substr(implementation_hex,27,40)) END AS implementation,CASE WHEN oracle_hex IS NOT NULL AND length(oracle_hex)>=66 THEN concat('0x', substr(oracle_hex,27,40)) END AS oracle,try(CAST(bytearray_to_uint256(from_hex(substr(close_factor_hex,3,64))) AS DOUBLE))/1e18 AS close_factor,try(CAST(bytearray_to_uint256(from_hex(substr(liq_incentive_hex,3,64))) AS DOUBLE))/1e18 AS liquidation_incentive,CASEWHEN admin_hex IS NULL OR length(admin_hex)<66 THEN 'ADMIN_SELECTOR_REVERT_OR_PROXY_PATTERN'WHEN lower(concat('0x', substr(admin_hex,27,40))) = lower(CASE WHEN pause_guardian_hex IS NOT NULL AND length(pause_guardian_hex)>=66 THEN concat('0x', substr(pause_guardian_hex,27,40)) END) THEN 'ADMIN_EQUALS_PAUSE_GUARDIAN'ELSE 'ADMIN_PRESENT'END AS admin_noteFROM callsORDER BY project, chain, comptroller