Query editor
WITH gate AS (SELECT project, chain,CASE chain WHEN 'optimism' THEN 'https://optimism-rpc.publicnode.com' WHEN 'arbitrum' THEN 'https://arbitrum-one-rpc.publicnode.com' END AS rpc,comptroller, market, cf_pctFROM query_7410589WHERE gate_decision='KEEP_GATE_OPEN' AND project IN ('wepiggy','aquariusloan')),sel AS (SELECTconcat('0x', substr(to_hex(keccak(to_utf8('admin()'))),1,8)) admin_sel,concat('0x', substr(to_hex(keccak(to_utf8('pendingAdmin()'))),1,8)) pending_admin_sel,concat('0x', substr(to_hex(keccak(to_utf8('pauseGuardian()'))),1,8)) pause_guardian_sel,concat('0x', substr(to_hex(keccak(to_utf8('comptrollerImplementation()'))),1,8)) implementation_sel,concat('0x', substr(to_hex(keccak(to_utf8('oracle()'))),1,8)) oracle_sel,concat('0x', substr(to_hex(keccak(to_utf8('closeFactorMantissa()'))),1,8)) close_factor_sel,concat('0x', substr(to_hex(keccak(to_utf8('liquidationIncentiveMantissa()'))),1,8)) liq_incentive_sel,concat('0x', substr(to_hex(keccak(to_utf8('interestRateModel()'))),1,8)) irm_sel,concat('0x', substr(to_hex(keccak(to_utf8('reserveFactorMantissa()'))),1,8)) reserve_factor_sel),comptrollers AS (SELECT DISTINCT project, chain, rpc, comptroller FROM gate),comp_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') 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') 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') 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') 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') 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') liq_incentive_hexFROM comptrollers c),comp_decoded AS (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 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_incentiveFROM comp_calls),market_calls AS (SELECT g.*,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', market, '","data":"', (SELECT admin_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') market_admin_hex,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', market, '","data":"', (SELECT irm_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') irm_hex,json_extract_scalar(json_parse(http_post(rpc, concat('{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"to":"', market, '","data":"', (SELECT reserve_factor_sel FROM sel), '"},"latest"]}'), ARRAY['Content-Type: application/json'])), '$.result') reserve_factor_hexFROM gate g),market_decoded AS (SELECT project, chain, comptroller, market, cf_pct,CASE WHEN market_admin_hex IS NOT NULL AND length(market_admin_hex)>=66 THEN concat('0x', substr(market_admin_hex,27,40)) END AS market_admin,CASE WHEN irm_hex IS NOT NULL AND length(irm_hex)>=66 THEN concat('0x', substr(irm_hex,27,40)) END AS interest_rate_model,try(CAST(bytearray_to_uint256(from_hex(substr(reserve_factor_hex,3,64))) AS DOUBLE))/1e18 AS reserve_factorFROM market_calls)SELECT m.project, m.chain, m.comptroller, c.admin AS comptroller_admin, c.pause_guardian, c.implementation AS comptroller_implementation,c.oracle, c.close_factor, c.liquidation_incentive,m.market, m.cf_pct, m.market_admin, m.interest_rate_model, m.reserve_factor,CASE