Skip to main content

Class: GeometricKandelDistributionGenerator

Title

Helper for generating geometric Kandel distributions.

Constructors​

constructor​

β€’ new GeometricKandelDistributionGenerator(geometricDistributionHelper, generalDistributionHelper, geometricKandelLib): GeometricKandelDistributionGenerator

Parameters​

NameType
geometricDistributionHelperGeometricKandelDistributionHelper
generalDistributionHelperGeneralKandelDistributionHelper
geometricKandelLibGeometricKandelLib

Returns​

GeometricKandelDistributionGenerator

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:17

Properties​

geometricDistributionHelper​

β€’ geometricDistributionHelper: GeometricKandelDistributionHelper

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:13


generalDistributionHelper​

β€’ generalDistributionHelper: GeneralKandelDistributionHelper

Defined in​

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


geometricKandelLib​

β€’ geometricKandelLib: GeometricKandelLib

Defined in​

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

Methods​

calculateGeometricDistributionParams​

β–Έ calculateGeometricDistributionParams(params): Object

Generates a geometric price distribution.

Parameters​

NameTypeDescription
paramsDistributionParamsParameters for the distribution. Exactly three of minPrice (or minBaseQuoteTick), maxPrice (or maxBaseQuoteTick), priceRatio (or baseQuoteTickOffset), and pricePoints must be provided. If tick-based arguments are provided, they take precedence.

Returns​

Object

NameType
baseQuoteTickOffsetnumber
pricePointsnumber
firstAskIndexnumber
baseQuoteTickIndex0number
stepSizenumber

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:30


calculateFirstOfferIndexAndFirstAskIndex​

β–Έ calculateFirstOfferIndexAndFirstAskIndex(generateFromMid, minBaseQuoteTick, midBaseQuoteTick, baseQuoteTickOffset, pricePoints, stepSize): Object

Calculates the tick of the lowest priced price point and the index of the first ask. It is assumed the parameters are sensible based on, e.g., a call to getTickDistributionParams.

Parameters​

NameTypeDescription
generateFromMidbooleanWhether to generate the distribution outwards from the midPrice or upwards from the minPrice.
minBaseQuoteTicknumberThe minimum base quote tick in the distribution.
midBaseQuoteTicknumberThe mid-price as base quote tick used to determine when to switch from bids to asks.
baseQuoteTickOffsetnumberThe number of ticks to jump between two price points.
pricePointsnumberThe number of price points in the distribution.
stepSizenumberThe step size used when transporting funds from an offer to its dual.

Returns​

Object

The tick of the lowest priced price point and the index of the first ask

NameType
baseQuoteTickIndex0number
firstAskIndexnumber

Dev

if midBaseQuoteTick becomes a tick, then it is arbitrarily chosen to be a bid to simplify the math. So, if mid==min then firstAskIndex is 1. To have no bids, mid should be strictly less than min.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:69


calculateMinimumDistribution​

β–Έ calculateMinimumDistribution(params): Promise<GeometricKandelDistribution>

Calculates a minimal recommended volume distribution of bids and asks and their base and quote amounts to match the geometric price distribution given by parameters.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the geometric price distribution.
params.distributionParamsDistributionParamsThe parameters for the geometric price distribution.
params.constantBase?booleanWhether the base amount should be constant for all offers.
params.constantQuote?booleanWhether the quote amount should be constant for all offers.
params.minimumBasePerOfferBigSourceThe minimum amount of base to give for each offer. Should be at least minimumBasePerOfferFactor from KandelConfiguration multiplied with the minimum volume for the market.
params.minimumQuotePerOfferBigSourceThe minimum amount of quote to give for each offer. Should be at least minimumQuotePerOfferFactor from KandelConfiguration multiplied with the minimum volume for the market.

Returns​

Promise<GeometricKandelDistribution>

The distribution of bids and asks and their base and quote amounts.

Remarks

The price distribution may not match the distributionParams exactly due to limited precision.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:110


calculateDistribution​

β–Έ calculateDistribution(params): Promise<GeometricKandelDistribution>

Calculates distribution of bids and asks and their base and quote amounts to match the geometric price distribution given by parameters.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the geometric distribution.
params.distributionParamsDistributionParamsThe parameters for the geometric price distribution.
params.initialAskGives?BigSourceThe initial amount of base to give for all asks. Should be at least minimumBasePerOfferFactor from KandelConfiguration multiplied with the minimum volume for the market. If not provided, then initialBidGives is used as quote for asks, and the base the ask gives is set to according to the price.
params.initialBidGives?BigSourceThe initial amount of quote to give for all bids. Should be at least minimumQuotePerOfferFactor from KandelConfiguration multiplied with the minimum volume for the market. If not provided, then initialAskGives is used as base for bids, and the quote the bid gives is set to according to the price.

