Query editor
with borrowed as (select sum(assets) as borrowed_assetsfrom accountable_v1_1_ethereum.accountableopenterm_evt_borrowedwhere contract_address = 0xffb6e81582be17b03e448a312d5af04e6cf6bd50), repaid as (select sum(assets) as repaid_assetsfrom accountable_v1_1_ethereum.accountableopenterm_evt_loanrepaidwhere contract_address = 0xffb6e81582be17b03e448a312d5af04e6cf6bd50), price as (select output_answer / 1e18 as usd_per_tgldfrom chainlink_ethereum.eacaggregatorproxy_v2_call_latestrounddatawhere contract_address = 0x369c67e8b026cc4ef98350f332d7dd52b85b7674and call_successorder by call_block_number desclimit 1)select ((borrowed_assets - coalesce(repaid_assets,0)) / 1e18) * usd_per_tgld as usd_value from borrowed cross join repaid cross join price