Skip to main content

Class: GeometricKandelDistribution

Title

A geometric distribution of bids and ask for a geometric Kandel.

Hierarchy​

Constructors​

constructor​

β€’ new GeometricKandelDistribution(geometricHelper, baseQuoteTickIndex0, baseQuoteTickOffset, firstAskIndex, bidGives, askGives, pricePoints, stepSize, offers, market): GeometricKandelDistribution

Constructor

Parameters​

NameTypeDescription
geometricHelperGeometricKandelDistributionHelper-
baseQuoteTickIndex0numberThe base quote tick index of the first price point.
baseQuoteTickOffsetnumberThe number of ticks to jump between two price points - this gives the geometric progression. Should be >=1.
firstAskIndexnumberThe index of the first live ask in the distribution.
bidGivesundefined | BigSourceThe amount of quote to give for each bid (undefined means derive from constant ask gives)
askGivesundefined | BigSourceThe amount of base to give for each ask (undefined means derive from constant bid gives)
pricePointsnumberThe number of price points in the distribution.
stepSizenumberThe step size used when transporting funds from an offer to its dual. Should be >=1.
offersOfferDistributionThe distribution of bids and asks.
marketKeyResolvedForCalculationThe key data about the market.

Returns​

GeometricKandelDistribution

Overrides​

KandelDistribution.constructor

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:28

Properties​

baseQuoteTickIndex0​

β€’ baseQuoteTickIndex0: number

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:9


baseQuoteTickOffset​

β€’ baseQuoteTickOffset: number

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:10


bidGives​

β€’ bidGives: undefined | BigSource

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:11


askGives​

β€’ askGives: undefined | BigSource

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:12


firstAskIndex​

β€’ firstAskIndex: number

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:14


geometricHelper​

β€’ geometricHelper: GeometricKandelDistributionHelper

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:15


offers​

β€’ offers: OfferDistribution

Inherited from​

KandelDistribution.offers

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:27


market​

β€’ market: KeyResolvedForCalculation

Inherited from​

KandelDistribution.market

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:28


pricePoints​

β€’ pricePoints: number

Inherited from​

KandelDistribution.pricePoints

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:29


stepSize​

β€’ stepSize: number

Inherited from​

KandelDistribution.stepSize

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:30


helper​

β€’ helper: KandelDistributionHelper

Inherited from​

KandelDistribution.helper

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:31

Methods​

getPriceRatio​

β–Έ getPriceRatio(): Big

Gets the price ratio given by the baseQuoteTickOffset.

Returns​

Big

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:51


chunkGeometricDistribution​

β–Έ chunkGeometricDistribution(maxOffersInChunk): { from: number ; to: number }[]

Split a distribution into chunks according to the maximum number of offers in a single chunk.

Parameters​

NameTypeDescription
maxOffersInChunknumberThe maximum number of offers in a single chunk.

Returns​

{ from: number ; to: number }[]

The chunks.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:62


verifyDistribution​

β–Έ verifyDistribution(): void

Verifies the distribution is valid.

Returns​

void

Remarks

Throws if the distribution is invalid.

Overrides​

KandelDistribution.verifyDistribution

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistribution.ts:74


calculateOfferGives​

β–Έ calculateOfferGives(offerType, offerCount, totalVolume): Big

Calculates the gives for a single offer of the given type given the total available volume and the count of offers of that type.

Parameters​

NameTypeDescription
offerTypeBAThe type of offer.
offerCountnumberThe count of offers of the given type.
totalVolumeBigThe total available volume.

Returns​

Big

The amount of base or quote to give for the offer.

Inherited from​

KandelDistribution.calculateOfferGives

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:60


getOffers​

β–Έ getOffers(offerType): OfferList

Gets all offers of the given type

Parameters​

NameTypeDescription
offerTypeBAThe type of offer.

Returns​

OfferList

All offers of the given type.

Inherited from​

KandelDistribution.getOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:88


getLiveOffers​

β–Έ getLiveOffers(offerType): { index: number ; gives: Big ; tick: number }[]

Gets all live offers of the given type (offers with non-zero gives)

Parameters​

NameTypeDescription
offerTypeBAThe type of offer.

Returns​

{ index: number ; gives: Big ; tick: number }[]

All live offers of the given type (offers with non-zero gives)

Inherited from​

KandelDistribution.getLiveOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:96


getDeadOffers​

β–Έ getDeadOffers(offerType): { index: number ; gives: Big ; tick: number }[]

Gets all dead offers of the given type (offers with 0 gives)

Parameters​

NameTypeDescription
offerTypeBAThe type of offer.

Returns​

{ index: number ; gives: Big ; tick: number }[]

All dead offers of the given type (offers with 0 gives)

Inherited from​

KandelDistribution.getDeadOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:104


getOfferAtIndex​

β–Έ getOfferAtIndex(offerType, index): undefined | { index: number ; gives: Big ; tick: number }

Gets the offer at the given index for the given offer type

Parameters​

NameTypeDescription
offerTypeBAThe type of offer.
indexnumberThe index of the offer.

Returns​

undefined | { index: number ; gives: Big ; tick: number }

The offer at the given index for the given offer type.

Inherited from​

