Skip to content

Commit

Permalink
fix: Dirty fix for ETH farms (pancakeswap#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
RabbitDoge authored Feb 5, 2021
1 parent e8a5c0d commit 6cfec6f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 207 deletions.
1 change: 1 addition & 0 deletions src/config/constants/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default {
},
eth: {
56: '0x2170ed0880ac9a755fd29b2688956bd959f933f8',
97: '',
},
claimRefund: {
56: '0xE7e53A7e9E3Cf6b840f167eF69519175c497e149',
Expand Down
4 changes: 2 additions & 2 deletions src/config/constants/farms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const farms: FarmConfig[] = [
97: '',
56: '0x99d865ed50d2c32c1493896810fa386c1ce81d91',
},
tokenSymbol: 'ETH',
tokenSymbol: 'BETH',
tokenAddresses: {
97: '',
56: '0x2170ed0880ac9a755fd29b2688956bd959f933f8',
56: '0x250632378e573c6be1ac2f97fcdf00515d0aa91b',
},
quoteTokenSymbol: QuoteToken.ETH,
quoteTokenAdresses: contracts.eth,
Expand Down
4 changes: 3 additions & 1 deletion src/views/Farms/Farms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ const Farms: React.FC = () => {
const cakeRewardPerBlock = CAKE_PER_BLOCK.times(farm.poolWeight)
const cakeRewardPerYear = cakeRewardPerBlock.times(BLOCKS_PER_YEAR)

// cakePriceInQuote * cakeRewardPerYear / lpTotalInQuoteToken
let apy = cakePriceVsBNB.times(cakeRewardPerYear).div(farm.lpTotalInQuoteToken)

if (farm.quoteTokenSymbol === QuoteToken.BUSD || farm.quoteTokenSymbol === QuoteToken.UST) {
apy = cakePriceVsBNB.times(cakeRewardPerYear).div(farm.lpTotalInQuoteToken).times(bnbPrice)
} else if (farm.quoteTokenSymbol === QuoteToken.ETH) {
apy = cakePriceVsBNB.times(cakeRewardPerYear).div(farm.lpTotalInQuoteToken).times(ethPriceUsd)
apy = cakePrice.div(ethPriceUsd).times(cakeRewardPerYear).div(farm.lpTotalInQuoteToken)
} else if (farm.quoteTokenSymbol === QuoteToken.CAKE) {
apy = cakeRewardPerYear.div(farm.lpTotalInQuoteToken)
} else if (farm.dual) {
Expand All @@ -80,6 +81,7 @@ const Farms: React.FC = () => {
removed={removed}
bnbPrice={bnbPrice}
cakePrice={cakePrice}
ethPrice={ethPriceUsd}
ethereum={ethereum}
account={account}
/>
Expand Down
202 changes: 0 additions & 202 deletions src/views/Farms/components/FarmCard.tsx

This file was deleted.

8 changes: 6 additions & 2 deletions src/views/Farms/components/FarmCard/FarmCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ interface FarmCardProps {
removed: boolean
cakePrice?: BigNumber
bnbPrice?: BigNumber
ethPrice?: BigNumber
ethereum?: provider
account?: string
}

const FarmCard: React.FC<FarmCardProps> = ({ farm, removed, cakePrice, bnbPrice, ethereum, account }) => {
const FarmCard: React.FC<FarmCardProps> = ({ farm, removed, cakePrice, bnbPrice, ethPrice, ethereum, account }) => {
const TranslateString = useI18n()

const [showExpandableSection, setShowExpandableSection] = useState(false)
Expand All @@ -112,8 +113,11 @@ const FarmCard: React.FC<FarmCardProps> = ({ farm, removed, cakePrice, bnbPrice,
if (farm.quoteTokenSymbol === QuoteToken.CAKE) {
return cakePrice.times(farm.lpTotalInQuoteToken)
}
if (farm.quoteTokenSymbol === QuoteToken.ETH) {
return ethPrice.times(farm.lpTotalInQuoteToken)
}
return farm.lpTotalInQuoteToken
}, [bnbPrice, cakePrice, farm.lpTotalInQuoteToken, farm.quoteTokenSymbol])
}, [bnbPrice, cakePrice, ethPrice, farm.lpTotalInQuoteToken, farm.quoteTokenSymbol])

const totalValueFormated = totalValue
? `$${Number(totalValue).toLocaleString(undefined, { maximumFractionDigits: 0 })}`
Expand Down

0 comments on commit 6cfec6f

Please sign in to comment.