Fixed PR comments, now onto writing tests

This commit is contained in:
Noah Khamliche 2021-08-13 17:43:24 -04:00 committed by Noah Khamliche
parent 57c767c3b1
commit 17e81432f1
4 changed files with 41 additions and 46 deletions

View File

@ -33,7 +33,7 @@ import "./features/interfaces/INativeOrdersFeature.sol";
import "./features/interfaces/IBatchFillNativeOrdersFeature.sol";
import "./features/interfaces/IMultiplexFeature.sol";
import "./features/interfaces/IOtcOrdersFeature.sol";
import "./features/interfaces/IEpFundRecoveryFeature.sol";
import "./features/interfaces/IFundRecoveryFeature.sol";
/// @dev Interface for a fully featured Exchange Proxy.
@ -50,7 +50,7 @@ interface IZeroEx is
IBatchFillNativeOrdersFeature,
IMultiplexFeature,
IOtcOrdersFeature,
IEpFundRecoveryFeature
IFundRecoveryFeature
{
// solhint-disable state-visibility

View File

@ -16,55 +16,24 @@ pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
import "../vendor/IUniswapV3Pool.sol";
import "../migrations/LibMigrate.sol";
import "../fixins/FixinCommon.sol";
import "../fixins/FixinTokenSpender.sol";
import "./interfaces/IFeature.sol";
import "./interfaces/IEpFundRecoveryFeature.sol";
import "./interfaces/IFundRecoveryFeature.sol";
import "../transformers/LibERC20Transformer.sol";
contract EpFundRecoveryFeature is
contract FundRecoveryFeature is
IFeature,
IEpFundRecoveryFeature,
FixinCommon,
FixinTokenSpender
IFundRecoveryFeature,
FixinCommon
{
/// @dev Name of this feature.
string public constant override FEATURE_NAME = "EpFundRecoveryFeature";
string public constant override FEATURE_NAME = "FundRecoveryFeature";
/// @dev Version of this feature.
uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 0, 0);
/// @dev Deployed exchange proxy address.
address private immutable ZEROEX_EP_ADDRESS;
/// @dev Construct this contract.
/// @param exchangeProxy Exchange Proxy contract address
constructor(address exchangeProxy) public {
ZEROEX_EP_ADDRESS = exchangeProxy;
}
// solhint-enable state-visibility
/// @dev recovers WETH from the 0x Exchange Proxy contract
function recoverToDesignatedWallet(
IERC20TokenV06 erc20,
uint256 amountOut,
address payable designatedWallet
)
external
override
{
if(amountOut == uint256(-1)) {
amountOut = erc20.balanceOf(ZEROEX_EP_ADDRESS);
}
if(LibERC20Transformer.isTokenETH(erc20))
{
payable(designatedWallet).transfer(amountOut);
}
else{
erc20.transferFrom(ZEROEX_EP_ADDRESS,designatedWallet,amountOut);
}
}
constructor() public {}
/// @dev Initialize and register this feature.
/// Should be delegatecalled by `Migrate.migrate()`.
@ -73,8 +42,29 @@ contract EpFundRecoveryFeature is
external
returns (bytes4 success)
{
//_registerFeatureFunction(this.sellEthForTokenToUniswapV3.selector);
_registerFeatureFunction(this.recoverToDesignatedWallet.selector);
_registerFeatureFunction(this.transferTrappedTokensTo.selector);
return LibMigrate.MIGRATE_SUCCESS;
}
// solhint-enable state-visibility
/// @dev recovers WETH from the 0x Exchange Proxy contract
/// @param erc20 ERC20 Token Address.
/// @param amountOut Amount of tokens to withdraw.
/// @param recipientWallet Recipient wallet address.
function transferTrappedTokensTo(
IERC20TokenV06 erc20,
uint256 amountOut,
address payable recipientWallet
)
external
override
onlyOwner
{
if(amountOut == uint256(-1)) {
amountOut = LibERC20Transformer.getTokenBalanceOf(erc20, address(this));
}
LibERC20Transformer.transformerTransfer(erc20, recipientWallet, amountOut);
}
}

View File

@ -18,13 +18,18 @@ pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
/// @dev VIP Exchange Proxy Recovery Functions
interface IEpFundRecoveryFeature {
function recoverToDesignatedWallet(
/// @dev Exchange Proxy Recovery Functions
interface IFundRecoveryFeature {
/// @dev calledFrom FundRecoveryFeature.transferTrappedTokensTo() This will be delegatecalled
/// in the context of the Exchange Proxy instance being used.
/// @param erc20 ERC20 Token Address.
/// @param amountOut Amount of tokens to withdraw.
/// @param recipientWallet Recipient wallet address.
function transferTrappedTokensTo(
IERC20TokenV06 erc20,
uint256 amountOut,
address payable designatedWallet
address payable recipientWallet
)
external;
}