-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup oracle account, Add CLI commands to report oracle values #1394
Conversation
from reporting again.
… values accessible to tests
…onfig value defined
const sortedOracles = await this.kit.contracts.getSortedOracles() | ||
|
||
const rates = await sortedOracles.getRates(res.args.token) | ||
console.log( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: You might want to use cli.table
that we use in other cli commands as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh cool! I didn't know about it until now and it's great!
numerator = numerator.multipliedBy(multiplier) | ||
denominator = denominator.multipliedBy(multiplier) | ||
} | ||
// const numerator = price.multipliedBy(denominator).toNumber() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
const res = this.parse(ReportPrice) | ||
let token: CeloToken | ||
if (res.flags.token === CeloContract.StableToken) { | ||
token = CeloContract.StableToken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does token have to be set if res.flags.token
is equal to StableToken? Alternatively, you could set the options
option on the flag to require token to be member of a set
async run() { | ||
const supportedTokens: CeloToken[] = [CeloContract.StableToken] | ||
const res = this.parse(GetRates) | ||
if (!supportedTokens.includes(res.args.token)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the options
option of the argument to ensure that token is in a specific set
…rever when you try to locally sign things
I split this up into multiple PRs |
Description
This adds a new account type that can have its private key and account address derived from the mnemonic. This price oracle account gets funded in the genesis block to cover the fees of its transactions.
The other component of this PR is two new CLI commands. One of them reports the exchange rate between a specified token (currently just
StableToken
) andCeloGold
. The other gets the currently reported rates. This one I added to easily check if the reporting was working, and figured it might be useful enough to keep.Tested
The oracle account's inclusion in the genesis block and ability to act as an oracle was tested manually by spinning up a testnet and running the added CLI commands. Report transactions sent from the oracle account were successful and ones sent from other accounts were not.
Other changes
In the code-comments documentation for
SortedOracles.report
, thedenominator
param was missing. I added an explanation of what it is.Related issues