Skip to content

Commit

Permalink
Merge branch 'develop' into preview
Browse files Browse the repository at this point in the history
  • Loading branch information
anhnh12 committed May 23, 2024
2 parents 6c9278c + e348e1a commit 265504d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
28 changes: 14 additions & 14 deletions src/commands/vault/info/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,16 @@ export async function runGetVaultDetail(
const creator = await getDiscordRenderableByProfileId(profileId)
const { trade_rounds: rounds, account } = data
const basicInfo = [
`${getEmoji("ANIMATED_VAULT", true)}\`Name. ${data.name}\``,
`${getEmoji("ANIMATED_VAULT", true)}\`Name. \` ${data.name}`,
`${getEmoji("ANIMATED_VAULT_KEY", true)}\`Creator. \`${creator}`,
`${getEmoji("CALENDAR")}\`Created. \` ${formatDate(
new Date(data.created_at),
)}`,
`${getEmoji("ANIMATED_BADGE_1")}\`Tier. \` ${account.tier.name}`,
`${getEmoji("CASH")}\`Balance. \`$${formatUsdDigit(account.balance)}`,
`${getEmoji("ANIMATED_VAULT_KEY")}\`Key. \` ${account.api_key}`,
`${getEmoji("ANIMATED_BADGE_1")}\`Tier. \` ${account.tier.name}`,
`${getEmoji("CASH")}\`Balance. \`${utils.formatUsdPriceDigit(
account.balance,
)}`,
`${getEmoji("ANIMATED_VAULT_KEY")}\`Key. \` ${account.api_key}`,
].join("\n")

const openRound = rounds.find((r: any) => r.status === 1)
Expand All @@ -204,19 +206,19 @@ export async function runGetVaultDetail(

const roundFields = [
`**Round info**`,
`${getEmoji("CALENDAR")} \`Start. \` ${formatDate(
`${getEmoji("CALENDAR")} \`Start. \` ${formatDate(
startDate.toDate(),
)}, ${startDiff}`,
`🟢 \`Acc. PnL. \` ${utils.formatUsdPriceDigit(
`🟢 \`Acc. PnL. \` ${utils.formatUsdPriceDigit(
account.accumulative_pnl,
)} (${utils.formatPercentDigit(account.accumulative_pl * 100)})`,
`🏎️ \`Rounds. \` ${openRound.no}`,
`🏎️ \`Rounds. \` ${openRound.no}`,
`🎫 \`Total fee. \` ${utils.formatUsdPriceDigit(openRound.fee)}`,
].join("\n")

const vaultEquity = [
"**Vault equity**",
`${getEmoji("CHART")} \`Your share. \` 100%`,
`${getEmoji("CHART")} \`Your share. \` 100%`,
`${getEmoji("MONEY")} \`Claimable amount. \` ${utils.formatUsdPriceDigit(
account.claimable,
)}`,
Expand Down Expand Up @@ -246,9 +248,6 @@ export async function runGetVaultDetail(
r.pnl_percentage >= 0 ? "green" : "red"
}_circle: ${utils.formatPercentDigit(r.pnl_percentage)})`,
),
// `\`24.05.07\` ${getEmoji(
// "WAVING_HAND",
// )} Init: $10,653 💰 PnL: -$247 (:red_circle: -2.32%)`,
].join("\n")

const address = [
Expand All @@ -261,12 +260,13 @@ export async function runGetVaultDetail(
)}\``,
].join("\n")

const description = `${basicInfo}\n\n${vaultEquity}\n\n${address}\n\n${roundFields}\n\n${openTrades}\n\n${
closedRounds.length ? closedTrades : ""
}`
const embed = composeEmbedMessage2(interaction as any, {
color: msgColors.BLUE,
author: ["Trading vault info", getEmojiURL(emojis.ANIMATED_DIAMOND)],
description: `${basicInfo}\n\n${vaultEquity}\n\n${address}\n\n${roundFields}\n\n${openTrades}\n\n${
closedTrades.length > 1 ? closedTrades : ""
}`,
description,
})

return {
Expand Down
39 changes: 21 additions & 18 deletions src/commands/vault/list/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ export async function runVaultList(interaction: CommandInteraction) {
? await config.vaultList(interaction.guildId)
: await config.vaultList("", false, userProfile.id)

const tradingVaults = (await mochiPay.listEarningVaults(userProfile.id)).map(
(v: any) => ({
id: v.id,
name: v.name,
wallet_address: v.evm_wallet_address,
total: utils.formatUsdPriceDigit(v.account.balance),
threshold: 100,
type: "trading",
discord_guild: { name: "" },
}),
)
const tradingVaults = (
(await mochiPay.listEarningVaults(userProfile.id)) || []
).map((v: any) => ({
id: v.id,
name: v.name,
wallet_address: v.evm_wallet_address,
total: utils.formatUsdPriceDigit(v.account.balance),
threshold: 100,
type: "trading",
discord_guild: { name: "" },
}))

const data = [...spotVaults, ...tradingVaults]

Expand Down Expand Up @@ -111,13 +111,16 @@ export async function runVaultList(interaction: CommandInteraction) {
data.filter((d) => d.type !== "trading"),
interaction.guildId || "",
)
description += "\n\n"
description += "**Trading**\n"
description += formatVaults(
// @ts-ignore
data.filter((d) => d.type === "trading"),
interaction.guildId || "",
)

if (tradingVaults.length > 0) {
description += "\n\n"
description += "**Trading**\n"
description += formatVaults(
// @ts-ignore
data.filter((d) => d.type === "trading"),
interaction.guildId || "",
)
}

const embed = composeEmbedMessage(null, {
title: `${getEmoji("MOCHI_CIRCLE")} Vault List`,
Expand Down

0 comments on commit 265504d

Please sign in to comment.