Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Oracle API standardizations #1916

Closed
rowgraus opened this issue Oct 26, 2020 · 10 comments
Closed

Oracle API standardizations #1916

rowgraus opened this issue Oct 26, 2020 · 10 comments
Labels
enhancement New feature or request Zoe package: Zoe

Comments

@rowgraus
Copy link

rowgraus commented Oct 26, 2020

What is the Problem Being Solved?

The oracle aggregator contract should present a standard API for querying aggregated prices without exposing the individual oracle identities or query parameters.

Description of the Design

Type declarations for the current design:

/**
 * @typedef {Object} PriceQuote
 * @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} 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 {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 {(brandIn: Brand, brandOut: Brand) => ERef<Issuer>} getQuoteIssuer
 * Get the ERTP issuer of PriceQuotes for a given brandIn/brandOut pair
 * @property {(brandIn: Brand, brandOut: Brand) => ERef<TimerService>}
 * getTimerService get the timer used in PriceQuotes for a given
 * brandIn/brandOut pair
 * @property {(brandIn: Brand, brandOut: Brand) => ERef<Notifier<PriceQuote>>}
 * getPriceNotifier
 * @property {(deadline: Timestamp, amountIn: Amount, brandOut: Brand) =>
 * Promise<PriceQuote>} quoteAtTime Resolves after `deadline` passes on the
 * priceAuthority's timerService with the price quote of `amountIn` at that time
 * @property {(amountIn: Amount, brandOut: Brand) => Promise<PriceQuote>}
 * quoteGiven get a quote corresponding to the specified amountIn
 * @property {(brandIn: Brand, amountOut: Amount) => Promise<PriceQuote>}
 * quoteWanted get a quote corresponding to the specified amountOut
 * @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`
 */

Security Considerations

Test Plan

@rowgraus rowgraus added enhancement New feature or request Small labels Oct 26, 2020
@katelynsills
Copy link
Contributor

I copied in what was in the doc that we worked on. Happy to add more if needed. @Chris-Hibbert does this match what you have implemented in the call spread?

@Chris-Hibbert
Copy link
Contributor

does this match what you have implemented in the call spread?

I didn't have a timer in the call, and my result doesn't include a timeStamp in the PriceQuote. Those are easy enough to add. Otherwise, compatible.

assetAmount can't default to 1 unit unless we have other mechanism for specifying the brand.

@katelynsills
Copy link
Contributor

For the priceQuote, the properties shouldn't be capitalized because they aren't keywords: { asset, price, timer, timestamp }

@katelynsills
Copy link
Contributor

assetAmount can't default to 1 unit unless we have other mechanism for specifying the brand.

Agreed. Let's not make it optional

@katelynsills
Copy link
Contributor

katelynsills commented Oct 26, 2020

A PriceQuote is a payment for which: quoteMath.getValue(priceQuote) => { asset, price, timer, timestamp }

Also, the value must be an array if it's MathKind.SET

@michaelfig
Copy link
Member

I've updated the above API with the type definitions I understood from our conversation. Please update the issue description if you have changes, with a new comment to draw attention to them.

@michaelfig
Copy link
Member

Pivot the naming from 'asset' and 'price' to be more general ('amountIn', 'amountOut' and 'Quote').

@michaelfig
Copy link
Member

Remove timer argument from quoteAtTime and add getTimerService(brandIn, brandOut) to retrieve the authority's timer for brandIn/brandOut.

@michaelfig
Copy link
Member

Update for quoteGiven and quoteWanted.

@katelynsills
Copy link
Contributor

Closed by #1952

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request Zoe package: Zoe
Projects
None yet
Development

No branches or pull requests

4 participants