diff --git a/apps/trading/client-pages/referrals/apply-code-form.tsx b/apps/trading/client-pages/referrals/apply-code-form.tsx
index 8f3262008..b4121aee4 100644
--- a/apps/trading/client-pages/referrals/apply-code-form.tsx
+++ b/apps/trading/client-pages/referrals/apply-code-form.tsx
@@ -18,6 +18,7 @@ import { Routes } from '../../lib/links';
import { useTransactionEventSubscription } from '@vegaprotocol/web3';
import { t } from '@vegaprotocol/i18n';
import { Statistics } from './referral-statistics';
+import { useReferralProgram } from './hooks/use-referral-program';
const RELOAD_DELAY = 3000;
@@ -32,6 +33,7 @@ const validateCode = (value: string) => {
};
export const ApplyCodeForm = () => {
+ const program = useReferralProgram();
const navigate = useNavigate();
const openWalletDialog = useVegaWalletDialogStore(
(store) => store.openVegaWalletDialog
@@ -237,7 +239,7 @@ export const ApplyCodeForm = () => {
{previewData ? (
{t('You are joining')}
-
+
) : null}
>
diff --git a/apps/trading/client-pages/referrals/hooks/Referees.graphql b/apps/trading/client-pages/referrals/hooks/Referees.graphql
index 9050131bb..c8476ee0b 100644
--- a/apps/trading/client-pages/referrals/hooks/Referees.graphql
+++ b/apps/trading/client-pages/referrals/hooks/Referees.graphql
@@ -1,5 +1,5 @@
-query Referees($code: ID!, $aggregationDays: Int) {
- referralSetReferees(id: $code, aggregationDays: $aggregationDays) {
+query Referees($code: ID!, $aggregationEpochs: Int) {
+ referralSetReferees(id: $code, aggregationEpochs: $aggregationEpochs) {
edges {
node {
referralSetId
diff --git a/apps/trading/client-pages/referrals/hooks/ReferralSetStats.graphql b/apps/trading/client-pages/referrals/hooks/ReferralSetStats.graphql
index 35795c913..7d0fba752 100644
--- a/apps/trading/client-pages/referrals/hooks/ReferralSetStats.graphql
+++ b/apps/trading/client-pages/referrals/hooks/ReferralSetStats.graphql
@@ -10,6 +10,7 @@ query ReferralSetStats($code: ID!, $epoch: Int) {
referralSetRunningNotionalTakerVolume
rewardsMultiplier
rewardsFactorMultiplier
+ referrerTakerVolume
}
}
}
diff --git a/apps/trading/client-pages/referrals/hooks/__generated__/Referees.ts b/apps/trading/client-pages/referrals/hooks/__generated__/Referees.ts
index 5eafc568c..b5235998f 100644
--- a/apps/trading/client-pages/referrals/hooks/__generated__/Referees.ts
+++ b/apps/trading/client-pages/referrals/hooks/__generated__/Referees.ts
@@ -5,7 +5,7 @@ import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type RefereesQueryVariables = Types.Exact<{
code: Types.Scalars['ID'];
- aggregationDays?: Types.InputMaybe;
+ aggregationEpochs?: Types.InputMaybe;
}>;
@@ -13,8 +13,8 @@ export type RefereesQuery = { __typename?: 'Query', referralSetReferees: { __typ
export const RefereesDocument = gql`
- query Referees($code: ID!, $aggregationDays: Int) {
- referralSetReferees(id: $code, aggregationDays: $aggregationDays) {
+ query Referees($code: ID!, $aggregationEpochs: Int) {
+ referralSetReferees(id: $code, aggregationEpochs: $aggregationEpochs) {
edges {
node {
referralSetId
@@ -42,7 +42,7 @@ export const RefereesDocument = gql`
* const { data, loading, error } = useRefereesQuery({
* variables: {
* code: // value for 'code'
- * aggregationDays: // value for 'aggregationDays'
+ * aggregationEpochs: // value for 'aggregationEpochs'
* },
* });
*/
diff --git a/apps/trading/client-pages/referrals/hooks/__generated__/ReferralSetStats.ts b/apps/trading/client-pages/referrals/hooks/__generated__/ReferralSetStats.ts
index e8d957bbc..7647ede92 100644
--- a/apps/trading/client-pages/referrals/hooks/__generated__/ReferralSetStats.ts
+++ b/apps/trading/client-pages/referrals/hooks/__generated__/ReferralSetStats.ts
@@ -9,7 +9,7 @@ export type ReferralSetStatsQueryVariables = Types.Exact<{
}>;
-export type ReferralSetStatsQuery = { __typename?: 'Query', referralSetStats: { __typename?: 'ReferralSetStatsConnection', edges: Array<{ __typename?: 'ReferralSetStatsEdge', node: { __typename?: 'ReferralSetStats', atEpoch: number, partyId: string, discountFactor: string, rewardFactor: string, epochNotionalTakerVolume: string, referralSetRunningNotionalTakerVolume: string, rewardsMultiplier: string, rewardsFactorMultiplier: string } } | null> } };
+export type ReferralSetStatsQuery = { __typename?: 'Query', referralSetStats: { __typename?: 'ReferralSetStatsConnection', edges: Array<{ __typename?: 'ReferralSetStatsEdge', node: { __typename?: 'ReferralSetStats', atEpoch: number, partyId: string, discountFactor: string, rewardFactor: string, epochNotionalTakerVolume: string, referralSetRunningNotionalTakerVolume: string, rewardsMultiplier: string, rewardsFactorMultiplier: string, referrerTakerVolume: string } } | null> } };
export const ReferralSetStatsDocument = gql`
@@ -25,6 +25,7 @@ export const ReferralSetStatsDocument = gql`
referralSetRunningNotionalTakerVolume
rewardsMultiplier
rewardsFactorMultiplier
+ referrerTakerVolume
}
}
}
diff --git a/apps/trading/client-pages/referrals/hooks/use-referral.ts b/apps/trading/client-pages/referrals/hooks/use-referral.ts
index 8080cab1e..28deb09f5 100644
--- a/apps/trading/client-pages/referrals/hooks/use-referral.ts
+++ b/apps/trading/client-pages/referrals/hooks/use-referral.ts
@@ -5,14 +5,14 @@ import compact from 'lodash/compact';
import type { ReferralSetsQueryVariables } from './__generated__/ReferralSets';
import { useReferralSetsQuery } from './__generated__/ReferralSets';
-const DEFAULT_AGGREGATION_DAYS = 30;
+export const DEFAULT_AGGREGATION_DAYS = 30;
export type Role = 'referrer' | 'referee';
type UseReferralArgs = (
| { code: string }
| { pubKey: string | null; role: Role }
) & {
- aggregationDays?: number;
+ aggregationEpochs?: number;
};
const prepareVariables = (
@@ -70,9 +70,9 @@ export const useReferral = (args: UseReferralArgs) => {
} = useRefereesQuery({
variables: {
code: referralSet?.id as string,
- aggregationDays:
- args.aggregationDays != null
- ? args.aggregationDays
+ aggregationEpochs:
+ args.aggregationEpochs != null
+ ? args.aggregationEpochs
: DEFAULT_AGGREGATION_DAYS,
},
skip: !referralSet?.id,
diff --git a/apps/trading/client-pages/referrals/referral-statistics.tsx b/apps/trading/client-pages/referrals/referral-statistics.tsx
index 45d19ffdb..7a89288d1 100644
--- a/apps/trading/client-pages/referrals/referral-statistics.tsx
+++ b/apps/trading/client-pages/referrals/referral-statistics.tsx
@@ -6,7 +6,7 @@ import {
} from '@vegaprotocol/ui-toolkit';
import { useVegaWallet } from '@vegaprotocol/wallet';
-import { useReferral } from './hooks/use-referral';
+import { DEFAULT_AGGREGATION_DAYS, useReferral } from './hooks/use-referral';
import { CreateCodeContainer } from './create-code-form';
import classNames from 'classnames';
import { Table } from './table';
@@ -32,21 +32,25 @@ import maxBy from 'lodash/maxBy';
export const ReferralStatistics = () => {
const { pubKey } = useVegaWallet();
+ const program = useReferralProgram();
+
const { data: referee } = useReferral({
pubKey,
role: 'referee',
+ aggregationEpochs: program.details?.windowLength,
});
const { data: referrer } = useReferral({
pubKey,
role: 'referrer',
+ aggregationEpochs: program.details?.windowLength,
});
if (referee?.code) {
- return ;
+ return ;
}
if (referrer?.code) {
- return ;
+ return ;
}
return ;
@@ -54,14 +58,16 @@ export const ReferralStatistics = () => {
export const Statistics = ({
data,
+ program,
as,
}: {
data: NonNullable['data']>;
+ program: ReturnType;
as: 'referrer' | 'referee';
}) => {
+ const { benefitTiers, details } = program;
const { data: epochData } = useCurrentEpochInfoQuery();
const { stakeAvailable } = useStakeAvailable();
- const { benefitTiers } = useReferralProgram();
const { data: statsData } = useReferralSetStatsQuery({
variables: {
code: data.code,
@@ -72,6 +78,13 @@ export const Statistics = ({
const currentEpoch = Number(epochData?.epoch.id);
+ const compactNumFormat = new Intl.NumberFormat(getUserLocale(), {
+ minimumFractionDigits: 0,
+ maximumFractionDigits: 2,
+ notation: 'compact',
+ compactDisplay: 'short',
+ });
+
const stats =
statsData?.referralSetStats.edges &&
compact(removePaginationWrapper(statsData.referralSetStats.edges));
@@ -87,10 +100,13 @@ export const Statistics = ({
const runningVolumeValue = statsAvailable
? Number(statsAvailable.referralSetRunningNotionalTakerVolume)
: 0;
+ const referrerVolumeValue = statsAvailable
+ ? Number(statsAvailable.referrerTakerVolume)
+ : 0;
const multiplier = statsAvailable
? Number(statsAvailable.rewardsMultiplier)
: 1;
- const finalCommissionValue = !isNaN(multiplier)
+ const finalCommissionValue = isNaN(multiplier)
? baseCommissionValue
: multiplier * baseCommissionValue;
@@ -118,7 +134,13 @@ export const Statistics = ({
: 0;
const baseCommissionTile = (
-
+
{baseCommissionValue * 100}%
);
@@ -134,7 +156,16 @@ export const Statistics = ({
);
const finalCommissionTile = (
-
+
{finalCommissionValue * 100}%
);
@@ -143,12 +174,21 @@ export const Statistics = ({
{numberOfTradersValue}
);
- const codeTile = ;
- const createdAtTile = (
-
-
- {getDateFormat().format(new Date(data.createdAt))}
-
+ const codeTile = (
+
+ );
+
+ const referrerVolumeTile = (
+
+ {compactNumFormat.format(referrerVolumeValue)}
);
@@ -157,7 +197,10 @@ export const Statistics = ({
.reduce((all, r) => all.plus(r), new BigNumber(0));
const totalCommissionTile = (
{getNumberFormat(0).format(Number(totalCommissionValue))}
@@ -174,20 +217,13 @@ export const Statistics = ({
{codeTile}
- {createdAtTile}
+ {referrerVolumeTile}
{numberOfTradersTile}
{totalCommissionTile}
>
);
- const compactNumFormat = new Intl.NumberFormat(getUserLocale(), {
- minimumFractionDigits: 0,
- maximumFractionDigits: 2,
- notation: 'compact',
- compactDisplay: 'short',
- });
-
const currentBenefitTierTile = (
{currentBenefitTierValue?.tier || 'None'}
@@ -266,7 +302,7 @@ export const Statistics = ({
{/* Referees (only for referrer view) */}
{as === 'referrer' && data.referees.length > 0 && (
-
{t('Referees')}
+
{t('Referees')}
{
) : (
({
...bt,
tierElement: (
@@ -162,6 +163,7 @@ const StakingTiers = ({
const TiersTable = ({
data,
+ windowLength,
}: {
data: Array<{
tier: number;
@@ -170,6 +172,7 @@ const TiersTable = ({
discount: string;
volume: string;
}>;
+ windowLength?: number;
}) => {
return (
({
diff --git a/apps/trading/client-pages/referrals/tile.tsx b/apps/trading/client-pages/referrals/tile.tsx
index c81aab82b..3fe4bbbe1 100644
--- a/apps/trading/client-pages/referrals/tile.tsx
+++ b/apps/trading/client-pages/referrals/tile.tsx
@@ -7,6 +7,7 @@ import {
import classNames from 'classnames';
import type { HTMLAttributes, ReactNode } from 'react';
import { Button } from './buttons';
+import { t } from '@vegaprotocol/i18n';
export const Tile = ({
className,
@@ -54,13 +55,18 @@ const FADE_OUT_STYLE = classNames(
export const CodeTile = ({
code,
+ createdAt,
className,
}: {
code: string;
+ createdAt?: string;
className?: string;
}) => {
return (
-
+
- Copy
+ {t('Copy')}
diff --git a/libs/types/src/__generated__/types.ts b/libs/types/src/__generated__/types.ts
index 080a4229c..4829a0429 100644
--- a/libs/types/src/__generated__/types.ts
+++ b/libs/types/src/__generated__/types.ts
@@ -813,7 +813,7 @@ export type DispatchStrategy = {
/** Minimum notional time-weighted averaged position required for a party to be considered eligible */
notionalTimeWeightedAveragePositionRequirement: Scalars['String'];
/** Ascending order list of start rank and corresponding share ratio */
- rankTable?: Maybe;
+ rankTable?: Maybe>>;
/** Minimum number of governance tokens, e.g. VEGA, staked for a party to be considered eligible */
stakingRequirement: Scalars['String'];
/** The teams in scope for the reward, if the entity is teams */
@@ -3624,6 +3624,8 @@ export type PartyVestingStats = {
__typename?: 'PartyVestingStats';
/** Epoch for which the statistics are valid */
epochSeq: Scalars['Int'];
+ /** The balance of the party, in quantum. */
+ quantumBalance: Scalars['String'];
/** The reward bonus multiplier */
rewardBonusMultiplier: Scalars['String'];
};
@@ -4831,7 +4833,7 @@ export type QueryprotocolUpgradeProposalsArgs = {
/** Queries allow a caller to read data and filter data via GraphQL. */
export type QueryreferralSetRefereesArgs = {
- aggregationDays?: InputMaybe;
+ aggregationEpochs?: InputMaybe;
id?: InputMaybe;
pagination?: InputMaybe;
referee?: InputMaybe;
@@ -5088,6 +5090,8 @@ export type ReferralSetStats = {
partyId: Scalars['ID'];
/** Running volume for the set based on the window length of the current referral program. */
referralSetRunningNotionalTakerVolume: Scalars['String'];
+ /** The referrer's taker volume */
+ referrerTakerVolume: Scalars['String'];
/** Reward factor applied to the party. */
rewardFactor: Scalars['String'];
/** The proportion of the referees taker fees to be rewarded to the referrer. */