Skip to main content

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​

NameType
basestring | Token
quotestring | Token
tickSpacingnumber

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

KeyResolved

Type declaration​

NameType
baseTokenCalculations
quoteTokenCalculations
tickSpacingnumber

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​

NameType
baseToken
quoteToken
tickSpacingnumber

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​

NameType
offerIdnumber
reasonstring
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​

NameType
offerIdnumber
gotBig
gaveBig

Defined in​

@mangrovedao/mangrove.js/src/market.ts:91


OrderSummary​

Ζ¬ OrderSummary: Object

A summary of the result of a trade.

Type declaration​

NameType
olKeyHashstring
takerstring
fillOrKill?boolean
ticknumber
fillVolumeBig
fillWantsboolean
restingOrder?boolean
restingOrderId?number
fee?Big
totalGotBig
totalGaveBig
partialFillboolean
bounty?BigNumber

Defined in​

@mangrovedao/mangrove.js/src/market.ts:100


CleanSummary​

Ζ¬ CleanSummary: Object

A summary of the result of cleaning.

Type declaration​

NameType
olKeyHashstring
takerstring
offersToBeCleanednumber
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​

NameType
txReceiptethers.ContractReceipt
summary?OrderSummary
cleanSummary?CleanSummary
successesSuccess[]
tradeFailuresFailure[]
posthookFailuresFailure[]
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​

NameTypeDescription
resultPromise<TResult>The result of the market transaction. Resolves when the transaction has been included on-chain. Rejects if the transaction fails.
responsePromise<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 (if fillWants=true), or sell (if fillWants=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​

NameType
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 cleaned
  • takerWants: the amount of base token (for asks) or quote token (for bids) the taker wants
  • tick: the tick of the offer to be cleaned
  • gasreq: 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​

NameType
targets{ offerId: number ; takerWants: Bigish ; tick: number ; gasreq: number }[]
baBA
taker?string

Defined in​

@mangrovedao/mangrove.js/src/market.ts:267


RawCleanParams​

Ζ¬ RawCleanParams: Object

Type declaration​

NameType
baBA
olKeyOLKeyStruct
targetsMgvLib.CleanTargetStruct[]
takerstring

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​

NameType
bookOptionsBookOptions
noInitboolean

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​

NameType
idnumber
gaspricenumber
makerstring
gasreqnumber
ticknumber
priceBig
givesBig
wantsBig
volumeBig

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​
NameType
cbArgBookSubscriptionCbArgument
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​

NameType
asksSemibook
bidsSemibook

Defined in​

@mangrovedao/mangrove.js/src/market.ts:481


VolumeEstimate​

Ζ¬ VolumeEstimate: Object

A volume estimate for a trade.

Type declaration​

NameType
maxTickMatchednumber | undefined
estimatedVolumeBig
estimatedFeeBig
remainingFillVolumeBig

Defined in​

@mangrovedao/mangrove.js/src/market.ts:486

  • Type Aliases
    • Key
    • KeyResolvedForCalculation
    • KeyResolved
    • BA
    • BS
    • MgvReader
    • Failure
    • Success
    • OrderSummary
    • CleanSummary
    • DirtyOrderResult
    • OrderResult
    • CleanResult
    • UpdateRestingOrderResult
    • RetractRestingOrderResult
    • Transaction
    • OrderRoute
    • TradeParams
    • RestingOrderParams
    • UpdateRestingOrderParams
    • CleanParams
    • RawCleanParams
    • VolumeParams
    • DirectionlessVolumeParams
    • OptionalParams
    • CacheContentsOptions
    • BookOptions
    • OfferSlim
    • Offer
    • BookSubscriptionEvent
    • BookSubscriptionCbArgument
    • MarketCallback
    • StorableMarketCallback
    • MarketFilter
    • SubscriptionParam
    • Book
    • VolumeEstimate