1

I'm getting an error like:

Got 20000000000000000 WETH.
Approved!
Depositing...
Deposited!
You have 20000000000000000 worth of ETH deposited.
Yoy have 0 worth of ETH borrowed.
You can borrow 16500000000000000 worth of ETH.
The DAI/ETH price is 610793206588811
You can Borrow 25.66335026471977 DAI
25663350264719770000n
Error: VM Exception while processing transaction: reverted with reason string '12'
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at HardhatNode._mineBlockWithPendingTxs (/home/manu/hh-ethers/hardhat_defi/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1840:23)
    at HardhatNode.mineBlock (/home/manu/hh-ethers/hardhat_defi/node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:517:16)
    at EthModule._sendTransactionAndReturnHash (/home/manu/hh-ethers/hardhat_defi/node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1532:18)
    at HardhatNetworkProvider.request (/home/manu/hh-ethers/hardhat_defi/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:123:18)
    at HardhatEthersSigner.sendTransaction (/home/manu/hh-ethers/hardhat_defi/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at send (/home/manu/hh-ethers/hardhat_defi/node_modules/ethers/src.ts/contract/contract.ts:299:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

borrowDai function:

async function borrowDai(daiAddress, lendingPool, amountDaiToBorrow, account) {
    const borrowTx = await lendingPool.borrow(daiAddress, amountDaiToBorrow, 1, 0, account)
    await borrowTx.wait(1)
    console.log("You've borrowed!")
}

Script part from getting DAI price and Borrow block:

    //Getting DAI PRICE
    const daiPrice = await getDaiPrice()
    const amountDaiToBorrow = (availableBorrowsETH.toString() * 0.95) / daiPrice.toString()
    console.log(`You can Borrow ${amountDaiToBorrow} DAI`)

    const amountDaiToBorrowWei = ethers.parseEther(amountDaiToBorrow.toString())
    console.log(amountDaiToBorrowWei)

    //Borrow -----
    const daiTokenAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F"

    await borrowDai(daiTokenAddress, lendingPool, amountDaiToBorrowWei, deployer)
    await getBorrowUserData(lendingPool, deployer)

Please help me with this error !! I've followed PatrickAlphaC tutorial.

2 Answers 2

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

12 means "Stable borrowing not enabled";

https://docs.aave.com/developers/v/2.0/guides/troubleshooting-errors#reference-guide

you should use the "variable type" which is "2"

async function borrowDai(daiAddress, lendingPool, amountDaiToBorrow, account) {
    const borrowTx = await lendingPool.borrow(daiAddress, amountDaiToBorrow, 2, 0, account)
    await borrowTx.wait(1)
    console.log("You've borrowed!")
}

the repay function is the same!

1
  • Thanks for pointing this out !! It worked. Commented Sep 26, 2023 at 12:58
0

The error you get is the address 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 is a lending pool on the Ethereum mainnet, but I assume you are running the tutorial on some other network, most likely an Ethereum testnet. This address is not a contract on Goerli or Sepolia, for example.

You would need to dig around the Aave docs to see if they have the lending pool V2 (which is what you are trying to use) deployed on other testnets (Ethereum or other EVMs) and will need to change that probably in your env setup. Don't forget that the other addresses (eg DAI, WETH) might be different as well for the network that you will switch to for the tutorial to run it.

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.