-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02c6147
commit 8b1c582
Showing
3 changed files
with
178 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,92 @@ | ||
/** | ||
* @typedef {Object} TimerService Gives the ability to get the current time, | ||
* schedule a single wake() call, create a repeater that will allow scheduling | ||
* of events at regular intervals, or remove scheduled calls. | ||
* @property {() => Timestamp} getCurrentTimestamp Retrieve the latest timestamp | ||
* @property {(baseTime: Timestamp, handler: TimerServiceHandler) => Timestamp} | ||
* setWakeup Return value is the time at which the call is scheduled to take | ||
* place | ||
* @property {(handler: TimerServiceHandler) => Array<Timestamp>} removeWakeup Remove | ||
* the handler from all its scheduled wakeup, whether produced by | ||
* `timer.setWakeup(h)` or `repeater.schedule(h)`. | ||
* @property {(baseTime: Timestamp, interval: RelativeTime) => TimerRepeater} | ||
* createRepeater Create and return a repeater that will schedule `wake()` calls | ||
* repeatedly at times that are a multiple of interval following baseTime. | ||
* Interval is the delay between successive times at which wake will be called. | ||
* When `schedule(h)` is called, `h.wake()` will be scheduled to be called after | ||
* the next multiple of interval from the base. Since times can be | ||
* coarse-grained, the actual call may occur later, but this won't change when | ||
* the next event will be called. | ||
*/ | ||
|
||
/** | ||
* @typedef {number} Timestamp An absolute individual stamp returned by a | ||
* TimerService. Note that different timer services may have different | ||
* interpretations of actual Timestamp values. | ||
* @typedef {number} RelativeTime Difference between two Timestamps. Note that | ||
* different timer services may have different interpretations of actual | ||
* RelativeTime values. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} TimerServiceHandler | ||
* @property {(timestamp: Timestamp) => void} wake The timestamp passed to | ||
* `wake()` is the time that the call was scheduled to occur. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} TimerRepeater | ||
* @property {(handler: TimerHandler) => void} schedule Returns the time | ||
* scheduled for the first call on handler. The handler will continue to be | ||
* scheduled for a `wake()` call every interval until the repeater is disabled. | ||
* @property {() => void} disable Disable this repeater, so `schedule()` can't | ||
* be called, and handlers already scheduled with this repeater won't be | ||
* rescheduled again after `wake()` is next called on them. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} PriceQuote | ||
* @property {Payment} quotePayment The quote wrapped as a payment | ||
* @property {Amount} quoteAmount Amount of `quotePayment` (`quoteIssuer.getAmountOf(quotePayment)`) | ||
* @property {Amount} quoteAmount Amount whose value is a PriceQuoteValue | ||
* @property {Payment} quotePayment The `quoteAmount` wrapped as a payment | ||
*/ | ||
|
||
/** | ||
* @typedef {Array<PriceDescription>} PriceQuoteValue A set of PriceDescriptions | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} PriceQuoteValue An individual quote's value | ||
* @property {Amount} assetAmount The amount of the asset being quoted | ||
* @property {Amount} price The quoted price for the `assetAmount` | ||
* @typedef {Object} PriceDescription A description of a single quote | ||
* @property {Amount} amountIn The amount supplied to a trade | ||
* @property {Amount} amountOut The quoted result of trading `amountIn` | ||
* @property {TimerService} timer The service that gave the `timestamp` | ||
* @property {number} timestamp A timestamp for the quote according to `timer` | ||
* @property {Timestamp} timestamp A timestamp according to `timer` for the | ||
* quote | ||
* @property {any=} conditions Additional conditions for the quote | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} PriceAuthority An object that mints PriceQuotes and handles | ||
* triggers and notifiers for changes in the price | ||
* @property {(assetBrand: Brand, priceBrand: Brand) => ERef<Issuer>} | ||
* getQuoteIssuer Get the ERTP issuer of PriceQuotes | ||
* @property {(brandIn: Brand, brandOut: Brand) => ERef<Issuer>} getQuoteIssuer | ||
* Get the ERTP issuer of PriceQuotes | ||
* @property {(amountIn: Amount, brandOut: Brand) => Promise<PriceQuote>} | ||
* getInputPrice calculate the amount of brandOut that will be returned if the | ||
* amountIn is sold at the current price | ||
* @property {(amountOut: Amount, brandIn: Brand) => Promise<PriceQuote>} | ||
* getOutputPrice calculate the amount of brandIn that is required in order to | ||
* get amountOut using the current price | ||
* @property {(assetBrand: Brand, priceBrand: Brand) => ERef<Notifier<PriceQuote>>} | ||
* getAmountInQuote get a quote corresponding to the specified amountIn | ||
* @property {(brandIn: Brand, amountOut: Amount) => Promise<PriceQuote>} | ||
* getAmountOutQuote get a quote corresponding to the specified amountOut | ||
* @property {(brandIn: Brand, brandOut: Brand) => ERef<Notifier<PriceQuote>>} | ||
* getPriceNotifier | ||
* @property {(timer: TimerService, deadline: number, assetAmount: Amount, | ||
* priceBrand: Brand) => Promise<PriceQuote>} priceAtTime Resolves after | ||
* `deadline` passes on `timer` with the price of `assetAmount` at that time | ||
* @property {(assetAmount: Amount, priceLimit: Amount) => Promise<PriceQuote>} | ||
* priceWhenGT Resolve when the price of `assetAmount` exceeds `priceLimit` | ||
* @property {(assetAmount: Amount, priceLimit: Amount) => Promise<PriceQuote>} | ||
* priceWhenGTE Resolve when the price of `assetAmount` reaches or exceeds | ||
* `priceLimit` | ||
* @property {(assetAmount: Amount, priceLimit: Amount) => Promise<PriceQuote>} | ||
* priceWhenLTE Resolve when the price of `assetAmount` reaches or drops below | ||
* `priceLimit` | ||
* @property {(assetAmount: Amount, priceLimit: Amount) => Promise<PriceQuote>} | ||
* priceWhenLT Resolve when the price of `assetAmount` drops below `priceLimit` | ||
* @property {(timer: TimerService, deadline: number, amountIn: Amount, | ||
* brandOut: Brand) => Promise<PriceQuote>} quoteAtTime Resolves after | ||
* `deadline` passes on `timer` with the price quote of `amountIn` at that time | ||
* @property {(amountIn: Amount, amountOutLimit: Amount) => Promise<PriceQuote>} | ||
* quoteWhenGT Resolve when a price quote of `amountIn` exceeds `amountOutLimit` | ||
* @property {(amountIn: Amount, amountOutLimit: Amount) => Promise<PriceQuote>} | ||
* quoteWhenGTE Resolve when a price quote of `amountIn` reaches or exceeds | ||
* `amountOutLimit` | ||
* @property {(amountIn: Amount, amountOutLimit: Amount) => Promise<PriceQuote>} | ||
* quoteWhenLTE Resolve when a price quote of `amountIn` reaches or drops below | ||
* `amountOutLimit` | ||
* @property {(amountIn: Amount, amountOutLimit: Amount) => Promise<PriceQuote>} | ||
* quoteWhenLT Resolve when the price quote of `amountIn` drops below | ||
* `amountOutLimit` | ||
*/ |