Query editor
WITH wallet_mints AS (-- Mints from the old contractSELECTc.provider AS wallet_address,SUM(CAST(m.mintedAmount AS DOUBLE)) / 1e18 AS total_mintedFROM resolv_ethereum.USRMintAndRedeemRequests_evt_MintRequestCompleted mJOIN resolv_ethereum.USRMintAndRedeemRequests_evt_MintRequestCreated cON m.id = c.idGROUP BY c.providerUNION ALL-- Mints from the new contractSELECTc.provider AS wallet_address,SUM(CAST(m.mintedAmount AS DOUBLE)) / 1e18 AS total_mintedFROM resolv_ethereum.USRExternalRequestsManager_evt_MintRequestCompleted mJOIN resolv_ethereum.USRExternalRequestsManager_evt_MintRequestCreated cON m.id = c.idGROUP BY c.provider),wallet_burns AS (-- Burns from the old contractSELECTc.provider AS wallet_address,SUM(CAST(b.burnedAmount AS DOUBLE)) / 1e18 AS total_burnedFROM resolv_ethereum.USRMintAndRedeemRequests_evt_BurnRequestCompleted bJOIN resolv_ethereum.USRMintAndRedeemRequests_evt_BurnRequestCreated cON b.id = c.idGROUP BY c.providerUNION ALL-- Burns from the new contractSELECTc.provider AS wallet_address,SUM(CAST(b.burnedAmount AS DOUBLE)) / 1e18 AS total_burnedFROM resolv_ethereum.USRExternalRequestsManager_evt_BurnRequestCompleted bJOIN resolv_ethereum.USRExternalRequestsManager_evt_BurnRequestCreated cON b.id = c.idGROUP BY c.provider),aggregated_mints AS (SELECT wallet_address, SUM(total_minted) AS total_mintedFROM wallet_mintsGROUP BY wallet_address),aggregated_burns AS (SELECT wallet_address, SUM(total_burned) AS total_burnedFROM wallet_burnsGROUP BY wallet_address),wallet_net_mints AS (SELECTCOALESCE(m.wallet_address, b.wallet_address) AS wallet_address,COALESCE(m.total_minted, 0) AS total_minted,COALESCE(b.total_burned, 0) AS total_burned,COALESCE(m.total_minted, 0) - COALESCE(b.total_burned, 0) AS net_mintsFROM aggregated_mints mFULL OUTER JOIN aggregated_burns b