Skip to content

Instantly share code, notes, and snippets.

@pi0neerpat
Created May 19, 2020 15:53
Show Gist options
  • Save pi0neerpat/062ee6c6995a519f3e91dd0dd7ef7724 to your computer and use it in GitHub Desktop.
Save pi0neerpat/062ee6c6995a519f3e91dd0dd7ef7724 to your computer and use it in GitHub Desktop.
compound rate
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