calc

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: BlueOak-1.0.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const RateEncodingFactor = 1e8

RateEncodingFactor is used when encoding an exchange rate as an integer. https://github.com/decred/dcrdex/blob/master/spec/comm.mediawiki#Rate_Encoding

Variables

This section is empty.

Functions

func BaseToQuote

func BaseToQuote(rate uint64, base uint64) (quote uint64)

BaseToQuote computes a quote asset amount based on a base asset amount and an integer representation of the price rate. That is,

quoteAmt = rate * baseAmt / atomsPerCoin

func ConventionalRate added in v0.4.0

func ConventionalRate(msgRate uint64, baseInfo, quoteInfo dex.UnitInfo) float64

ConventionalRate converts an exchange rate in message-rate encoding to a conventional exchange rate, using the base and quote assets' UnitInfo.

func ConventionalRateAlt added in v0.4.0

func ConventionalRateAlt(msgRate uint64, baseFactor, quoteFactor uint64) float64

ConventionalRateAlt converts an exchange rate in message-rate encoding to a conventional exchange rate using the base and quote assets' conventional conversion factors.

func MessageRate added in v1.0.0

func MessageRate(conventionalRate float64, baseInfo, quoteInfo dex.UnitInfo) uint64

MessageRate converts an exchange rate in conventional encoding to one in message-rate encoding using the base and quote assets' UnitInfo.

func MessageRateAlt added in v1.0.0

func MessageRateAlt(conventionalRate float64, baseFactor, quoteFactor uint64) uint64

MessageRateAlt converts an exchange rate in conventional encoding to one in message-rate encoding using the base and quote assets' conventional conversion factors.

func MinimumMarketRate added in v1.0.0

func MinimumMarketRate(baseLotSize, quoteDust uint64) uint64

func Parcels added in v1.0.0

func Parcels(makerQty, takerQty, lotSize uint64, parcelSize uint32) float64

Parcels calculates the number of parcels associated with the given order quantities, lot size and parcel size. Any quantity currently settling should be summed in with the makerQty.

func QuoteToBase

func QuoteToBase(rate uint64, quote uint64) (base uint64)

QuoteToBase computes a base asset amount based on a quote asset amount and an integer representation of the price rate. That is,

baseAmt = quoteAmt * atomsPerCoin / rate

func RequiredOrderFunds

func RequiredOrderFunds(swapVal, inputsSize, maxSwaps, swapSizeBase, swapSize, feeRate uint64) uint64

RequiredOrderFunds calculates the funds required for an order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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