Skip to main content

Class: GeometricKandelInstance

Title

A geometric distribution of bids and ask for geometric Kandel.

Hierarchy​

Constructors​

constructor​

β€’ new GeometricKandelInstance(params): GeometricKandelInstance

Constructor. See create

Parameters​

NameType
paramsObject
params.addressstring
params.kandelCoreKandel
params.marketMarket
params.distributionHelperKandelDistributionHelper
params.offerLogicOfferLogic
params.configurationKandelConfiguration
params.seederKandelSeeder
params.generalKandelDistributionGeneratorGeneralKandelDistributionGenerator
params.geometricKandelGeometricKandel
params.geometricGeneratorGeometricKandelDistributionGenerator
params.kandelStatusGeometricKandelStatus

Returns​

GeometricKandelInstance

Overrides​

CoreKandelInstance.constructor

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:95

Properties​

kandel​

β€’ kandel: CoreKandel

Inherited from​

CoreKandelInstance.kandel

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:58


address​

β€’ address: string

Inherited from​

CoreKandelInstance.address

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:59


market​

β€’ market: Market

Inherited from​

CoreKandelInstance.market

Defined in​

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


distributionHelper​

β€’ distributionHelper: KandelDistributionHelper

Inherited from​

CoreKandelInstance.distributionHelper

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:61


generalKandelDistributionGenerator​

β€’ generalKandelDistributionGenerator: GeneralKandelDistributionGenerator

Inherited from​

CoreKandelInstance.generalKandelDistributionGenerator

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:62


configuration​

β€’ configuration: KandelConfiguration

Inherited from​

CoreKandelInstance.configuration

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:63


seeder​

β€’ seeder: KandelSeeder

Inherited from​

CoreKandelInstance.seeder

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:64


offerLogic​

β€’ offerLogic: OfferLogic

Expose logic relevant for all offer logic implementations, including Kandel.

Inherited from​

CoreKandelInstance.offerLogic

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:67


geometricKandel​

β€’ geometricKandel: GeometricKandel

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:47


geometricGenerator​

β€’ geometricGenerator: GeometricKandelDistributionGenerator

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:48


geometricStatus​

β€’ geometricStatus: GeometricKandelStatus

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:49

Methods​

createCoreParams​

β–Έ createCoreParams(params): Promise<{ address: string = params.address; market: Market ; kandel: CoreKandel ; distributionHelper: KandelDistributionHelper ; generalKandelDistributionHelper: GeneralKandelDistributionHelper ; offerLogic: OfferLogic ; configuration: KandelConfiguration ; seeder: KandelSeeder ; generalKandelDistributionGenerator: GeneralKandelDistributionGenerator }>

Parameters​

NameType
paramsObject
params.addressstring
params.signerSigner
params.marketMarketOrMarketFactory

Returns​

Promise<{ address: string = params.address; market: Market ; kandel: CoreKandel ; distributionHelper: KandelDistributionHelper ; generalKandelDistributionHelper: GeneralKandelDistributionHelper ; offerLogic: OfferLogic ; configuration: KandelConfiguration ; seeder: KandelSeeder ; generalKandelDistributionGenerator: GeneralKandelDistributionGenerator }>

Inherited from​

CoreKandelInstance.createCoreParams

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:69


getBase​

β–Έ getBase(): Token

Gets the base of the market Kandel is making

Returns​

Token

Inherited from​

CoreKandelInstance.getBase

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:139


getQuote​

β–Έ getQuote(): Token

Gets the quote of the market Kandel is making

Returns​

Token

Inherited from​

CoreKandelInstance.getQuote

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:144


getTickSpacing​

β–Έ getTickSpacing(): number

Gets the tick spacing of the market Kandel is making

Returns​

number

Inherited from​

CoreKandelInstance.getTickSpacing

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:149


getReserveId​

β–Έ getReserveId(): Promise<string>

Retrieves the identifier of this contract's reserve when using a router

Returns​

Promise<string>

Inherited from​

CoreKandelInstance.getReserveId

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:154


getBalance​

β–Έ getBalance(offerType): Promise<Big>

Retrieves the total balance available for this Kandel instance of the offered token for the given offer type.

Parameters​

NameTypeDescription
offerTypeBAThe offer type.

Returns​

Promise<Big>

The balance of the asset.

Remarks

with liquidity sharing and a router, this will be shared among other Kandel instances.

Inherited from​

CoreKandelInstance.getBalance

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:163


getUnpublished​

β–Έ getUnpublished(offerType): Promise<Big>

Retrieves the amount of liquidity that is available for the Kandel instance but not offered by the given offer type.

Parameters​

NameTypeDescription
offerTypeBAThe offer type.

Returns​

Promise<Big>

the unpublished liquidity.

Remarks

