Stable borrowing not enabled.
Closed this issue · 4 comments
Hi @PatrickAlphaC, I'm getting the error while borrowing. I understand the error is from Aave I figured that out from the docs:
https://docs.aave.com/developers/v/2.0/guides/troubleshooting-errors
But I want to know how I enable Stable borrowing.
Error
Error: VM Exception while processing transaction: reverted with reason string '12'
Console
$ npx hardhat run scripts/aaveBorrow.js
Got 100000000000000000 WETH
Approved!
Depositing WETH...
Desposited!
You have 100000000000000000 worth of ETH deposited.
You have 0 worth of ETH borrowed.
You can borrow 82500000000000000 worth of ETH.
The DAI/ETH price is 411563342609836
You can borrow 190.4324119417503 DAI
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:95:5)
at HardhatNode._mineBlockWithPendingTxs (C:\Users\Lenovo\work\PatrickAlphaC\hardhat-defi-fcc.git\node_modules\hardhat\src\internal\hardhat-network\provider\node.ts:1650:23)
at HardhatNode.mineBlock (C:\Users\Lenovo\work\PatrickAlphaC\hardhat-defi-fcc.git\node_modules\hardhat\src\internal\hardhat-network\provider\node.ts:459:16)
at EthModule._sendTransactionAndReturnHash (C:\Users\Lenovo\work\PatrickAlphaC\hardhat-defi-fcc.git\node_modules\hardhat\src\internal\hardhat-network\provider\modules\eth.ts:1496:18)
at HardhatNetworkProvider.request (C:\Users\Lenovo\work\PatrickAlphaC\hardhat-defi-fcc.git\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:117:18)
at EthersProviderWrapper.send (C:\Users\Lenovo\work\PatrickAlphaC\hardhat-defi-fcc.git\node_modules\@nomiclabs\hardhat-ethers\src\internal\ethers-provider-wrapper.ts:13:20)
Hmmm... If it's not enabled, you'll have to do variable borrowing.
Hmmm... If it's not enabled, you'll have to do variable borrowing.
How do I do that exactly any example would be appreciated, thanks!
In this 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!")
}
You'll want to change the 1
to `2.
See the function here:
/**
* @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower
* already deposited enough collateral, or he was given enough allowance by a credit delegator on the
* corresponding debt token (StableDebtToken or VariableDebtToken)
* - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet
* and 100 stable/variable debt tokens, depending on the `interestRateMode`
* @param asset The address of the underlying asset to borrow
* @param amount The amount to be borrowed
* @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable
* @param referralCode Code used to register the integrator originating the operation, for potential rewards.
* 0 if the action is executed directly by the user, without any middle-man
* @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself
* calling the function if he wants to borrow against his own collateral, or the address of the credit delegator
* if he has been given credit delegation allowance
**/
function borrow(
address asset,
uint256 amount,
uint256 interestRateMode,
uint16 referralCode,
address onBehalfOf
) external;
I have updated the codebase with this change. Thanks for reporting, should work end-to-end now.
Cool, thanks! Deeply appreciated.