Class: CoreKandelInstance
Title
Management of a single Kandel instance.
Hierarchyβ
CoreKandelInstance
Constructorsβ
constructorβ
β’ new CoreKandelInstance(params
): CoreKandelInstance
Constructor. See createCoreParams
Parametersβ
Name | Type |
---|---|
params | Object |
params.address | string |
params.kandel | CoreKandel |
params.market | Market |
params.distributionHelper | KandelDistributionHelper |
params.offerLogic | OfferLogic |
params.configuration | KandelConfiguration |
params.seeder | KandelSeeder |
params.generalKandelDistributionGenerator | GeneralKandelDistributionGenerator |
Returnsβ
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β
Name | Type |
---|---|
params | Object |
params.address | string |
params.signer | Signer |
params.market | MarketOrMarketFactory |
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β
Defined inβ
@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:139
getQuoteβ
βΈ getQuote(): Token
Gets the quote of the market Kandel is making
Returnsβ
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β
Name | Type | Description |
---|---|---|
offerType | BA | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The 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β
Name | Type | Description |
---|---|---|
parameters | KandelParameterOverrides | The Kandel parameters to override, those left out will keep their current value. |
distributionPricePoints? | number | The number of price points of the Kandel distribution. |
distributionStepSize? | number | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The bid/ask identifier. |
Returnsβ
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β
Name | Type | Description |
---|---|---|
offerType | BA | The bid/ask identifier. |
index | number | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The bid/ask identifier. |
offerId | number | The 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β
Name | Type | Description |
---|---|---|
distribution | OfferDistribution | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for the distribution. |
params.explicitOffers | Object | The explicit offers to use. |
params.explicitOffers.bids | OffersWithGives | - |
params.explicitOffers.asks | OffersWithGives | - |
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β
Name | Type | Description |
---|---|---|
offerType | BA | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for the minimum volumes. |
params.minimumBasePerOffer? | BigSource | The minimum base token volume per offer. If not provided, then the minimum base token volume is used. |
params.minimumQuotePerOffer? | BigSource | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for the new distribution. |
params.explicitOffers | Object | The explicit offers to use. |
params.explicitOffers.bids | OffersWithGives | - |
params.explicitOffers.asks | OffersWithGives | - |
params.baseDelta? | BigSource | The delta to apply to the base token volume. If not provided, then the base token volume is unchanged. |
params.quoteDelta? | BigSource | The delta to apply to the quote token volume. If not provided, then the quote token volume is unchanged. |
params.minimumBasePerOffer? | BigSource | The minimum base token volume per offer. If not provided, then the minimum base token volume is used. |
params.minimumQuotePerOffer? | BigSource | The 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β
Name | Type | Description |
---|---|---|
baseArgs | ApproveArgs | The arguments for approving the base token. If not provided, then infinite approval is used. |
quoteArgs | ApproveArgs | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters to use when depositing funds. |
params.baseAmount? | BigSource | The amount of base to deposit. If not provided, then no base is deposited. |
params.quoteAmount? | BigSource | The amount of quote to deposit. If not provided, then no quote is deposited. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters. |
params.distribution | GeneralKandelDistribution | The distribution to split. |
params.maxOffersInChunk? | number | The 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β
Name | Type |
---|---|
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β
Name | Type | Description |
---|---|---|
params | Object | The parameters used to calculate the provision. |
params.distribution? | KandelDistribution | The distribution to calculate the provision for. Optional if askCount and bidCount are provided. |
params.bidCount? | number | The number of bids to calculate the provision for. Optional if distribution is provided. |
params.askCount? | number | The number of asks to calculate the provision for. Optional if distribution is provided. |
params.gasprice? | number | The 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? | number | The 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β
Name | Type | Description |
---|---|---|
existingOffers | Object | the offers to calculate provision for. |
existingOffers.bids | OfferProvisionParams [] | - |
existingOffers.asks | OfferProvisionParams [] | - |
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β
Name | Type | Description |
---|---|---|
params | Object | The parameters. |
params.gasreq? | number | An optional new gas required to execute a trade. Default is retrieved from Kandel parameters. |
params.gasprice? | number | An optional new gas price to calculate provision for. Default is retrieved from Kandel parameters. |
params.distribution? | KandelDistribution | The distribution to calculate the provision for. Optional. |
params.bidCount? | number | The number of bids to calculate the provision for. Optional. |
params.askCount? | number | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for the required provision. |
params.gasreq? | number | An optional new gas required to execute a trade. Default is retrieved from Kandel parameters. |
params.gasprice? | number | An optional new gas price to calculate provision for. Default is retrieved from Kandel parameters. |
params.distribution? | KandelDistribution | The distribution to calculate the provision for. Optional. |
params.bidCount? | number | The number of bids to calculate the provision for. Optional. |
params.askCount? | number | The number of asks to calculate the provision for. Optional. |
existingOffers | Object | the offers with potential locked provision. |
existingOffers.bids | OfferProvisionParams [] | - |
existingOffers.asks | OfferProvisionParams [] | - |
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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for populating the offers. |
params.distribution? | KandelDistribution | The distribution of offers to populate. |
params.parameters? | KandelParameterOverrides | The 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? | BigSource | The amount of base to deposit. If not provided, then no base is deposited. |
params.depositQuoteAmount? | BigSource | The amount of quote to deposit. If not provided, then no quote is deposited. |
params.funds? | BigSource | The amount of funds to provision. If not provided, then the required funds are provisioned according to getRequiredProvision. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for populating the offers. |
params.distribution? | GeneralKandelDistribution | The distribution of offers to populate. Can be undefined to allow setting parameters and depositing in a single transaction. |
params.parameters? | KandelParameterOverrides | The 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? | BigSource | The amount of base to deposit. If not provided, then no base is deposited. |
params.depositQuoteAmount? | BigSource | The amount of quote to deposit. If not provided, then no quote is deposited. |
params.funds? | BigSource | The amount of funds to provision. If not provided, then the required funds are provisioned according to getRequiredProvision. (if a distribution is provided) |
params.maxOffersInChunk? | number | The maximum number of offers to include in a single populate transaction. If not provided, then KandelConfiguration is used. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for populating the offers. |
params.distribution? | GeneralKandelDistribution | The distribution of offers to populate. |
params.maxOffersInChunk? | number | The 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. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
rawDistributions | DistributionStruct [] | The raw chunked distributions in internal representation to populate. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters. |
params.startIndex? | number | The start Kandel index of offers to retract. If not provided, then 0 is used. |
params.endIndex? | number | The 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? | BigSource | The amount of funds to withdraw in ethers. If not provided, then the entire provision on Mangrove is withdrawn. |
params.withdrawBaseAmount? | BigSource | The amount of base to withdraw. If not provided, then the entire base balance on Kandel is withdrawn. |
params.withdrawQuoteAmount? | BigSource | The amount of quote to withdraw. If not provided, then the entire quote balance on Kandel is withdrawn. |
params.recipientAddress? | string | The address to withdraw the tokens to. If not provided, then the address of the signer is used. |
params.maxOffersInChunk? | number | The maximum number of offers to include in a single retract transaction. If not provided, then KandelConfiguration is used. |
params.firstAskIndex? | number | The 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. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters. |
params.startIndex? | number | The start Kandel index of offers to retract. If not provided, then 0 is used. |
params.endIndex? | number | The 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? | number | The maximum number of offers to include in a single retract transaction. If not provided, then KandelConfiguration is used. |
params.firstAskIndex? | number | The 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. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters. |
params.retractParams | Object | The parameters for retracting offers. See retractOffers |
params.retractParams.startIndex? | number | - |
params.retractParams.endIndex? | number | - |
params.retractParams.maxOffersInChunk? | number | - |
params.retractParams.firstAskIndex? | number | - |
params.skipLast | boolean | Whether to skip the last chunk. This is used to allow the last chunk to be retracted while withdrawing funds. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters. |
params.baseAmount? | BigSource | The amount of base to withdraw. If not provided, then the entire base balance on Kandel is withdrawn. |
params.quoteAmount? | BigSource | The amount of quote to withdraw. If not provided, then the entire quote balance on Kandel is withdrawn. |
params.recipientAddress? | string | The address to withdraw the tokens to. If not provided, then the address of the signer is used. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
gasprice | number | The gas price to set. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
gasreq | number | The gas requirement to set. |
overrides | Overrides | The 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