Skip to content

Commit be0c47c

Browse files
authored
prevent negative veBAL balances (#1445)
1 parent b380abb commit be0c47c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

deprecated-dune-v1-abstractions/ethereum/balancer/view_vebal_balances.sql

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ SELECT
9797
b.provider,
9898
bpt_balance,
9999
lock_period,
100-
COALESCE((bpt_balance *
101-
(lock_period / (365*86400)) *
102-
((unlocked_at - (FLOOR(EXTRACT(EPOCH FROM b.day))+86400)) / lock_period)), 0) AS vebal
100+
GREATEST(
101+
COALESCE((bpt_balance *
102+
(lock_period / (365*86400)) *
103+
((unlocked_at - (FLOOR(EXTRACT(EPOCH FROM b.day))+86400)) / lock_period)), 0) ,
104+
105+
0
106+
) AS vebal
103107
FROM running_balances b
104108
LEFT JOIN locks_info l
105109
ON l.provider = b.provider

0 commit comments

Comments
 (0)