Skip to content

feat: add oracle price conditions (Chainlink + Pyth) #65

Open
minhtr09 wants to merge 2 commits into
mainfrom
conditional-swap-oracle
Open

feat: add oracle price conditions (Chainlink + Pyth) #65
minhtr09 wants to merge 2 commits into
mainfrom
conditional-swap-oracle

Conversation

@minhtr09

@minhtr09 minhtr09 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@minhtr09 minhtr09 force-pushed the conditional-swap-oracle branch from 25c4647 to d26d596 Compare June 19, 2026 08:13
Comment thread src/libraries/OracleLib.sol Outdated
Comment on lines +89 to +91
priceIn < config.oracleIn.priceLimits >> 128
|| priceIn > uint128(config.oracleIn.priceLimits)
) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should use packu128 for more concise code, or use unpack it clearly

Comment thread src/libraries/OracleLib.sol Outdated
Comment thread src/libraries/OracleLib.sol Outdated
Comment on lines +107 to +108
uint256 oracleUpdateIndex,
bytes[] calldata updateData

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oracle's updateData shouldn't be in the scope of the validation

Comment thread src/libraries/OracleLib.sol Outdated
}

// slippage guard: needs both legs to derive the ratio
uint256 maxDeviationBps = uint128(config.oracleParams);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't assume the quote is usd

Comment on lines +123 to +125
priceIn = _usdPrice(config.oracleIn, maxStaleness);
priceOut = _usdPrice(config.oracleOut, maxStaleness);
ratio = _ratio(priceIn, priceOut, tokenIn, tokenOut);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if we only single oracle, right between tokenIn and tokenOut?

@thepluck thepluck Jun 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants