Class: Market
The Market class focuses on a Mangrove market. On-chain, markets are implemented as two offer lists, one for asks (base,quote), the other for bids (quote,base).
Market initialization needs to store the network name, so you cannot
directly use the constructor. Instead of new Market(...)
, do await Market.connect(...)
.
See
Propertiesβ
mgvβ
β’ mgv: Mangrove
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:505
baseβ
β’ base: Token
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:506
quoteβ
β’ quote: Token
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:507
tickSpacingβ
β’ tickSpacing: number
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:508
olKeyBaseQuoteβ
β’ olKeyBaseQuote: OLKeyStruct
The OLKey for the base, quote offer list
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:510
olKeyQuoteBaseβ
β’ olKeyQuoteBase: OLKeyStruct
The OLKey for the quote, base offer list
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:512
tradeβ
β’ trade: Trade
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:517
tradeEventManagementβ
β’ tradeEventManagement: TradeEventManagement
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:518
prettyPβ
β’ prettyP: PrettyPrint
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:519
minVolumeAskβ
β’ Optional
minVolumeAsk: Big
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:524
minVolumeBidβ
β’ Optional
minVolumeBid: Big
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:525
Methodsβ
connectβ
βΈ connect(params
): Promise
<Market
>
Connect to a market.
Parametersβ
Name | Type | Description |
---|---|---|
params | { mgv : Mangrove } & Key & Partial <OptionalParams > | A set of parameters identifying the market on Mangrove to connect to. |
Returnsβ
Promise
<Market
>
A promise that resolves to a Market instance.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:532
closeβ
βΈ close(): void
Close a Market instance.
Returnsβ
void
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:611
initializeβ
βΈ initialize(): Promise
<void
>
Initialize the market.
Returnsβ
Promise
<void
>
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:627
getOLKeyβ
βΈ getOLKey(ba
): OLKeyStruct
Get the configuration of the specified offer list of the market.
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
Returnsβ
OLKeyStruct
The configuration of the specified offer list of the market.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:692
getBookβ
βΈ getBook(): Book
Return the two semibooks of this market.
Asks are standing offers to sell base and buy quote. Bids are standing offers to buy base and sell quote. All prices are in quote/base, all volumes are in base. Offers are ordered from best to worse from the taker perspective.
Returnsβ
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:734
getSemibookβ
βΈ getSemibook(ba
): Semibook
Return the bids or asks semibook.
Parametersβ
Name | Type |
---|---|
ba | BA |
Returnsβ
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:747
requestBookβ
βΈ requestBook(opts?
): Promise
<{ asks
: Offer
[] ; bids
: Offer
[] }>
Return the asks and bids semibook.
Parametersβ
Name | Type | Default value | Description |
---|---|---|---|
opts | BookOptions | bookOptsDefault | Options to filter the offers in the book. |
Returnsβ
Promise
<{ asks
: Offer
[] ; bids
: Offer
[] }>
The asks and bids semibooks, with the offers that match the options.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:759
spreadβ
βΈ spread(): Promise
<{ absoluteSpread
: undefined
; relativeSpread
: undefined
; tickSpread
: undefined
} | { absoluteSpread
: Big
; relativeSpread
: Big
; tickSpread
: number
}>
Gets the absolute, relative, and tick spread between bids and asks on the market.
Returnsβ
Promise
<{ absoluteSpread
: undefined
; relativeSpread
: undefined
; tickSpread
: undefined
} | { absoluteSpread
: Big
; relativeSpread
: Big
; tickSpread
: number
}>
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:776
spreadβ
βΈ spread(market
, bestAsk?
, bestBid?
): { absoluteSpread
: undefined
; relativeSpread
: undefined
; tickSpread
: undefined
} | { absoluteSpread
: Big
; relativeSpread
: Big
; tickSpread
: number
}
Gets the absolute, relative, and tick spread between a bid and an ask on the market.
Parametersβ
Name | Type |
---|---|
market | KeyResolvedForCalculation |
bestAsk? | Object |
bestAsk.price | BigSource |
bestAsk.tick | number |
bestBid? | Object |
bestBid.price | BigSource |
bestBid.tick | number |
Returnsβ
{ absoluteSpread
: undefined
; relativeSpread
: undefined
; tickSpread
: undefined
} | { absoluteSpread
: Big
; relativeSpread
: Big
; tickSpread
: number
}
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:788
isActiveβ
βΈ isActive(): boolean
Is the market active?
Returnsβ
boolean
Whether the market is active, i.e., whether both the asks and bids semibooks are active.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:813
isLiveβ
βΈ isLive(ba
, offerId
): Promise
<boolean
>
Is the offer corresponding to the given offerId in the book ba live?
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | Bids or asks. |
offerId | number | An offer id to check. |
Returnsβ
Promise
<boolean
>
True, if a corresponding live offer was found, else false.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:824
isLiveOfferβ
βΈ isLiveOffer(offer
): boolean
Is the offer live?
Parametersβ
Name | Type | Description |
---|---|---|
offer | Offer | An offer to check. |
Returnsβ
boolean
True, if the offer is live, else false.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:834
getOfferProvisionβ
βΈ getOfferProvision(ba
, gasreq
, gasprice?
): Promise
<Big
>
Gets the amount of ethers necessary to provision an offer on the market.
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
gasreq | number | gas required for the offer execution. |
gasprice? | number | gas price to use for the calculation. If undefined, then Mangrove's current gas price is used. |
Returnsβ
Promise
<Big
>
the amount of ethers necessary to provision the offer.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:844
getBidProvisionβ
βΈ getBidProvision(gasreq
, gasprice?
): Promise
<Big
>
Gets the amount of ethers necessary to provision a bid on the market.
Parametersβ
Name | Type | Description |
---|---|---|
gasreq | number | gas required for the offer execution. |
gasprice? | number | gas price to use for the calculation. If undefined, then Mangrove's current gas price is used. |
Returnsβ
Promise
<Big
>
the amount of ethers necessary to provision the offer.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:864
getAskProvisionβ
βΈ getAskProvision(gasreq
, gasprice?
): Promise
<Big
>
Gets the amount of ethers necessary to provision a bid on the market.
Parametersβ
Name | Type | Description |
---|---|---|
gasreq | number | gas required for the offer execution. |
gasprice? | number | gas price to use for the calculation. If undefined, then Mangrove's current gas price is used. |
Returnsβ
Promise
<Big
>
the amount of ethers necessary to provision the offer.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:873
getMissingProvisionβ
βΈ getMissingProvision(ba
, lockedProvision
, gasreq
, gasprice?
): Promise
<Big
>
Gets the missing provision in ethers for an offer with the given parameters
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
lockedProvision | BigSource | the provision already locked with the offer |
gasreq | number | gas required for the offer execution. |
gasprice? | number | gas price to use for the calculation. If undefined, then Mangrove's current gas price is used. |
Returnsβ
Promise
<Big
>
the additional required provision, in ethers.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:884
bidInfoβ
βΈ bidInfo(offerId
): Promise
<Offer
>
Returns the offer info for the given offerId in the bids offer list.
Parametersβ
Name | Type | Description |
---|---|---|
offerId | number | id of the offer to get info for. |
Returnsβ
Promise
<Offer
>
the offer info for the given offerId.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:906
askInfoβ
βΈ askInfo(offerId
): Promise
<Offer
>
Returns the offer info for the given offerId in the asks offer list.
Parametersβ
Name | Type | Description |
---|---|---|
offerId | number | id of the offer to get info for. |
Returnsβ
Promise
<Offer
>
the offer info for the given offerId.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:915
offerInfoβ
βΈ offerInfo(ba
, offerId
): Promise
<Offer
>
Returns struct containing offer details in the current market state.
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
offerId | number | id of the offer to get info for. |
Returnsβ
Promise
<Offer
>
the offer info for the given offerId.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:924
permitβ
βΈ permit(action
, data
): Promise
<ContractTransaction
>
Sign permit data. If action="buy", will permit buying base with spender's quote token. If action="sell", will permit buying quote with spender's base token.
Parametersβ
Name | Type | Description |
---|---|---|
action | "buy" | "sell" | "buy" or "sell" |
data | Omit <SimplePermitData , "outbound_tkn" | "inbound_tkn" > | permit data |
Returnsβ
Promise
<ContractTransaction
>
a promise that resolves to the permit signature.
See
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:937
buyβ
βΈ buy(params
, overrides?
): Promise
<Transaction
<OrderResult
>>
Market buy order. Will attempt to buy base token using quote tokens.
Parametersβ
Name | Type | Description |
---|---|---|
params | TradeParams | Trade parameters - see Market.TradeParams. |
overrides | Overrides | ethers overrides for the transaction. |
Returnsβ
Promise
<Transaction
<OrderResult
>>
a promise that resolves to the transaction response and the result of the trade.
Remarks
Will stop if
- book is empty, or
- price no longer good, or
wants
tokens have been bought.
Example
const market = await mgv.market({base:"USDC",quote:"DAI"};
market.buy({volume: 100, price: '1.01'}) //use strings to be exact
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:979
sellβ
βΈ sell(params
, overrides?
): Promise
<Transaction
<OrderResult
>>
Market sell order. Will attempt to sell base token for quote tokens.
Parametersβ
Name | Type | Description |
---|---|---|
params | TradeParams | Trade parameters - see Market.TradeParams. |
overrides | Overrides | ethers overrides for the transaction. |
Returnsβ
Promise
<Transaction
<OrderResult
>>
a promise that resolves to the transaction response and the result of the trade.
Remarks
Will stop if
- book is empty, or
- price no longer good, or
-
gives
tokens have been sold.
Example
const market = await mgv.market({base:"USDC",quote:"DAI"})
market.sell({volume: 100, price: 1})
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1006
gasEstimateBuyβ
βΈ gasEstimateBuy(params
): Promise
<BigNumber
>
Estimate amount of gas for a buy order corresponding to the given trade parameters.
Parametersβ
Name | Type | Description |
---|---|---|
params | TradeParams | Trade parameters. |
Returnsβ
Promise
<BigNumber
>
a gas estimate for the trade.
See
- buy for the corresponding trade method.
- Market.TradeParams for a description of trade parameters
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1019
gasEstimateSellβ
βΈ gasEstimateSell(params
): Promise
<BigNumber
>
Estimate amount of gas for a sell order corresponding to the given trade parameters.
Parametersβ
Name | Type | Description |
---|---|---|
params | TradeParams | Trade parameters. |
Returnsβ
Promise
<BigNumber
>
a gas estimate for the trade.
See
- sell for the corresponding trade method.
- Market.TradeParams for a description of trade parameters
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1030
updateRestingOrderβ
βΈ updateRestingOrder(ba
, params
, overrides?
): Promise
<Transaction
<void
>>
Update a resting order posted by MangroveOrder.
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | whether the offer is a bid or ask |
params | UpdateRestingOrderParams | update parameters - see Market.UpdateRestingOrderParams |
overrides | Overrides | overrides for the transaction |
Returnsβ
Promise
<Transaction
<void
>>
a promise that resolves to the transaction response and the result of the update.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1042
retractRestingOrderβ
βΈ retractRestingOrder(ba
, id
, deprovision?
, overrides?
): Promise
<Transaction
<void
>>
Retract a resting order posted by MangroveOrder.
Parametersβ
Name | Type | Default value | Description |
---|---|---|---|
ba | BA | undefined | whether the offer is a bid or ask |
id | number | undefined | the offer id |
deprovision | boolean | false | whether to deprovision the offer. If true, the offer's provision will be returned to the maker's balance on Mangrove. |
overrides | Overrides | {} | overrides for the transaction |
Returnsβ
Promise
<Transaction
<void
>>
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1057
cleanβ
βΈ clean(params
, overrides?
): Promise
<{ result
: Promise
<CleanResult
> ; response
: Promise
<ContractTransaction
> }>
Clean a set of given offers.
Parametersβ
Name | Type | Description |
---|---|---|
params | CleanParams | Parameters for the cleaning, specifying the target offers, the side of the market to clean, and optionally the taker to impersonate. |
overrides | Overrides | ethers overrides for the transaction. |
Returnsβ
Promise
<{ result
: Promise
<CleanResult
> ; response
: Promise
<ContractTransaction
> }>
a promise that resolves to the transasction response and the result of the cleaning.
See
Market.CleanParams for a description of params.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1074
getRawCleanParamsβ
βΈ getRawCleanParams(params
): Promise
<RawCleanParams
>
Gets parameters to send to function market.mgv.cleanerContract.cleanByImpersonation
.
Parametersβ
Name | Type | Description |
---|---|---|
params | CleanParams | Parameters for the cleaning, specifying the target offers, the side of the market to clean, and optionally the taker to impersonate |
Returnsβ
Promise
<RawCleanParams
>
a promise that resolves to the raw parameters to send to the cleaner contract
Remarks
In more detail, the parameters should be an object with the following fields:
targets
: an array of
offerId
: the offer to be cleaned
takerWants
: the amount of base token (for asks) or quote token (for bids) the taker wants
tick
: the 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
ba
: whether to clean asks
or bids
taker
: specifies what taker to impersonate, if not specified, the caller of the function will be used
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1102
estimateGasβ
βΈ estimateGas(bs
, volume
): Promise
<BigNumber
>
Estimate amount of gas for a buy or sell order for the given volume.
Parametersβ
Name | Type | Description |
---|---|---|
bs | BS | buy or sell |
volume | BigNumber | volume to trade |
Returnsβ
Promise
<BigNumber
>
an estimate of the gas required for the trade
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1114
simulateGasβ
βΈ simulateGas(ba
, maxTick
, fillVolume
, fillWants
): Promise
<BigNumber
>
Uses Semibook.simulateMarketOrder to simulate the gas required for a market order. An overhead of 50% is added to account for changes to the book and failing offers.
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
maxTick | number | the maximum to reach for the market order. |
fillVolume | BigNumber | the amount to fill (wants or gives) |
fillWants | boolean | whether to fill wants or gives |
Returnsβ
Promise
<BigNumber
>
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1141
estimateVolumeβ
βΈ estimateVolume(params
): Promise
<VolumeEstimate
>
Volume estimation for buying or selling:
If you say estimateVolume({given:100,what:"base",to:"buy"})
,
an estimate of how much quote token you would have to spend to get 100 base tokens will be returned.
If you say estimateVolume({given:10,what:"quote",to:"sell"})
,
an estimate of how much base tokens you'd have to buy in order to spend 10 quote tokens will be returned.
Parametersβ
Name | Type | Description |
---|---|---|
params | VolumeParams | Parameters for the volume estimation - see Market.VolumeParams |
Returnsβ
Promise
<VolumeEstimate
>
a promise that resolves to the volume estimation.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1181
estimateVolumeToReceiveβ
βΈ estimateVolumeToReceive(params
): Promise
<VolumeEstimate
>
Convenience method: Estimate volume to be received given an amount of base/quote you are ready to spend.
Parametersβ
Name | Type | Description |
---|---|---|
params | DirectionlessVolumeParams | Parameters for the volume estimation - see Market.DirectionlessVolumeParams |
Returnsβ
Promise
<VolumeEstimate
>
a promise that resolves to the volume estimation.
See
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1201
estimateVolumeToSpendβ
βΈ estimateVolumeToSpend(params
): Promise
<VolumeEstimate
>
Convenience method: Estimate volume to be spent given an amount of base/quote you want to receive.
Parametersβ
Name | Type | Description |
---|---|---|
params | DirectionlessVolumeParams | Parameters for the volume estimation - see Market.DirectionlessVolumeParams |
Returnsβ
Promise
<VolumeEstimate
>
a promise that resolves to the volume estimation.
See
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1214
configβ
βΈ config(): Object
Return config local to a market.
Returnsβ
Object
The config for the asks and bids side of the market.
Name | Type |
---|---|
asks | LocalConfig |
bids | LocalConfig |
Remarks
- Amounts are converted to plain numbers.
- density is converted to public token units per gas used
- fee remains in basis points of the token being bought
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1230
consoleAsksβ
βΈ consoleAsks(filter?
): void
Pretty prints the current state of the asks of the market
Parametersβ
Name | Type |
---|---|
filter? | prettyPrintFilter |
Returnsβ
void
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1241
consoleBidsβ
βΈ consoleBids(filter?
): void
Pretty prints the current state of the bids of the market
Parametersβ
Name | Type |
---|---|
filter? | prettyPrintFilter |
Returnsβ
void
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1246
prettyPrintβ
βΈ prettyPrint(ba
, filter
): void
Pretty prints the current state of the asks or bids of the market
Parametersβ
Name | Type |
---|---|
ba | BA |
filter | prettyPrintFilter |
Returnsβ
void
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1251
subscribeβ
βΈ subscribe(cb
): void
Subscribe to order book updates.
Parametersβ
Name | Type | Description |
---|---|---|
cb | MarketCallback <void > | a callback, which gets called whenever the order book is updated. |
Returnsβ
void
Remarks
The first argument of cb, event
, is a summary of the event.
It has the following properties:
type
the type of change. May be:"OfferWrite"
: an offer was inserted or moved in the book."OfferFail"
,"OfferSuccess"
,"OfferRetract"
: an offer was removed from the book because it failed, succeeded, or was canceled.ba
is either"bids"
or"asks"
. The offer concerned by the change is either an ask (an offer forbase
asking forquote
) or a bid (an offer for
quoteasking for
base`).offer
is information about the offer, see typeOffer
.taker
,takerWants
,takerGives
(for"OfferFail"
and"OfferSuccess"
only): address of the taker who executed the offer as well as the volumes that were requested by the taker.mgvData
: extra data from mangrove and the maker contract. See the Mangrove contracts documentation for the list of possible status codes.
opts
may specify the maximum of offers to read initially, and the chunk
size used when querying the reader contract (always ran locally).
Example
const market = await mgv.market({base:"USDC",quote:"DAI"}
market.subscribe((event,utils) => console.log(event.type, utils.book()))
Note
Only one subscription may be active at a time.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1295
onceβ
βΈ once<T
>(cb
, filter?
): Promise
<T
>
Returns a promise which is fulfilled after execution of the callback.
Type parametersβ
Name |
---|
T |
Parametersβ
Name | Type |
---|---|
cb | MarketCallback <T > |
filter? | MarketFilter |
Returnsβ
Promise
<T
>
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1302
unsubscribeβ
βΈ unsubscribe(cb
): void
Stop calling a user-provided callback function on book-related events.
Parametersβ
Name | Type |
---|---|
cb | StorableMarketCallback |
Returnsβ
void
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1316
getOutboundInboundβ
βΈ getOutboundInbound(ba
): Object
Determine which token will be Mangrove's outbound/inbound depending on whether you're working with bids or asks.
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
Returnsβ
Object
the outbound and inbound tokens.
Name | Type |
---|---|
outbound_tkn | Token |
inbound_tkn | Token |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1324
getOutboundInboundβ
βΈ getOutboundInbound<T
>(ba
, base
, quote
): Object
Determine which token will be Mangrove's outbound/inbound depending on whether you're working with bids or asks.
Type parametersβ
Name |
---|
T |
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
base | T | base token |
quote | T | quote token |
Returnsβ
Object
the outbound and inbound tokens.
Name | Type |
---|---|
outbound_tkn | T |
inbound_tkn | T |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1337
getBaseQuoteVolumesβ
βΈ getBaseQuoteVolumes(ba
, gives
, wants
): Object
Determine whether gives or wants will be baseVolume/quoteVolume depending on whether you're working with bids or asks.
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
gives | Big | amount of token to give |
wants | Big | amount of token to receive |
Returnsβ
Object
the base and quote volumes.
Name | Type |
---|---|
baseVolume | Big |
quoteVolume | Big |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1357
getWantsForPriceβ
βΈ getWantsForPrice(ba
, gives
, price
): Big
Determine the wants from gives and price depending on whether you're working with bids or asks.
Parametersβ
Name | Type |
---|---|
ba | BA |
gives | Big |
price | Big |
Returnsβ
Big
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1369
getGivesForPriceβ
βΈ getGivesForPrice(ba
, wants
, price
): Big
Determine the gives from wants and price depending on whether you're working with bids or asks.
Parametersβ
Name | Type |
---|---|
ba | BA |
wants | Big |
price | Big |
Returnsβ
Big
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1374
getGivesWantsForVolumeAtPriceβ
βΈ getGivesWantsForVolumeAtPrice(ba
, volume
, price
): Object
Determine gives and wants from a volume (in base) and a price depending on whether you're working with bids or asks.
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
volume | Big | volume of the offer |
price | Big | price of the offer |
Returnsβ
Object
the gives and wants
Name | Type |
---|---|
gives | Big |
wants | Big |
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1384
getDisplayDecimalsForPriceDifferencesβ
βΈ getDisplayDecimalsForPriceDifferences(): number
Determine the first decimal place where the smallest price difference between neighboring offers in the order book cache is visible.
Returnsβ
number
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1398
getDisplayDecimalsForPriceDifferencesβ
βΈ getDisplayDecimalsForPriceDifferences(offers
): number
Determine the first decimal place where the smallest price difference between neighboring offers is visible.
Parametersβ
Name | Type | Description |
---|---|---|
offers | Offer [] | offers to consider |
Returnsβ
number
the first decimal place where the smallest price difference between neighboring offers is visible.
Defined inβ
@mangrovedao/mangrove.js/src/market.ts:1410