diff --git a/packages/synthetic-chain/src/lib/econHelpers.js b/packages/synthetic-chain/src/lib/econHelpers.js index 231e011f..3fc7a7d5 100644 --- a/packages/synthetic-chain/src/lib/econHelpers.js +++ b/packages/synthetic-chain/src/lib/econHelpers.js @@ -1,6 +1,12 @@ import { executeOffer, waitForBlock } from './commonUpgradeHelpers.js'; import { ATOM_DENOM, CHAINID, VALIDATORADDR } from './constants.js'; -import { agd, agops, executeCommand, agopsLocation } from './cliHelper.js'; +import { + agd, + agops, + executeCommand, + agopsLocation, + agoric as agoricAmbient, +} from './cliHelper.js'; import { GOV1ADDR, GOV2ADDR, GOV3ADDR } from './constants.js'; import { queryVstorage, getQuoteBody, getInstanceBoardId } from './vstorage.js'; @@ -198,6 +204,16 @@ export const pushPrices = async (price, brandIn, oraclesByBrand, round) => { } }; +export const getRoundId = async (price, io = {}) => { + const { + agoric = { follow: agoricAmbient.follow }, + prefix = 'published.', + } = io; + const path = `:${prefix}priceFeed.${price}-USD_price_feed.latestRound`; + const round = await agoric.follow('-lF', path); + return parseInt(round.roundId); +}; + export const getPriceQuote = async price => { const path = `published.priceFeed.${price}-USD_price_feed`; const body = await getQuoteBody(path); diff --git a/packages/synthetic-chain/test/snapshots/test-exports.ts.md b/packages/synthetic-chain/test/snapshots/test-exports.ts.md index 44e233da..34e950d0 100644 --- a/packages/synthetic-chain/test/snapshots/test-exports.ts.md +++ b/packages/synthetic-chain/test/snapshots/test-exports.ts.md @@ -68,6 +68,7 @@ Generated by [AVA](https://avajs.dev). getPriceQuote: AsyncFunction {}, getProvisionPoolMetrics: AsyncFunction [], getQuoteBody: AsyncFunction {}, + getRoundId: AsyncFunction {}, getUser: AsyncFunction {}, getVatDetails: AsyncFunction {}, getVaultPrices: AsyncFunction {}, diff --git a/packages/synthetic-chain/test/snapshots/test-exports.ts.snap b/packages/synthetic-chain/test/snapshots/test-exports.ts.snap index 17997e70..d4255a46 100644 Binary files a/packages/synthetic-chain/test/snapshots/test-exports.ts.snap and b/packages/synthetic-chain/test/snapshots/test-exports.ts.snap differ