with liquidity sharing and a router, the balance will be shared among other Kandel instances and the unpublished can be seen as a buffer.

Inherited from​

CoreKandelInstance.getUnpublished

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:173


getOfferedVolume​

β–Έ getOfferedVolume(offerType): Promise<Big>

Retrieves the total offered volume for the offer type for this Kandel instance.

Parameters​

NameTypeDescription
offerTypeBAThe offer type.

Returns​

Promise<Big>

The offered volume.

Inherited from​

CoreKandelInstance.getOfferedVolume

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:182


getParameters​

β–Έ getParameters(): Promise<KandelParameters>

Retrieves the current Kandel parameters

Returns​

Promise<KandelParameters>

Inherited from​

CoreKandelInstance.getParameters

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:188


getParametersWithOverrides​

β–Έ getParametersWithOverrides(parameters, distributionPricePoints?, distributionStepSize?): Promise<KandelParameters>

Gets new Kandel parameters based on current and some overrides. If gasprice is not set, the current gasprice and cover factor is used.

Parameters​

NameTypeDescription
parametersKandelParameterOverridesThe Kandel parameters to override, those left out will keep their current value.
distributionPricePoints?numberThe number of price points of the Kandel distribution.
distributionStepSize?numberThe step size for the Kandel distribution.

Returns​

Promise<KandelParameters>

The new Kandel parameters.

Inherited from​

CoreKandelInstance.getParametersWithOverrides

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:204


getOutboundToken​

β–Έ getOutboundToken(offerType): Token

Gets the outbound token for bids/asks.

Parameters​

NameTypeDescription
offerTypeBAThe bid/ask identifier.

Returns​

Token

The outbound token.

Inherited from​

CoreKandelInstance.getOutboundToken

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:280


getOfferIdAtIndex​

β–Έ getOfferIdAtIndex(offerType, index): Promise<number>

Gets the Mangrove offer id for a Kandel index.

Parameters​

NameTypeDescription
offerTypeBAThe bid/ask identifier.
indexnumberThe Kandel index.

Returns​

Promise<number>

The Mangrove offer id.

Inherited from​

CoreKandelInstance.getOfferIdAtIndex

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:289


getIndexOfOfferId​

β–Έ getIndexOfOfferId(offerType, offerId): Promise<number>

Gets the Kandel index for a Mangrove offer id.

Parameters​

NameTypeDescription
offerTypeBAThe bid/ask identifier.
offerIdnumberThe Mangrove offer id.

Returns​

Promise<number>

The Kandel index.

Inherited from​

CoreKandelInstance.getIndexOfOfferId

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:300


getRawDistribution​

β–Έ getRawDistribution(distribution): DistributionStruct

Convert public Kandel distribution to internal representation.

Parameters​

NameTypeDescription
distributionOfferDistributionThe Kandel distribution.

Returns​

DistributionStruct

The internal representation of the Kandel distribution.

Inherited from​

CoreKandelInstance.getRawDistribution

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:310


getOfferIds​

β–Έ getOfferIds(): Promise<{ bids: { offerId: number ; index: number }[] ; asks: { offerId: number ; index: number }[] }>

Retrieves the Mangrove offer ids for all offers.

Returns​

Promise<{ bids: { offerId: number ; index: number }[] ; asks: { offerId: number ; index: number }[] }>

The Mangrove offer ids for all offers along with their offer type and Kandel index.

Inherited from​

CoreKandelInstance.getOfferIds

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:324


getOffers​

β–Έ getOffers(): Promise<{ bids: { index: number = x.index; live: boolean ; id: number ; gasprice: number ; maker: string ; gasreq: number ; tick: number ; price: Big ; gives: Big ; wants: Big ; volume: Big ; nextAtTick: undefined | number ; prevAtTick: undefined | number ; gasbase: number }[] ; asks: { index: number = x.index; live: boolean ; id: number ; gasprice: number ; maker: string ; gasreq: number ; tick: number ; price: Big ; gives: Big ; wants: Big ; volume: Big ; nextAtTick: undefined | number ; prevAtTick: undefined | number ; gasbase: number }[] }>

Retrieves all offers for the Kandel instance by querying the market.

Returns​

Promise<{ bids: { index: number = x.index; live: boolean ; id: number ; gasprice: number ; maker: string ; gasreq: number ; tick: number ; price: Big ; gives: Big ; wants: Big ; volume: Big ; nextAtTick: undefined | number ; prevAtTick: undefined | number ; gasbase: number }[] ; asks: { index: number = x.index; live: boolean ; id: number ; gasprice: number ; maker: string ; gasreq: number ; tick: number ; price: Big ; gives: Big ; wants: Big ; volume: Big ; nextAtTick: undefined | number ; prevAtTick: undefined | number ; gasbase: number }[] }>

Inherited from​

CoreKandelInstance.getOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:342


