From a59859d598e4e733f6ec5179671a66aee79da126 Mon Sep 17 00:00:00 2001 From: Mikhail Melnik Date: Thu, 1 Feb 2024 14:10:32 +0400 Subject: [PATCH] simplify dy call flow --- contracts/oracles/CurveOracle.sol | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/contracts/oracles/CurveOracle.sol b/contracts/oracles/CurveOracle.sol index 45b4ca12..1efb098b 100644 --- a/contracts/oracles/CurveOracle.sol +++ b/contracts/oracles/CurveOracle.sol @@ -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); }