Class: GeometricKandelDistribution
Title
A geometric distribution of bids and ask for a geometric Kandel.
Hierarchyβ
β³
GeometricKandelDistribution
Constructorsβ
constructorβ
β’ new GeometricKandelDistribution(geometricHelper
, baseQuoteTickIndex0
, baseQuoteTickOffset
, firstAskIndex
, bidGives
, askGives
, pricePoints
, stepSize
, offers
, market
): GeometricKandelDistribution
Constructor
Parametersβ
Name | Type | Description |
---|---|---|
geometricHelper | GeometricKandelDistributionHelper | - |
baseQuoteTickIndex0 | number | The base quote tick index of the first price point. |
baseQuoteTickOffset | number | The number of ticks to jump between two price points - this gives the geometric progression. Should be >=1. |
firstAskIndex | number | The index of the first live ask in the distribution. |
bidGives | undefined | BigSource | The amount of quote to give for each bid (undefined means derive from constant ask gives) |
askGives | undefined | BigSource | The amount of base to give for each ask (undefined means derive from constant bid gives) |
pricePoints | number | The number of price points in the distribution. |
stepSize | number | The step size used when transporting funds from an offer to its dual. Should be >=1. |
offers | OfferDistribution | The distribution of bids and asks. |
market | KeyResolvedForCalculation | The key data about the market. |
Returnsβ
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β
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:27
marketβ
β’ market: KeyResolvedForCalculation
Inherited fromβ
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β
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:30
helperβ
β’ helper: KandelDistributionHelper
Inherited fromβ
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β
Name | Type | Description |
---|---|---|
maxOffersInChunk | number | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The type of offer. |
offerCount | number | The count of offers of the given type. |
totalVolume | Big | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The type of offer. |
Returnsβ
All offers of the given type.
Inherited fromβ
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β
Name | Type | Description |
---|---|---|
offerType | BA | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The type of offer. |
index | number | The 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.
Name | Type |
---|---|
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β
Name | Type | Description |
---|---|---|
availableBase? | Big | The available base to consume. |
availableQuote? | Big | The available quote to consume. |
Returnsβ
Object
The amount of base or quote to give for each offer.
Name | Type |
---|---|
askGives | undefined | Big |
bidGives | undefined | 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.
Name | Type |
---|---|
requiredBase | Big |
requiredQuote | Big |
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β
Name | Type | Description |
---|---|---|
params | Object | The parameters used to calculate the provision. |
params.market | Market | The market to get provisions for bids and asks from. |
params.gasreq | number | The gas required to execute a trade. |
params.gasprice | number | The 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β
Name | Type | Description |
---|---|---|
minimumBasePerOffer | Big | The minimum base to give for each offer. |
minimumQuotePerOffer | Big | The 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.
Name | Type |
---|---|
askGives | Big |
bidGives | Big |
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β
Name | Type |
---|---|
offers | Object |
offers.bids | T [] |
offers.asks | T [] |
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β
Name | Type |
---|---|
offers | Object |
offers.bids | T [] |
offers.asks | T [] |
f | (x : T , ba : BA ) => R |
Returnsβ
Object
Name | Type |
---|---|
bids | R [] |
asks | R [] |
Inherited fromβ
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:292