Query editor
WITH nftfi_loan_started as (SELECT'nftfi' as loan_type,contract_address,borrower,lender,CASEWHEN CAST(loanDuration as double) >= 86400 THEN CAST(loanDuration as double) / 86400ELSE CAST(loanDuration as double)END as loan_duration,loanERC20Denomination as loan_token_address,CAST(loanId as VARCHAR) as loan_id,loanPrincipalAmount as loan_amount,CAST(loanStartTime as double) as loan_start,maximumRepaymentAmount as maximum_repayment_amount,nftCollateralContract as collateral_contract,CAST(nftCollateralId as VARCHAR) as collateral_id,evt_block_number,evt_block_time,evt_index,evt_tx_hash,CAST(loanDuration as double) as loan_duration_raw,null as isProRataFROMnftfi_ethereum.NFTfi_evt_LoanStarted),directloanfixedcollectionoffer_v2_3_loanstarted as (SELECT'DirectLoanFixedCollectionOffer_v2.3' as loan_type,contract_address,borrower,lender,CASEWHEN CAST(json_extract_scalar(loanTerms, '$.loanDuration') as double) >= 86400 THEN CAST(json_extract_scalar(loanTerms, '$.loanDuration') as double) / 86400ELSE CAST(json_extract_scalar(loanTerms, '$.loanDuration') as double)END as loan_duration,from_hex(json_extract_scalar(loanTerms, '$.loanERC20Denomination')) as loan_token_address,CAST(loanId as VARCHAR) as loan_id,CAST(json_extract_scalar(loanTerms, '$.loanPrincipalAmount') as UINT256) as loan_amount,CAST(json_extract_scalar(loanTerms, '$.loanStartTime') as double) as loan_start,CAST(json_extract_scalar(loanTerms, '$.maximumRepaymentAmount') as UINT256) as maximum_repayment_amount,from_hex(json_extract_scalar(loanTerms, '$.nftCollateralContract')) as collateral_contract,CAST(json_extract_scalar(loanTerms, '$.nftCollateralId') as VARCHAR) as collateral_id,evt_block_number,evt_block_time,evt_index,evt_tx_hash,CAST(json_extract_scalar(loanTerms, '$.loanDuration') as double) as loan_duration_raw,null as isProRataFROMnftfi_ethereum.DirectLoanFixedCollectionOffer_v2_3_evt_LoanStarted),directloanfixedoffer_v2_3_loanstarted as (SELECT'DirectLoanFixedOffer_v2.3' as loan_type,contract_address,borrower,