createDistributionWithOffers​

β–Έ createDistributionWithOffers(params): Promise<GeneralKandelDistribution>

Creates a distribution based on an explicit set of offers based on the Kandel parameters.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the distribution.
params.explicitOffersObjectThe explicit offers to use.
params.explicitOffers.bidsOffersWithGives-
params.explicitOffers.asksOffersWithGives-

Returns​

Promise<GeneralKandelDistribution>

The new distribution.

Inherited from​

CoreKandelInstance.createDistributionWithOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:356


getMinimumVolume​

β–Έ getMinimumVolume(offerType): Promise<Big>

Retrieves the minimum volume for a given offer type.

Parameters​

NameTypeDescription
offerTypeBAThe offer type to get the minimum volume for.

Returns​

Promise<Big>

The minimum volume for the given offer type.

See

KandelSeeder.getMinimumVolumeForGasreq for parameterized function.

Inherited from​

CoreKandelInstance.getMinimumVolume

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:377


getMinimumOrOverrides​

β–Έ getMinimumOrOverrides(params): Promise<{ minimumBasePerOffer: Big ; minimumQuotePerOffer: Big }>

Retrieves the minimum volumes for base and quote, or the provided overrides.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the minimum volumes.
params.minimumBasePerOffer?BigSourceThe minimum base token volume per offer. If not provided, then the minimum base token volume is used.
params.minimumQuotePerOffer?BigSourceThe minimum quote token volume per offer. If not provided, then the minimum quote token volume is used.

Returns​

Promise<{ minimumBasePerOffer: Big ; minimumQuotePerOffer: Big }>

The minimum volumes for base and quote, or the provided overrides.

Inherited from​

CoreKandelInstance.getMinimumOrOverrides

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:391


calculateDistributionWithUniformlyChangedVolume​

β–Έ calculateDistributionWithUniformlyChangedVolume(params): Promise<{ distribution: GeneralKandelDistribution ; totalBaseChange: Big ; totalQuoteChange: Big }>

Calculates a new distribution based on the provided offers and deltas.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the new distribution.
params.explicitOffersObjectThe explicit offers to use.
params.explicitOffers.bidsOffersWithGives-
params.explicitOffers.asksOffersWithGives-
params.baseDelta?BigSourceThe delta to apply to the base token volume. If not provided, then the base token volume is unchanged.
params.quoteDelta?BigSourceThe delta to apply to the quote token volume. If not provided, then the quote token volume is unchanged.
params.minimumBasePerOffer?BigSourceThe minimum base token volume per offer. If not provided, then the minimum base token volume is used.
params.minimumQuotePerOffer?BigSourceThe minimum quote token volume per offer. If not provided, then the minimum quote token volume is used.

Returns​

Promise<{ distribution: GeneralKandelDistribution ; totalBaseChange: Big ; totalQuoteChange: Big }>

The new distribution for the live offers, dead offers are not included.

Remarks

The base and quote deltas are applied uniformly to all offers, except during decrease where offers are kept above their minimum volume.

Inherited from​

CoreKandelInstance.calculateDistributionWithUniformlyChangedVolume

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:415


approveIfHigher​

β–Έ approveIfHigher(baseArgs?, quoteArgs?): Promise<(undefined | ContractTransaction)[]>

Approves the Kandel instance for transferring from signer to itself if allowance is not already high enough.

Parameters​

NameTypeDescription
baseArgsApproveArgsThe arguments for approving the base token. If not provided, then infinite approval is used.
quoteArgsApproveArgsThe arguments for approving the quote token. If not provided, then infinite approval is used.

Returns​

Promise<(undefined | ContractTransaction)[]>

Inherited from​

CoreKandelInstance.approveIfHigher

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:442


deposit​

β–Έ deposit(params, overrides?): Promise<ContractTransaction>

Deposits the amounts on the Kandel instance to be available for offers.

Parameters​

NameTypeDescription
paramsObjectThe parameters to use when depositing funds.
params.baseAmount?BigSourceThe amount of base to deposit. If not provided, then no base is deposited.
params.quoteAmount?BigSourceThe amount of quote to deposit. If not provided, then no quote is deposited.
overridesOverridesThe ethers overrides to use when calling the deposit function.

Returns​

Promise<ContractTransaction>

Inherited from​

CoreKandelInstance.deposit

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:458


getMostSpecificConfig​

β–Έ getMostSpecificConfig(): KandelNetworkConfiguration & Partial<KandelMarketConfiguration>

Gets the most specific available default configuration for Kandel instances.

Returns​

KandelNetworkConfiguration & Partial<KandelMarketConfiguration>

Inherited from​

CoreKandelInstance.getMostSpecificConfig

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:473


getDistributionChunks​

β–Έ getDistributionChunks(params): Promise<OfferDistribution[]>

