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

feat: New syrup pool cards #874

Merged
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6e5bc69
feat(syrup-pool-v2): Update PageHeader and TabButtons
ChefHutch Apr 13, 2021
a72465a
feat(syrup-pool-v2): Reorg component structure and add new styledCard…
ChefHutch Apr 13, 2021
3efb72d
feat(syrup-pool-v2): Yeet some sheet
ChefHutch Apr 13, 2021
b99f8fa
feat(syrup-pool-v2): Add finished sash and handle finished state of c…
ChefHutch Apr 13, 2021
70ca891
feat(syrup-pool-v2): Create APR row comp
ChefHutch Apr 13, 2021
8292e86
Merge branch 'develop' into feature/syrup-pool-new-cards
ChefHutch Apr 14, 2021
ee5a35e
feat(syrup-pool-v2): Tidy up & restyling of footer
ChefHutch Apr 14, 2021
f5c1e51
fix(syrup-pool-v2): Fix merge conflicts
ChefHutch Apr 19, 2021
e5f7df2
feat(syrup-pool-v2): Finish up various footer comps
ChefHutch Apr 19, 2021
a82d259
feat(syrup-pool-v2): Upgrade ApyCalculatorModal to handle different e…
ChefHutch Apr 19, 2021
affa828
feat(syrup-pool-v2): Loading states for footer and APR
ChefHutch Apr 19, 2021
215f482
Merge branch 'develop' into feature/syrup-pool-new-cards
ChefHutch Apr 20, 2021
3cdb0b9
fix(syrup-pool-v2): Fix merge conflicts
ChefHutch Apr 20, 2021
8b69e2f
fix(syrup-pool-v2): Fix lint error
ChefHutch Apr 20, 2021
1ce5132
chore(syrup-pool-v2): Break CardActions into its own component and re…
ChefHutch Apr 20, 2021
c188ea3
feat(syrup-pool-v2): Create separate Staking / HarvestActions comps
ChefHutch Apr 20, 2021
32adaa8
feat(syrup-pool-v2): Approval and Staking actions
ChefHutch Apr 20, 2021
9f30bfc
Merge branch 'develop' into feature/syrup-pool-new-cards
ChefHutch Apr 21, 2021
55bb60b
feat(pool-stake-modal): Basics of stake modal laid out
ChefHutch Apr 21, 2021
41a6b0d
feat(syrup-pool-v2): Styling of cards and improvements to error repor…
ChefHutch Apr 21, 2021
057967b
feat(syrup-pool-v2): Add proper USD calculation
ChefHutch Apr 21, 2021
886c428
Merge branch 'develop' of https://github.com/pancakeswap/pancake-fron…
ChefHutch Apr 22, 2021
40846f1
feat(syrup-pool-v2): Adding unstaking buttons and rough modal operations
ChefHutch Apr 22, 2021
fcbb1e4
feat(syrup-pool-v2): Refactor footer for performance and add HarvestA…
ChefHutch Apr 22, 2021
43044fa
feat(syrup-pool-v2): Basic harvest modal and functionality added
ChefHutch Apr 22, 2021
278ed66
feat(syrup-pool-v2): Styling fixes and pass account down from pool view
ChefHutch Apr 22, 2021
40922fd
feat(syrup-pool-v2): Styling and tooltip for compounding modal
ChefHutch Apr 22, 2021
c81e054
feat(syrup-pool-v2): Finish compounding modal
ChefHutch Apr 22, 2021
db54948
feat(syrup-pool-v2): Style for promoted pool (& cake) and organising …
ChefHutch Apr 22, 2021
d8d575e
fix(syrup-pool-v2): Fix merge conflicts
ChefHutch Apr 23, 2021
1d918dc
feat(syrup-pool-v2): Massive proptypes tidy up
ChefHutch Apr 23, 2021
c7eb515
chore(syrup-pool-v2): Del unused SVG
ChefHutch Apr 23, 2021
a8be471
Merge branch 'develop' of https://github.com/pancakeswap/pancake-fron…
ChefHutch Apr 24, 2021
9b56b02
feat(syrup-pool-v2): Add loading states for different card elements
ChefHutch Apr 24, 2021
7b7ec7b
feat(syrup-pool-v2): Add bunny img
ChefHutch Apr 24, 2021
df92291
feat(syrup-pool-v2): Fix high price token showing 0% APR
ChefHutch Apr 24, 2021
b5e02c9
chore(syrup-pool-v2): Cleanup white space
ChefHutch Apr 24, 2021
1d4806f
chore(syrup-pool-v2): Re-add usePersistState
ChefHutch Apr 24, 2021
8890e77
chore(syrup-pool-v2): Add comments to help
ChefHutch Apr 24, 2021
2fb7cc7
Merge branch 'develop' into feature/syrup-pool-new-cards
ChefHutch Apr 26, 2021
6130692
chore(syrup-pool-v2): Remove unused components
ChefHutch Apr 26, 2021
2791d21
Merge branch 'develop' of https://github.com/pancakeswap/pancake-fron…
ChefHutch Apr 27, 2021
49daf7c
fix(syrup-pool-v2): Fix useToast
ChefHutch Apr 27, 2021
db1d8dd
feat(syrup-pool-v2): Move help to pooltabbuttons bar
ChefHutch Apr 27, 2021
9fe4356
feat(syrup-pool-v2): Disabled button when stakeAmount is zero or unset
ChefHutch Apr 28, 2021
6475897
Merge branch 'develop' of https://github.com/pancakeswap/pancake-fron…
ChefHutch Apr 28, 2021
dbd1706
Merge branch 'develop' of https://github.com/pancakeswap/pancake-fron…
ChefHutch Apr 28, 2021
dfa6bc5
fix(pool-cards-v2): Amendments based on Doge's CR comments
ChefHutch Apr 28, 2021
0097dcc
fix(pool-cards-v2): Proper finished handling on staking actions
ChefHutch Apr 28, 2021
91f9de5
fix(pool-cards-v2): Follow up CR comments
ChefHutch Apr 29, 2021
7cc8518
feat(syrup-pool-v2): Add new uikit version
ChefHutch Apr 29, 2021
6799004
Merge branch 'develop' of https://github.com/pancakeswap/pancake-fron…
ChefHutch Apr 29, 2021
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
Binary file added public/images/3d-syrup-bunnies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/components/ApyCalculatorModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface ApyCalculatorModalProps {
linkLabel: string
linkHref: string
earningTokenSymbol?: string
roundingDecimals?: number
Copy link
Contributor Author

@ChefHutch ChefHutch Apr 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add options roundingDecimals parameter to the APR calculator helpers - necessary for tokens where $1000 worth will earn you less than 0.01 of that token per day. Logic for calculating the decimals is within ../PoolCard/AprRow.tsx - https://github.com/pancakeswap/pancake-frontend/pull/874/files#diff-531735dee83d86ed0f944dd084cd541f9442af155febeac6c4ea575ccc55b1c3R29

}

