primitivefinance / portfolio

Portfolio is an automated market making protocol for implementing custom strategies at the lowest cost possible.

Home Page:https://www.primitive.xyz/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix: invariant check in swap

Alexangelj opened this issue · comments

Description

In swap, the virtual reserves per liquidity are both rounded down:

iteration.virtualX.divWadDown(iteration.liquidity), // Expects X per liquidity.
iteration.virtualY.divWadDown(iteration.liquidity), // Expects Y per liquidity.

However, we are aware of needing to round in the proper direction, and thus we made changes in _getLatestInvariantAndPrice function to do that. To be consistent, we should further investigate if we need to make the same change here.

This should go along with fixing #339

Fixed in #372