Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@nicholaspai
Copy link
Member

Signed-off-by: Nick Pai [email protected]

Motivation

Currently, the SyntheticPegMonitor assumes that the TOKEN_PRICE_FEED (i.e. the "synthetic") and the MEDIANIZER_PRICE_FEED (i.e. the "peg") are returning prices denominated in the same currency. However, consider the case where the synthetic market is (zeldaCash - USDC) and the peg market is tracking (STABLESPREAD/ETH). This can result in the following erroneous log:

Screen Shot 2021-01-07 at 20 40 29

Summary

Adds an optional construction parameter to this monitor called the denominatorPriceFeed which will divide the synthetic price if available.

Example environment variable to divide the synthetic price by the price of ETHUSD:

TOKEN_DENOMINATOR_PRICE_FEED_CONFIG={"type":"cryptowatch","apiKey":"XXX","exchange":"coinbase-pro","pair":"ethusd","lookback":"3600","minTimeBetweenUpdates":60}

@nicholaspai nicholaspai added the bots Related to off-chain bot infra label Jan 8, 2021
… by another price feed

Signed-off-by: Nick Pai <[email protected]>

Remove debug logs from BasketSpreadPriceFeed

These clog up the logs
@nicholaspai nicholaspai force-pushed the npai/denominate-synthetic-peg branch from 4f6c6c3 to 7ef0de7 Compare January 8, 2021 01:56
@nicholaspai nicholaspai changed the title fix(synthetic-peg-monitor): Add feature to denominate synthetic price by another price feed fix(bots): Add feature to denominate synthetic price by another price feed + remove noisy BasketSpreadPriceFeed logs Jan 8, 2021
return null;
}
const experimentalMean = this._computeMean(experimentalPrices);
this.logger.debug({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These clog up the logs, removing now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, this will help

@coveralls
Copy link

coveralls commented Jan 8, 2021

Coverage Status

Coverage remained the same at 93.284% when pulling 7edab8b on npai/denominate-synthetic-peg into cdf0e2f on master.

Copy link
Member

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome. I was trying to consider other ways to handle the pool being against a different currency without having to provide yet another feed, but I don't have a good solution. LGTM!

return null;
}
const experimentalMean = this._computeMean(experimentalPrices);
this.logger.debug({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, this will help

Signed-off-by: Nick Pai <[email protected]>
twapLength,
poolDecimals = 18,
decimals = 18
priceFeedDecimals = 18
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a nasty bug: because this construction was named decimals and not priceFeedDecimals, then DefaultPriceFeedConfigs was not correctly overriding this precision.

config.twapLength,
config.poolDecimals,
config.decimals // This defaults to 18 unless supplied by user
config.priceFeedDecimals // This defaults to 18 unless supplied by user
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.decimals doesn't actually exist when the config is constructed by DefaultPriceFeedConfigs, so I renamed to priceFeedDecimals which CryptoWatchPriceFeed uses.

web3.eth.getBlock("latest"),
createTokenPriceFeedForEmp(logger, web3, networker, getTime, empAddress, tokenPriceFeedConfig),
createReferencePriceFeedForEmp(logger, web3, networker, getTime, empAddress, medianizerPriceFeedConfig)
createTokenPriceFeedForEmp(logger, web3, networker, getTime, empAddress, {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's some new logic: I enforce that all of the pricefeeds use the same precision.

Signed-off-by: Nick Pai <[email protected]>
Signed-off-by: Nick Pai <[email protected]>
STABLESPREAD: {
// This is alternatively known as "STABLESPREAD/ETH"
type: "basketspread",
lookback: 7200,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These EMP's all have huge lookback's so I want to override them

Copy link
Member

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!


const { ConvertDecimals, createFormatFunction, formatHours, createObjectFromDefaultProps } = require("@uma/common");

// TODO: Rename "medianizerPriceFeed" ==> "pegPriceFeed" and "uniswapPriceFeed" ==> "syntheticPriceFeed"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

STABLESPREAD: {
// This is alternatively known as "STABLESPREAD/ETH"
type: "basketspread",
lookback: 7200,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@nicholaspai nicholaspai merged commit cf7ddbb into master Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bots Related to off-chain bot infra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants