Skip to main content

GeometricKandel

GeometricKandel​

SetBaseQuoteTickOffset​

event SetBaseQuoteTickOffset(uint256 value)

The tick offset for absolute price used for the on-chain geometric progression deployment in createDistribution. It is recommended that this is a multiple of tickSpacing for the offer lists to avoid rounding.

Parameters​

NameTypeDescription
valueuint256the tick offset.

baseQuoteTickOffset​

uint256 baseQuoteTickOffset

The tick offset for absolute price used for the on-chain geometric progression deployment in createDistribution. It is recommended that this is a multiple of tickSpacing for the offer lists to avoid rounding.

constructor​

constructor(contract IMangrove mgv, struct OLKey olKeyBaseQuote, address reserveId) internal

Constructor

Parameters​

NameTypeDescription
mgvcontract IMangroveThe Mangrove deployment.
olKeyBaseQuotestruct OLKeyThe OLKey for the outbound_tkn base and inbound_tkn quote offer list Kandel will act on, the flipped OLKey is used for the opposite offer list.
reserveIdaddressidentifier of this contract's reserve when using a router.

setBaseQuoteTickOffset​

function setBaseQuoteTickOffset(uint256 _baseQuoteTickOffset) public

sets the tick offset if different from existing.

Parameters​

NameTypeDescription
_baseQuoteTickOffsetuint256the new tick offset.

createDistribution​

function createDistribution(uint256 from, uint256 to, Tick baseQuoteTickIndex0, uint256 _baseQuoteTickOffset, uint256 firstAskIndex, uint256 bidGives, uint256 askGives, uint256 pricePoints, uint256 stepSize) public pure returns (struct DirectWithBidsAndAsksDistribution.Distribution distribution)

Creates a distribution of bids and asks given by the parameters. Dual offers are included with gives=0.

the absolute price of an offer is the ratio of quote/base volumes of tokens it trades the tick of offers on Mangrove are in relative taker price of maker's inbound/outbound volumes of tokens it trades for Bids, outbound_tkn=quote, inbound_tkn=base so relative taker price of a a bid is the inverse of the absolute price. for Asks, outbound_tkn=base, inbound_tkn=quote so relative taker price of an ask coincides with absolute price. Index0 will contain the ask with the lowest relative price and the bid with the highest relative price. Absolute price is geometrically increasing over indexes. tickOffset moves an offer relative price s.t. `AskTick{i+1} = AskTicki + tickOffsetandBidTick{i+1} = BidTicki - tickOffsetA hole is left in the middle at the size of stepSize - either an offer or its dual is posted, not both. The caller should make sure the minimum and maximum tick does not exceed the MIN_TICK and MAX_TICK from respectively; otherwise, populate will fail for those offers. If type(uint).max is used forbidGivesoraskGives` then very high or low prices can yield gives=0 (which results in both offer an dual being dead) or gives>=type(uin96).max which is not supported by Mangrove.

Parameters​

NameTypeDescription
fromuint256populate offers starting from this index (inclusive). Must be at most pricePoints.
touint256populate offers until this index (exclusive). Must be at most pricePoints.
baseQuoteTickIndex0Tickthe tick for the price point at index 0 given as a tick on the base, quote offer list, i.e. corresponding to an ask with a quote/base ratio. It is recommended that this is a multiple of tickSpacing for the offer lists to avoid rounding.
_baseQuoteTickOffsetuint256the tick offset used for the geometric progression deployment. Must be at least 1. It is recommended that this is a multiple of tickSpacing for the offer lists to avoid rounding.
firstAskIndexuint256the (inclusive) index after which offer should be an ask. Must be at most pricePoints.
bidGivesuint256The initial amount of quote to give for all bids. If 0, only book the offer, if type(uint).max then askGives is used as base for bids, and the quote the bid gives is set to according to the price.
askGivesuint256The initial amount of base to give for all asks. If 0, only book the offer, if type(uint).max then bidGives is used as quote for asks, and the base the ask gives is set to according to the price.
pricePointsuint256the number of price points for the Kandel instance. Must be at least 2.
stepSizeuint256in amount of price points to jump for posting dual offer. Must be less than pricePoints.

Return Values​

NameTypeDescription
distributionstruct DirectWithBidsAndAsksDistribution.Distributionthe distribution of bids and asks to populate

populateFromOffset​

function populateFromOffset(uint256 from, uint256 to, Tick baseQuoteTickIndex0, uint256 _baseQuoteTickOffset, uint256 firstAskIndex, uint256 bidGives, uint256 askGives, struct CoreKandel.Params parameters, uint256 baseAmount, uint256 quoteAmount) public payable

publishes bids/asks according to a geometric distribution, and sets all parameters according to inputs.

See createDistribution for further details.

Parameters​

NameTypeDescription
fromuint256populate offers starting from this index (inclusive).
touint256populate offers until this index (exclusive).
baseQuoteTickIndex0Tickthe tick for the price point at index 0 given as a tick on the base, quote offer list, i.e. corresponding to an ask with a quote/base ratio. It is recommended that this is a multiple of tickSpacing for the offer lists to avoid rounding.
_baseQuoteTickOffsetuint256the tick offset used for the geometric progression deployment. It is recommended that this is a multiple of tickSpacing for the offer lists to avoid rounding.
firstAskIndexuint256the (inclusive) index after which offer should be an ask.
bidGivesuint256The initial amount of quote to give for all bids. If 0, only book the offer, if type(uint).max then askGives is used as base for bids, and the quote the bid gives is set to according to the price.
askGivesuint256The initial amount of base to give for all asks. If 0, only book the offer, if type(uint).max then bidGives is used as quote for asks, and the base the ask gives is set to according to the price.
parametersstruct CoreKandel.Paramsthe parameters for Kandel. Only changed parameters will cause updates. Set gasreq and gasprice to 0 to keep existing values.
baseAmountuint256base amount to deposit
quoteAmountuint256quote amount to deposit

populateChunkFromOffset​

function populateChunkFromOffset(uint256 from, uint256 to, Tick baseQuoteTickIndex0, uint256 firstAskIndex, uint256 bidGives, uint256 askGives) public payable

publishes bids/asks according to a geometric distribution, and reads parameters from the Kandel instance.

This is typically used after a call to populateFromOffset to populate the rest of the offers with the same parameters. See that function for further details.

Parameters​

NameTypeDescription
fromuint256populate offers starting from this index (inclusive).
touint256populate offers until this index (exclusive).
baseQuoteTickIndex0Tickthe tick for the price point at index 0 given as a tick on the base, quote offer list, i.e. corresponding to an ask with a quote/base ratio. It is recommended that this is a multiple of tickSpacing for the offer lists to avoid rounding.
firstAskIndexuint256the (inclusive) index after which offer should be an ask.
bidGivesuint256The initial amount of quote to give for all bids. If 0, only book the offer, if type(uint).max then askGives is used as base for bids, and the quote the bid gives is set to according to the price.
askGivesuint256The initial amount of base to give for all asks. If 0, only book the offer, if type(uint).max then bidGives is used as quote for asks, and the base the ask gives is set to according to the price.