// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.6; import "./TestBase.sol"; import "../src/ERC20BridgeSampler.sol"; contract UniswapV2SamplerTest is TestBase { ERC20BridgeSampler sampler; function setUp() public { sampler = new ERC20BridgeSampler(); sampler.setSampleValues(_toSingleValueArray(1e18)); } function testUniswapV2Sell() public skip() requiresChainId(1) requiresBlockNumberGte(14000000) { 0x000000000000000000636f6E736F6C652e6c6F68.call(""); address router = 0xf164fC0Ec4E93095b804a4795bBe1e041497b92a; address weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; address dai = 0x6B175474E89094C44Da98b954EedeAC495271d0F; address[] memory path = new address[](3); path[0] = weth; path[1] = usdc; path[2] = dai; uint256[] memory values = sampler.sampleSellsFromUniswapV2Global( router, path ); uint256[] memory samples; samples = _getSamples(13); emit log_string("13"); 0x000000000000000000636f6E736F6C652e6c6F68.call(""); values = sampler._sampleSellsFromUniswapV2( router, path, samples ); 0x000000000000000000636f6E736F6C652e6c6F68.call(""); samples = _getSamples(100); emit log_string("100"); 0x000000000000000000636f6E736F6C652e6c6F68.call(""); values = sampler._sampleSellsFromUniswapV2( router, path, samples ); 0x000000000000000000636f6E736F6C652e6c6F68.call(""); samples = _getSamples(1000); emit log_string("1000"); 0x000000000000000000636f6E736F6C652e6c6F68.call(""); values = sampler._sampleSellsFromUniswapV2( router, path, samples ); 0x000000000000000000636f6E736F6C652e6c6F68.call(""); samples = _getSamples(10000); emit log_string("1000"); 0x000000000000000000636f6E736F6C652e6c6F68.call(""); values = sampler._sampleSellsFromUniswapV2( router, path, samples ); 0x000000000000000000636f6E736F6C652e6c6F68.call(""); assertGt(values[0], 0); } function _getSamples(uint256 numSamples) public pure returns (uint256[] memory) { uint256[] memory samples = new uint256[](numSamples); for (uint i = 0; i < numSamples; i++) { samples[i] = 1e18; } return samples; } function fromHexChar(uint8 c) public pure returns (uint8) { if (bytes1(c) >= bytes1('0') && bytes1(c) <= bytes1('9')) { return c - uint8(bytes1('0')); } if (bytes1(c) >= bytes1('a') && bytes1(c) <= bytes1('f')) { return 10 + c - uint8(bytes1('a')); } if (bytes1(c) >= bytes1('A') && bytes1(c) <= bytes1('F')) { return 10 + c - uint8(bytes1('A')); } } // Convert an hexadecimal string to raw bytes function fromHex(string memory s) public pure returns (bytes memory) { bytes memory ss = bytes(s); require(ss.length%2 == 0); // length must be even bytes memory r = new bytes(ss.length/2); for (uint i=0; i