Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SolveConstantProductInvariant ¶
func SolveConstantProductInvariant( xPrior, xAfter, _xWeight, yPrior, _yWeight sdk.Dec, ) (deltaY sdk.Dec)
solveConstantFunctionInvariant solves the constant function of an AMM that determines the relationship between the differences of two sides of assets inside the pool. For fixed xPrior, xAfter, xWeight, yPrior, yWeight, we could deduce the deltaY, calculated by: deltaY = balanceY * (1 - (xPrior/xAfter)^(xWeight/yWeight)) deltaY is positive when y's balance liquidity decreases. deltaY is negative when y's balance liquidity increases. panics if yWeight is 0.
TODO(https://github.com/NibiruChain/nibiru/issues/141): Currently always calculates the invariant assuming constant weight (xy=k). Once we figure out the floating point arithmetic conversions for exponentiation, we can add unequal weights.
Types ¶
This section is empty.