Query editor
with bend_dao as (select users, amount_weth as amount, token_address, "nftAsset", "nftTokenId", tx_id,dt, nft_collection, typesfrom (select "onBehalfOf" as users, ("amount"/1e18) as amount_weth, "reserve" as token_address,"nftAsset", "nftTokenId", "evt_block_time"::date dt,"evt_tx_hash" as tx_id, 'borrow' as typesfrom bend."LendingPool_evt_Borrow"unionselect "borrower" as users, ("amount"/1e18) as amount_weth, "reserve" as token_address,"nftAsset", "nftTokenId", "evt_block_time"::date dt,"evt_tx_hash" as tx_id, 'repay' as typesfrom bend."LendingPool_evt_Repay") bendleft join dune_user_generated."cryptuschrist_nft_projects5" nft onnft."nft_contract" = bend."nftAsset"),blend_borrow as (select '\xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'::bytea as coin_address, tx_id, dt, nft_address, token_id,amount_weth/1e18 as amount_weth, nft_collection, borrower, 'borrow' as typesfrom (select date_trunc('day', block_time) as dt, tx_hash as tx_id,bytea2numeric(substring(data,184,9)) as amount_weth,bytea2numeric(substring(data,63,2)) as loan_id,bytea2numeric(substring(data,350,6)) as token_id,substring(data, 141 , 20) as borrower,substring(data, 109 , 20) as lender,substring(data, 77 , 20) as nft_addressfrom ethereum."logs"where topic1 = '\x06a333c2d6fe967ca967f7a35be2eb45e8caeb6cf05e16f55d42b91b5fe31255'and contract_address = '\x29469395eaf6f95920e59f858042f0e28d98a20b') aleft join dune_user_generated."cryptuschrist_nft_projects5" nft onnft."nft_contract" = a.nft_address),blend_repay as (select '\xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'::bytea as coin_address, coin_tx, dt, nft_address, token_id,amount_weth, nft_collection, repayer, 'repay' as typesfrom (select "from" as repayer, "to" as lender, "value"/1e18 as amount_weth, evt_tx_hash as coin_tx,date_trunc('day', evt_block_time) as dt,row_number() over (partition by evt_tx_hash order by value desc) as ordersfrom erc20."ERC20_evt_Transfer"where evt_tx_hash in (select tx_hashfrom ethereum."logs"where topic1 = '\x2469cc9e12e74c63438d5b1117b318cd3a4cdaf9d659d9eac6d975d14d963254'and contract_address = '\x29469395eaf6f95920e59f858042f0e28d98a20b')) erc20join(select contract_address as nft_address, "tokenId" as token_id, evt_tx_hash as nft_txfrom erc721."ERC721_evt_Transfer") erc721 onerc20.coin_tx = erc721.nft_txleft join dune_user_generated."cryptuschrist_nft_projects5" nft onnft."nft_contract" = erc721.nft_addresswhere orders = 1