CoreKandel
CoreKandel
is agnostic to the chosen price distribution.
SetGasprice
the gasprice has been set. By emitting this data, an indexer will be able to keep track of what gasprice is used.
Parameters
value
uint256
the gasprice for offers.
SetGasreq
the gasreq has been set. By emitting this data, an indexer will be able to keep track of what gasreq is used.
Parameters
value
uint256
the gasreq (including router's gasreq) for offers
SetStepSize
the step size has been set.
Parameters
value
uint256
the step size in amount of price points to jump for posting dual offer
Credit
the Kandel instance is credited of amount
by its owner.
By emitting this data, an indexer will be able to keep track of what credits are made.
Parameters
token
contract IERC20
the asset. This is indexed so that RPC calls can filter on it.
amount
uint256
the amount.
Debit
the Kandel instance is debited of amount
by its owner.
By emitting this data, an indexer will be able to keep track of what debits are made.
Parameters
token
contract IERC20
the asset. This is indexed so that RPC calls can filter on it.
amount
uint256
the amount.
Params
Core Kandel parameters
Parameters
params
Storage of the parameters for the strat.
setStepSize
sets the step size
Parameters
stepSize
uint256
the step size.
setGasprice
sets the gasprice for offers
Parameters
gasprice
uint256
the gasprice.
setGasreq
sets the gasreq (including router's gasreq) for offers
Parameters
gasreq
uint256
the gasreq.
setParams
Updates the params to new values.
Parameters
newParams
struct CoreKandel.Params
the new params to set.
constructor
Constructor
Parameters
mgv
contract IMangrove
The Mangrove deployment.
olKeyBaseQuote
struct OLKey
The 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.
reserveId
address
identifier of this contract's reserve when using a router.
populate
publishes bids/asks for the distribution in the indices
. Care must be taken to publish offers in meaningful chunks. For Kandel an offer and its dual should be published in the same chunk (one being optionally initially dead).
This function is used at initialization and can fund with provision for the offers.
Use populateChunk
to split up initialization or re-initialization with same parameters, as this function will emit.
If this function is invoked with different pricePoints or stepSize, then first retract all offers.
msg.value must be enough to provision all posted offers (for chunked initialization only one call needs to send native tokens).
Parameters
distribution
struct DirectWithBidsAndAsksDistribution.Distribution
the distribution of bids and asks to populate
parameters
struct CoreKandel.Params
the parameters for Kandel. Only changed parameters will cause updates. Set gasreq
and gasprice
to 0 to keep existing values.
baseAmount
uint256
base amount to deposit
quoteAmount
uint256
quote amount to deposit
populateChunk
Publishes bids/asks for the distribution in the indices
. Care must be taken to publish offers in meaningful chunks. For Kandel an offer and its dual should be published in the same chunk (one being optionally initially dead).
This function is used externally after populate
to reinitialize some indices or if multiple transactions are needed to split initialization due to gas cost.
This function is not payable, use populate
to fund along with populate.
Parameters
distribution
struct DirectWithBidsAndAsksDistribution.Distribution
the distribution of bids and asks to populate
reserveBalance
the total balance available for the strat of the offered token for the given offer type.
Parameters
ba
enum OfferType
the offer type.
Return Values
balance
uint256
the balance of the token.
logUpdateOfferStatus
takes care of status for updating dual and logging of potential issues.
Parameters
offerId
uint256
the Mangrove offer id.
args
struct IOfferLogic.OfferArgs
the arguments of the offer.
updateOfferStatus
bytes32
the status returned from the _updateOffer
function.
transportSuccessfulOrder
update or create dual offer according to transport logic
Parameters
order
struct MgvLib.SingleOrder
is a recall of the taker order that is at the origin of the current trade.
transportLogic
transport logic followed by Kandel
Parameters
ba
enum OfferType
whether the offer that was executed is a bid or an ask
order
struct MgvLib.SingleOrder
a recap of the taker order (order.offer is the executed offer)
Return Values
dualOfferId
uint256
the offer id of the dual offer
args
struct IOfferLogic.OfferArgs
the argument for updating an offer
pending
gets pending liquidity for base (ask) or quote (bid). Will be negative if funds are not enough to cover all offer's promises.
Gas costly function, better suited for off chain calls.
Parameters
ba
enum OfferType
offer type.
Return Values
[0]
int256
the pending amount
depositFunds
Deposits funds to the contract's reserve
Parameters
baseAmount
uint256
the amount of base tokens to deposit.
quoteAmount
uint256
the amount of quote tokens to deposit.
withdrawFunds
withdraws funds from the contract's reserve
it is up to the caller to make sure there are still enough funds for live offers.
Parameters
baseAmount
uint256
the amount of base tokens to withdraw. Use type(uint).max to denote the entire reserve balance.
quoteAmount
uint256
the amount of quote tokens to withdraw. Use type(uint).max to denote the entire reserve balance.
recipient
address
the address to which the withdrawn funds should be sent to.
withdrawFundsForToken
withdraws funds from the contract's reserve for the given token
Parameters
token
contract IERC20
the token to withdraw.
amount
uint256
the amount of tokens to withdraw. Use type(uint).max to denote the entire reserve balance.
recipient
address
the address to which the withdrawn funds should be sent to.
retractAndWithdraw
Retracts offers, withdraws funds, and withdraws free wei from Mangrove.
Parameters
from
uint256
retract offers starting from this index.
to
uint256
retract offers until this index.
baseAmount
uint256
the amount of base tokens to withdraw. Use type(uint).max to denote the entire reserve balance.
quoteAmount
uint256
the amount of quote tokens to withdraw. Use type(uint).max to denote the entire reserve balance.
freeWei
uint256
the amount of wei to withdraw from Mangrove. Use type(uint).max to withdraw entire available balance.
recipient
address payable
the recipient of the funds.