Class: KandelDistribution
Title
A distribution of bids and ask for Kandel.
Hierarchyβ
KandelDistribution
Constructorsβ
constructorβ
β’ new KandelDistribution(pricePoints
, stepSize
, offers
, market
): KandelDistribution
Constructor
Parametersβ
Name | Type | Description |
---|---|---|
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β
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:39
Propertiesβ
offersβ
β’ offers: OfferDistribution
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:27
marketβ
β’ market: KeyResolvedForCalculation
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:28
pricePointsβ
β’ pricePoints: number
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:29
stepSizeβ
β’ stepSize: number
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:30
helperβ
β’ helper: KandelDistributionHelper
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:31
Methodsβ
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.
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.
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)
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)
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.
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 }[] |
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 |
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.
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.
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 |
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:187
verifyDistributionβ
βΈ verifyDistribution(): void
Verifies the distribution is valid.
Returnsβ
void
Remarks
Throws if the distribution is invalid. The verification checks that indices are ascending and bids come before asks. The price distribution is not verified, except that the tick of each offer is a multiple of the tick spacing.
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:199
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.
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 |
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
>[] }>
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 [] |
Defined inβ
@mangrovedao/mangrove.js/src/kandel/kandelDistribution.ts:292