Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { lightFormat } from "date-fns";
import { useState } from "react";
import { useCopyToClipboard } from "react-use";

import { REFERRALS_DOCS_URL } from "config/links";
import {
useAffiliateTier,
useCodeOwner,
Expand All @@ -12,13 +13,18 @@ import {
useTraderReferralStats,
useUserReferralCode,
} from "domain/referrals";
import { getReferralCodeTradeUrl, getSharePercentage } from "domain/referrals/utils/referralsHelper";
import {
getProtocolReferralCodeType,
getReferralCodeTradeUrl,
getSharePercentage,
} from "domain/referrals/utils/referralsHelper";
import { useTimeRange } from "domain/synthetics/markets/useTimeRange";
import { useChainId } from "lib/chains";
import { helperToast } from "lib/helperToast";
import { formatUsd } from "lib/numbers";

import Button from "components/Button/Button";
import ExternalLink from "components/ExternalLink/ExternalLink";
import { Faq } from "components/Faq/Faq";
import ModalWithPortal from "components/Modal/ModalWithPortal";
import { ReferralsDocsCard } from "components/Referrals/shared/cards/ReferralsDocsCard";
Expand Down Expand Up @@ -147,14 +153,7 @@ export function ReferralsTradersContent({ account }: ReferralsTradersContentProp
</Button>
</div>
<Card>
<Trans>
<div className="text-body-medium mb-2 font-medium text-typography-primary">
You're now receiving a {currentTierDiscount}% discount on your trades!
</div>
<div className="text-body-small text-typography-secondary">
The reduced rate applies to every open and close fee.
</div>
</Trans>
<ActiveCodeExplanation currentTierDiscount={currentTierDiscount} codeString={userReferralCodeString} />
</Card>
</div>
<ReferralsDocsCard />
Expand Down Expand Up @@ -184,6 +183,55 @@ function Card({ children, className }: { children: React.ReactNode; className?:
);
}

function ActiveCodeExplanation({
currentTierDiscount,
codeString,
}: {
currentTierDiscount: string | number | undefined;
codeString: string | undefined;
}) {
const protocolCodeType = getProtocolReferralCodeType(codeString);

if (protocolCodeType === "organic") {
return (
<div className="text-body-small text-typography-primary">
<Trans>
You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a{" "}
{currentTierDiscount}% discount on opening and closing fees.{" "}
<ExternalLink href={REFERRALS_DOCS_URL} className="text-blue-300">
Read more
</ExternalLink>
</Trans>
</div>
);
}

if (protocolCodeType === "graduated") {
return (
<div className="text-body-small text-typography-primary">
<Trans>
Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral
program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees.{" "}
<ExternalLink href={REFERRALS_DOCS_URL} className="text-blue-300">
Read more
</ExternalLink>
</Trans>
</div>
);
}

return (
<Trans>
<div className="text-body-medium mb-2 font-medium text-typography-primary">
You're now receiving a {currentTierDiscount}% discount on your trades!
</div>
<div className="text-body-small text-typography-secondary">
The reduced rate applies to every open and close fee.
</div>
</Trans>
);
}

function formatUsdDelta(value: bigint): string {
return formatUsd(value, { displayPlus: value >= 0n }) ?? "";
}
17 changes: 17 additions & 0 deletions src/domain/referrals/utils/referralsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,20 @@ export function getCodeError(value: string): string {
export function getReferralCodeTradeUrl(referralCode: string): string {
return `${getRootUrl()}/#/trade/?${REFERRAL_CODE_QUERY_PARAM}=${referralCode}`;
}

export type ProtocolReferralCodeType = "organic" | "graduated";

const PROTOCOL_REFERRAL_CODES: Record<string, ProtocolReferralCodeType> = {
EARNED_TRADER_DISCOUNT_5: "organic",
EARNED_TRADER_DISCOUNT_10: "organic",
DIRECT_GMX_DISCOUNT_5: "graduated",
DIRECT_GMX_DISCOUNT_10: "graduated",
};

export function getProtocolReferralCodeType(codeString: string | undefined): ProtocolReferralCodeType | undefined {
if (!codeString) {
return undefined;
}

return PROTOCOL_REFERRAL_CODES[codeString];
}
8 changes: 8 additions & 0 deletions src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "TP/SL-Orders überschreiten die Position"
msgid "pay"
msgstr "zahlen"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Ihr bisheriger Empfehlungscode wurde durch einen GMX-Protokollcode ersetzt, nachdem Ihre Trades die Abschluss-Schwelle des Empfehlungsprogramms erreicht haben. Sie behalten Ihren {currentTierDiscount}% Rabatt auf Eröffnungs- und Schließungsgebühren. <0>Mehr erfahren</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "Keine Möglichkeiten entsprechen Ihren Beständen"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "Erneut signieren"
msgid "Depositing to GMX Account..."
msgstr "Einzahlung auf GMX Account..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Sie haben eine Handelsvolumen-Schwelle erreicht, daher hat GMX Ihnen diesen Protokoll-Empfehlungscode zugewiesen. Sie erhalten {currentTierDiscount}% Rabatt auf Eröffnungs- und Schließungsgebühren. <0>Mehr erfahren</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "TP/SL orders exceed the position"
msgid "pay"
msgstr "pay"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "No opportunities match your holdings"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "Re-sign"
msgid "Depositing to GMX Account..."
msgstr "Depositing to GMX Account..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "Órdenes TP/SL exceden la posición"
msgid "pay"
msgstr "pagar"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Tu código de referido anterior fue reemplazado por un código del protocolo GMX después de que tus operaciones alcanzaran el umbral de graduación del programa de referidos. Conservas tu descuento del {currentTierDiscount}% en las comisiones de apertura y cierre. <0>Más información</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "Ninguna oportunidad coincide con sus tenencias"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "Re-firmar"
msgid "Depositing to GMX Account..."
msgstr "Depositando en GMX Account..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Has alcanzado un umbral de volumen de trading, por lo que GMX te asignó este código de referido del protocolo. Estás recibiendo un descuento del {currentTierDiscount}% en las comisiones de apertura y cierre. <0>Más información</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "Les ordres TP/SL dépassent la position"
msgid "pay"
msgstr "payer"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Votre code de parrainage précédent a été remplacé par un code de protocole GMX après que vos transactions ont atteint le seuil de fin du programme de parrainage. Vous conservez votre réduction de {currentTierDiscount}% sur les frais d'ouverture et de clôture. <0>En savoir plus</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "Aucune opportunité ne correspond à vos avoirs"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "Re-signer"
msgid "Depositing to GMX Account..."
msgstr "Dépôt vers GMX Account en cours..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Vous avez atteint un seuil de volume de trading, donc GMX vous a attribué ce code de parrainage du protocole. Vous bénéficiez d'une réduction de {currentTierDiscount}% sur les frais d'ouverture et de clôture. <0>En savoir plus</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/ja/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "TP/SL注文がポジションを超過"
msgid "pay"
msgstr "支払い"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "お取引が紹介プログラムの卒業しきい値に達したため、以前の紹介コードはGMXプロトコルコードに置き換えられました。オープンおよびクローズ手数料の{currentTierDiscount}%割引は維持されます。<0>詳細</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "お持ちの資産に一致する機会はありません"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "再署名"
msgid "Depositing to GMX Account..."
msgstr "GMX Account に入金中..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "取引高のしきい値に達したため、GMXがこのプロトコル紹介コードを割り当てました。オープンおよびクローズ手数料が{currentTierDiscount}%割引されます。<0>詳細</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/ko/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "TP/SL 주문이 포지션을 초과합니다"
msgid "pay"
msgstr "지불"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "거래가 추천 프로그램의 졸업 기준에 도달한 후 이전 추천 코드가 GMX 프로토콜 코드로 대체되었습니다. 개시 및 종료 수수료에 대한 {currentTierDiscount}% 할인이 유지됩니다. <0>자세히 보기</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "보유 자산과 일치하는 기회가 없습니다"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "재서명"
msgid "Depositing to GMX Account..."
msgstr "GMX Account에 입금 중..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "거래량 기준에 도달하여 GMX가 이 프로토콜 추천 코드를 할당했습니다. 개시 및 종료 수수료에 대해 {currentTierDiscount}% 할인을 받고 있습니다. <0>자세히 보기</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/pseudo/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr ""
msgid "pay"
msgstr ""

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr ""

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr ""
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr ""
msgid "Depositing to GMX Account..."
msgstr ""

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr ""

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/ru/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "Ордера TP/SL превышают позицию"
msgid "pay"
msgstr "оплатить"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Ваш предыдущий реферальный код был заменён на протокольный код GMX после того, как объём ваших сделок достиг порога завершения реферальной программы. Вы сохраняете скидку {currentTierDiscount}% на комиссии за открытие и закрытие. <0>Подробнее</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "Нет возможностей, соответствующих вашим активам"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "Переподписать"
msgid "Depositing to GMX Account..."
msgstr "Депозит на GMX Account..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "Вы достигли порога объёма торгов, поэтому GMX присвоил вам этот протокольный реферальный код. Вы получаете скидку {currentTierDiscount}% на комиссии за открытие и закрытие. <0>Подробнее</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/zh-tw/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "TP/SL 訂單超過倉位"
msgid "pay"
msgstr "支付"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "在您的交易達到推薦計畫的畢業門檻後,您先前的推薦碼已被替換為 GMX 協議碼。您將保留開倉和平倉費用 {currentTierDiscount}% 的折扣。<0>瞭解更多</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "沒有符合您持有資產的機會"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "重新簽署"
msgid "Depositing to GMX Account..."
msgstr "正在存入至 GMX Account..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "您已達到交易量門檻,因此 GMX 為您分配了此協議推薦碼。您將享有開倉和平倉費用 {currentTierDiscount}% 的折扣。<0>瞭解更多</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
8 changes: 8 additions & 0 deletions src/locales/zh/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -6695,6 +6695,10 @@ msgstr "TP/SL 订单超过头寸"
msgid "pay"
msgstr "支付"

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "Your previous referral code has been replaced with a GMX protocol code after your trades reached the referral program's graduation threshold. You keep your {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "在您的交易达到推荐计划的毕业门槛后,您之前的推荐码已被替换为 GMX 协议码。您将保留开仓和平仓费用 {currentTierDiscount}% 的折扣。<0>了解更多</0>"

#: src/pages/Earn/EarnAdditionalOpportunitiesPage.tsx
msgid "No opportunities match your holdings"
msgstr "没有与您持仓匹配的机会"
Expand Down Expand Up @@ -10221,6 +10225,10 @@ msgstr "重新签名"
msgid "Depositing to GMX Account..."
msgstr "正在存入 GMX Account..."

#: src/components/Referrals/traders/dashboard/ReferralsTradersContent.tsx
msgid "You've reached a trading volume threshold, so GMX assigned this protocol referral code. You're receiving a {currentTierDiscount}% discount on opening and closing fees. <0>Read more</0>"
msgstr "您已达到交易量门槛,因此 GMX 为您分配了此协议推荐码。您将享受开仓和平仓费用 {currentTierDiscount}% 的折扣。<0>了解更多</0>"

#: src/components/AddressDropdown/AddressDropdownWithoutMultichain.tsx
#: src/components/GmxAccountModal/MainView.tsx
msgid "Address copied"
Expand Down
Loading