Skip to content

Commit

Permalink
fixup! fixup! fixup! wip: naive insta_rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Mar 31, 2024
1 parent d6648c3 commit 06e2376
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/sql/accounts/accounts_stake_address.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,13 @@ SELECT sa.view AS "stake_address",
-- SUM of all utxos + withdrawables (rewards (all types including rewards + refunds + treasury + reserves) - withdrawals
)::TEXT AS "controlled_amount", -- cast to TEXT to avoid number overflow
(
COALESCE(rewards_sum.amount, 0)
+ COALESCE(instant_rewards_sum.amount, 0)
COALESCE(rewards_sum.amount, 0) + COALESCE(instant_rewards_sum.amount, 0)
)::TEXT AS "rewards_sum", -- cast to TEXT to avoid number overflow
COALESCE(withdrawals_sum.amount, 0)::TEXT AS "withdrawals_sum", -- cast to TEXT to avoid number overflow
COALESCE(reserves_sum.amount, 0)::TEXT AS "reserves_sum", -- cast to TEXT to avoid number overflow
COALESCE(treasury_sum.amount, 0)::TEXT AS "treasury_sum", -- cast to TEXT to avoid number overflow
(
(
COALESCE(rewards_sum.amount, 0) + COALESCE(instant_rewards_sum.amount, 0) + COALESCE(refunds_sum.amount, 0) - COALESCE(withdrawals_sum.amount, 0)
)
COALESCE(rewards_sum.amount, 0) + COALESCE(instant_rewards_sum.amount, 0) + COALESCE(refunds_sum.amount, 0) - COALESCE(withdrawals_sum.amount, 0)
)::TEXT AS "withdrawable_amount", -- cast to TEXT to avoid number overflow
(
SELECT pool_id
Expand Down Expand Up @@ -120,7 +117,6 @@ FROM stake_address sa
SELECT *
FROM current_epoch
)
AND type <> 'refund'
)
GROUP BY addr_id
) AS "instant_rewards_sum" ON (instant_rewards_sum.addr_id = sa.id)
Expand Down

0 comments on commit 06e2376

Please sign in to comment.