mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-14 08:58:02 -05:00
* incorporating configuration panes from #1078 * standardizing player hero subcomponents & removing `owner` var from `useProfileField` 🚪 * switching box type, ambiguating overly-specific names, & massaging heights 📱 * reordering profile details sections, updating deployment environment, & conditionally wrapping the hero elements 🎬 * fixing render of color disposition selector 🕍 * self code review changes: removed some `;`s 🎋 * getting yarn typecheck && yarn lint to pass post rebase 🏇🏾 * handling "missing <div> in <button>" error with mounted check & setting HTTP return codes for OpenSea API endpoint 🕺 * `ProfileWizard` extends `Wizard`, roles display better on mobile, & pronouns use `ProfileWizardPane` 🍊 * properly encapsulating ETH address regex 🚲 * adding some tasks 🏥 * fixed skills layou * handling default values? ❔ * corrections for revision comments from @dan13ram (UI bugs to follow) 🌋 * cleaning up memberships & explorer type 🧫 * refactoring player roles configuration and display to use `WizardPane` 🔮 * bunches of mobile fixes & repairing the display of deserialized skills 📟 * removing redirect in static props & formatting memberships display for responsiveness 🪆 * improving comprehensability of `/me` & more mobile tweaking 🍦 * various spacing fixes & a “try again” button for connecting 🫕 * maybe fixed issue with saving images for fields with default values 🇩🇿 * switched roles selection to a bounded `SimpleGrid` to fix sizing weirdness 🧰 * fix: removed verify on brightId button * fix: clean up username page * formatting & fixing skills issues 🥩 * reformatting NFT display 🚂 * adding `/join` 🚉 * style: peth's suggestions * added mainnet required message * style: slight tweak of megamenu item positions * chore(release): 0.2.0 Co-authored-by: tenfinney <scott@1box.onmicrosoft.com> Co-authored-by: dan13ram <dan13ram@gmail.com> Co-authored-by: vidvidvid <weetopol@gmail.com>
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
export type HighLowType = {
|
|
high: string;
|
|
low: string;
|
|
};
|
|
|
|
export function findHighLowPrice(
|
|
days: Array<Array<number>>,
|
|
range: number,
|
|
): HighLowType {
|
|
// we only want to get the last 7 of 30 days
|
|
const lastWeek = days.slice(-range);
|
|
const plots = lastWeek.map((d) => d[1]);
|
|
|
|
const high = Number(Math.max(...plots)).toFixed(2);
|
|
const low = Number(Math.min(...plots)).toFixed(2);
|
|
|
|
return { high, low };
|
|
}
|
|
|
|
export function volumeChange(
|
|
vols: Array<Array<number>>,
|
|
{ usd: today }: Record<string, number>,
|
|
): number {
|
|
const plots = vols.map(([date, volume]) => ({ date, volume }));
|
|
if (plots.length < 2) {
|
|
throw new Error('Insufficient Data');
|
|
}
|
|
const [{ volume: previous }] = plots.slice(-2);
|
|
const Δ = today - previous;
|
|
const percent = Number((Δ / today) * 100);
|
|
|
|
return percent;
|
|
}
|
|
|
|
type TickerProps = {
|
|
market: MarketProps;
|
|
token_info_url: string;
|
|
};
|
|
|
|
type MarketProps = {
|
|
identifier: string;
|
|
};
|
|
|
|
export const ticker = (
|
|
tickers: Array<TickerProps>,
|
|
pool: string,
|
|
): TickerProps => {
|
|
const getTicker = () =>
|
|
tickers?.filter(
|
|
(tick: TickerProps) => tick.market.identifier === pool && tick,
|
|
) || null;
|
|
|
|
return getTicker()[0];
|
|
};
|
|
|
|
export const priceIncreased = (priceChange: number): number =>
|
|
Math.sign(priceChange);
|
|
|
|
export const volIncreased = (
|
|
vols: number[][],
|
|
vol: Record<string, number>,
|
|
): number => Math.sign(volumeChange(vols, vol));
|