Namespace: Semibook
Interfacesβ
Type Aliasesβ
Eventβ
Ζ¬ Event: Object
Type declarationβ
Name | Type |
---|---|
cbArg | BookSubscriptionCbArgument |
event | BookSubscriptionEvent |
ethersLog | ethers.providers.Log |
Defined inβ
@mangrovedao/mangrove.js/src/semibook.ts:36
EventListenerβ
Ζ¬ EventListener: (e
: Event
) => Promise
<void
>
Type declarationβ
βΈ (e
): Promise
<void
>
Parametersβ
Name | Type |
---|---|
e | Event |
Returnsβ
Promise
<void
>
Defined inβ
@mangrovedao/mangrove.js/src/semibook.ts:42
BlockListenerβ
Ζ¬ BlockListener: (n
: number
) => Promise
<void
>
Type declarationβ
βΈ (n
): Promise
<void
>
Parametersβ
Name | Type |
---|---|
n | number |
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β
Name | Type | Description |
---|---|---|
given | Bigish | Amount of token to trade. |
to | BS | Whether given is base to be bought or quote to be sold. |
limitPrice? | Bigish | Optional: 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β
Name | Type |
---|---|
tick | number |
offerCount | number |
firstOfferId | number |
lastOfferId | number |
prev | Bin | undefined |
next | Bin | 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β
Name | Type |
---|---|
localConfig | LocalConfig |
offerCache | Map <number , Offer > |
binCache | Map <number , Bin > |
bestBinInCache | Bin | undefined |
worstBinInCache | Bin | undefined |
isComplete | boolean |
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