Skip to content

Commit

Permalink
Addressed PriceOracle audit feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-momin committed Dec 15, 2023
1 parent 43bf316 commit 86ef241
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 148 deletions.
68 changes: 51 additions & 17 deletions configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@

These fields must be known prior to deployment.

- [anchorToleranceMantissa_](#anchortolerancemantissa_)
- [anchorPeriod_](#anchorperiod_)
- [anchorToleranceMantissa\_](#anchortolerancemantissa_)
- [anchorPeriod\_](#anchorperiod_)
- [configs](#configs)

# anchorToleranceMantissa_
## anchorToleranceMantissa\_

TYPE: `uint256`

The precentage tolerance for the Uniswap anchor.

For 15%, this equals: `150000000000000000`

# anchorPeriod_
## anchorPeriod\_

TYPE: `uint256`

Anchor window size.

For 30 minutes, this equals: `1800`

# configs
## configs

The configs parameter is an array of `TokenConfig` structs which contains the following fields:

Expand All @@ -39,35 +39,35 @@ The configs parameter is an array of `TokenConfig` structs which contains the fo
- [reporterMultiplier](#reportermultiplier)
- [isUniswapReversed](#isuniswapreversed)

## cToken
### cToken

TYPE: `address`

The address of the Compound interest baring token. For the `LINK` market configuration, this would be the address of the `cLINK` token.

## underlying
### underlying

TYPE: `address`

The address of the underlying market token. For this `LINK` market configuration, this would be the address of the `LINK` token.

## symbolHash
### symbolHash

TYPE: `bytes32`

The bytes32 hash of the underlying symbol. For the `LINK` market configuration, this would be `0x921a3539bcb764c889432630877414523e7fbca00c211bc787aeae69e2e3a779`, calculated using:

```javascript
keccak256("LINK")
keccak256("LINK");
```

## baseUnit
### baseUnit

TYPE: `uint256`

The number of smallest units of measurement in a single whole unit. For example: 1 ETH has 1e18 WEI, therefore the baseUnit of ETH is 1e18 (1,000,000,000,000,000,000)

## priceSource
### priceSource

TYPE: `enum PriceSource` (defined as an integer)

Expand All @@ -77,32 +77,32 @@ Options:
- 1 - FIXED_USD - The `fixedPrice` is a constant multiple of USD price, which is 1
- 2 - REPORTER - The price is set by the `reporter` (most common. CL price feed `ValidatorProxy`s are the reporters)

## fixedPrice
### fixedPrice

TYPE: `uint256`

The fixed price multiple of either ETH or USD, depending on the `priceSource`. If `priceSource` is `reporter`, this is unused.

## uniswapMarket
### uniswapMarket

TYPE: `address`

The address of the pool being used as the anchor for this market.

## reporter
### reporter

TYPE: `address`

The address of the `ValidatorProxy` acting as the reporter

## reporterMultiplier
### reporterMultiplier

TYPE: `uint256`

Prices reported by a `ValidatorProxy` must be transformed to 6 decimals for the UAV. Chainlink USD pairs are usually 8 decimals, which is two decimals too many. This field is used to transform the price, using this equation:

```javascript
price = (reportedPrice * reporterMultiplier) / 1e18
price = (reportedPrice * reporterMultiplier) / 1e18;
```

Using Chainlink USD pairs as an example, and `reportedPrice = 2000000000` ($20):
Expand All @@ -112,9 +112,43 @@ Using Chainlink USD pairs as an example, and `reportedPrice = 2000000000` ($20):
reporterMultiplier = 10000000000000000
```

## isUniswapReversed
### isUniswapReversed

TYPE: `bool`

If the `uniswapMarket` pair is X / ETH, this is `false`.
If the `uniswapMarket` pair is ETH / X, this is `true`.

# PriceOracle Configuration

[`parameters-price-oracle.js`](./parameters-price-oracle.ts) details the constructor parameters that are passed in when deploying the PriceOracle.

These fields must be known prior to deployment.

- [configs](#configs-1)

## configs

The configs parameter is an array of `TokenConfig` structs which contains the following fields:

- [cToken](#ctoken)
- [underlyingAssetDecimals](#underlyingassetdecimals)
- [priceFeed](#pricefeed)

### cToken

TYPE: `address`

The address of the Compound interest baring token. For the `LINK` market configuration, this would be the address of the `cLINK` token.

### underlyingAssetDecimals

TYPE: `uint8`

The decimals of the underlying asset. For `ETH`, the value would be `18`.

### priceFeed

TYPE: `address`

The address to the Chainlink feed used for the underlying asset's price
19 changes: 19 additions & 0 deletions configuration/parameters-price-oracle-goerli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { TokenConfig } from "./parameters-price-oracle";

export const parameters: TokenConfig[] = [
{
// "NAME": "ETH",
cToken: "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5",
underlyingAssetDecimals: "18",
priceFeed: "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e",
},
];

export const usdcConfig = {
// "NAME": "USDC",
cToken: "0x39AA39c021dfbaE8faC545936693aC917d5E7563",
underlyingAssetDecimals: "6",
priceFeed: "0xAb5c49580294Aff77670F839ea425f5b78ab3Ae7",
};

export default parameters;
38 changes: 19 additions & 19 deletions configuration/parameters-price-oracle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type TokenConfig = {
// The address of the Compound Token
cToken: string;
// The number of smallest units of measurement in a single whole unit.
baseUnit: string;
// Decimals of the underlying asset
underlyingAssetDecimals: string;
// Address to Chainlink feed used for asset price
priceFeed: string;
};
Expand All @@ -11,103 +11,103 @@ const parameters: TokenConfig[] = [
{
// "NAME": "ETH",
cToken: "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419",
},
{
// "NAME": "DAI",
cToken: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0xaed0c38402a5d19df6e4c03f4e2dced6e29c1ee9",
},
{
// "NAME": "USDC",
cToken: "0x39AA39c021dfbaE8faC545936693aC917d5E7563",
baseUnit: "1000000",
underlyingAssetDecimals: "6",
priceFeed: "0x8fffffd4afb6115b954bd326cbe7b4ba576818f6",
},
{
// "NAME": "USDT",
cToken: "0xf650C3d88D12dB855b8bf7D11Be6C55A4e07dCC9",
baseUnit: "1000000",
underlyingAssetDecimals: "6",
priceFeed: "0x3e7d1eab13ad0104d2750b8863b489d65364e32d",
},
{
// "NAME": "WBTCv2",
cToken: "0xccf4429db6322d5c611ee964527d42e5d685dd6a",
baseUnit: "100000000",
underlyingAssetDecimals: "8",
priceFeed: "0x45939657d1CA34A8FA39A924B71D28Fe8431e581", // Custom Compound Feed
},
{
// "NAME": "BAT",
cToken: "0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0x9441D7556e7820B5ca42082cfa99487D56AcA958",
},
{
// "NAME": "ZRX",
cToken: "0xB3319f5D18Bc0D84dD1b4825Dcde5d5f7266d407",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0x2885d15b8af22648b98b122b22fdf4d2a56c6023",
},
{
// "NAME": "UNI",
cToken: "0x35A18000230DA775CAc24873d00Ff85BccdeD550",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0x553303d460ee0afb37edff9be42922d8ff63220e",
},
{
// "NAME": "COMP",
cToken: "0x70e36f6BF80a52b3B46b3aF8e106CC0ed743E8e4",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0xdbd020caef83efd542f4de03e3cf0c28a4428bd5",
},
{
// "NAME": "LINK",
cToken: "0xFAce851a4921ce59e912d19329929CE6da6EB0c7",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0x2c1d072e956affc0d435cb7ac38ef18d24d9127c",
},
{
// "NAME": "TUSD",
cToken: "0x12392F67bdf24faE0AF363c24aC620a2f67DAd86",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0xec746ecf986e2927abd291a2a1716c940100f8ba",
},
{
// "NAME": "AAVE",
cToken: "0xe65cdB6479BaC1e22340E4E755fAE7E509EcD06c",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0x547a514d5e3769680ce22b2361c10ea13619e8a9",
},
{
// "NAME": "SUSHI",
cToken: "0x4B0181102A0112A2ef11AbEE5563bb4a3176c9d7",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0xcc70f09a6cc17553b2e31954cd36e4a2d89501f7",
},
{
// "NAME": "MKR",
cToken: "0x95b4eF2869eBD94BEb4eEE400a99824BF5DC325b",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0xec1d1b3b0443256cc3860e24a46f108e699484aa",
},
{
// "NAME": "YFI",
cToken: "0x80a2AE356fc9ef4305676f7a3E2Ed04e12C33946",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0xa027702dbb89fbd58938e4324ac03b58d812b0e1",
},
{
// "NAME": "USDP",
cToken: "0x041171993284df560249B57358F931D9eB7b925D",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0x09023c0da49aaf8fc3fa3adf34c6a7016d38d5e3",
},
{
// "NAME": "MATIC",
cToken: "0x944dd1c7ce133b75880cee913d513f8c07312393",
baseUnit: "1000000000000000000",
underlyingAssetDecimals: "18",
priceFeed: "0x7bac85a8a13a4bcd8abb3eb7d6b4d632c5a57676",
},
];
Expand Down

0 comments on commit 86ef241

Please sign in to comment.