Skip to content

Commit

Permalink
Merge pull request #113 from 1inch/patch-1
Browse files Browse the repository at this point in the history
simplify dy call flow
  • Loading branch information
zZoMROT authored Feb 1, 2024
2 parents 4cbb900 + a59859d commit 39c9fd1
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions contracts/oracles/CurveOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,13 @@ contract CurveOracle is IOracle {

if (b0 != 0 && b1 != 0) {
(success, data) = pool.staticcall(abi.encodeWithSelector(info.dyFuncInt128, srcTokenIndex, dstTokenIndex, b0));
if (success && data.length >= 32) { // vyper could return redundant bytes
b1 = abi.decode(data, (uint256));
} else {
if (!success || data.length < 32) {
(success, data) = pool.staticcall(abi.encodeWithSelector(info.dyFuncUint256, uint128(srcTokenIndex), uint128(dstTokenIndex), b0));
if (success && data.length >= 32) { // vyper could return redundant bytes
b1 = abi.decode(data, (uint256));
} else {
pool = registries[i].find_pool_for_coins(address(srcToken), address(dstToken), ++registryIndex);
continue;
}
}
ratesAndWeights.append(OraclePrices.OraclePrice(Math.mulDiv(b1, 1e18, b0), w));
if (success && data.length >= 32) { // vyper could return redundant bytes
b1 = abi.decode(data, (uint256));
ratesAndWeights.append(OraclePrices.OraclePrice(Math.mulDiv(b1, 1e18, b0), w));
}
}
pool = registries[i].find_pool_for_coins(address(srcToken), address(dstToken), ++registryIndex);
}
Expand Down

0 comments on commit 39c9fd1

Please sign in to comment.