Repeatable solution to find the current Health Factor of a specified AAVE Wallet Address. Also returns the current block for fact checking. This work was done as a project for Wintermute Trading.
- Javascript
- @aave/protocol-v2 (^1.0.1)
- ethers (^5.2.0)
- userAddress: This is the wallet address of the user you would like to check the Health Factor of.
- contractAddress: The address on the network of the AAVE LendingPool Smart Contract.
The current values that you can use for the mainnets (please check the above link as these may be outdated):- Ethereum Mainmarket:
0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9
- Polygon (Matic) Mainmarket:
0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf
- Ethereum Mainmarket:
- infuraProjectUrl: This project connects to the blockchains using the infura nodes. As they offer both ethereum and polygon nodes for free. Get your own url from the Infura Website
The health factor can be calculated manually using the AAVE formula. In this project however we are querying the AAVE LendingPool smart contract directly and making use of it's ability to return a health factor for a given account.
The health factor is shown in the console in 3 formats:
- hex: This is the format of the health factor returned by the smart contract.
- decimal: This is the hex formatted using the Javascript BigInt() method
- as ether: The health factor in the AAVE UI is shown as "a percent". However, it is just the above decimal formatted using a fromWeiToEther Command (Also known as moving the decimal place 18 places).
Brandon Grant
Email
Project Github