Getting a execution reverted message: code: -32000 calling a new function

Expert

I'm banging my head against the wall with this problem:

When I supplyLiquidity and using the contract's address for onBehalfOf, I can later approve the contract address on the WETH gateway and withdrawLiquidity no problem. Works every time.

function supplyLiquidityContract() external payable{
       address onBehalfOf = address(this);
       WETHGateway.depositETH{value: msg.value}(pool, onBehalfOf, 0);
   }
   function withdrawlLiquidity() external{
       uint256 balance = AaveWMatic.balanceOf(address(this));

       AaveWMatic.approve(address(WETHGateway), balance);
       WETHGateway.withdrawETH(pool, balance, address(this));
   }

If instead I supplyLiquidity using msg.sender as onBehalfOf, and later transfer that aToken to the contract, I should then be able to withdrawLiquidty from the contract the same as before, but it consistently reverts, even though everything from approvals to aToken balance on the contract appear to be right.

revert message is 
"code": -32000,
"message": "execution reverted"

am I missing something? why would it matter if the contract's Aave tokens came from a transfer from another account first instead of directly with supply liquidity?

Answers 1

1 is a really bad number to use and just doesn't work, were 2 or higher might if there's any native tokens in the contract so you can burn your aTokens.

The withdrawETH function will not work on testnet markets. All reserves on Aave testnet markets are custom mintable tokens, so the WETH or WMATIC on testnet markets (like kovan testnet) is not backed by real ETH/MATIC, so there is nothing to withdraw.