VRGDAs icon indicating copy to clipboard operation
VRGDAs copied to clipboard

This implementation violates the invariant that the VRGDA should never reach 0

Open 0xAlcibiades opened this issue 3 years ago • 9 comments

image

Noticed this during invariant testing of an Art Gobblers adjacent project. As we approach infinity, this implementation rounds down. The conjecture is that it should round up to 1 wei.

Credit to @mevbandit @MarcusWentz @horsefacts for the help in discovering this.

image

0xAlcibiades avatar Nov 13 '22 22:11 0xAlcibiades

i dont think not reaching 0 is necessarily an invariant, whats the use case you have in mind where it needs to round up?

transmissions11 avatar Nov 14 '22 16:11 transmissions11

Looking at the equation, the function should never reach zero. I noticed it because we hit divide by zeros during invariant test and that function rounding up was one of the invariants.

0xAlcibiades avatar Nov 15 '22 05:11 0xAlcibiades

we have finite precision, beyond a certain point both rounding up and rounding down are "wrong" behavior mathematically

transmissions11 avatar Nov 15 '22 16:11 transmissions11

Agree, but my conjecture is it's always a non-zero value, and so rounding up is more correct. Agree there is no right choice here though :).

0xAlcibiades avatar Nov 15 '22 18:11 0xAlcibiades

i am a little biased cuz its a bit scary changing things to differ from the gobbler implementation, but i do kinda agree with you

specifically if you, say, wanted to sell something only to people who can get access to some token (say the token is normally soulbound or something) if you round down you allow people without access to that token to purchase

transmissions11 avatar Nov 16 '22 02:11 transmissions11

also iirc this led to some weird behavior in lower elos of monaco

transmissions11 avatar Nov 16 '22 02:11 transmissions11

@0xAlcibiades if you want to make a PR for this i think i'd be willing to merge it thru 👍

transmissions11 avatar Nov 16 '22 02:11 transmissions11

Alright, let me take a look at that mañana :)

0xAlcibiades avatar Nov 16 '22 02:11 0xAlcibiades

awesome <3

transmissions11 avatar Nov 16 '22 02:11 transmissions11