Query editor
WITHREQPAYMENTS AS (SELECT'BNB' AS currency,DATE_TRUNC('{{aggregation period}}', BSCtx."block_time") AS Time,(BSCtx."value" / CAST(POWER(10, tok1.decimals) AS DOUBLE)) AS Amount,((BSCtx."value" * usd1.price) / CAST(POWER(10, tok1.decimals) AS DOUBLE)) AS Amount_USDFROMbnb.transactions AS BSCtxLEFT JOIN tokens.erc20 AS tok1 ON tok1."symbol" = 'BNB'LEFT JOIN prices.usd AS usd1 ON usd1."contract_address" = tok1."contract_address"AND usd1."minute" = DATE_TRUNC('minute', BSCtx."block_time")WHEREusd1.blockchain = 'bnb'AND tok1.blockchain = 'bnb'AND BSCtx."block_time" > CURRENT_TIMESTAMP - INTERVAL '{{x}}' {{last x}}AND "to" IN (0x37A8f5F64f2a84f2377481537F04D2A59C9f59B6 /* EthereumProxy v1 */,0x322F0037d272E980984F89E94Aae43BD0FC065E6 /* EthereumProxy v3 */,0xCa3353a15fCb5C83a1Ff64BFf055781aC5c4d2F4 /* EthConversionProxy v1 */,0x7Ebf48a26253810629C191b56C3212Fd0D211c26 /* EthConversionProxy v2 */)UNIONSELECTtok2.symbol AS currency,DATE_TRUNC('{{aggregation period}}', BEP20."evt_block_time") AS Time,(bep20."value" / CAST(POWER(10, tok2.decimals) AS DOUBLE)) AS Amount,((bep20."value" * usd2."price") / CAST(POWER(10, tok2."decimals") AS DOUBLE)) AS Amount_USDFROMbnb."logs" AS BSCtx2INNER JOIN erc20_bnb.evt_Transfer AS bep20 ON BSCtx2."tx_hash" = bep20."evt_tx_hash"AND bep20."to" <> 0x35d0e078755cd84d3e0656caab417dee1d7939c7LEFT JOIN tokens.erc20 AS tok2 ON tok2."contract_address" = bep20."contract_address"LEFT JOIN prices.usd AS usd2 ON usd2."contract_address" = bep20."contract_address"AND usd2."minute" = DATE_TRUNC('minute', bep20."evt_block_time") /* here needs the contract address to be specified along with its payment function in topic1 (TransferWithReferenceAndFee, TransferWithConversionAndReference, TransferWithReference). This can be found in the eventlog of a transaction on Etherscan for example */WHEREusd2.blockchain = 'bnb'AND tok2.blockchain = 'bnb'AND BSCtx2."block_time" > CURRENT_TIMESTAMP - INTERVAL '{{x}}' {{last x}}AND ((BSCtx2."contract_address" = 0x370DE27fdb7D1Ff1e1BaA7D11c5820a324Cf623CAND "topic0" = 0x9f16cbcc523c67a60c450e5ffe4f3b7b6dbe772e7abcadb2686ce029a9a0a2b6)OR (BSCtx2."contract_address" = 0xe72Ecea44b6d8B2b3cf5171214D9730E86213cA2AND "topic0" = 0x96d0d1d75923f40b50f6fe74613b2c23239149607848fbca3941fee7ac041cdc)OR (BSCtx2."contract_address" = 0x5f821c20947ff9be22e823edc5b3c709b33121b3AND "topic0" = 0x4d4e9dbb7207a31cc25529ccb52e52ddba30ded7734e32691d13da66df7f81da)