aave-protocol-v2/contracts/fees/MockKyberProxy.sol

45 lines
1.4 KiB
Solidity
Raw Normal View History

// SPDX-License-Identifier: agpl-3.0
pragma solidity ^0.6.8;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
2020-06-02 13:49:24 +00:00
import "../libraries/UniversalERC20.sol";
import "../mocks/tokens/MintableERC20.sol";
/// @title MockKyberProxy
/// @author Aave
/// @notice Mock contract to simulate the behaviour of the Kyber DEX
/// - Receives ETH/tokens
/// - Mints the tokenToBurn
/// - Sends back the tokenToBurn
contract MockKyberProxy {
2020-06-02 13:49:24 +00:00
using UniversalERC20 for IERC20;
2020-06-02 15:16:27 +00:00
using UniversalERC20 for MintableERC20;
/// @notice The token which the msg.sender of tradeWithHint will burn
MintableERC20 public tokenToBurn;
constructor(MintableERC20 _tokenToBurn) public {
tokenToBurn = _tokenToBurn;
}
/// @notice Simulates the function with the same name on the Kyber Proxy contract
function tradeWithHint(
IERC20 _fromToken,
uint256 _amount,
IERC20 _toToken,
address _receiver,
uint256 _maxAmount,
2020-06-02 13:49:24 +00:00
uint256 minConversionRate,
address _referral,
bytes calldata _filtering
2020-06-02 13:49:24 +00:00
) external payable returns (uint256) {
require(tokenToBurn.mint(1 ether), "TRADE_WITH_HINT. Reverted mint()");
2020-06-02 13:49:24 +00:00
if (!_fromToken.isETH()) {
_fromToken.universalTransferFromSenderToThis(_amount, true);
}
2020-06-02 15:16:27 +00:00
tokenToBurn.universalTransfer(msg.sender, 1 ether);
return 1 ether;
}
2020-06-02 13:49:24 +00:00
}