KandelDistribution.getOfferAtIndex

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:115


getOffersWithPrices​

β–Έ getOffersWithPrices(): Object

Gets an offer distribution adorned with prices of offers.

Returns​

Object

An offer distribution adorned with prices of offers.

NameType
bids{ index: number ; gives: Big ; tick: number ; price: Big }[]
asks{ index: number ; gives: Big ; tick: number ; price: Big }[]

Inherited from​

KandelDistribution.getOffersWithPrices

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:122


calculateConstantGivesPerOffer​

β–Έ calculateConstantGivesPerOffer(availableBase?, availableQuote?): Object

Calculates the gives for bids and asks based on the available volume for the distribution.

Parameters​

NameTypeDescription
availableBase?BigThe available base to consume.
availableQuote?BigThe available quote to consume.

Returns​

Object

The amount of base or quote to give for each offer.

NameType
askGivesundefined | Big
bidGivesundefined | Big

Inherited from​

KandelDistribution.calculateConstantGivesPerOffer

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:141


getFirstLiveAskIndex​

β–Έ getFirstLiveAskIndex(): number

Gets the index of the first ask in the distribution. If there are no live asks, then the length of the distribution is returned.

Returns​

number

The index of the first ask in the distribution. If there are no live asks, then the length of the distribution is returned.

Inherited from​

KandelDistribution.getFirstLiveAskIndex

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:166


getLastLiveBidIndex​

β–Έ getLastLiveBidIndex(): number

Gets the index of the last live ask in the distribution. If there are no live bids, then -1 is returned.

Returns​

number

The index of the last live ask in the distribution. If there are no live bids, then -1 is returned.

Inherited from​

KandelDistribution.getLastLiveBidIndex

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:176


getOfferedVolumeForDistribution​

β–Έ getOfferedVolumeForDistribution(): Object

Gets the required volume of base and quote for the distribution to be fully provisioned.

Returns​

Object

The offered volume of base and quote for the distribution to be fully provisioned.

NameType
requiredBaseBig
requiredQuoteBig

Inherited from​

KandelDistribution.getOfferedVolumeForDistribution

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:187


getRequiredProvision​

β–Έ getRequiredProvision(params): Promise<Big>

Determines the required provision for the price points in the distribution.

Parameters​

NameTypeDescription
paramsObjectThe parameters used to calculate the provision.
params.marketMarketThe market to get provisions for bids and asks from.
params.gasreqnumberThe gas required to execute a trade.
params.gaspricenumberThe gas price to calculate provision for.

Returns​

Promise<Big>

The provision required for the number of offers.

Remarks

This takes into account that each of the offers represent a price point which can become both an ask and a bid which both require provision.

Inherited from​

KandelDistribution.getRequiredProvision

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:251


calculateMinimumInitialGives​

β–Έ calculateMinimumInitialGives(minimumBasePerOffer, minimumQuotePerOffer): Object

Calculates the minimum initial gives for each offer such that all possible gives of fully taken offers at all price points will be above the minimums provided.

Parameters​

NameTypeDescription
minimumBasePerOfferBigThe minimum base to give for each offer.
minimumQuotePerOfferBigThe minimum quote to give for each offer.

Returns​

Object

The minimum initial gives for each offer such that all possible gives of fully taken offers at all price points will be above the minimums provided.

NameType
askGivesBig
bidGivesBig

Inherited from​

KandelDistribution.calculateMinimumInitialGives

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:268


mapAsyncOffers​

β–Έ mapAsyncOffers<T, R>(offers, f): Promise<{ bids: Awaited<R>[] ; asks: Awaited<R>[] }>

Maps bids and asks arrays to a new value using an async function

Type parameters​

Name
T
R

Parameters​

NameType
offersObject
offers.bidsT[]
offers.asksT[]
f(x: T, ba: BA) => Promise<R>

Returns​

Promise<{ bids: Awaited<R>[] ; asks: Awaited<R>[] }>

Inherited from​

KandelDistribution.mapAsyncOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:281


mapOffers​

β–Έ mapOffers<T, R>(offers, f): Object

Maps bids and asks arrays to a new value using a function

Type parameters​

Name
T
R

Parameters​

NameType
offersObject
offers.bidsT[]
offers.asksT[]
f(x: T, ba: BA) => R

Returns​

Object

NameType
bidsR[]
asksR[]

Inherited from​

KandelDistribution.mapOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:292

  • Hierarchy
  • Constructors
    • constructor
  • Properties
    • baseQuoteTickIndex0
    • baseQuoteTickOffset
    • bidGives
    • askGives
    • firstAskIndex
    • geometricHelper
    • offers
    • market
    • pricePoints
    • stepSize
    • helper
  • Methods
    • getPriceRatio
    • chunkGeometricDistribution
    • verifyDistribution
    • calculateOfferGives
    • getOffers
    • getLiveOffers
    • getDeadOffers
    • getOfferAtIndex
    • getOffersWithPrices
    • calculateConstantGivesPerOffer
    • getFirstLiveAskIndex
    • getLastLiveBidIndex
    • getOfferedVolumeForDistribution
    • getRequiredProvision
    • calculateMinimumInitialGives
    • mapAsyncOffers
    • mapOffers