Skip to content

Commit f2534f5

Browse files
authored
Merge pull request #2579 from IntersectMBO/fix/2460-usersnap-the-stated-ada-for-my-voting-power-is-incorrect-others-are-also-reporting-the-same-bug-on-reddit
fix(#2460): fix calculating live voting power
2 parents 3fe4890 + 29f24b9 commit f2534f5

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ changes.
1616

1717
### Fixed
1818

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

2121
### Changed
2222

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
select coalesce(sum(uv.value), 0) as amount
2-
from utxo_view uv
3-
join delegation_vote dv on uv.stake_address_id = dv.addr_id
4-
join drep_hash dh on dv.drep_hash_id = dh.id
5-
where dh.raw = decode(?,'hex')
6-
and dv.cert_index != 0
1+
WITH LatestDelegationVote AS (
2+
SELECT
3+
addr_id,
4+
MAX(id) AS latest_vote_id
5+
FROM
6+
delegation_vote
7+
GROUP BY
8+
addr_id
9+
)
10+
SELECT
11+
SUM(uv.value) AS total_value
12+
FROM
13+
utxo_view uv
14+
JOIN
15+
stake_address sa ON sa.id = uv.stake_address_id
16+
JOIN
17+
LatestDelegationVote ldv ON uv.stake_address_id = ldv.addr_id
18+
JOIN
19+
delegation_vote dv ON dv.id = ldv.latest_vote_id
20+
WHERE
21+
dv.drep_hash_id = (SELECT id FROM drep_hash WHERE raw = decode(?,'hex'))

0 commit comments

Comments
 (0)