Skip to content

Commit

Permalink
chore: add a method for getting latest round if for a given price feed
Browse files Browse the repository at this point in the history
  • Loading branch information
anilhelvaci authored and turadg committed Oct 30, 2024
1 parent c9644d6 commit 39b9fcf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/synthetic-chain/src/lib/econHelpers.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions packages/synthetic-chain/test/snapshots/test-exports.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Generated by [AVA](https://avajs.dev).
getPriceQuote: AsyncFunction {},
getProvisionPoolMetrics: AsyncFunction [],
getQuoteBody: AsyncFunction {},
getRoundId: AsyncFunction {},
getUser: AsyncFunction {},
getVatDetails: AsyncFunction {},
getVaultPrices: AsyncFunction {},
Expand Down
Binary file modified packages/synthetic-chain/test/snapshots/test-exports.ts.snap
Binary file not shown.

0 comments on commit 39b9fcf

Please sign in to comment.