primitivefinance / DFMM

Smart contracts of the DFMM protocol
https://www.primitive.xyz/blog/dfmm_protocol
18 stars 6 forks source link

Fix/strategy lib muldiv #100

Closed clemlak closed 6 months ago

clemlak commented 6 months ago

Cf https://github.com/cantinasec/review-primitive-excalibur/pull/2#discussion_r1541547702 and https://github.com/cantinasec/review-primitive-excalibur/pull/2#discussion_r1541558624.

clemlak commented 6 months ago

One test is still failing, looks like the function we're using the compute the price of a LogNormal pool is rounding in the wrong direction?

clemlak commented 6 months ago

@kinrezC and I discovered a weird behavior in the LogNormal pool, if someone allocates a small amount of token Y (for example 0.77), the price of the pool might change and decrease by 2. This issue is only happening if the total liquidity in the pool is less than 20 WAD and the price is 1.