Query editor
withod_nftfi as (selectborrower as borrower_nftfi,sum(amount * price) as od,count(DISTINCT unique_id) as loansfrom(selectunique_id,case when borrower in (0x25ff4b398cd97b5bfbbe68378aae1f23cbe13bba, 0x6701b1d2e6d34727c0c37cdbd0cf421d3357dd0c) then tx_from else Borrower end as Borrower,token_contract,amountfrom query_3715978left join ethereum.logs on tx_hash = evt_tx_hashand topic0 = 0xaa4f96e6c4824e4edc8a9aaf6bdc9473a9ee27b3a46e44cc2f96e2d36de70c1fand block_time >= cast('2023-01-01' as date)where loan_status = 'Active')aleft join query_3675587 p on a.token_contract = p.contract_addressgroup by 1)select"Loan Due in",Borrower,a.Lender,a.Protocol,case when a.protocol = 'Gondi' and nft_collection = 0x823de2c44369e94cac3da789ad4b6493e27e4bfe then 'GONDI_USER_VAULT_V2'else Collectionend as Collection,"NFT ID","Loan Principal","Currency",APR,Duration,"Due Date","startDate","Loan Start tx",case when a.protocol in ('Zharta', 'Gondi') then 'Flexible'when a.protocol in ('Arcade','X2Y2') then 'Fixed'when a.protocol = 'NFTfi' and isProRata = true then 'Flexible'else 'Fixed'end as "fixed/flexible",--loanId,--contract_address,nft_collection,--version,link,loan_amount_usd,"Has the Borrower Used NFTfi","Borrower OD [in USD]","Borrower Active Loans","OD on Arcade [in USD] Borrower","Number of Active Loans on Arcade Borrower" as "Active Loans on Arcade Borrower",n.od as "OD on NFTfi [in USD] Borrower",n.loans as "Active Loans on NFTfi Borrower","OD on Gondi [in USD] Borrower",