Query editor
SELECTchain, time, repaid,'simple v1.0' as loan_type,loanId, lender, borrower,from_hex(json_value(collateral, 'strict $.assetAddress')) as collateralAddress,cast(json_query(collateral, 'strict $.category') as integer) as collateralCategory,cast(json_query(collateral, 'strict $.amount') as uint256) as collateralAmount,cast(json_query(collateral, 'strict $.id') as uint256) as collateralId,from_hex(json_value(asset, 'strict $.assetAddress')) as loanAssetAddress,cast(json_query(asset, 'strict $.amount') as uint256) as loanAmount,loanRepayAmount - cast(json_query(asset, 'strict $.amount') as uint256) as loanYield,date_diff('second', time, expiration) as duration,expirationFROM (SELECTchain, time, repaid, loanId,from_hex(json_value(terms, 'strict $.lender')) as lender,from_hex(json_value(terms, 'strict $.borrower')) as borrower,json_value(terms, 'strict $.collateral') as collateral,json_value(terms, 'strict $.asset') as asset,cast(json_query(terms, 'strict $.loanRepayAmount') as uint256) as loanRepayAmount,from_unixtime(cast(json_query(terms, 'strict $.expiration') as bigint)) as expirationFROM (SELECT'ethereum' as chain,c.evt_block_time as time,c.loanId,c.terms,r.evt_block_time as repaidFROM pwn_ethereum.PWNSimpleLoanV1_0_evt_LOANCreated as cLEFT JOIN pwn_ethereum.PWNSimpleLoanV1_0_evt_LOANPaidBack as rON c.loanId = r.loanIdUNION ALLSELECT'polygon' as chain,c.evt_block_time as time,c.loanId,c.terms,r.evt_block_time as repaidFROM pwn_polygon.PWNSimpleLoanV1_0_evt_LOANCreated as cLEFT JOIN pwn_polygon.PWNSimpleLoanV1_0_evt_LOANPaidBack as rON c.loanId = r.loanId))