Namespace: Market
Type Aliasesβ
Keyβ
Ζ¬ Key: Object
Parameters to identify a market on Mangrove.
Param
The base token of the market, or a string identifying the base token.
Param
The quote token of the market, or a string identifying the quote token.
Param
The tick spacing of the market.
Type declarationβ
Name | Type |
---|---|
base | string | Token |
quote | string | Token |
tickSpacing | number |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:40
KeyResolvedForCalculationβ
Ζ¬ KeyResolvedForCalculation: Object
Values needed for converting between ticks/prices/volumes, is a subset of
See
Type declarationβ
Name | Type |
---|---|
base | TokenCalculations |
quote | TokenCalculations |
tickSpacing | number |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:47
KeyResolvedβ
Ζ¬ KeyResolved: Object
Parameters to identify a market on Mangrove - with resolved tokens.
Param
The base token of the market.
Param
The quote token of the market.
Param
The tick spacing of the market.
Type declarationβ
Name | Type |
---|---|
base | Token |
quote | Token |
tickSpacing | number |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:59
BAβ
Ζ¬ BA: "bids"
| "asks"
Identifies the bids or asks offer list.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:68
BSβ
Ζ¬ BS: "buy"
| "sell"
Identifies a type of order.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:73
MgvReaderβ
Ζ¬ MgvReader: typechain.MgvReader
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:75
Failureβ
Ζ¬ Failure: Object
Result type for trade failures.
Type declarationβ
Name | Type |
---|---|
offerId | number |
reason | string |
FailToDeliver? | Big |
volumeGiven? | Big |
penalty? | BigNumber |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:80
Successβ
Ζ¬ Success: Object
Result type for trade successes.
Type declarationβ
Name | Type |
---|---|
offerId | number |
got | Big |
gave | Big |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:91
OrderSummaryβ
Ζ¬ OrderSummary: Object
A summary of the result of a trade.
Type declarationβ
Name | Type |
---|---|
olKeyHash | string |
taker | string |
fillOrKill? | boolean |
tick | number |
fillVolume | Big |
fillWants | boolean |
restingOrder? | boolean |
restingOrderId? | number |
fee? | Big |
totalGot | Big |
totalGave | Big |
partialFill | boolean |
bounty? | BigNumber |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:100
CleanSummaryβ
Ζ¬ CleanSummary: Object
A summary of the result of cleaning.
Type declarationβ
Name | Type |
---|---|
olKeyHash | string |
taker | string |
offersToBeCleaned | number |
bounty? | BigNumber |
offersCleaned? | number |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:119
DirtyOrderResultβ
Ζ¬ DirtyOrderResult: Object
Order results, with a summary field that may not be set.
Type declarationβ
Name | Type |
---|---|
txReceipt | ethers.ContractReceipt |
summary? | OrderSummary |
cleanSummary? | CleanSummary |
successes | Success [] |
tradeFailures | Failure [] |
posthookFailures | Failure [] |
offerWrites | { ba : BA ; offer : OfferSlim }[] |
restingOrder? | OfferSlim |
restingOrderId? | number |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:130
OrderResultβ
Ζ¬ OrderResult: Omit
<DirtyOrderResult
, "summary"
| "cleanSummary"
> & { summary
: OrderSummary
}
Order results, with a definite summary.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:145
CleanResultβ
Ζ¬ CleanResult: Omit
<DirtyOrderResult
, "summary"
| "cleanSummary"
> & { summary
: CleanSummary
}
Cleaning results, with a definite summary.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:155
UpdateRestingOrderResultβ
Ζ¬ UpdateRestingOrderResult: void
Update resting order results.
No data is returned, but the transaction may fail.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:167
RetractRestingOrderResultβ
Ζ¬ RetractRestingOrderResult: void
Retract resting order results.
No data is returned, but the transaction may fail.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:174
Transactionβ
Ζ¬ Transaction<TResult
>: Object
A transaction that has been submitted to a market.
Market operations return this type so that the caller can track the state of the low-level transaction that has been submitted as well as the result of the market operation.
Type parametersβ
Name |
---|
TResult |
Type declarationβ
Name | Type | Description |
---|---|---|
result | Promise <TResult > | The result of the market transaction. Resolves when the transaction has been included on-chain. Rejects if the transaction fails. |
response | Promise <ethers.ContractTransaction > | The low-level transaction that has been submitted to the chain. |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:182
OrderRouteβ
Ζ¬ OrderRoute: "Mangrove"
| "MangroveOrder"
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:195
TradeParamsβ
Ζ¬ TradeParams: { forceRoutingToMangroveOrder?
: boolean
; slippage?
: number
; fillOrKill?
: boolean
; expiryDate?
: number
; gasLowerBound?
: ethers.BigNumberish
} & { restingOrder?
: RestingOrderParams
} & { volume
: Bigish
; limitPrice
: Bigish
} | { total
: Bigish
; limitPrice
: Bigish
} | { maxTick
: number
; fillVolume
: Bigish
; fillWants?
: boolean
} | { gives
: Bigish
; wants
: Bigish
; fillWants?
: boolean
}
Parameters for trading on a market.
The parameters specify the trade to be executed, and optionally a resting order to be created. These are the base parameters, which may be given:
Param
whether to force routing to MangroveOrder, even if the market is not active.
Param
the maximum slippage to accept, in % of the amount of quote token.
Param
whether to fill the order completely or not at all.
Param
the expiry date of the order, in seconds since unix epoch.
Param
the minimum gas to use for the trade.
Param
whether to create a resting order, and if so, the parameters for the resting order.
The remaining parameters specify the kind of trade to be executed in one of the following ways:
{volume, limitPrice}
the volume of base token to buy or sell, and the limit price to accept.{total, limitPrice}
the total amount of quote token to spend or receive, and the limit price to accept.{maxTick, fillVolume, fillWants}
the maximum tick to accept, the volume of token to buy (iffillWants=true
), or sell (iffillWants=false
, and a boolean indicating whether to try to get all the tokens that the taker wants (fillWants=true
), or, to sell all the token the taker gives (fillWants=false
).{gives, wants, fillWants}
the amount of token to sell, the amount of token to buy, and a boolean indicating whether to try to get all the tokens that the taker wants (fillWants=true
), or, to sell all the token the taker gives (fillWants=false
).
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:216
RestingOrderParamsβ
Ζ¬ RestingOrderParams: Object
Type declarationβ
Name | Type |
---|---|
provision? | Bigish |
offerId? | number |
restingOrderGasreq? | number |
restingOrderGaspriceFactor? | number |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:235
UpdateRestingOrderParamsβ
Ζ¬ UpdateRestingOrderParams: { offerId
: number
} & { gives
: Bigish
} | { tick
: number
} | { gives
: Bigish
; tick
: number
} | { price
: Bigish
} | { volume
: Bigish
} | { total
: Bigish
} | { price
: Bigish
; volume
: Bigish
} | { price
: Bigish
; total
: Bigish
} & Omit
<RestingOrderParams
, "offerId"
>
Parameters for updating an existing resting order.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:243
CleanParamsβ
Ζ¬ CleanParams: Object
Parameters for cleaning a set of offers.
Param
an array of targets to clean, each target is an object with the following fields:
offerId
: the offer to be cleanedtakerWants
: the amount of base token (for asks) or quote token (for bids) the taker wantstick
: the tick of the offer to be cleanedgasreq
: the maximum gasreq the taker/cleaner, wants to use to clean the offer, has to be at least the same as the gasreq of the offer in order for it be cleaned.
Param
bids or asks
Param
the taker to impersonate, if not specified, the caller of the function will be used
Type declarationβ
Name | Type |
---|---|
targets | { offerId : number ; takerWants : Bigish ; tick : number ; gasreq : number }[] |
ba | BA |
taker? | string |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:267
RawCleanParamsβ
Ζ¬ RawCleanParams: Object
Type declarationβ
Name | Type |
---|---|
ba | BA |
olKey | OLKeyStruct |
targets | MgvLib.CleanTargetStruct [] |
taker | string |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:278
VolumeParamsβ
Ζ¬ VolumeParams: VolumeParams
& { what
: "base"
| "quote"
}
Specification of how much volume to (potentially) trade on the market.
{given:100, what:"base", to:"buy"}
means buying 100 base tokens.
{given:10, what:"quote", to:"sell"})
means selling 10 quote tokens.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:292
DirectionlessVolumeParamsβ
Ζ¬ DirectionlessVolumeParams: Omit
<VolumeParams
, "to"
>
Specification of how much volume to (potentially) trade on the market, without specifying the direction of the trade.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:300
OptionalParamsβ
Ζ¬ OptionalParams: Object
Optional parameters for connecting to a Mangrove market - gives optional parameters for how the book cache behaves (see Market.BookOptions), and the timing of when the market is initialized.
Type declarationβ
Name | Type |
---|---|
bookOptions | BookOptions |
noInit | boolean |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:305
CacheContentsOptionsβ
Ζ¬ CacheContentsOptions: { targetNumberOfTicks?
: number
} | { desiredPrice
: Bigish
} | { desiredVolume
: VolumeParams
}
Options that specify what the cache fetches and retains.
targetNumberOfTicks
, desiredPrice
, and desiredVolume
are mutually exclusive.
If none of these are specified, the default is targetNumberOfTicks
= Semibook.DEFAULT_TARGET_NUMBER_OF_TICKS
.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:316
BookOptionsβ
Ζ¬ BookOptions: CacheContentsOptions
& { chunkSize?
: number
}
Options that control how the book cache behaves.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:342
OfferSlimβ
Ζ¬ OfferSlim: Object
Offers in the book cache.
Type declarationβ
Name | Type |
---|---|
id | number |
gasprice | number |
maker | string |
gasreq | number |
tick | number |
price | Big |
gives | Big |
wants | Big |
volume | Big |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:352
Offerβ
Ζ¬ Offer: OfferSlim
& { nextAtTick
: number
| undefined
; prevAtTick
: number
| undefined
; gasbase
: number
}
Offers in the book cache, with a given gasbase and pointers to the next and
previous offer at the same tick; undefined
means no such offer, ie, the
offer is first or last at the tick.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:369
BookSubscriptionEventβ
Ζ¬ BookSubscriptionEvent: { name
: "OfferWrite"
} & TCM.OfferWriteEvent
| { name
: "OfferFail"
} & TCM.OfferFailEvent
| { name
: "OfferFailWithPosthookData"
} & TCM.OfferFailEvent
| { name
: "OfferSuccess"
} & TCM.OfferSuccessEvent
| { name
: "OfferSuccessWithPosthookData"
} & TCM.OfferSuccessEvent
| { name
: "OfferRetract"
} & TCM.OfferRetractEvent
| { name
: "SetActive"
} & TCM.SetActiveEvent
| { name
: "SetFee"
} & TCM.SetFeeEvent
| { name
: "SetGasbase"
} & TCM.SetGasbaseEvent
| { name
: "SetDensity96X32"
} & TCM.SetDensity96X32Event
Type for events emitted by the Mangrove market.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:378
BookSubscriptionCbArgumentβ
Ζ¬ BookSubscriptionCbArgument: { ba
: BA
} & { type
: "SetActive"
; active
: boolean
} | { type
: "SetFee"
; fee
: number
} | { type
: "SetGasbase"
; offerGasbase
: number
} | { type
: "SetDensity96X32"
; density
: Density
} | { offerId?
: number
; offer?
: Offer
} & { type
: "OfferWrite"
} | { type
: "OfferFail"
; taker
: string
; takerWants
: Big
; takerGives
: Big
; mgvData
: string
} | { type
: "OfferFailWithPosthookData"
; taker
: string
; takerWants
: Big
; takerGives
: Big
; mgvData
: string
} | { type
: "OfferSuccess"
; taker
: string
; takerWants
: Big
; takerGives
: Big
} | { type
: "OfferSuccessWithPosthookData"
; taker
: string
; takerWants
: Big
; takerGives
: Big
} | { type
: "OfferRetract"
}
The arguments passed to a an order book event callback function - see Market.subscribe.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:393
MarketCallbackβ
Ζ¬ MarketCallback<T
>: (cbArg
: BookSubscriptionCbArgument
, event?
: BookSubscriptionEvent
, ethersLog?
: ethers.providers.Log
) => T
| Promise
<T
>
A callback function that is called when an order book event occurs.
Type parametersβ
Name |
---|
T |
Type declarationβ
βΈ (cbArg
, event?
, ethersLog?
): T
| Promise
<T
>
Parametersβ
Name | Type |
---|---|
cbArg | BookSubscriptionCbArgument |
event? | BookSubscriptionEvent |
ethersLog? | ethers.providers.Log |
Returnsβ
T
| Promise
<T
>
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:450
StorableMarketCallbackβ
Ζ¬ StorableMarketCallback: MarketCallback
<any
>
A type for MarketCallback that is stored in a map.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:459
MarketFilterβ
Ζ¬ MarketFilter: MarketCallback
<boolean
>
A filter function that can be used to filter order book events.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:464
SubscriptionParamβ
Ζ¬ SubscriptionParam: { type
: "multiple"
} | { type
: "once"
; ok
: (...a
: any
[]) => any
; ko
: (...a
: any
[]) => any
; filter?
: (...a
: any
[]) => boolean
| Promise
<boolean
> }
A subscription parameter that specifies how a subscription to order book events should behave.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:469
Bookβ
Ζ¬ Book: Object
Order books - an asks semibook and a bids semibook.
Type declarationβ
Name | Type |
---|---|
asks | Semibook |
bids | Semibook |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:481
VolumeEstimateβ
Ζ¬ VolumeEstimate: Object
A volume estimate for a trade.
Type declarationβ
Name | Type |
---|---|
maxTickMatched | number | undefined |
estimatedVolume | Big |
estimatedFee | Big |
remainingFillVolume | Big |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:486