PatrickAlphaC/hardhat-defi-fcc

Error: VM Exception while processing transaction: reverted with reason string '11'

Opened this issue · 5 comments

I am getting the error: Error: VM Exception while processing transaction: reverted with reason string '11' after the console.log portion that shows my USDC Borrow Available. I have also attached the script which starts running after that console log.

yarn run v1.22.19
warning package.json: No license field
$ /Users/eugenekhoo/personalprojects/solidity-tutorial/hardhat-defi/node_modules/.bin/hardhat run scripts/aaveBorrow.js
Balance: 100000000000000000 WETH
Lending Pool Address: 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9
Approved!
Depositing...
Deposited
ETH Deposited: 100000000000000000
ETH Borrowed: 0
Borrow Available: 82500000000000000
ETH/USDC price: 575691981762078
USDC Borrow Available: 71.6529
Error: VM Exception while processing transaction: reverted with reason string '11'
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at HardhatNode._mineBlockWithPendingTxs (/Users/eugenekhoo/personalprojects/solidity-tutorial/hardhat-defi/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1840:23)
    at HardhatNode.mineBlock (/Users/eugenekhoo/personalprojects/solidity-tutorial/hardhat-defi/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:517:16)
    at EthModule._sendTransactionAndReturnHash (/Users/eugenekhoo/personalprojects/solidity-tutorial/hardhat-defi/node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1532:18)
    at HardhatNetworkProvider.request (/Users/eugenekhoo/personalprojects/solidity-tutorial/hardhat-defi/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:123:18)
    at EthersProviderWrapper.send (/Users/eugenekhoo/personalprojects/solidity-tutorial/hardhat-defi/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
error Command failed with exit code 1.

Script starting from console.log USDC Borrow Available

    console.log(`USDC Borrow Available: ${amountUsdcToBorrow}`)
    const amountUsdcToBorrowWei = ethers.utils.parseEther(
        amountUsdcToBorrow.toString()
    )
    // Borrow
    const usdcTokenAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
    await borrowUsdc(
        usdcTokenAddress,
        lendingPool,
        amountUsdcToBorrowWei,
        deployer
    )
    await getBorrowUserData(lendingPool, deployer)

borrowUsdc()

async function borrowUsdc(
    usdcAddress,
    lendingPool,
    amountUsdcToBorrow,
    account
) {
    const tx = await lendingPool.borrow(
        usdcAddress,
        amountUsdcToBorrow,
        1,
        0,
        account
    )
    await tx.wait(1)
    console.log("Borrow successful!")
}

Do you get this error when you clone the repo? Can you try cloning the repo and installing packages and running everything?

Hi Patrick, it works when i used the DAI contracts.. i suspect its got something to do with the USDC decimal places but havent got to troubleshooting yet!

Hi Patrick, it works when i used the DAI contracts.. i suspect its got something to do with the USDC decimal places but havent got to troubleshooting yet!

Can't totally understand that.. An elaborated solution will really help me a lot.

This error occur when There is not enough collateral to cover a new borrow.... so check how much you are borrowing..

Refer to this if someone getting this type of .. reverted with string error -- https://docs.aave.com/developers/v/2.0/guides/troubleshooting-errors