Splits the distribution into chunks

Parameters​

NameTypeDescription
paramsObjectThe parameters.
params.distributionGeneralKandelDistributionThe distribution to split.
params.maxOffersInChunk?numberThe maximum number of offers in a chunk. If not provided, then KandelConfiguration is used.

Returns​

Promise<OfferDistribution[]>

The distribution chunks.

Inherited from​

CoreKandelInstance.getDistributionChunks

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:488


getGasreqAndGasprice​

β–Έ getGasreqAndGasprice(gasreq?, gasprice?): Promise<{ gasreq: number ; gasprice: number }>

Parameters​

NameType
gasreq?number
gasprice?number

Returns​

Promise<{ gasreq: number ; gasprice: number }>

Inherited from​

CoreKandelInstance.getGasreqAndGasprice

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:500


getRequiredProvision​

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

Determines the required provision for the offers in the distribution or the supplied offer count.

Parameters​

NameTypeDescription
paramsObjectThe parameters used to calculate the provision.
params.distribution?KandelDistributionThe distribution to calculate the provision for. Optional if askCount and bidCount are provided.
params.bidCount?numberThe number of bids to calculate the provision for. Optional if distribution is provided.
params.askCount?numberThe number of asks to calculate the provision for. Optional if distribution is provided.
params.gasprice?numberThe gas price to calculate provision for. Default is retrieved from Kandel parameters. So the gaspriceFactor is should be accounted for in this value.
params.gasreq?numberThe gas required to execute a trade. Default is retrieved from Kandel parameters.

Returns​

Promise<Big>

The provision required for the number of offers.

Remarks

Existing locked provision or balance on Mangrove is not accounted for.

Inherited from​

CoreKandelInstance.getRequiredProvision

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:521


getLockedProvision​

β–Έ getLockedProvision(): Promise<Big>

Calculates the provision locked by existing offers based on the given parameters

Returns​

Promise<Big>

the locked provision, in ethers.

Inherited from​

CoreKandelInstance.getLockedProvision

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:562


getLockedProvisionFromOffers​

β–Έ getLockedProvisionFromOffers(existingOffers): Big

Calculates the provision locked for a set of offers based on the given parameters

Parameters​

NameTypeDescription
existingOffersObjectthe offers to calculate provision for.
existingOffers.bidsOfferProvisionParams[]-
existingOffers.asksOfferProvisionParams[]-

Returns​

Big

the locked provision, in ethers.

Inherited from​

CoreKandelInstance.getLockedProvisionFromOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:571


getMissingProvision​

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

Gets the missing provision based on provision already available on Mangrove, potentially locked by existing offers. It assumes all locked provision will be made available via deprovision or due to offers being replaced.

Parameters​

NameTypeDescription
paramsObjectThe parameters.
params.gasreq?numberAn optional new gas required to execute a trade. Default is retrieved from Kandel parameters.
params.gasprice?numberAn optional new gas price to calculate provision for. Default is retrieved from Kandel parameters.
params.distribution?KandelDistributionThe distribution to calculate the provision for. Optional.
params.bidCount?numberThe number of bids to calculate the provision for. Optional.
params.askCount?numberThe number of asks to calculate the provision for. Optional.

Returns​

Promise<Big>

the additional required provision, in ethers.

Remarks

If neither params.distribution nor params.offerCount is provided, then the current number of price points is used.

Inherited from​

CoreKandelInstance.getMissingProvision

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:590


getMissingProvisionFromOffers​

β–Έ getMissingProvisionFromOffers(params, existingOffers): Promise<Big>

Gets the missing provision based on provision already available on Mangrove, potentially locked by existing offers, and the new distribution requiring provision. It assumes all the provision locked in the existingOffers will be made available via deprovision or due to offers being updated.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the required provision.
params.gasreq?numberAn optional new gas required to execute a trade. Default is retrieved from Kandel parameters.
params.gasprice?numberAn optional new gas price to calculate provision for. Default is retrieved from Kandel parameters.
params.distribution?KandelDistributionThe distribution to calculate the provision for. Optional.
params.bidCount?numberThe number of bids to calculate the provision for. Optional.
params.askCount?numberThe number of asks to calculate the provision for. Optional.
existingOffersObjectthe offers with potential locked provision.
existingOffers.bidsOfferProvisionParams[]-
existingOffers.asksOfferProvisionParams[]-

Returns​

Promise<Big>

the additional required provision, in ethers.

Remarks

If neither distribution nor askCount or bidCount is provided, then the current number of price points less the stepSize is used.

Inherited from​

CoreKandelInstance.getMissingProvisionFromOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:612


getRawParametersForPopulate​

β–Έ getRawParametersForPopulate(params, overrides?): Promise<{ overridesWithFunds: PayableOverrides ; rawParameters: KandelParameters ; rawDepositBaseAmount: BigNumber ; rawDepositQuoteAmount: BigNumber }>

