Query editor
/*Query outputs the list of holders of a target token, including:1. Wallet addresses2. Wallet balance3. % of the total token supply held4. Staking balance if the project has any token staking*/WITH/*1. Calculating net balances of wallets which interacted with the target token at least once:-- token_sales_timestamp_1 -> wallets which sold the token and amounts sold by wallet-- token_buys_timestamp_1 -> wallets which bought the token and amounts bought by wallet-- holders_balances_timestamp_1 -> net (bought-sold) per walletNOTE! We use token transfer events here, so this will include airdrops and other indirect token flows in and out.*/token_sales_timestamp_1 AS (SELECT "from" AS seller, SUM(value) AS amt_soldFROM erc20_{{blockchain}}.evt_transferWHERE contract_address = {{token_address}}AND "from" NOT IN ({{addresses_to_ignore}})AND evt_block_time <= TIMESTAMP '{{timestamp 1}}'GROUP BY "from"),token_sales_timestamp_2 AS (SELECT "from" AS seller, SUM(value) AS amt_soldFROM erc20_{{blockchain}}.evt_transferWHERE contract_address = {{token_address}}AND "from" NOT IN ({{addresses_to_ignore}})AND evt_block_time <= TIMESTAMP '{{timestamp 2}}'GROUP BY "from"),token_sales_current AS (SELECT "from" AS seller, SUM(value) AS amt_soldFROM erc20_{{blockchain}}.evt_transferWHERE contract_address = {{token_address}}AND "from" NOT IN ({{addresses_to_ignore}})GROUP BY "from"),token_buys_timestamp_1 AS (SELECT "to" AS buyer, SUM(value) AS amt_boughtFROM erc20_{{blockchain}}.evt_transferWHERE contract_address = {{token_address}}AND "to" NOT IN ({{addresses_to_ignore}})AND evt_block_time <= TIMESTAMP '{{timestamp 1}}'GROUP BY "to"),token_buys_timestamp_2 AS (SELECT "to" AS buyer, SUM(value) AS amt_boughtFROM erc20_{{blockchain}}.evt_transferWHERE contract_address = {{token_address}}AND "to" NOT IN ({{addresses_to_ignore}})AND evt_block_time <= TIMESTAMP '{{timestamp 2}}'GROUP BY "to"),token_buys_current AS (SELECT "to" AS buyer, SUM(value) AS amt_boughtFROM erc20_{{blockchain}}.evt_transferWHERE contract_address = {{token_address}}