Skip to content

Commit

Permalink
Optimize KyberDmmOracle
Browse files Browse the repository at this point in the history
  • Loading branch information
zZoMROT committed Aug 13, 2024
1 parent 50277fe commit e1b4810
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contracts/oracles/KyberDmmOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ contract KyberDmmOracle is IOracle {

ratesAndWeights = OraclePrices.init(pools0.length * pools1.length);
for (uint256 i = 0; i < pools0.length; i++) {
(uint256 b0, uint256 bc0) = _getBalances(srcToken, connector, pools0[i]);
if (b0 == 0 || bc0 == 0) {
continue;
}
for (uint256 j = 0; j < pools1.length; j++) {
(uint256 b0, uint256 bc0) = _getBalances(srcToken, connector, pools0[i]);
(uint256 bc1, uint256 b1) = _getBalances(connector, dstToken, pools1[j]);
if (bc1 == 0 || b1 == 0) {
continue;
}
uint256 w = Math.min(b0 * bc0, b1 * bc1).sqrt();
ratesAndWeights.append(OraclePrices.OraclePrice(Math.mulDiv(b1 * bc0, 1e18, bc1 * b0), w));
}
Expand Down

0 comments on commit e1b4810

Please sign in to comment.