formula

package
v0.4.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package formula defines the formulas that implements the MarketFormula interface

Index

Constants

View Source
const (
	BalancedReservesType = 1
)

Variables

View Source
var (
	// 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")
)

Functions

This section is empty.

Types

type BalancedReserves

type BalancedReserves struct{}

BalancedReserves defines an AMM strategy with fixed 50/50 reserves

func (BalancedReserves) FormulaType

func (BalancedReserves) FormulaType() int

func (BalancedReserves) InGivenOut

func (BalancedReserves) InGivenOut(opts *marketmaking.FormulaOpts, amountOut uint64) (amountIn uint64, 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 *marketmaking.FormulaOpts, amountIn uint64) (amountOut uint64, err error)

OutGivenIn returns the amountOut of asset that will be exchanged for the given amountIn

func (BalancedReserves) SpotPrice

func (BalancedReserves) SpotPrice(opts *marketmaking.FormulaOpts) (spotPrice decimal.Decimal, err error)

SpotPrice calculates the spot price (without fees) given the balances fo the two reserves. The weight reserve ratio is fixed at 50/50

Jump to

Keyboard shortcuts

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