diff --git a/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/down.sql b/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/down.sql new file mode 100644 index 000000000..92e6e3639 --- /dev/null +++ b/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/down.sql @@ -0,0 +1 @@ +DROP VIEW IF EXISTS num_active_delegator_per_pool; diff --git a/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/up.sql b/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/up.sql new file mode 100644 index 000000000..3f572c106 --- /dev/null +++ b/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/up.sql @@ -0,0 +1,9 @@ +-- need this for delegation staking +CREATE OR REPLACE VIEW num_active_delegator_per_pool AS +SELECT pool_address, + COUNT(DISTINCT delegator_address) AS num_active_delegator +FROM current_delegator_balances +WHERE shares > 0 + AND delegator_address != '0x0000000000000000000000000000000000000000000000000000000000000000' + AND pool_type = 'active_shares' +GROUP BY 1;