formula

package
v0.8.19 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 3 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 (
	// ErrInvalidOptsType ...
	ErrInvalidOptsType = 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")
)

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 interface{}, amountOut uint64) (uint64, 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 uint64) (uint64, error)

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

func (BalancedReserves) SpotPrice

func (BalancedReserves) SpotPrice(_opts interface{}) (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

type BalancedReservesOpts added in v0.4.4

type BalancedReservesOpts struct {
	BalanceIn  uint64
	BalanceOut uint64
	WeightIn   uint64
	WeightOut  uint64
	// The fee should be in satoshis and represents the calculated fee to take out from the swap.
	Fee uint64
	// Defines if the fee should be charged on the way in (ie. on )
	ChargeFeeOnTheWayIn bool
}

BalancedReservesOpts defines the parameters needed to calculate the spot price

Jump to

Keyboard shortcuts

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