Skip to content

Commit

Permalink
fix: Use farms data to get the cake price (pancakeswap#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
RabbitDoge authored Mar 22, 2021
1 parent 95f12b6 commit 2900cfb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/state/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,14 @@ export const useGetApiPrice = (token: string) => {
}

export const usePriceCakeBusd = (): BigNumber => {
const cakePrice = useGetApiPrice('cake')
return new BigNumber(cakePrice)
const ZERO = new BigNumber(0)
const cakeBnbFarm = useFarmFromPid(1)
const bnbBusdFarm = useFarmFromPid(2)

const bnbBusdPrice = bnbBusdFarm.tokenPriceVsQuote ? new BigNumber(1).div(bnbBusdFarm.tokenPriceVsQuote) : ZERO
const cakeBusdPrice = cakeBnbFarm.tokenPriceVsQuote ? bnbBusdPrice.times(cakeBnbFarm.tokenPriceVsQuote) : ZERO

return cakeBusdPrice
}

// Block
Expand Down

0 comments on commit 2900cfb

Please sign in to comment.