math

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL