Query editor
--> percentage under-collateralised operatorsWITH CurrentSDPriceInETH AS (SELECTcall_block_time,output_0 / 1e18 AS sd_price_in_ethFROM stader_ethereum.StaderOracle_call_getSDPriceInETHORDER BY call_block_time DESCLIMIT 1),bondTransactions AS (SELECT"from" AS operator,SUM(value / 1e18) AS total_ethFROM ethereum.transactionsWHERE"to" = 0x4f4Bfa0861F62309934a5551E0B2541Ee82fdcF1AND value > 0GROUP BY "from"),sdTransactionsSum AS (SELECT"from" AS operator,SUM(ROUND(value / 1e18)) AS total_sdFROM erc20_ethereum.evt_TransferWHERE"to" = 0x7af4730cc8ebad1a050dcad5c03c33d2793ee91fGROUP BY "from"),AllOperators AS (SELECTeth.operator,eth.total_eth,COALESCE(sd.total_sd, 0) AS total_sd,eth.total_eth / 4 AS number_of_validators,COALESCE(sd.total_sd, 0) / (eth.total_eth / 4) AS actual_sd_per_validator,COALESCE(sd.total_sd, 0) / (eth.total_eth / 4) * CurrentSDPriceInETH.sd_price_in_eth AS sd_in_ethFROM bondTransactions AS ethLEFT JOIN sdTransactionsSum AS sd ON eth.operator = sd.operatorCROSS JOIN CurrentSDPriceInETH),UnderCollateralizedOperators AS (SELECT operatorFROM AllOperatorsWHERE sd_in_eth < 0.4)SELECT(COUNT(DISTINCT operator) * 100.0 / (SELECT COUNT(DISTINCT operator) FROM AllOperators)) AS under_collateralized_percentageFROM UnderCollateralizedOperators;