diff --git a/contracts/CowSwapSeller.sol b/contracts/CowSwapSeller.sol index bc62107..4447c56 100644 --- a/contracts/CowSwapSeller.sol +++ b/contracts/CowSwapSeller.sol @@ -29,7 +29,7 @@ struct Quote { uint256[] poolFees; // specific pool fees involved in the optimal swap path, typically in Uniswap V3 } interface OnChainPricing { - function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external returns (Quote memory); + function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view returns (Quote memory); } // END OnchainPricing diff --git a/contracts/OnChainPricingMainnet.sol b/contracts/OnChainPricingMainnet.sol index 3ca7a72..b8a6fe6 100644 --- a/contracts/OnChainPricingMainnet.sol +++ b/contracts/OnChainPricingMainnet.sol @@ -188,13 +188,13 @@ contract OnChainPricingMainnet { /// @param tokenIn - The token you want to sell /// @param tokenOut - The token you want to buy /// @param amountIn - The amount of token you want to sell - function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external virtual returns (Quote memory) { + function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view virtual returns (Quote memory) { return _findOptimalSwap(tokenIn, tokenOut, amountIn); } /// @dev View function for testing the routing of the strategy /// See {findOptimalSwap} - function _findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) internal returns (Quote memory) { + function _findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) internal view returns (Quote memory) { bool wethInvolved = (tokenIn == WETH || tokenOut == WETH); uint256 length = wethInvolved? 5 : 7; // Add length you need diff --git a/contracts/OnChainPricingMainnetLenient.sol b/contracts/OnChainPricingMainnetLenient.sol index 4ac27dd..b315cc4 100644 --- a/contracts/OnChainPricingMainnetLenient.sol +++ b/contracts/OnChainPricingMainnetLenient.sol @@ -48,7 +48,7 @@ contract OnChainPricingMainnetLenient is OnChainPricingMainnet { // === PRICING === // /// @dev View function for testing the routing of the strategy - function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external override returns (Quote memory q) { + function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view override returns (Quote memory q) { q = _findOptimalSwap(tokenIn, tokenOut, amountIn); q.amountOut = q.amountOut * (MAX_BPS - slippage) / MAX_BPS; } diff --git a/contracts/OnChainSwapMainnet.sol b/contracts/OnChainSwapMainnet.sol index 2a25112..f125f09 100644 --- a/contracts/OnChainSwapMainnet.sol +++ b/contracts/OnChainSwapMainnet.sol @@ -31,7 +31,7 @@ struct Quote { } interface OnChainPricing { - function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external returns (Quote memory); + function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view returns (Quote memory); } /// @dev Mainnet Version of swap for various on-chain dex diff --git a/contracts/tests/PricerWrapper.sol b/contracts/tests/PricerWrapper.sol new file mode 100644 index 0000000..2854367 --- /dev/null +++ b/contracts/tests/PricerWrapper.sol @@ -0,0 +1,42 @@ +pragma solidity 0.8.10; +pragma experimental ABIEncoderV2; + +enum SwapType { + CURVE, //0 + UNIV2, //1 + SUSHI, //2 + UNIV3, //3 + UNIV3WITHWETH, //4 + BALANCER, //5 + BALANCERWITHWETH //6 +} + +// Onchain Pricing Interface +struct Quote { + SwapType name; + uint256 amountOut; + bytes32[] pools; // specific pools involved in the optimal swap path + uint256[] poolFees; // specific pool fees involved in the optimal swap path, typically in Uniswap V3 +} +interface OnChainPricing { + function isPairSupported(address tokenIn, address tokenOut, uint256 amountIn) external view returns (bool); + function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view returns (Quote memory); +} +// END OnchainPricing + +contract PricerWrapper { + address public pricer; + constructor(address _pricer) { + pricer = _pricer; + } + + function isPairSupported(address tokenIn, address tokenOut, uint256 amountIn) external view returns (bool) { + return OnChainPricing(pricer).isPairSupported(tokenIn, tokenOut, amountIn); + } + + function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external view returns (uint256, Quote memory) { + uint256 _gasBefore = gasleft(); + Quote memory q = OnChainPricing(pricer).findOptimalSwap(tokenIn, tokenOut, amountIn); + return (_gasBefore - gasleft(), q); + } +} \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 5b98b31..7c33946 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,6 +55,13 @@ def swapexecutor(): return OnChainSwapMainnet.deploy({"from": accounts[0]}) +@pytest.fixture +def pricerwrapper(): + univ3simulator = UniV3SwapSimulator.deploy({"from": accounts[0]}) + balancerV2Simulator = BalancerSwapSimulator.deploy({"from": accounts[0]}) + pricer = OnChainPricingMainnet.deploy(univ3simulator.address, balancerV2Simulator.address, {"from": accounts[0]}) + return PricerWrapper.deploy(pricer.address, {"from": accounts[0]}) + @pytest.fixture def pricer(): univ3simulator = UniV3SwapSimulator.deploy({"from": accounts[0]}) diff --git a/tests/gas_benchmark/benchmark_pricer_gas.py b/tests/gas_benchmark/benchmark_pricer_gas.py index 4aef242..1922774 100644 --- a/tests/gas_benchmark/benchmark_pricer_gas.py +++ b/tests/gas_benchmark/benchmark_pricer_gas.py @@ -8,80 +8,87 @@ Rename the file to test_benchmark_pricer_gas.py to make this part of the testing suite if required """ -def test_gas_only_uniswap_v2(oneE18, weth, pricer): +def test_gas_only_uniswap_v2(oneE18, weth, pricerwrapper): + pricer = pricerwrapper token = "0xBC7250C8c3eCA1DfC1728620aF835FCa489bFdf3" # some swap (GM-WETH) only in Uniswap V2 ## 1e18 sell_count = 100000000 sell_amount = sell_count * 1000000000 ## 1e9 tx = pricer.findOptimalSwap(token, weth.address, sell_amount) - assert tx.return_value[0] == 1 ## UNIV2 - assert tx.return_value[1] > 0 - assert tx.gas_used <= 80000 ## 73925 in test simulation + assert tx[1][0] == 1 ## UNIV2 + assert tx[1][1] > 0 + assert tx[0] <= 80000 ## 73925 in test simulation -def test_gas_uniswap_v2_sushi(oneE18, weth, pricer): +def test_gas_uniswap_v2_sushi(oneE18, weth, pricerwrapper): + pricer = pricerwrapper token = "0x2e9d63788249371f1DFC918a52f8d799F4a38C94" # some swap (TOKE-WETH) only in Uniswap V2 & SushiSwap ## 1e18 sell_count = 5000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, weth.address, sell_amount) - assert (tx.return_value[0] == 1 or tx.return_value[0] == 2) ## UNIV2 or SUSHI - assert tx.return_value[1] > 0 - assert tx.gas_used <= 90000 ## 83158 in test simulation + assert (tx[1][0] == 1 or tx[1][0] == 2) ## UNIV2 or SUSHI + assert tx[1][1] > 0 + assert tx[0] <= 90000 ## 83158 in test simulation -def test_gas_only_balancer_v2(oneE18, weth, aura, pricer): +def test_gas_only_balancer_v2(oneE18, weth, aura, pricerwrapper): + pricer = pricerwrapper token = aura # some swap (AURA-WETH) only in Balancer V2 ## 1e18 - sell_count = 2000 + sell_count = 8000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, weth.address, sell_amount) - assert tx.return_value[0] == 5 ## BALANCER - assert tx.return_value[1] > 0 - assert tx.gas_used <= 110000 ## 101190 in test simulation + assert tx[1][0] == 5 ## BALANCER + assert tx[1][1] > 0 + assert tx[0] <= 110000 ## 101190 in test simulation -def test_gas_only_balancer_v2_with_weth(oneE18, wbtc, aura, pricer): +def test_gas_only_balancer_v2_with_weth(oneE18, wbtc, aura, pricerwrapper): + pricer = pricerwrapper token = aura # some swap (AURA-WETH-WBTC) only in Balancer V2 via WETH in between as connector ## 1e18 - sell_count = 2000 + sell_count = 8000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, wbtc.address, sell_amount) - assert tx.return_value[0] == 6 ## BALANCERWITHWETH - assert tx.return_value[1] > 0 - assert tx.gas_used <= 170000 ## 161690 in test simulation + assert tx[1][0] == 6 ## BALANCERWITHWETH + assert tx[1][1] > 0 + assert tx[0] <= 170000 ## 161690 in test simulation -def test_gas_only_uniswap_v3(oneE18, weth, pricer): +def test_gas_only_uniswap_v3(oneE18, weth, pricerwrapper): + pricer = pricerwrapper token = "0xf4d2888d29D722226FafA5d9B24F9164c092421E" # some swap (LOOKS-WETH) only in Uniswap V3 ## 1e18 sell_count = 600000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, weth.address, sell_amount) - assert tx.return_value[0] == 3 ## UNIV3 - assert tx.return_value[1] > 0 - assert tx.gas_used <= 160000 ## 158204 in test simulation + assert tx[1][0] == 3 ## UNIV3 + assert tx[1][1] > 0 + assert tx[0] <= 160000 ## 158204 in test simulation -def test_gas_only_uniswap_v3_with_weth(oneE18, wbtc, pricer): +def test_gas_only_uniswap_v3_with_weth(oneE18, wbtc, pricerwrapper): + pricer = pricerwrapper token = "0xf4d2888d29D722226FafA5d9B24F9164c092421E" # some swap (LOOKS-WETH-WBTC) only in Uniswap V3 via WETH in between as connector ## 1e18 sell_count = 600000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, wbtc.address, sell_amount) - assert tx.return_value[0] == 4 ## UNIV3WITHWETH - assert tx.return_value[1] > 0 - assert tx.gas_used <= 230000 ## 227498 in test simulation + assert tx[1][0] == 4 ## UNIV3WITHWETH + assert tx[1][1] > 0 + assert tx[0] <= 230000 ## 227498 in test simulation -def test_gas_almost_everything(oneE18, wbtc, weth, pricer): +def test_gas_almost_everything(oneE18, wbtc, weth, pricerwrapper): + pricer = pricerwrapper token = weth # some swap (WETH-WBTC) almost in every DEX, the most gas-consuming scenario ## 1e18 sell_count = 10 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, wbtc.address, sell_amount) - assert (tx.return_value[0] <= 3 or tx.return_value[0] == 5) ## CURVE or UNIV2 or SUSHI or UNIV3 or BALANCER - assert tx.return_value[1] > 0 - assert tx.gas_used <= 210000 ## 200229 in test simulation + assert (tx[1][0] <= 3 or tx[1][0] == 5) ## CURVE or UNIV2 or SUSHI or UNIV3 or BALANCER + assert tx[1][1] > 0 + assert tx[0] <= 210000 ## 200229 in test simulation \ No newline at end of file diff --git a/tests/gas_benchmark/benchmark_token_coverage.py b/tests/gas_benchmark/benchmark_token_coverage.py index c527522..6e3a300 100644 --- a/tests/gas_benchmark/benchmark_token_coverage.py +++ b/tests/gas_benchmark/benchmark_token_coverage.py @@ -48,12 +48,13 @@ ] @pytest.mark.parametrize("token,count", TOP_DECIMAL18_TOKENS) -def test_token_decimal18(oneE18, weth, token, count, pricer): +def test_token_decimal18(oneE18, weth, token, count, pricerwrapper): + pricer = pricerwrapper sell_token = token ## 1e18 sell_count = count sell_amount = sell_count * oneE18 ## 1e18 - quote = pricer.findOptimalSwap.call(sell_token, weth.address, sell_amount) - assert quote[1] > 0 + quote = pricer.findOptimalSwap(sell_token, weth.address, sell_amount) + assert quote[1][1] > 0 \ No newline at end of file diff --git a/tests/heuristic_equivalency/test_heuristic_equivalency.py b/tests/heuristic_equivalency/test_heuristic_equivalency.py index 97c2772..d458f5b 100644 --- a/tests/heuristic_equivalency/test_heuristic_equivalency.py +++ b/tests/heuristic_equivalency/test_heuristic_equivalency.py @@ -1,5 +1,6 @@ from rich.console import Console +import pytest console = Console() """ @@ -13,125 +14,132 @@ """ ### Test findOptimalSwap Equivalencies for different cases -def test_pricing_equivalency_uniswap_v2(weth, pricer, pricer_legacy): +def test_pricing_equivalency_uniswap_v2(weth, pricerwrapper, pricer_legacy): + pricer = pricerwrapper token = "0xBC7250C8c3eCA1DfC1728620aF835FCa489bFdf3" # some swap (GM-WETH) only in Uniswap V2 ## 1e18 sell_count = 100000000 sell_amount = sell_count * 1000000000 ## 1e9 tx = pricer.findOptimalSwap(token, weth.address, sell_amount) - assert tx.return_value[0] == 1 ## UNIV2 - quote = tx.return_value[1] + assert tx[1][0] == 1 ## UNIV2 + quote = tx[1][1] tx2 = pricer_legacy.findOptimalSwap(token, weth.address, sell_amount) assert tx2.return_value[0] == 1 ## UNIV2 quote_legacy = tx2.return_value[1] assert quote >= quote_legacy # Optimized quote must be the same or better - assert tx.gas_used < tx2.gas_used + assert tx[0] > 0 and tx[0] < tx2.gas_used -def test_pricing_equivalency_uniswap_v2_sushi(oneE18, weth, pricer, pricer_legacy): +def test_pricing_equivalency_uniswap_v2_sushi(oneE18, weth, pricerwrapper, pricer_legacy): + pricer = pricerwrapper token = "0x2e9d63788249371f1DFC918a52f8d799F4a38C94" # some swap (TOKE-WETH) only in Uniswap V2 & SushiSwap ## 1e18 sell_count = 5000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, weth.address, sell_amount) - assert (tx.return_value[0] == 1 or tx.return_value[0] == 2) ## UNIV2 or SUSHI - quote = tx.return_value[1] + assert (tx[1][0] == 1 or tx[1][0] == 2) ## UNIV2 or SUSHI + quote = tx[1][1] tx2 = pricer_legacy.findOptimalSwap(token, weth.address, sell_amount) assert (tx2.return_value[0] == 1 or tx2.return_value[0] == 2) ## UNIV2 or SUSHI quote_legacy = tx2.return_value[1] assert quote >= quote_legacy # Optimized quote must be the same or better - assert tx.gas_used < tx2.gas_used + assert tx[0] > 0 and tx[0] < tx2.gas_used -def test_pricing_equivalency_balancer_v2(oneE18, weth, aura, pricer, pricer_legacy): +def test_pricing_equivalency_balancer_v2(oneE18, weth, aura, pricerwrapper, pricer_legacy): + pricer = pricerwrapper token = aura # some swap (AURA-WETH) only in Balancer V2 ## 1e18 - sell_count = 2000 + sell_count = 8000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, weth.address, sell_amount) - assert tx.return_value[0] == 5 ## BALANCER - quote = tx.return_value[1] + assert tx[1][0] == 5 ## BALANCER + quote = tx[1][1] tx2 = pricer_legacy.findOptimalSwap(token, weth.address, sell_amount) assert tx2.return_value[0] == 5 ## BALANCER quote_legacy = tx2.return_value[1] assert quote >= quote_legacy # Optimized quote must be the same or better - assert tx.gas_used < tx2.gas_used + assert tx[0] > 0 and tx[0] < tx2.gas_used -def test_pricing_equivalency_balancer_v2_with_weth(oneE18, wbtc, aura, pricer, pricer_legacy): +def test_pricing_equivalency_balancer_v2_with_weth(oneE18, wbtc, aura, pricerwrapper, pricer_legacy): + pricer = pricerwrapper token = aura # some swap (AURA-WETH-WBTC) only in Balancer V2 via WETH in between as connector ## 1e18 - sell_count = 2000 + sell_count = 8000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, wbtc.address, sell_amount) - assert tx.return_value[0] == 6 ## BALANCERWITHWETH - quote = tx.return_value[1] + assert tx[1][0] == 6 ## BALANCERWITHWETH + quote = tx[1][1] tx2 = pricer_legacy.findOptimalSwap(token, wbtc.address, sell_amount) assert tx2.return_value[0] == 6 ## BALANCERWITHWETH quote_legacy = tx2.return_value[1] assert quote >= quote_legacy # Optimized quote must be the same or better - assert tx.gas_used < tx2.gas_used + assert tx[0] > 0 and tx[0] < tx2.gas_used -def test_pricing_equivalency_uniswap_v3(oneE18, weth, pricer, pricer_legacy): +def test_pricing_equivalency_uniswap_v3(oneE18, weth, pricerwrapper, pricer_legacy): + pricer = pricerwrapper token = "0xf4d2888d29D722226FafA5d9B24F9164c092421E" # some swap (LOOKS-WETH) only in Uniswap V3 ## 1e18 sell_count = 600000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, weth.address, sell_amount) - assert tx.return_value[0] == 3 ## UNIV3 - quote = tx.return_value[1] + assert tx[1][0] == 3 ## UNIV3 + quote = tx[1][1] tx2 = pricer_legacy.findOptimalSwap(token, weth.address, sell_amount) assert tx2.return_value[0] == 3 ## UNIV3 quote_legacy = tx2.return_value[1] assert quote >= quote_legacy # Optimized quote must be the same or better - assert tx.gas_used < tx2.gas_used + assert tx[0] > 0 and tx[0] < tx2.gas_used -def test_pricing_equivalency_uniswap_v3_with_weth(oneE18, wbtc, pricer, pricer_legacy): +def test_pricing_equivalency_uniswap_v3_with_weth(oneE18, wbtc, pricerwrapper, pricer_legacy): + pricer = pricerwrapper token = "0xf4d2888d29D722226FafA5d9B24F9164c092421E" # some swap (LOOKS-WETH-WBTC) only in Uniswap V3 via WETH in between as connector ## 1e18 sell_count = 600000 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, wbtc.address, sell_amount) - assert tx.return_value[0] == 4 ## UNIV3WITHWETH - quote = tx.return_value[1] + assert tx[1][0] == 4 ## UNIV3WITHWETH + quote = tx[1][1] tx2 = pricer_legacy.findOptimalSwap(token, wbtc.address, sell_amount) assert tx2.return_value[0] == 4 ## UNIV3WITHWETH quote_legacy = tx2.return_value[1] assert quote >= quote_legacy # Optimized quote must be the same or better, note the fixed pair in new version of univ3 pricer might cause some nuance there - assert tx.gas_used < tx2.gas_used + assert tx[0] > 0 and tx[0] < tx2.gas_used -def test_pricing_equivalency_almost_everything(oneE18, wbtc, weth, pricer, pricer_legacy): +def test_pricing_equivalency_almost_everything(oneE18, wbtc, weth, pricerwrapper, pricer_legacy): + pricer = pricerwrapper token = weth # some swap (WETH-WBTC) almost in every DEX, the most gas-consuming scenario ## 1e18 sell_count = 10 sell_amount = sell_count * oneE18 ## 1e18 tx = pricer.findOptimalSwap(token, wbtc.address, sell_amount) - assert (tx.return_value[0] <= 3 or tx.return_value[0] == 5) ## CURVE or UNIV2 or SUSHI or UNIV3 or BALANCER - quote = tx.return_value[1] + assert (tx[1][0] <= 3 or tx[1][0] == 5) ## CURVE or UNIV2 or SUSHI or UNIV3 or BALANCER + quote = tx[1][1] tx2 = pricer_legacy.findOptimalSwap(token, wbtc.address, sell_amount) assert (tx2.return_value[0] <= 3 or tx2.return_value[0] == 5) ## CURVE or UNIV2 or SUSHI or UNIV3 or BALANCER quote_legacy = tx2.return_value[1] - assert tx2.return_value[0] == tx.return_value[0] + assert tx2.return_value[0] == tx[1][0] assert quote >= quote_legacy # Optimized quote must be the same or better, note the fixed pair in new version of univ3 pricer might cause some nuance there - assert tx.gas_used < tx2.gas_used + assert tx[0] > 0 and tx[0] < tx2.gas_used ### Test specific pricing functions for different underlying protocols diff --git a/tests/on_chain_pricer/test_balancer_pricer.py b/tests/on_chain_pricer/test_balancer_pricer.py index 7421947..11718f7 100644 --- a/tests/on_chain_pricer/test_balancer_pricer.py +++ b/tests/on_chain_pricer/test_balancer_pricer.py @@ -105,7 +105,8 @@ def test_get_balancer_price_aurabal_analytical(oneE18, aurabal, weth, pricer): """ getBalancerPrice quote for token A swapped to token B directly using given balancer pool: A - > B """ -def test_get_balancer_price_aurabal_bpt_analytical(oneE18, aurabal, balethbpt, pricer): +def test_get_balancer_price_aurabal_bpt_analytical(oneE18, aurabal, balethbpt, pricerwrapper): + pricer = pricerwrapper ## 1e18 sell_count = 100 sell_amount = sell_count * oneE18 @@ -114,8 +115,8 @@ def test_get_balancer_price_aurabal_bpt_analytical(oneE18, aurabal, balethbpt, p p = sell_count * 1 * oneE18 ## there is a proper pool in Balancer for AURABAL in BAL-ETH bpt - quote = pricer.findOptimalSwap(balethbpt.address, aurabal.address, sell_amount).return_value - assert quote[1] >= p + quote = pricer.findOptimalSwap(balethbpt.address, aurabal.address, sell_amount) + assert quote[1][1] >= p def test_balancer_not_supported_tokens(oneE18, tusd, usdc, pricer): ## tokenIn not in the given balancer pool diff --git a/tests/on_chain_pricer/test_bribe_tokens_supported.py b/tests/on_chain_pricer/test_bribe_tokens_supported.py index ea51619..c2d23af 100644 --- a/tests/on_chain_pricer/test_bribe_tokens_supported.py +++ b/tests/on_chain_pricer/test_bribe_tokens_supported.py @@ -47,7 +47,8 @@ ] @pytest.mark.parametrize("token", TOKENS_18_DECIMALS) -def test_are_bribes_supported(pricer, token): +def test_are_bribes_supported(pricerwrapper, token): + pricer = pricerwrapper """ Given a bunch of tokens historically used as bribes, verifies the pricer will return non-zero value We sell all to WETH which is pretty realistic @@ -60,5 +61,5 @@ def test_are_bribes_supported(pricer, token): assert res quote = pricer.findOptimalSwap.call(token, WETH, AMOUNT) - assert quote[1] > 0 + assert quote[1][1] > 0 diff --git a/tests/on_chain_pricer/test_univ3_pricer_simu.py b/tests/on_chain_pricer/test_univ3_pricer_simu.py index ff66592..5193dc6 100644 --- a/tests/on_chain_pricer/test_univ3_pricer_simu.py +++ b/tests/on_chain_pricer/test_univ3_pricer_simu.py @@ -83,7 +83,8 @@ def test_only_sushi_support(oneE18, xsushi, usdc, pricer): supported = pricer.isPairSupported(xsushi.address, usdc.address, sell_amount) assert supported == True -def test_only_curve_support(oneE18, usdc, pricer): +def test_only_curve_support(oneE18, usdc, badger, aura, pricerwrapper): + pricer = pricerwrapper ## 1e18 sell_amount = 1000 * oneE18 @@ -91,10 +92,10 @@ def test_only_curve_support(oneE18, usdc, pricer): supported = pricer.isPairSupported("0x2a54ba2964c8cd459dc568853f79813a60761b58", usdc.address, sell_amount) assert supported == True quoteTx = pricer.findOptimalSwap("0x2a54ba2964c8cd459dc568853f79813a60761b58", usdc.address, sell_amount) - assert quoteTx.return_value[1] > 0 - assert quoteTx.return_value[0] == 0 + assert quoteTx[1][1] > 0 + assert quoteTx[1][0] == 0 ## not supported yet - isBadgerAuraSupported = pricer.isPairSupported(pricer.BADGER(), pricer.AURA(), sell_amount * 100) + isBadgerAuraSupported = pricer.isPairSupported(badger.address, aura.address, sell_amount * 100) assert isBadgerAuraSupported == False \ No newline at end of file