Skip to main content

Class: CoreKandelInstance

Title

Management of a single Kandel instance.

Hierarchy​

Constructors​

constructor​

β€’ new CoreKandelInstance(params): CoreKandelInstance

Constructor. See createCoreParams

Parameters​

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

Returns​

CoreKandelInstance

Defined in​

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

Properties​

kandel​

β€’ kandel: CoreKandel

Defined in​

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


address​

β€’ address: string

Defined in​

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


market​

β€’ market: Market

Defined in​

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


distributionHelper​

β€’ distributionHelper: KandelDistributionHelper

Defined in​

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


generalKandelDistributionGenerator​

β€’ generalKandelDistributionGenerator: GeneralKandelDistributionGenerator

Defined in​

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


configuration​

β€’ configuration: KandelConfiguration

Defined in​

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


seeder​

β€’ seeder: KandelSeeder

Defined in​

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


offerLogic​

β€’ offerLogic: OfferLogic

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

Defined in​

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

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 }>

Defined in​

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


getBase​

β–Έ getBase(): Token

Gets the base of the market Kandel is making

Returns​

Token

Defined in​

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


getQuote​

β–Έ getQuote(): Token

Gets the quote of the market Kandel is making

Returns​

Token

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

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>

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.

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.

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.

Defined in​

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


getParameters​

β–Έ getParameters(): Promise<KandelParameters>

Retrieves the current Kandel parameters

Returns​

Promise<KandelParameters>

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.

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.

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.

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.

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.

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.

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 }[] }>

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.

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.

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.

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.

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)[]>

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>

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>

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.

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 }>

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

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.

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.

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.

Defined in​

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

  • Hierarchy
  • Constructors
    • constructor
  • Properties
    • kandel
    • address
    • market
    • distributionHelper
    • generalKandelDistributionGenerator
    • configuration
    • seeder
    • offerLogic
  • 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