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.