Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ changes.

- Fix responsive error on menu [Issue 3055](https://github.com/IntersectMBO/govtool/issues/3055)
- Fix wrong placement of nav items in disconnected menu [Issue 3057](https://github.com/IntersectMBO/govtool/issues/3057)
- Fix missing subtraction withdrawals from ada holder balance [Issue 3061](https://github.com/IntersectMBO/govtool/issues/3061)

### Changed

Expand Down
16 changes: 14 additions & 2 deletions govtool/backend/sql/get-stake-key-voting-power.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,32 @@ Balance AS (
GROUP BY
addr_id,
addr_raw
),
Withdrawal AS (
SELECT
COALESCE(SUM(w.amount), 0) AS withdrawal_amount,
w.addr_id
FROM
withdrawal w
GROUP BY
w.addr_id
)
SELECT
(COALESCE(rr.amount, 0) + COALESCE(r.amount, 0) + COALESCE(b.amount, 0)) AS total_balance,
(COALESCE(rr.amount, 0) + COALESCE(r.amount, 0) + COALESCE(b.amount, 0) - COALESCE(w.withdrawal_amount, 0)) AS total_balance,
b.addr_raw::text AS stake_address
FROM
Balance b
LEFT JOIN
RewardRest rr ON rr.addr_id = b.addr_id
LEFT JOIN
Reward r ON r.addr_id = rr.addr_id
LEFT JOIN
Withdrawal w ON w.addr_id = b.addr_id
WHERE
b.addr_id = (SELECT id FROM stake_address WHERE hash_raw = decode(?, 'hex'))
GROUP BY
b.addr_raw,
rr.amount,
r.amount,
b.amount
b.amount,
w.withdrawal_amount