Created
May 19, 2020 15:53
-
-
Save pi0neerpat/062ee6c6995a519f3e91dd0dd7ef7724 to your computer and use it in GitHub Desktop.
compound rate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const COMPOUND_RATE_API = | |
'https://api.compound.finance/api/v2/ctoken?addresses[]=0x5d3a536e4d6dbd6114cc1ead35777bab948e3643'; | |
export const getCompoundRate = async () => { | |
try { | |
const res = await axios.get(COMPOUND_RATE_API); | |
const rate = res.data.cToken[0].supply_rate.value; | |
return { rate, formattedRate: Math.round(rate * 10000) / 100 }; | |
} catch (error) { | |
return getErrorResponse(error, 'getCompoundRate'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment