Skip to content

Commit

Permalink
feat(oracle!): roundId in price results
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 5, 2022
1 parent 8c01bf9 commit 30f8d44
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
36 changes: 35 additions & 1 deletion packages/agoric-cli/src/commands/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const makeOracleCommand = async logger => {

oracle
.command('pushPrice')
.description('add a current price sample')
.description('add a current price sample to a priceAggregator')
.option('--offerId [number]', 'Offer id', Number, Date.now())
.requiredOption(
'--oracleAdminAcceptOfferId [number]',
Expand Down Expand Up @@ -128,6 +128,40 @@ export const makeOracleCommand = async logger => {
console.warn('Now execute the prepared offer');
});

oracle
.command('pushPriceRound')
.description('add a price for a round to a priceAggregatorChainlink')
.option('--offerId [number]', 'Offer id', Number, Date.now())
.requiredOption(
'--oracleAdminAcceptOfferId [number]',
'offer that had continuing invitation result',
Number,
)
.requiredOption('--price [number]', 'price (format TODO)', String)
.requiredOption('--roundId [number]', 'round', Number)
.action(async function () {
// @ts-expect-error this implicit any
const opts = this.opts();

/** @type {import('../lib/psm.js').OfferSpec} */
const offer = {
id: Number(opts.offerId),
invitationSpec: {
source: 'continuing',
previousOffer: opts.oracleAdminAcceptOfferId,
invitationMakerName: 'makePushPriceInvitation',
invitationArgs: harden([{ data: opts.price, roundId: opts.roundId }]),
},
proposal: {},
};

outputAction({
method: 'executeOffer',
offer,
});

console.warn('Now execute the prepared offer');
});
oracle
.command('query')
.description('return current aggregated (median) price')
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/test/agops-oracle-smoketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ORACLE_OFFER_ID=$(jq ".body | fromjson | .offer.id" <"$ORACLE_OFFER")

# Use invitation result, with continuing invitationMakers to propose a vote
PROPOSAL_OFFER=$(mktemp -t agops.XXX)
bin/agops oracle pushPrice --price 1.01 --oracleAdminAcceptOfferId "$ORACLE_OFFER_ID" >|"$PROPOSAL_OFFER"
bin/agops oracle pushPriceRound --price 1.01 --roundId 1 --oracleAdminAcceptOfferId "$ORACLE_OFFER_ID" >|"$PROPOSAL_OFFER"
jq ".body | fromjson" <"$PROPOSAL_OFFER"
agoric wallet send --from "$WALLET" --offer "$PROPOSAL_OFFER"

Expand Down
6 changes: 3 additions & 3 deletions packages/inter-protocol/scripts/start-local-chain-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
}
],
"economicCommitteeAddresses": {
"voter": "agoric1ersatz"
"voter": "agoric109q3uc0xt8aavne94rgd6rfeucavrx924e0ztf"
},
"demoOracleAddresses": [
"agoric1ersatz"
"agoric109q3uc0xt8aavne94rgd6rfeucavrx924e0ztf"
]
},
"creationOptions": {
Expand Down Expand Up @@ -55,7 +55,7 @@
"sourceSpec": "@agoric/inter-protocol/src/econCommitteeCharter.js"
},
"priceAggregator": {
"sourceSpec": "@agoric/zoe/src/contracts/priceAggregator.js"
"sourceSpec": "@agoric/zoe/src/contracts/priceAggregatorChainlink.js"
},
"bank": {
"sourceSpec": "@agoric/vats/src/vat-bank.js"
Expand Down
2 changes: 2 additions & 0 deletions packages/zoe/src/contracts/priceAggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const INVITATION_MAKERS_DESC = 'oracle invitation';
/** @typedef {ParsableNumber | Ratio} Price */

/**
* @deprecated use priceAggregatorChainlink
*
* This contract aggregates price values from a set of oracles and provides a
* PriceAuthority for their median. This naive method is game-able and so this module
* is a stub until we complete what is now in `priceAggregatorChainlink.js`.
Expand Down

0 comments on commit 30f8d44

Please sign in to comment.