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

fix: ticker - add more market data #1624

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Changes from all commits
Commits
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
36 changes: 34 additions & 2 deletions src/commands/ticker/index/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
getEmojiToken,
TokenEmojiKey,
getEmojiURL,
shortenHashOrAddress,
} from "utils/common"
import {
renderCompareTokenChart,
Expand All @@ -33,7 +32,7 @@ import {
} from "./chart"
import { getProfileIdByDiscord } from "../../../utils/profile"
import { utils } from "@consolelabs/mochi-formatter"
// import { Util } from "discord.js"
import moment from "moment-timezone"

const CURRENCY = "usd"
const DIVIDER = getEmoji("LINE").repeat(5)
Expand Down Expand Up @@ -152,7 +151,20 @@ export async function renderSingle(
price_change_percentage_1h_in_currency,
price_change_percentage_24h_in_currency,
price_change_percentage_7d_in_currency,
ath,
total_volume,
max_supply,
} = coin.market_data
let icoDate = `${(coin as any)?.ico_data?.ico_start_date}`
const diff = moment.duration(
icoDate ? moment(moment.now()).diff(moment(icoDate)) : 0,
)
const age = icoDate
? `${diff.years()}y${
diff.months() ? `${moment.duration(diff).months()}m` : ""
}`
: "N/A"

const current =
type === ChartType.Dominance
? utils.formatPercentDigit(
Expand Down Expand Up @@ -196,6 +208,21 @@ export async function renderSingle(
coin.name,
inline: true,
},
{
name: `${getEmoji("ANIMATED_FLASH")} ATH`,
value: `${utils.formatUsdDigit(ath[CURRENCY])}`,
inline: true,
},
{
name: `${getEmoji("ANIMATED_FLASH")} Volume (24h)`,
value: `${utils.formatUsdDigit(total_volume[CURRENCY])}`,
inline: true,
},
{
name: `${getEmoji("ANIMATED_FLASH")} FDV`,
value: `${utils.formatUsdDigit(current_price[CURRENCY] * max_supply)}`,
inline: true,
},
{
name: "Change (H1)",
value: getChangePercentage(
Expand All @@ -217,6 +244,11 @@ export async function renderSingle(
),
inline: true,
},
{
name: `${getEmoji("ANIMATED_FLASH")} Age`,
value: age,
inline: true,
},
...(hasPlatforms && coin.asset_platform_id
? [
{
Expand Down
Loading