Skip to main content

Namespace: Semibook

Interfaces​

Type Aliases​

Event​

Ζ¬ Event: Object

Type declaration​

NameType
cbArgBookSubscriptionCbArgument
eventBookSubscriptionEvent
ethersLogethers.providers.Log

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:36


EventListener​

Ζ¬ EventListener: (e: Event) => Promise<void>

Type declaration​

β–Έ (e): Promise<void>

Parameters​
NameType
eEvent
Returns​

Promise<void>

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:42


BlockListener​

Ζ¬ BlockListener: (n: number) => Promise<void>

Type declaration​

β–Έ (n): Promise<void>

Parameters​
NameType
nnumber
Returns​

Promise<void>

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:44


VolumeParams​

Ζ¬ VolumeParams: Object

Specification of how much volume to (potentially) trade on the semibook.

{given:100, to:"buy"} means buying 100 base tokens. {given:100, to:"buy", limitPrice: 0.1}) means buying 100 base tokens for a max. price of 0.1 quote/base.

{given:10, to:"sell"}) means selling 10 quote tokens. {given:10, to:"sell", limitPrice: 0.5}) means selling 10 quote tokens for a max. price of 0.5 quote/base (i.e. a min. "price" of 1/(0.5) = 2 base/quote).

Type declaration​

NameTypeDescription
givenBigishAmount of token to trade.
toBSWhether given is base to be bought or quote to be sold.
limitPrice?BigishOptional: a max price after which to stop buying/selling.

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:55


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/semibook.ts:70


Options​

Ζ¬ Options: CacheContentsOptions & { chunkSize?: number }

Options that control how the book cache behaves.

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:96


ResolvedOptions​

Ζ¬ ResolvedOptions: { targetNumberOfTicks: number } | { desiredPrice: Bigish } | { desiredVolume: VolumeParams } & { chunkSize: number }

Options with defaults resolved

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:106


Bin​

Ζ¬ Bin: Object

An ordered list of all offers in the cache with a given tick. In the Mangrove protoocol this is called a "bin".

Only non-empty bins are stored in the cache and they are linked together in a doubly-linked list for easy traversal and update.

Type declaration​

NameType
ticknumber
offerCountnumber
firstOfferIdnumber
lastOfferIdnumber
prevBin | undefined
nextBin | undefined

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:159


State​

Ζ¬ State: Object

The cache at a given block. It holds a prefix of the on-chain offer list: All offers with a tick less than or equal to a max tick.

Must only be modified using the methods in SemibookCacheOperations to ensure cache consistency.

Invariants:

  • tick in binCache => all offers for that tick are in offerCache and there is at least one such offer
  • tick1 in binCache && tick2 < tick1 && βˆƒoffer: offer.tick == tick2 => tick2 in binCache
  • bestBinInCache.tick != undefined => bestBinInCache.tick is the best tick in the offer list
  • isComplete => all offers in the offer list are in the cache

Type declaration​

NameType
localConfigLocalConfig
offerCacheMap<number, Offer>
binCacheMap<number, Bin>
bestBinInCacheBin | undefined
worstBinInCacheBin | undefined
isCompleteboolean

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:179


FetchOfferListResult​

Ζ¬ FetchOfferListResult: Result<{ bins: Map<number, Offer[]> ; endOfListReached: boolean }, LogSubscriber.Error>

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:188


FetchConfigResult​

Ζ¬ FetchConfigResult: Result<LocalConfigFull, LogSubscriber.Error>

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:196


RawOfferSlim​

Ζ¬ RawOfferSlim: Omit<OfferWriteEventObject, "olKeyHash">

Defined in​

@mangrovedao/mangrove.js/src/semibook.ts:203

  • Interfaces
  • Type Aliases
    • Event
    • EventListener
    • BlockListener
    • VolumeParams
    • CacheContentsOptions
    • Options
    • ResolvedOptions
    • Bin
    • State
    • FetchOfferListResult
    • FetchConfigResult
    • RawOfferSlim