My smart contract is trying to use stETH as collateral to borrow 250 WETH on the Aave Lending Pool V2, but the borrow function reverts with code 59:

BORROW_ALLOWANCE_NOT_ENOUGH = '59'; // User borrows on behalf, but allowance are too small.

When I call the getUserData function my account everything looks fine for borrowing:

totalCollateralETH 349999999999999999998
totalDebtETH 0
availableBorrowsETH 251999999999999999999
currentLiquidationThreshold 8300
ltv 7200
healthFactor 115792089237316195423570985008687907853269984665640564039457584007913129639935

Here's the two lines of code I'm using to borrow. Thanks in advance for any help.

IERC20(wethAddress).approve(aaveAddress, loanAmount);
IAAVE(aaveAddress).borrow(wethAddress, loanAmount, 2, 0, owner);

2 Answers 2


You're doing the approve thing wrong. The user you borrow on behalf of (here, owner, which i assume is just your address), needs to approve your contract to spend its interest-bearing token (here, aSTETH , the receipt token you get when you deposit stETH on AAVE), your contract itself doesnt need to approve anything

  • I added a modifier for onlyOwner and created the following function in my contract function approve(address spender, uint256 amount) external onlyOwner { IERC20(astethAddress).approve(spender, amount); } and I'm calling it from my js code as such await STRATEGY.approve(STRATEGY.address, formattedBorrow);. STRATEGY is the name assigned to the smart contract in the js code. Still getting the revert 59 error so I still must be missing something... Jul 2, 2023 at 18:31
  • That is not how approve works, here's you're approving spender to spend the contracts (strategy) tokens. What you want to do is to approve strategy to spend your tokens. You need to call aSTETH's approve function directly in your JS code, not in your contract.
    – Foxxxey
    Jul 2, 2023 at 21:01

Finally found the solution to this. Turns out the answer had nothing to do with stETH. All of Aave's borrowings fall into two categories, either stable interest rate or variable interest rate. Since I was borrowing WETH with a variable rate, I had to delegate approval to my contract to borrow Aave's variable rate WETH token, which is a different token address than regular WETH.

Just had to call the approveDelegation() function from my js code with the variable rate WETH address:

const vWethApprove = new ethers.Contract(vWETH, aaveABI, signerWallet);
await vWethApprove.approveDelegation(STRATEGY.address, formattedBorrow);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.