Skip to content

Commit

Permalink
Merge pull request #2579 from IntersectMBO/fix/2460-usersnap-the-stat…
Browse files Browse the repository at this point in the history
…ed-ada-for-my-voting-power-is-incorrect-others-are-also-reporting-the-same-bug-on-reddit

fix(#2460): fix calculating live voting power
  • Loading branch information
MSzalowski authored Dec 27, 2024
2 parents 3fe4890 + 29f24b9 commit f2534f5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ changes.

### Fixed

-
- Fix calculating DRep live voting power [Issue 2460](https://github.com/IntersectMBO/govtool/issues/2460)

### Changed

Expand Down
27 changes: 21 additions & 6 deletions govtool/backend/sql/get-voting-power.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
select coalesce(sum(uv.value), 0) as amount
from utxo_view uv
join delegation_vote dv on uv.stake_address_id = dv.addr_id
join drep_hash dh on dv.drep_hash_id = dh.id
where dh.raw = decode(?,'hex')
and dv.cert_index != 0
WITH LatestDelegationVote AS (
SELECT
addr_id,
MAX(id) AS latest_vote_id
FROM
delegation_vote
GROUP BY
addr_id
)
SELECT
SUM(uv.value) AS total_value
FROM
utxo_view uv
JOIN
stake_address sa ON sa.id = uv.stake_address_id
JOIN
LatestDelegationVote ldv ON uv.stake_address_id = ldv.addr_id
JOIN
delegation_vote dv ON dv.id = ldv.latest_vote_id
WHERE
dv.drep_hash_id = (SELECT id FROM drep_hash WHERE raw = decode(?,'hex'))

0 comments on commit f2534f5

Please sign in to comment.