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

View File

@ -16,55 +16,24 @@ pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; 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 "../migrations/LibMigrate.sol";
import "../fixins/FixinCommon.sol"; import "../fixins/FixinCommon.sol";
import "../fixins/FixinTokenSpender.sol";
import "./interfaces/IFeature.sol"; import "./interfaces/IFeature.sol";
import "./interfaces/IEpFundRecoveryFeature.sol"; import "./interfaces/IFundRecoveryFeature.sol";
import "../transformers/LibERC20Transformer.sol"; import "../transformers/LibERC20Transformer.sol";
contract EpFundRecoveryFeature is contract FundRecoveryFeature is
IFeature, IFeature,
IEpFundRecoveryFeature, IFundRecoveryFeature,
FixinCommon, FixinCommon
FixinTokenSpender
{ {
/// @dev Name of this feature. /// @dev Name of this feature.
string public constant override FEATURE_NAME = "EpFundRecoveryFeature"; string public constant override FEATURE_NAME = "FundRecoveryFeature";
/// @dev Version of this feature. /// @dev Version of this feature.
uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 0, 0); 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. /// @dev Construct this contract.
/// @param exchangeProxy Exchange Proxy contract address constructor() public {}
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);
}
}
/// @dev Initialize and register this feature. /// @dev Initialize and register this feature.
/// Should be delegatecalled by `Migrate.migrate()`. /// Should be delegatecalled by `Migrate.migrate()`.
@ -73,8 +42,29 @@ contract EpFundRecoveryFeature is
external external
returns (bytes4 success) returns (bytes4 success)
{ {
//_registerFeatureFunction(this.sellEthForTokenToUniswapV3.selector); _registerFeatureFunction(this.transferTrappedTokensTo.selector);
_registerFeatureFunction(this.recoverToDesignatedWallet.selector);
return LibMigrate.MIGRATE_SUCCESS; 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"; import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
/// @dev VIP Exchange Proxy Recovery Functions /// @dev Exchange Proxy Recovery Functions
interface IEpFundRecoveryFeature { interface IFundRecoveryFeature {
function recoverToDesignatedWallet( /// @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, IERC20TokenV06 erc20,
uint256 amountOut, uint256 amountOut,
address payable designatedWallet address payable recipientWallet
) )
external; external;
} }