Gets the raw parameters for invoking populate

Parameters​

NameTypeDescription
paramsObjectThe parameters for populating the offers.
params.distribution?KandelDistributionThe distribution of offers to populate.
params.parameters?KandelParameterOverridesThe parameters to set leave out values to keep their current value. If gasprice is not set, the current gasprice and cover factor is used.
params.depositBaseAmount?BigSourceThe amount of base to deposit. If not provided, then no base is deposited.
params.depositQuoteAmount?BigSourceThe amount of quote to deposit. If not provided, then no quote is deposited.
params.funds?BigSourceThe amount of funds to provision. If not provided, then the required funds are provisioned according to getRequiredProvision.
overridesOverridesThe ethers overrides to use when calling the populate and populateChunk functions.

Returns​

Promise<{ overridesWithFunds: PayableOverrides ; rawParameters: KandelParameters ; rawDepositBaseAmount: BigNumber ; rawDepositQuoteAmount: BigNumber }>

The raw parameters.

Inherited from​

CoreKandelInstance.getRawParametersForPopulate

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:663


populateGeneralDistribution​

β–Έ populateGeneralDistribution(params, overrides?): Promise<ContractTransaction[]>

Populates the offers in the distribution for the Kandel instance and sets parameters.

Parameters​

NameTypeDescription
paramsObjectThe parameters for populating the offers.
params.distribution?GeneralKandelDistributionThe distribution of offers to populate. Can be undefined to allow setting parameters and depositing in a single transaction.
params.parameters?KandelParameterOverridesThe parameters to set leave out values to keep their current value. If gasprice is not set, the current gasprice and cover factor is used.
params.depositBaseAmount?BigSourceThe amount of base to deposit. If not provided, then no base is deposited.
params.depositQuoteAmount?BigSourceThe amount of quote to deposit. If not provided, then no quote is deposited.
params.funds?BigSourceThe amount of funds to provision. If not provided, then the required funds are provisioned according to getRequiredProvision. (if a distribution is provided)
params.maxOffersInChunk?numberThe maximum number of offers to include in a single populate transaction. If not provided, then KandelConfiguration is used.
overridesOverridesThe ethers overrides to use when calling the populate and populateChunk functions.

Returns​

Promise<ContractTransaction[]>

The transaction(s) used to populate the offers.

Remarks

If this function is invoked with a different distribution, e.g., due to new pricePoints, or stepSize, then first retract all offers; otherwise, Kandel will enter an inconsistent state. This function does not set the baseQuoteTickOffset for geometric Kandels.

Inherited from​

CoreKandelInstance.populateGeneralDistribution

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:719


populateGeneralChunks​

β–Έ populateGeneralChunks(params, overrides?): Promise<ContractTransaction[]>

Populates the offers in a general distribution for the Kandel instance. To set parameters or add funds, use populate.

Parameters​

NameTypeDescription
paramsObjectThe parameters for populating the offers.
params.distribution?GeneralKandelDistributionThe distribution of offers to populate.
params.maxOffersInChunk?numberThe maximum number of offers to include in a single populate transaction. If not provided, then KandelConfiguration is used.
params.distributionChunks?OfferDistribution[]Home-grown distribution chunks to populate (can be used to populate, e.g., a single offer) - takes precedence over distribution. Take care to ensure duals are included or already populated with correct parameters.
overridesOverridesThe ethers overrides to use when calling the populateChunk function.

Returns​

Promise<ContractTransaction[]>

The transaction(s) used to populate the offers.

Inherited from​

CoreKandelInstance.populateGeneralChunks

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:779


populateRawChunks​

β–Έ populateRawChunks(rawDistributions, overrides?): Promise<ContractTransaction[]>

Populates the offers in the distribution for the Kandel instance.

Parameters​

NameTypeDescription
rawDistributionsDistributionStruct[]The raw chunked distributions in internal representation to populate.
overridesOverridesThe ethers overrides to use when calling the populateChunk function.

Returns​

Promise<ContractTransaction[]>

The transaction(s) used to populate the offers.

Inherited from​

CoreKandelInstance.populateRawChunks

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:810


retractAndWithdraw​

β–Έ retractAndWithdraw(params?, overrides?): Promise<ContractTransaction[]>

Retracts offers and withdraws tokens and provision

Parameters​

