Skip to content

Commit

Permalink
prevent negative veBAL balances (#1445)
Browse files Browse the repository at this point in the history
  • Loading branch information
markusbkoch authored Aug 30, 2022
1 parent b380abb commit be0c47c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ SELECT
b.provider,
bpt_balance,
lock_period,
COALESCE((bpt_balance *
(lock_period / (365*86400)) *
((unlocked_at - (FLOOR(EXTRACT(EPOCH FROM b.day))+86400)) / lock_period)), 0) AS vebal
GREATEST(
COALESCE((bpt_balance *
(lock_period / (365*86400)) *
((unlocked_at - (FLOOR(EXTRACT(EPOCH FROM b.day))+86400)) / lock_period)), 0) ,

0
) AS vebal
FROM running_balances b
LEFT JOIN locks_info l
ON l.provider = b.provider
Expand Down

0 comments on commit be0c47c

Please sign in to comment.