Returns​

Promise<GeometricKandelDistribution>

The distribution of bids and asks and their base and quote amounts.

Remarks

The price distribution may not match the priceDistributionParams exactly due to limited precision.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:153


calculateDistributionFromGeometricParams​

β–Έ calculateDistributionFromGeometricParams(geometricParams, initialAskGives?, initialBidGives?): Promise<GeometricKandelDistribution>

Calculates distribution of bids and asks and their base and quote amounts to match the geometric price distribution given by parameters.

Parameters​

NameTypeDescription
geometricParamsObjectThe parameters for the geometric price distribution.
geometricParams.baseQuoteTickOffsetnumberThe number of ticks to jump between two price points.
geometricParams.pricePointsnumberThe number of price points in the distribution.
geometricParams.firstAskIndexnumberThe index of the first live ask.
geometricParams.baseQuoteTickIndex0numberThe tick of the lowest priced price point.
geometricParams.stepSizenumberThe step size used when transporting funds from an offer to its dual.
initialAskGives?BigSourceThe initial amount of base to give for all asks. Should be at least minimumBasePerOfferFactor from KandelConfiguration multiplied with the minimum volume for the market. If not provided, then initialBidGives is used as quote for asks, and the base the ask gives is set to according to the price.
initialBidGives?BigSourceThe initial amount of quote to give for all bids. Should be at least minimumQuotePerOfferFactor from KandelConfiguration multiplied with the minimum volume for the market. If not provided, then initialAskGives is used as base for bids, and the quote the bid gives is set to according to the price.

Returns​

Promise<GeometricKandelDistribution>

The distribution of bids and asks and their base and quote amounts.

Remarks

The price distribution may not match the priceDistributionParams exactly due to limited precision.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:181


recalculateDistributionFromAvailable​

β–Έ recalculateDistributionFromAvailable(params): Promise<GeometricKandelDistribution>

Recalculates the gives for offers in the distribution such that the available base and quote is consumed uniformly, while preserving the price distribution.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the recalculation.
params.distributionGeometricKandelDistributionThe distribution to reset the gives for.
params.availableBase?BigSourceThe available base to consume. If not provided, then the quote for bids is also used as quote for asks, and the base the ask gives is set to according to the price.
params.availableQuote?BigSourceThe available quote to consume. If not provided, then the base for asks is also used as base for bids, and the quote the bid gives is set to according to the price.

Returns​

Promise<GeometricKandelDistribution>

The distribution of bids and asks and their base and quote amounts.

Remarks

The required volume can be slightly less than available due to rounding due to token decimals. Note that the resulting offered base volume for each offer should be at least minimumBasePerOfferFactor from KandelConfiguration multiplied with the minimum volume for the market - and similar for quote.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:215


getMinimumVolumeForIndex​

β–Έ getMinimumVolumeForIndex(params): Big

Retrieves the minimum volume for a given offer type at the given index.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the minimum volume.
params.offerTypeBAThe offer type to get the minimum volume for.
params.indexnumberThe Kandel index.
params.ticknumberThe tick at the index (the tick price of base per quote for bids and quote per base for asks).
params.baseQuoteTickOffsetnumberThe number of ticks to jump between two price points - this gives the geometric progression.
params.stepSizenumberThe step size used when transporting funds from an offer to its dual.
params.pricePointsnumberThe number of price points.
params.minimumBasePerOfferBigSourceThe minimum base token volume per offer. If not provided, then the minimum base token volume is used.
params.minimumQuotePerOfferBigSourceThe minimum quote token volume per offer. If not provided, then the minimum quote token volume is used.

Returns​

Big

The minimum volume for the given offer type and the index.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelDistributionGenerator.ts:244

  • Constructors
    • constructor
  • Properties
    • geometricDistributionHelper
    • generalDistributionHelper
    • geometricKandelLib
  • Methods
    • calculateGeometricDistributionParams
    • calculateFirstOfferIndexAndFirstAskIndex
    • calculateMinimumDistribution
    • calculateDistribution
    • calculateDistributionFromGeometricParams
    • recalculateDistributionFromAvailable
    • getMinimumVolumeForIndex