Documentation ¶
Overview ¶
Package formula defines the formulas that implements the MarketFormula interface
Index ¶
- Variables
- type BalancedReserves
- func (BalancedReserves) InGivenOut(_opts interface{}, amountOut decimal.Decimal) (amountIn decimal.Decimal, err error)
- func (BalancedReserves) OutGivenIn(_opts interface{}, amountIn decimal.Decimal) (amountOut decimal.Decimal, err error)
- func (BalancedReserves) SpotPrice(_opts interface{}) (spotPrice decimal.Decimal, err error)
- type BalancedReservesOpts
- type Pluggable
- func (s Pluggable) InGivenOut(_opts interface{}, amountOut decimal.Decimal) (amountIn decimal.Decimal, err error)
- func (s Pluggable) OutGivenIn(_opts interface{}, amountIn decimal.Decimal) (amountOut decimal.Decimal, err error)
- func (s Pluggable) SpotPrice(_ interface{}) (spotPrice decimal.Decimal, err error)
- type PluggableOpts
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidBalancedReservesOptsType ... ErrInvalidBalancedReservesOptsType = errors.New( "opts must be of type BalancedReservesOpts", ) // ErrAmountTooLow ... ErrAmountTooLow = errors.New("provided amount is too low") // ErrAmountTooBig ... ErrAmountTooBig = errors.New("provided amount is too big") // ErrBalanceTooLow ... ErrBalanceTooLow = errors.New("reserve balance amount is too low") )
View Source
var (
ErrInvalidPluggableOptsType = fmt.Errorf("opts must be of type PluggableOpts")
)
Functions ¶
This section is empty.
Types ¶
type BalancedReserves ¶
type BalancedReserves struct{}
BalancedReserves defines an AMM strategy with fixed 50/50 reserves
func (BalancedReserves) InGivenOut ¶
func (BalancedReserves) InGivenOut( _opts interface{}, amountOut decimal.Decimal, ) (amountIn decimal.Decimal, err error)
InGivenOut returns the amountIn of assets that will be needed for having the desired amountOut in return.
func (BalancedReserves) OutGivenIn ¶
func (BalancedReserves) OutGivenIn( _opts interface{}, amountIn decimal.Decimal, ) (amountOut decimal.Decimal, err error)
OutGivenIn returns the amountOut of asset that will be exchanged for the given amountIn.
type BalancedReservesOpts ¶ added in v0.4.4
type BalancedReservesOpts struct { BalanceIn decimal.Decimal BalanceOut decimal.Decimal WeightIn uint64 WeightOut uint64 }
BalancedReservesOpts defines the parameters needed to calculate the spot price
type Pluggable ¶ added in v1.0.0
type Pluggable struct{}
func (Pluggable) InGivenOut ¶ added in v1.0.0
func (Pluggable) OutGivenIn ¶ added in v1.0.0
Click to show internal directories.
Click to hide internal directories.