-
-
Notifications
You must be signed in to change notification settings - Fork 134
Sats per Big Mac #2543
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
base: master
Are you sure you want to change the base?
Sats per Big Mac #2543
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ import { usePriceCarousel } from './nav/price-carousel' | |
|
||
export const PriceContext = React.createContext({ | ||
price: null, | ||
fiatSymbol: null | ||
fiatSymbol: null, | ||
bigMacPrice: null | ||
}) | ||
|
||
export function usePrice () { | ||
|
@@ -34,8 +35,9 @@ export function PriceProvider ({ price, children }) { | |
|
||
const contextValue = useMemo(() => ({ | ||
price: data?.price || price, | ||
fiatSymbol: CURRENCY_SYMBOLS[fiatCurrency] || '$' | ||
}), [data?.price, price, me?.privates?.fiatCurrency]) | ||
fiatSymbol: CURRENCY_SYMBOLS[fiatCurrency] || '$', | ||
bigMacPrice: data?.bigMacPrice || 5.79 | ||
}), [data?.price, data?.bigMacPrice, price, me?.privates?.fiatCurrency]) | ||
|
||
return ( | ||
<PriceContext.Provider value={contextValue}> | ||
|
@@ -56,7 +58,7 @@ function AccessibleButton ({ id, description, children, ...props }) { | |
export default function Price ({ className }) { | ||
const [selection, handleClick] = usePriceCarousel() | ||
|
||
const { price, fiatSymbol } = usePrice() | ||
const { price, fiatSymbol, bigMacPrice } = usePrice() | ||
const { height: blockHeight, halving } = useBlockHeight() | ||
const { fee: chainFee } = useChainFee() | ||
|
||
|
@@ -106,6 +108,15 @@ export default function Price ({ className }) { | |
) | ||
} | ||
|
||
if (selection === 'bigmac') { | ||
if (!price || price < 0 || !bigMacPrice) return null | ||
return ( | ||
<AccessibleButton id='bigmac-hint' description='Show satoshis per Big Mac' className={compClassName} onClick={handleClick} variant='link'> | ||
{fixedDecimal(Math.round((bigMacPrice / price) * 100000000), 0)} sats/Big Mac | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if it's a Whopper instead? 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can put the whole MC menu :P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fwiw, I like |
||
</AccessibleButton> | ||
) | ||
} | ||
|
||
if (selection === 'fiat') { | ||
if (!price || price < 0) return null | ||
return ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good enough for the first version, but I think it would be a lot cooler if the data would update more frequently. It seems to update every 6 months but for some reason, the last update is 2025-01-01, not 2025-07-01 🤔
They documented here how they calculated it.
I think it would be really funny if we would have the most up-to-date big mac prices just to show them in sats, could be good for marketing haha
But as mentioned, more something for a follow-up PR, #2502 is only labeled as good-first-issue anyway.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, I forgot the number we display is going to update frequently because we calculate it in sats anyway. I thought we would just be staring at the same number for a long time.
And I assume Big Mac prices in USD don't update that often, that's why The Economist is also not issuing updates very often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to find a more frequently updated price source but Big Macs are as stable as gold ahah