NameTypeDescription
paramsObjectThe parameters.
params.startIndex?numberThe start Kandel index of offers to retract. If not provided, then 0 is used.
params.endIndex?numberThe end index of offers to retract. This is exclusive of the offer the index 'endIndex'. If not provided, then the number of price points is used.
params.withdrawFunds?BigSourceThe amount of funds to withdraw in ethers. If not provided, then the entire provision on Mangrove is withdrawn.
params.withdrawBaseAmount?BigSourceThe amount of base to withdraw. If not provided, then the entire base balance on Kandel is withdrawn.
params.withdrawQuoteAmount?BigSourceThe amount of quote to withdraw. If not provided, then the entire quote balance on Kandel is withdrawn.
params.recipientAddress?stringThe address to withdraw the tokens to. If not provided, then the address of the signer is used.
params.maxOffersInChunk?numberThe maximum number of offers to include in a single retract transaction. If not provided, then KandelConfiguration is used.
params.firstAskIndex?numberThe index of the first ask in the distribution. It is used to determine the order in which to retract offers if multiple chunks are needed; if not provided, the midpoint between start and end is used.
overridesOverridesThe ethers overrides to use when calling the retractAndWithdraw, and retractOffers functions.

Returns​

Promise<ContractTransaction[]>

The transaction(s) used to retract the offers.

Remarks

This function or retractOffers should be used to retract all offers before changing the baseQuoteTickOffset, pricePoints, or stepSize using populate. If offers are retracted over multiple transactions, then the chunks are retracted in opposite order from the populate function.

Inherited from​

CoreKandelInstance.retractAndWithdraw

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:854


retractOffers​

β–Έ retractOffers(params?, overrides?): Promise<ContractTransaction[]>

Retracts offers

Parameters​

NameTypeDescription
paramsObjectThe parameters.
params.startIndex?numberThe start Kandel index of offers to retract. If not provided, then 0 is used.
params.endIndex?numberThe end index of offers to retract. This is exclusive of the offer the index 'endIndex'. If not provided, then the number of price points is used.
params.maxOffersInChunk?numberThe maximum number of offers to include in a single retract transaction. If not provided, then KandelConfiguration is used.
params.firstAskIndex?numberThe index of the first ask in the distribution. It is used to determine the order in which to retract offers if multiple chunks are needed; if not provided, the midpoint between start and end is used.
overridesOverridesThe ethers overrides to use when calling the retractOffers function.

Returns​

Promise<ContractTransaction[]>

The transaction(s) used to retract the offers.

Remarks

This function or retractAndWithdraw should be used to retract all offers before changing the baseQuoteTickOffset, pricePoints, or stepSize using populate. If offers are retracted over multiple transactions, then the chunks are retracted in opposite order from the populate function. Note that when retracting an offer the dual should also be retracted, else it can be resurrected.

Inherited from​

CoreKandelInstance.retractOffers

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:910


retractOfferChunks​

β–Έ retractOfferChunks(params, overrides): Promise<{ txs: ContractTransaction[] ; lastChunk: { from: number ; to: number } }>

Retracts offers

Parameters​

NameTypeDescription
paramsObjectThe parameters.
params.retractParamsObjectThe parameters for retracting offers. See retractOffers
params.retractParams.startIndex?number-
params.retractParams.endIndex?number-
params.retractParams.maxOffersInChunk?number-
params.retractParams.firstAskIndex?number-
params.skipLastbooleanWhether to skip the last chunk. This is used to allow the last chunk to be retracted while withdrawing funds.
overridesOverridesThe ethers overrides to use when calling the retractOffers function.

Returns​

Promise<{ txs: ContractTransaction[] ; lastChunk: { from: number ; to: number } }>

The transaction(s) used to retract the offers.

Dev

Inherited from​

CoreKandelInstance.retractOfferChunks

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:935


withdraw​

β–Έ withdraw(params?, overrides?): Promise<ContractTransaction>

Withdraws tokens from the Kandel instance.

Parameters​

NameTypeDescription
paramsObjectThe parameters.
params.baseAmount?BigSourceThe amount of base to withdraw. If not provided, then the entire base balance on Kandel is withdrawn.
params.quoteAmount?BigSourceThe amount of quote to withdraw. If not provided, then the entire quote balance on Kandel is withdrawn.
params.recipientAddress?stringThe address to withdraw the tokens to. If not provided, then the address of the signer is used.
overridesOverridesThe ethers overrides to use when calling the retractAndWithdraw, and retractOffers functions.

Returns​

Promise<ContractTransaction>

The transaction used to withdraw the offers.

Remarks

it is up to the caller to make sure there are still enough funds for live offers.

Inherited from​

CoreKandelInstance.withdraw

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:997


setGasprice​

β–Έ setGasprice(gasprice, overrides?): Promise<ContractTransaction>

Sets the gas price used when provisioning offers.

Parameters​

NameTypeDescription
gaspricenumberThe gas price to set.
overridesOverridesThe ethers overrides to use when calling the setGasprice function.

Returns​

Promise<ContractTransaction>

The transaction used to set the gas price.

Inherited from​

CoreKandelInstance.setGasprice

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:1024


setGasreq​

