Skip to content

Instantly share code, notes, and snippets.

@alexroan
Last active July 10, 2020 11:28
Show Gist options
  • Save alexroan/555d648c2b3790a8284e91679721e50d to your computer and use it in GitHub Desktop.
Save alexroan/555d648c2b3790a8284e91679721e50d to your computer and use it in GitHub Desktop.
aave_full_redeem.js
// Get reserve data
const reserveData = await lendingPool.methods.getReserveData("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE").call()
.catch((e) => {
throw Error(`Error getting aave reserve data: ${e.message}`)
});
// Get aToken address
const aTokenAddress = reserveData.aTokenAddress;
// Load aToken
const aTokenInstance = new web3.eth.Contract(aTokenABI, aTokenAddress);
// Redeem asset
aTokenInstance.methods.redeem(withdrawAmount).send({from: account})
.once('transactionHash', (hash) => {
// transaction hash
})
.on('confirmation', (number, receipt) => {
// number of confirmations
})
.on('error', (error) => {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment