Skip to content

Commit

Permalink
chore: use decimal everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatil12 committed Dec 12, 2024
1 parent c33f103 commit 54734c8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
1 change: 0 additions & 1 deletion pkg/rewards/10_goldAvsODRewardAmounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ WITH reward_snapshot_operators AS (
ap.reward_hash,
ap.snapshot AS snapshot,
ap.token,
ap.tokens_per_registered_snapshot,
ap.tokens_per_registered_snapshot_decimal,
ap.avs AS avs,
ap.operator AS operator,
Expand Down
18 changes: 5 additions & 13 deletions pkg/rewards/7_goldActiveODRewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ active_rewards_updated_start_timestamps AS (
COALESCE(MAX(g.snapshot), ap.reward_start_exclusive) AS reward_start_exclusive,
ap.reward_end_inclusive,
ap.token,
-- We use floor to ensure we are always underesimating total tokens per day
-- We use floor to ensure we are always underestimating total tokens per day
FLOOR(ap.amount) AS amount_decimal,
-- Round down to 15 sigfigs for double precision, ensuring know errouneous round up or down
ap.amount * ((POW(10, 15) - 1) / POW(10, 15)) AS amount,
ap.multiplier,
ap.strategy,
ap.reward_hash,
Expand All @@ -70,7 +68,7 @@ active_rewards_updated_start_timestamps AS (
ap.operator,
ap.reward_end_inclusive,
ap.token,
ap.amount,
ap.amount,
ap.multiplier,
ap.strategy,
ap.reward_hash,
Expand Down Expand Up @@ -109,7 +107,6 @@ active_rewards_cleaned AS (
operator,
CAST(day AS DATE) AS snapshot,
token,
amount,
amount_decimal,
multiplier,
strategy,
Expand Down Expand Up @@ -142,7 +139,7 @@ op_avs_num_registered_snapshots AS (
GROUP BY ar.reward_hash, ar.operator
),
-- Step 9: Divide amount to pay by the number of snapshots that the operator was registered
-- Step 10: Divide amount to pay by the number of snapshots that the operator was registered
active_rewards_with_registered_snapshots AS (
SELECT
arc.*,
Expand All @@ -154,20 +151,15 @@ active_rewards_with_registered_snapshots AS (
AND arc.operator = nrs.operator
),
-- Step 10: Divide amount to pay by the number of snapshots that the operator was registered
-- Step 11: Divide amount to pay by the number of snapshots that the operator was registered
active_rewards_final AS (
SELECT
ar.*,
CASE
-- If the operator was not registered for any snapshots, just get regular tokens per day to refund the AVS
WHEN ar.num_registered_snapshots = 0 THEN ar.amount_decimal / (duration / 86400)
ELSE ar.amount_decimal / ar.num_registered_snapshots
END AS tokens_per_registered_snapshot_decimal,
CASE
-- If the operator was not registered for any snapshots, just get regular tokens per day to refund the AVS
WHEN ar.num_registered_snapshots = 0 THEN ar.amount / (duration / 86400)
ELSE ar.amount / ar.num_registered_snapshots
END AS tokens_per_registered_snapshot
END AS tokens_per_registered_snapshot_decimal
FROM active_rewards_with_registered_snapshots ar
)
Expand Down
1 change: 0 additions & 1 deletion pkg/rewards/9_goldStakerODRewardAmounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ WITH reward_snapshot_operators AS (
ap.reward_hash,
ap.snapshot AS snapshot,
ap.token,
ap.tokens_per_registered_snapshot,
ap.tokens_per_registered_snapshot_decimal,
ap.avs AS avs,
ap.operator AS operator,
Expand Down

0 comments on commit 54734c8

Please sign in to comment.