Skip to content

Commit

Permalink
add default price config for RaiRedemptionRate
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshvarma committed Mar 14, 2021
1 parent a5d28e5 commit eacb633
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/financial-templates-lib/src/price-feed/CreatePriceFeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { CoinGeckoPriceFeed } = require("./CoinGeckoPriceFeed");
const { TraderMadePriceFeed } = require("./TraderMadePriceFeed");
const { PriceFeedMockScaled } = require("./PriceFeedMockScaled");
const { InvalidPriceFeedMock } = require("./InvalidPriceFeedMock");
const { RAIRedemptionRatePriceFeed } = require("./RAIRedemptionRatePriceFeed");
const { defaultConfigs } = require("./DefaultPriceFeedConfigs");
const { getTruffleContract } = require("@uma/core");
const { ExpressionPriceFeed, math, escapeSpecialCharacters } = require("./ExpressionPriceFeed");
Expand All @@ -25,6 +26,7 @@ const uniswapBlockCache = {};

async function createPriceFeed(logger, web3, networker, getTime, config) {
const Uniswap = getTruffleContract("Uniswap", web3, "latest");
const RateSetter = getTruffleContract("RateSetter", web3, "latest");
const ERC20 = getTruffleContract("ExpandedERC20", web3, "latest");
const Balancer = getTruffleContract("Balancer", web3, "latest");
const VaultInterface = getTruffleContract("VaultInterface", web3, "latest");
Expand Down Expand Up @@ -81,6 +83,35 @@ async function createPriceFeed(logger, web3, networker, getTime, config) {
config.priceFeedDecimals, // This defaults to 18 unless supplied by user
config.tickPeriod // Defaults to 60 unless supplied.
);
} else if (config.type === "rairate") {
const requiredFields = ["rateSetterAddress", "raiSubgraphUrl", "updateRateDelay"];

if (isMissingField(config, requiredFields, logger)) {
return null;
}

logger.debug({
at: "createPriceFeed",
message: "Creating RAIRedemptionRatePriceFeed",
config
});

return new RAIRedemptionRatePriceFeed(
logger,
RateSetter.abi,
config.rateSetterAddress,
config.raiSubgraphUrl,
web3,
networker,
config.updateRateDelay,
config.twapLength,
config.historicalLookback,
getTime,
config.priceFeedDecimals,
config.raiDecimals, // Defaults to 27
config.priceFeedDecimals, // This defaults to 18 unless supplied by user
config.blocks
);
} else if (config.type === "uniswap") {
const requiredFields = ["uniswapAddress", "twapLength", "lookback"];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ const { getPrecisionForIdentifier } = require("@uma/common");

// Default price feed configs for currently approved identifiers.
const defaultConfigs = {
RaiRedemptionRate: {
type: "rairate",
rateSetterAddress: "0x0641C280B21A31daf1518a91A68Ad396EcC6f2f0",
raiSubgraphUrl: "https://subgraph-kovan.reflexer.finance/subgraphs/name/reflexer-labs/rai",
updateRateDelay: 3 * 60 * 60,
twapLength: 8 * 60 * 60,
historicalLookback: 8 * 60 * 60
},
"ETH/BTC": {
type: "medianizer",
pair: "ethbtc",
Expand Down

0 comments on commit eacb633

Please sign in to comment.