feat: add oracle price conditions (Chainlink + Pyth) #65
Conversation
25c4647 to
d26d596
Compare
| priceIn < config.oracleIn.priceLimits >> 128 | ||
| || priceIn > uint128(config.oracleIn.priceLimits) | ||
| ) { |
There was a problem hiding this comment.
should use packu128 for more concise code, or use unpack it clearly
| uint256 oracleUpdateIndex, | ||
| bytes[] calldata updateData |
There was a problem hiding this comment.
Oracle's updateData shouldn't be in the scope of the validation
| } | ||
|
|
||
| // slippage guard: needs both legs to derive the ratio | ||
| uint256 maxDeviationBps = uint128(config.oracleParams); |
There was a problem hiding this comment.
This should only be for protection minAmountOut, not maxAmountOut
| } | ||
|
|
||
| /// @dev Token oracle price, USD-per-whole-token (1e18). | ||
| function _usdPrice(TokenOracle memory oracle, uint256 maxStaleness) |
| priceIn = _usdPrice(config.oracleIn, maxStaleness); | ||
| priceOut = _usdPrice(config.oracleOut, maxStaleness); | ||
| ratio = _ratio(priceIn, priceOut, tokenIn, tokenOut); |
There was a problem hiding this comment.
What if we only single oracle, right between tokenIn and tokenOut?
There was a problem hiding this comment.
This mostly happens if we use oracles other than Pyth and Chainlink. There are actually a few feeds for LSTs, LRTs, but the number is very small.
There was a problem hiding this comment.
one example: https://data.chain.link/feeds/base/base/steth-eth
There was a problem hiding this comment.
i think we could support both. USD-quoted prices are better if we want to support a broad range of tokens, while direct oracles could be used for LST and LRT cases
No description provided.