Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 88mph curve token substitution in rates function #281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions projects/88mph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const wrappedTokenToSubsitute = {
TVL
*/

async function tvl (timestamp, block) {
async function tvl(timestamp, block) {
const balances = {}
const poolToUnderlyingToken = {}

Expand Down Expand Up @@ -108,7 +108,7 @@ async function tvl (timestamp, block) {
return balances
}

async function rates (timestamp, block) {
async function rates(timestamp, block) {
const rates = {
lend: {},
borrow: {},
Expand All @@ -128,7 +128,12 @@ async function rates (timestamp, block) {

_.each(poolUnderlyingAddressResults.output, (token) => {
if (token.success) {
const underlyingTokenAddress = token.output
let underlyingTokenAddress = token.output
if (wrappedTokenToSubsitute[underlyingTokenAddress]) {
const substituteInfo = wrappedTokenToSubsitute[underlyingTokenAddress]
underlyingTokenAddress = substituteInfo.address
}

const poolAddress = token.input.target
poolToUnderlyingToken[poolAddress] = underlyingTokenAddress
if (!underlyingTokenToSymbol[underlyingTokenAddress]) {
Expand Down Expand Up @@ -171,7 +176,11 @@ async function rates (timestamp, block) {
const underlyingTokenAddress = poolToUnderlyingToken[poolAddress]
const underlyingTokenSymbol = underlyingTokenToSymbol[underlyingTokenAddress]

rates.lend[underlyingTokenSymbol] = interestRate.times(100).toString()
if (rates.lend[underlyingTokenSymbol]) {
rates.lend[underlyingTokenSymbol] = BigNumber.max(interestRate.times(100), rates.lend[underlyingTokenSymbol]).toString()
} else {
rates.lend[underlyingTokenSymbol] = interestRate.times(100).toString()
}
}
})

Expand All @@ -188,7 +197,7 @@ module.exports = {
category: 'lending',
start: 1606109629, // Monday, November 23, 2020 5:33:49 AM GMT
tvl,
// rates,
rates,
term: '7 days-1 year',
variability: 'None',
contributesTo: ['Aave', 'Compound', 'yearn.finance', 'Harvest Finance']
Expand Down