I’m attempting to get the active stake value from cardano-db-sync for a pool at a specific epoch so I know how much stake it had for the next snapshot.

I’m currently using the following query

SELECT SUM(amount) FROM epoch_stake 

WHERE epoch_stake.epoch_no = $1 AND pool_id = $2

This query seems to work, but my result is quite a bit off when compared to what cardanoscan.io shows as the active stake for the same pool.

  • Active stake is an instantaneous stake distribution at the current block (and can change with each new block) whereas the epoch_stake table gives the stake distribution for a single epoch. Sep 23 at 10:24

1 Answer 1

  ph.view AS pool_id,
  sa.view AS stake_address,
FROM epoch_stake es
JOIN stake_address sa
  ON sa.id = addr_id
JOIN pool_hash ph
  ON ph.id = pool_id
WHERE epoch_no = #{epochNumber}

There are a bunch of more queries that might be helpful that you can find here: AdaGate API

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.