const Grid = styled.div`
Expand All @@ -36,6 +37,7 @@ const ApyCalculatorModal: React.FC<ApyCalculatorModalProps> = ({
linkLabel,
linkHref,
earningTokenSymbol = 'CAKE',
roundingDecimals = 2,
}) => {
const TranslateString = useI18n()
const oneThousandDollarsWorthOfToken = 1000 / tokenPrice
Expand All @@ -44,21 +46,25 @@ const ApyCalculatorModal: React.FC<ApyCalculatorModalProps> = ({
numberOfDays: 1,
farmApr: apr,
tokenPrice,
roundingDecimals,
})
const tokenEarnedPerThousand7D = tokenEarnedPerThousandDollarsCompounding({
numberOfDays: 7,
farmApr: apr,
tokenPrice,
roundingDecimals,
})
const tokenEarnedPerThousand30D = tokenEarnedPerThousandDollarsCompounding({
numberOfDays: 30,
farmApr: apr,
tokenPrice,
roundingDecimals,
})
const tokenEarnedPerThousand365D = tokenEarnedPerThousandDollarsCompounding({
numberOfDays: 365,
farmApr: apr,
tokenPrice,
roundingDecimals,
})

return (
Expand Down
5 changes: 3 additions & 2 deletions src/components/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface TextProps {
isDisabled?: boolean
fontSize?: string
color?: string
bold?: boolean
}

interface BalanceProps extends TextProps {
Expand All @@ -14,15 +15,15 @@ interface BalanceProps extends TextProps {
unit?: string
}

const Balance: React.FC<BalanceProps> = ({ value, fontSize, color, decimals, isDisabled, unit }) => {
const Balance: React.FC<BalanceProps> = ({ value, fontSize, color, decimals, isDisabled, unit, bold }) => {
const previousValue = useRef(0)

useEffect(() => {
previousValue.current = value
}, [value])

return (
<Text bold color={isDisabled ? 'textDisabled' : color} fontSize={fontSize}>
<Text bold={bold} color={isDisabled ? 'textDisabled' : color} fontSize={fontSize}>
<CountUp start={previousValue.current} end={value} decimals={decimals} duration={1} separator="," />
{value && unit && <span>{unit}</span>}
</Text>
Expand Down
15 changes: 9 additions & 6 deletions src/utils/compoundApyHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const roundToTwoDp = (number) => Math.round(number * 100) / 100

export const tokenEarnedPerThousandDollarsCompounding = ({ numberOfDays, farmApr, tokenPrice }) => {
export const tokenEarnedPerThousandDollarsCompounding = ({
numberOfDays,
farmApr,
tokenPrice,
roundingDecimals = 2,
}) => {
// Everything here is worked out relative to a year, with the asset compounding daily
const timesCompounded = 365
// We use decimal values rather than % in the math for both APY and the number of days being calculates as a proportion of the year
Expand All @@ -12,10 +15,10 @@ export const tokenEarnedPerThousandDollarsCompounding = ({ numberOfDays, farmApr
const finalAmount = principal * (1 + aprAsDecimal / timesCompounded) ** (timesCompounded * daysAsDecimalOfYear)
// To get the TOKEN amount earned, deduct the amount after compounding (finalAmount) from the starting TOKEN balance (principal)
const interestEarned = finalAmount - principal
return roundToTwoDp(interestEarned)
return parseFloat(interestEarned.toFixed(roundingDecimals))
}

export const getRoi = ({ amountEarned, amountInvested }) => {
export const getRoi = ({ amountEarned, amountInvested, roundingDecimals = 2 }) => {
const percentage = (amountEarned / amountInvested) * 100
return percentage.toFixed(2)
return percentage.toFixed(roundingDecimals)
}
13 changes: 0 additions & 13 deletions src/views/Pools/components/CardContent.tsx

This file was deleted.

166 changes: 0 additions & 166 deletions src/views/Pools/components/CardFooter.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions src/views/Pools/components/CardTitle.tsx

This file was deleted.

80 changes: 0 additions & 80 deletions src/views/Pools/components/Coming.tsx

This file was deleted.

Loading