β–Έ setGasreq(gasreq, overrides?): Promise<ContractTransaction>

Sets the gas required to execute a trade.

Parameters​

NameTypeDescription
gasreqnumberThe gas requirement to set.
overridesOverridesThe ethers overrides to use when calling the setGasreq function.

Returns​

Promise<ContractTransaction>

The transaction used to set the gas requirement.

Inherited from​

CoreKandelInstance.setGasreq

Defined in​

@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:1033


create​

β–Έ create(params): Promise<GeometricKandelInstance>

Creates a GeometricKandelInstance object to interact with a Kandel strategy on Mangrove.

Parameters​

NameTypeDescription
paramsObjectThe parameters used to create an instance.
params.addressstringThe address of the Kandel instance.
params.signerSignerThe signer used to interact with the Kandel instance.
params.marketMarketOrMarketFactoryThe market used by the Kandel instance or a factory function to create the market.

Returns​

Promise<GeometricKandelInstance>

A new GeometricKandelInstance.

Dev

If a factory function is provided for the market, then remember to disconnect market when no longer needed.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:59


getBaseQuoteTickOffset​

β–Έ getBaseQuoteTickOffset(): Promise<{ baseQuoteTickOffset: number ; priceRatio: Big }>

Gets the base quote tick offset stored on the contract and the equivalent price ratio.

Returns​

Promise<{ baseQuoteTickOffset: number ; priceRatio: Big }>

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:115


getGeometricParametersWithOverrides​

β–Έ getGeometricParametersWithOverrides(parameters, distributionBaseQuoteTickOffset?): Promise<{ currentBaseQuoteTickOffset: number ; newBaseQuoteTickOffset: number }>

Gets new geometric Kandel parameters based on current and some overrides.

Parameters​

NameTypeDescription
parametersGeometricKandelParameterOverridesThe Geometric Kandel parameters to override, those left out will keep their current value.
distributionBaseQuoteTickOffset?numberThe number of ticks to jump between two price points - this gives the geometric progression.

Returns​

Promise<{ currentBaseQuoteTickOffset: number ; newBaseQuoteTickOffset: number }>

The new and current geometric Kandel parameters.

Remarks

base quote tick offset provided in the parameters must match a provided distribution.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:134


getOfferStatuses​

β–Έ getOfferStatuses(midPrice): Promise<Statuses>

Retrieves all offers from the market and determines their status.

Parameters​

NameTypeDescription
midPriceBigSourceThe current mid price of the market used to discern expected bids from asks.

Returns​

Promise<Statuses>

The status of all offers.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:176


getOfferStatusFromOffers​

β–Έ getOfferStatusFromOffers(params): Promise<Statuses>

Determines the status of the Kandel instance based on the passed in offers.

Parameters​

NameTypeDescription
paramsObjectThe parameters to use to determine the status.
params.midPriceBigSourceThe current mid price of the market used to discern expected bids from asks.
params.offersObjectThe offers used as a basis for determining the status. This should include all live and dead offers.
params.offers.bidsOffersWithLiveness-
params.offers.asksOffersWithLiveness-

Returns​

Promise<Statuses>

The status of the Kandel instance.

Remarks

The expected prices is determined by extrapolating from a live offer closest to the mid price. Offers are expected to be live bids below the mid price and asks above. Offers are expected to be dead near the mid price due to the step size between the live bid and ask.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:191


getMinimumVolumeForIndex​

β–Έ getMinimumVolumeForIndex(params): Promise<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.
params.minimumBasePerOffer?BigSourceThe minimum base token volume per offer. If not provided, then the minimum base token volume is used.
params.minimumQuotePerOffer?BigSourceThe minimum quote token volume per offer. If not provided, then the minimum quote token volume is used.

Returns​

Promise<Big>

The minimum volume for the given offer type.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:216


calculateUniformDistributionFromMinPrice​

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

Calculates a new uniform distribution based on the available base and quote balance and min price and mid price.

Parameters​

NameTypeDescription
paramsObjectThe parameters for the new distribution.
params.midPriceBigSourceThe current mid price of the market used to discern expected bids from asks.
params.minPriceBigSourceThe minimum price to generate the distribution from; can be retrieved from the status from getOfferStatuses or getOfferStatusFromOffers .
params.generateFromMidbooleanWhether to generate the distribution outwards from the midPrice or upwards from the minPrice.
params.minimumBasePerOffer?BigSourceThe minimum base token volume per offer. If not provided, then the minimum base token volume is used.
params.minimumQuotePerOffer?BigSourceThe minimum quote token volume per offer. If not provided, then the minimum quote token volume is used.

Returns​

Promise<GeometricKandelDistribution>

The new distribution, which can be used to re-populate the Kandel instance with this exact distribution.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:248


populateGeometricDistribution​

