Code answers to commonly asked math calculations when developing with the Compound Protocol.
Compound is an open-source, autonomous protocol built for developers, to unlock a universe of new financial applications. Interest and borrowing, for the open financial system. Learn more on the website:
If you haven't already, install Node.js LTS. Clone this repository, cd
to the root directory of the project, and run:
git clone [email protected]:compound-developers/protocol-math-examples.git
cd protocol-math-examples
npm install
To access the blockchain, each of the scripts use Infura. Add your Infura project key (it's free) as an environment variable. Or run each script on the command line like this: infuraApiKey="_key_here_" node someScript.js
Each of the hard coded main net contract addresses and ABIs can be found here: https://compound.finance/docs#networks
node decimals.js
node exchangeRate-cTokenToUnderlying.js
node exchangeRate-underlyingToCToken.js
node apy.js