Class: GeometricKandelInstance
Title
A geometric distribution of bids and ask for geometric Kandel.
Hierarchyβ
β³
GeometricKandelInstance
Constructorsβ
constructorβ
β’ new GeometricKandelInstance(params
): GeometricKandelInstance
Constructor. See create
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 |
params.geometricKandel | GeometricKandel |
params.geometricGenerator | GeometricKandelDistributionGenerator |
params.kandelStatus | GeometricKandelStatus |
Returnsβ
Overridesβ
CoreKandelInstance.constructor
Defined inβ
@mangrovedao/mangrove.js/src/kandel/geometricKandel/geometricKandelInstance.ts:95
Propertiesβ
kandelβ
β’ kandel: CoreKandel
Inherited fromβ
Defined inβ
@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:58
addressβ
β’ address: string
Inherited fromβ
Defined inβ
@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:59
marketβ
β’ market: Market
Inherited fromβ
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β
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β
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β
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
}>
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β
Inherited fromβ
Defined inβ
@mangrovedao/mangrove.js/src/kandel/coreKandelInstance.ts:139
getQuoteβ
βΈ getQuote(): Token
Gets the quote of the market Kandel is making
Returnsβ
Inherited fromβ
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β
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.
Inherited fromβ
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.
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β
Name | Type | Description |
---|---|---|
offerType | BA | The 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β
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.
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β
Name | Type | Description |
---|---|---|
offerType | BA | The bid/ask identifier. |
Returnsβ
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β
Name | Type | Description |
---|---|---|
offerType | BA | The bid/ask identifier. |
index | number | The 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β
Name | Type | Description |
---|---|---|
offerType | BA | The bid/ask identifier. |
offerId | number | The 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β
Name | Type | Description |
---|---|---|
distribution | OfferDistribution | The 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β
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.
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β
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.
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β
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.
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β
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.
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β
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
)[]>
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β
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
>
Inherited fromβ
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β
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.
Inherited fromβ
CoreKandelInstance.getDistributionChunks
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
}>
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β
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.
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β
Name | Type | Description |
---|---|---|
existingOffers | Object | the offers to calculate provision for. |
existingOffers.bids | OfferProvisionParams [] | - |
existingOffers.asks | OfferProvisionParams [] | - |
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β
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.
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β
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.
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β
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.
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β
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.
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β
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.
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β
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.
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β
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.
Inherited fromβ
CoreKandelInstance.retractAndWithdraw
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.
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β
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
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β
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.
Inherited fromβ
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.
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β
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.
Inherited fromβ
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β
Name | Type | Description |
---|---|---|
params | Object | The parameters used to create an instance. |
params.address | string | The address of the Kandel instance. |
params.signer | Signer | The signer used to interact with the Kandel instance. |
params.market | MarketOrMarketFactory | The 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β
Name | Type | Description |
---|---|---|
parameters | GeometricKandelParameterOverrides | The Geometric Kandel parameters to override, those left out will keep their current value. |
distributionBaseQuoteTickOffset? | number | The 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β
Name | Type | Description |
---|---|---|
midPrice | BigSource | The 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β
Name | Type | Description |
---|---|---|
params | Object | The parameters to use to determine the status. |
params.midPrice | BigSource | The current mid price of the market used to discern expected bids from asks. |
params.offers | Object | The offers used as a basis for determining the status. This should include all live and dead offers. |
params.offers.bids | OffersWithLiveness | - |
params.offers.asks | OffersWithLiveness | - |
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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for the minimum volume. |
params.offerType | BA | The offer type to get the minimum volume for. |
params.index | number | The Kandel index. |
params.tick | number | The tick at the index. |
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
<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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for the new distribution. |
params.midPrice | BigSource | The current mid price of the market used to discern expected bids from asks. |
params.minPrice | BigSource | The minimum price to generate the distribution from; can be retrieved from the status from getOfferStatuses or getOfferStatusFromOffers . |
params.generateFromMid | boolean | Whether to generate the distribution outwards from the midPrice or upwards from the minPrice. |
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
<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β
Name | Type | Description |
---|---|---|
params | Object | The parameters for populating the offers. |
params.distribution | GeometricKandelDistribution | 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.geometricParameters? | GeometricKandelParameterOverrides | The geometric parameters to set leave out values to keep their current value. |
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. |
params.maxOffersInChunk? | number | The 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. |
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/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β
Name | Type |
---|---|
baseQuoteTickOffset | number |
overrides | Overrides |
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β
Name | Type | Description |
---|---|---|
bidGives | undefined | BigSource | The amount of quote to give for each bid (undefined means derive from constant ask gives) |
askGives | undefined | BigSource | The amount of base to give for each ask (undefined means derive from constant bid gives) |
Returnsβ
Object
The raw values (or uint max if value should be derived).
Name | Type |
---|---|
rawBidGives | BigNumber |
rawAskGives | BigNumber |
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β
Name | Type | Description |
---|---|---|
chunks | { from : number ; to : number }[] | chunks to populate (from is inclusive, to is exclusive). |
distribution | GeometricKandelDistribution | The geometric distribution. |
overrides | Overrides | The 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