β–Έ populateGeometricDistribution(params, overrides?): Promise<ContractTransaction[]>

Populates the offers in the distribution for the Kandel instance and sets parameters.

Parameters​

NameTypeDescription
paramsObjectThe parameters for populating the offers.
params.distributionGeometricKandelDistributionThe distribution of offers to populate.
params.parameters?KandelParameterOverridesThe parameters to set leave out values to keep their current value. If gasprice is not set, the current gasprice and cover factor is used.
params.geometricParameters?GeometricKandelParameterOverridesThe geometric parameters to set leave out values to keep their current value.
params.depositBaseAmount?BigSourceThe amount of base to deposit. If not provided, then no base is deposited.
params.depositQuoteAmount?BigSourceThe amount of quote to deposit. If not provided, then no quote is deposited.
params.funds?BigSourceThe amount of funds to provision. If not provided, then the required funds are provisioned according to getRequiredProvision.
params.maxOffersInChunk?numberThe maximum number of offers to include in a single populate transaction. If not provided, then KandelConfiguration is used.
params.populateMode?"saveGas" | "reduceCallData"The mode to use when populating the offers. If not provided, then "reduceCallData" is used - it computes offers on-chain but reduces the amount of call data; "saveGas" computes offers off-chain and sends them as call data, but saves gas.
overridesOverridesThe ethers overrides to use when calling the populate and populateChunk functions.

Returns​

Promise<ContractTransaction[]>

The transaction(s) used to populate the offers.

Remarks

If this function is invoked with a different distribution, e.g., due to new pricePoints, or stepSize, then first retract all offers; otherwise, Kandel will enter an inconsistent state. This function does not set the baseQuoteTickOffset for geometric Kandels.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:299


setBaseQuoteTickOffset​

β–Έ setBaseQuoteTickOffset(baseQuoteTickOffset, overrides?): Promise<ContractTransaction>

Sets the number of ticks to jump between two price points - this gives the geometric progression. Should be >=1. Note offers should be retracted before this function is used.

Parameters​

NameType
baseQuoteTickOffsetnumber
overridesOverrides

Returns​

Promise<ContractTransaction>

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:392


getRawGives​

β–Έ getRawGives(bidGives, askGives): Object

Converts gives to raw values usable for geometric Kandel populateFromOffset functions.

Parameters​

NameTypeDescription
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)

Returns​

Object

The raw values (or uint max if value should be derived).

NameType
rawBidGivesBigNumber
rawAskGivesBigNumber

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:407


populateGeometricChunks​

β–Έ populateGeometricChunks(chunks, distribution, overrides?): Promise<ContractTransaction[]>

Populates the offers in the distribution for the geometric Kandel instance.

Parameters​

NameTypeDescription
chunks{ from: number ; to: number }[]chunks to populate (from is inclusive, to is exclusive).
distributionGeometricKandelDistributionThe geometric distribution.
overridesOverridesThe ethers overrides to use when calling the populateChunkFromOffset function.

Returns​

Promise<ContractTransaction[]>

The transaction(s) used to populate the offers.

Defined in​

@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:432

  • Hierarchy
  • Constructors
    • constructor
  • Properties
    • kandel
    • address
    • market
    • distributionHelper
    • generalKandelDistributionGenerator
    • configuration
    • seeder
    • offerLogic
    • geometricKandel
    • geometricGenerator
    • geometricStatus
  • Methods
    • createCoreParams
    • getBase
    • getQuote
    • getTickSpacing
    • getReserveId
    • getBalance
    • getUnpublished
    • getOfferedVolume
    • getParameters
    • getParametersWithOverrides
    • getOutboundToken
    • getOfferIdAtIndex
    • getIndexOfOfferId
    • getRawDistribution
    • getOfferIds
    • getOffers
    • createDistributionWithOffers
    • getMinimumVolume
    • getMinimumOrOverrides
    • calculateDistributionWithUniformlyChangedVolume
    • approveIfHigher
    • deposit
    • getMostSpecificConfig
    • getDistributionChunks
    • getGasreqAndGasprice
    • getRequiredProvision
    • getLockedProvision
    • getLockedProvisionFromOffers
    • getMissingProvision
    • getMissingProvisionFromOffers
    • getRawParametersForPopulate
    • populateGeneralDistribution
    • populateGeneralChunks
    • populateRawChunks
    • retractAndWithdraw
    • retractOffers
    • retractOfferChunks
    • withdraw
    • setGasprice
    • setGasreq
    • create
    • getBaseQuoteTickOffset
    • getGeometricParametersWithOverrides
    • getOfferStatuses
    • getOfferStatusFromOffers
    • getMinimumVolumeForIndex
    • calculateUniformDistributionFromMinPrice
    • populateGeometricDistribution
    • setBaseQuoteTickOffset
    • getRawGives
    • populateGeometricChunks