velodrome-finance / sugar

Sugar makes Velodrome devs life sweeter 🍭
Other
47 stars 26 forks source link

fix: CL gauge reward rate, CL gauge fees overflow #57

Closed ethzoomer closed 7 months ago

ethzoomer commented 7 months ago

Check periodFinish, avoid uint128 overflows when calculating CL gauge fees by converting to uint256 beforehand

ethzoomer commented 7 months ago

LGTM Think the multiplication won't overflow 256 since sqrt of 2*256 is 3.4028237e+20 1e18. We would need to have at least 3e20 liquidity and gauge fees which I don't see happening for now.

Kk. Btw the reason for the changes I made here was because the old gauge_fees.token1 * pool_liquidity portion was failing because that part was uint128 and for pools such as 0x4742B2760837C4b080D675c6770437CDb703c877 gauge_fees.token1 * pool_liquidity was equal to ~1.3e+39 which overflowed