fix: CryptoCom rollup (#98)
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
[
|
||||
{
|
||||
"version": "0.16.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix CryptoCom rollup"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.15.0",
|
||||
"changes": [
|
||||
|
||||
@@ -95,7 +95,7 @@ contract BridgeAdapter is
|
||||
MixinBancor(addresses)
|
||||
MixinCoFiX()
|
||||
MixinCurve()
|
||||
MixinCryptoCom(addresses)
|
||||
MixinCryptoCom()
|
||||
MixinDodo(addresses)
|
||||
MixinKyber(addresses)
|
||||
MixinMooniswap(addresses)
|
||||
|
||||
@@ -22,23 +22,12 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "./MixinAdapterAddresses.sol";
|
||||
import "./MixinUniswapV2.sol";
|
||||
|
||||
contract MixinCryptoCom is
|
||||
MixinAdapterAddresses
|
||||
contract MixinCryptoCom
|
||||
{
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
/// @dev Mainnet address of the `CryptoComRouter` contract.
|
||||
IUniswapV2Router02 private immutable CRYPTOCOM_ROUTER;
|
||||
|
||||
constructor(AdapterAddresses memory addresses)
|
||||
public
|
||||
{
|
||||
CRYPTOCOM_ROUTER = IUniswapV2Router02(addresses.cryptoComBridge);
|
||||
}
|
||||
|
||||
function _tradeCryptoCom(
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
@@ -48,7 +37,9 @@ contract MixinCryptoCom is
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
// solhint-disable indent
|
||||
address[] memory path = abi.decode(bridgeData, (address[]));
|
||||
address[] memory path;
|
||||
address router;
|
||||
(path, router) = abi.decode(bridgeData, (address[], address));
|
||||
// solhint-enable indent
|
||||
|
||||
require(path.length >= 2, "CryptoComBridge/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
|
||||
@@ -56,13 +47,10 @@ contract MixinCryptoCom is
|
||||
path[path.length - 1] == address(buyToken),
|
||||
"CryptoComBridge/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
|
||||
);
|
||||
// Grant the Uniswap router an allowance to sell the first token.
|
||||
IERC20TokenV06(path[0]).approveIfBelow(
|
||||
address(CRYPTOCOM_ROUTER),
|
||||
sellAmount
|
||||
);
|
||||
// Grant the CryptoCom router an allowance to sell the first token.
|
||||
IERC20TokenV06(path[0]).approveIfBelow(router, sellAmount);
|
||||
|
||||
uint[] memory amounts = CRYPTOCOM_ROUTER.swapExactTokensForTokens(
|
||||
uint[] memory amounts = IUniswapV2Router02(router).swapExactTokensForTokens(
|
||||
// Sell all tokens we hold.
|
||||
sellAmount,
|
||||
// Minimum buy amount.
|
||||
|
||||
Reference in New Issue
Block a user