fix(trading): update referral program proposal changes (#5030)

This commit is contained in:
Art 2023-10-16 16:45:00 +02:00 committed by GitHub
parent ef4cf6a87e
commit 55b092b216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 116 additions and 109 deletions

View File

@ -63,7 +63,6 @@ const mockReferralProposal = generateProposal({
terms: { terms: {
change: { change: {
__typename: 'UpdateReferralProgram', __typename: 'UpdateReferralProgram',
changes: {
benefitTiers: [ benefitTiers: [
{ {
minimumEpochs: 6, minimumEpochs: 6,
@ -84,7 +83,7 @@ const mockReferralProposal = generateProposal({
referralRewardFactor: '0.01', referralRewardFactor: '0.01',
}, },
], ],
endOfProgramTimestamp: '2026-10-03T10:34:34Z', endOfProgram: '2026-10-03T10:34:34Z',
windowLength: 3, windowLength: 3,
stakingTiers: [ stakingTiers: [
{ {
@ -102,7 +101,6 @@ const mockReferralProposal = generateProposal({
], ],
}, },
}, },
},
}); });
describe('<ProposalReferralProgramDetails />', () => { describe('<ProposalReferralProgramDetails />', () => {
@ -132,7 +130,6 @@ describe('<ProposalReferralProgramDetails />', () => {
terms: { terms: {
change: { change: {
__typename: 'UpdateReferralProgram', __typename: 'UpdateReferralProgram',
changes: {},
}, },
}, },
}); });

View File

@ -54,11 +54,10 @@ export const ProposalReferralProgramDetails = ({
return null; return null;
} }
const benefitTiers = proposal?.terms?.change?.changes?.benefitTiers; const benefitTiers = proposal?.terms?.change?.benefitTiers;
const stakingTiers = proposal?.terms?.change?.changes?.stakingTiers; const stakingTiers = proposal?.terms?.change?.stakingTiers;
const windowLength = proposal?.terms?.change?.changes?.windowLength; const windowLength = proposal?.terms?.change?.windowLength;
const endOfProgramTimestamp = const endOfProgramTimestamp = proposal?.terms?.change?.endOfProgram;
proposal?.terms?.change?.changes?.endOfProgramTimestamp;
if ( if (
!benefitTiers && !benefitTiers &&

View File

@ -47,14 +47,13 @@ fragment UpdateReferralProgram on Proposal {
terms { terms {
change { change {
... on UpdateReferralProgram { ... on UpdateReferralProgram {
changes {
benefitTiers { benefitTiers {
minimumEpochs minimumEpochs
minimumRunningNotionalTakerVolume minimumRunningNotionalTakerVolume
referralDiscountFactor referralDiscountFactor
referralRewardFactor referralRewardFactor
} }
endOfProgramTimestamp endOfProgram: endOfProgramTimestamp
windowLength windowLength
stakingTiers { stakingTiers {
minimumStakedTokens minimumStakedTokens
@ -63,7 +62,6 @@ fragment UpdateReferralProgram on Proposal {
} }
} }
} }
}
} }
fragment UpdateVolumeDiscountProgram on Proposal { fragment UpdateVolumeDiscountProgram on Proposal {

File diff suppressed because one or more lines are too long

View File

@ -47,14 +47,13 @@ fragment UpdateReferralPrograms on Proposal {
terms { terms {
change { change {
... on UpdateReferralProgram { ... on UpdateReferralProgram {
changes {
benefitTiers { benefitTiers {
minimumEpochs minimumEpochs
minimumRunningNotionalTakerVolume minimumRunningNotionalTakerVolume
referralDiscountFactor referralDiscountFactor
referralRewardFactor referralRewardFactor
} }
endOfProgramTimestamp endOfProgram: endOfProgramTimestamp
windowLength windowLength
stakingTiers { stakingTiers {
minimumStakedTokens minimumStakedTokens
@ -63,7 +62,6 @@ fragment UpdateReferralPrograms on Proposal {
} }
} }
} }
}
} }
fragment UpdateVolumeDiscountPrograms on Proposal { fragment UpdateVolumeDiscountPrograms on Proposal {

View File

@ -7,7 +7,7 @@ export type NewMarketProductFieldsFragment = { __typename?: 'Proposal', terms: {
export type UpdateMarketStatesFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState', updateType: Types.MarketUpdateType, price?: string | null, market: { __typename?: 'Market', decimalPlaces: number, id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, product: { __typename: 'Future', quoteName: string } | { __typename: 'Perpetual', quoteName: string } | { __typename: 'Spot' } } } } } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } }; export type UpdateMarketStatesFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState', updateType: Types.MarketUpdateType, price?: string | null, market: { __typename?: 'Market', decimalPlaces: number, id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, product: { __typename: 'Future', quoteName: string } | { __typename: 'Perpetual', quoteName: string } | { __typename: 'Spot' } } } } } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } };
export type UpdateReferralProgramsFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram', changes: { __typename?: 'ReferralProgram', endOfProgramTimestamp: string, windowLength: number, benefitTiers: Array<{ __typename?: 'BenefitTier', minimumEpochs: number, minimumRunningNotionalTakerVolume: string, referralDiscountFactor: string, referralRewardFactor: string }>, stakingTiers: Array<{ __typename?: 'StakingTier', minimumStakedTokens: string, referralRewardMultiplier: string }> } } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } }; export type UpdateReferralProgramsFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram', windowLength: number, endOfProgram: string, benefitTiers: Array<{ __typename?: 'BenefitTier', minimumEpochs: number, minimumRunningNotionalTakerVolume: string, referralDiscountFactor: string, referralRewardFactor: string }>, stakingTiers: Array<{ __typename?: 'StakingTier', minimumStakedTokens: string, referralRewardMultiplier: string }> } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } };
export type UpdateVolumeDiscountProgramsFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram', endOfProgramTimestamp: any, windowLength: number, benefitTiers: Array<{ __typename?: 'VolumeBenefitTier', minimumRunningNotionalTakerVolume: string, volumeDiscountFactor: string }> } } }; export type UpdateVolumeDiscountProgramsFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram', endOfProgramTimestamp: any, windowLength: number, benefitTiers: Array<{ __typename?: 'VolumeBenefitTier', minimumRunningNotionalTakerVolume: string, volumeDiscountFactor: string }> } } };
@ -21,7 +21,7 @@ export type ProposalsQueryVariables = Types.Exact<{
}>; }>;
export type ProposalsQuery = { __typename?: 'Query', proposalsConnection?: { __typename?: 'ProposalsConnection', edges?: Array<{ __typename?: 'ProposalEdge', node: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null, product?: { __typename: 'FutureProduct' } | { __typename: 'PerpetualProduct' } | { __typename: 'SpotProduct' } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState', updateType: Types.MarketUpdateType, price?: string | null, market: { __typename?: 'Market', decimalPlaces: number, id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, product: { __typename: 'Future', quoteName: string } | { __typename: 'Perpetual', quoteName: string } | { __typename: 'Spot' } } } } } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram', changes: { __typename?: 'ReferralProgram', endOfProgramTimestamp: string, windowLength: number, benefitTiers: Array<{ __typename?: 'BenefitTier', minimumEpochs: number, minimumRunningNotionalTakerVolume: string, referralDiscountFactor: string, referralRewardFactor: string }>, stakingTiers: Array<{ __typename?: 'StakingTier', minimumStakedTokens: string, referralRewardMultiplier: string }> } } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram', endOfProgramTimestamp: any, windowLength: number, benefitTiers: Array<{ __typename?: 'VolumeBenefitTier', minimumRunningNotionalTakerVolume: string, volumeDiscountFactor: string }> } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } } | null> | null } | null }; export type ProposalsQuery = { __typename?: 'Query', proposalsConnection?: { __typename?: 'ProposalsConnection', edges?: Array<{ __typename?: 'ProposalEdge', node: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null, product?: { __typename: 'FutureProduct' } | { __typename: 'PerpetualProduct' } | { __typename: 'SpotProduct' } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState', updateType: Types.MarketUpdateType, price?: string | null, market: { __typename?: 'Market', decimalPlaces: number, id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, product: { __typename: 'Future', quoteName: string } | { __typename: 'Perpetual', quoteName: string } | { __typename: 'Spot' } } } } } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram', windowLength: number, endOfProgram: string, benefitTiers: Array<{ __typename?: 'BenefitTier', minimumEpochs: number, minimumRunningNotionalTakerVolume: string, referralDiscountFactor: string, referralRewardFactor: string }>, stakingTiers: Array<{ __typename?: 'StakingTier', minimumStakedTokens: string, referralRewardMultiplier: string }> } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram', endOfProgramTimestamp: any, windowLength: number, benefitTiers: Array<{ __typename?: 'VolumeBenefitTier', minimumRunningNotionalTakerVolume: string, volumeDiscountFactor: string }> } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } } | null> | null } | null };
export const NewMarketProductFieldsFragmentDoc = gql` export const NewMarketProductFieldsFragmentDoc = gql`
fragment NewMarketProductFields on Proposal { fragment NewMarketProductFields on Proposal {
@ -75,14 +75,13 @@ export const UpdateReferralProgramsFragmentDoc = gql`
terms { terms {
change { change {
... on UpdateReferralProgram { ... on UpdateReferralProgram {
changes {
benefitTiers { benefitTiers {
minimumEpochs minimumEpochs
minimumRunningNotionalTakerVolume minimumRunningNotionalTakerVolume
referralDiscountFactor referralDiscountFactor
referralRewardFactor referralRewardFactor
} }
endOfProgramTimestamp endOfProgram: endOfProgramTimestamp
windowLength windowLength
stakingTiers { stakingTiers {
minimumStakedTokens minimumStakedTokens
@ -91,7 +90,6 @@ export const UpdateReferralProgramsFragmentDoc = gql`
} }
} }
} }
}
} }
`; `;
export const UpdateVolumeDiscountProgramsFragmentDoc = gql` export const UpdateVolumeDiscountProgramsFragmentDoc = gql`

View File

@ -104,7 +104,13 @@ describe('TradesTable', () => {
const [firstDateCell, secondDateCell] = createdAtCells; const [firstDateCell, secondDateCell] = createdAtCells;
// Compare the times as strings // Compare the times as strings
expect(firstDateCell.textContent).toBe('6:59:00 PM'); // Note: I've changed it form literal strings to this because of the
expect(secondDateCell.textContent).toBe('7:00:00 PM'); // locale mismatch. Mocking the format also resulted with strange "space" diff.
expect(firstDateCell.textContent).toBe(
getTimeFormat().format(new Date(trade2.createdAt))
);
expect(secondDateCell.textContent).toBe(
getTimeFormat().format(new Date(trade.createdAt))
);
}); });
}); });

View File

@ -4605,6 +4605,8 @@ export type QueryreferralFeeStatsArgs = {
assetId?: InputMaybe<Scalars['ID']>; assetId?: InputMaybe<Scalars['ID']>;
epoch?: InputMaybe<Scalars['Int']>; epoch?: InputMaybe<Scalars['Int']>;
marketId?: InputMaybe<Scalars['ID']>; marketId?: InputMaybe<Scalars['ID']>;
referee?: InputMaybe<Scalars['ID']>;
referrer?: InputMaybe<Scalars['ID']>;
}; };
@ -4620,9 +4622,9 @@ export type QueryreferralSetRefereesArgs = {
/** Queries allow a caller to read data and filter data via GraphQL. */ /** Queries allow a caller to read data and filter data via GraphQL. */
export type QueryreferralSetStatsArgs = { export type QueryreferralSetStatsArgs = {
epoch?: InputMaybe<Scalars['Int']>; epoch?: InputMaybe<Scalars['Int']>;
id: Scalars['ID'];
pagination?: InputMaybe<Pagination>; pagination?: InputMaybe<Pagination>;
partyId?: InputMaybe<Scalars['ID']>; partyId?: InputMaybe<Scalars['ID']>;
setId?: InputMaybe<Scalars['ID']>;
}; };
@ -4882,6 +4884,10 @@ export type ReferralSetStats = {
referralSetRunningNotionalTakerVolume: Scalars['String']; referralSetRunningNotionalTakerVolume: Scalars['String'];
/** Reward factor applied to the party. */ /** Reward factor applied to the party. */
rewardFactor: Scalars['String']; rewardFactor: Scalars['String'];
/** The proportion of the referees taker fees to be rewarded to the referrer. */
rewardsFactorMultiplier: Scalars['String'];
/** The multiplier applied to the referral reward factor when calculating referral rewards due to the referrer. */
rewardsMultiplier: Scalars['String'];
}; };
/** Connection type for retrieving cursor-based paginated referral set statistics information */ /** Connection type for retrieving cursor-based paginated referral set statistics information */
@ -6143,7 +6149,18 @@ export type UpdateProductConfiguration = UpdateFutureProduct | UpdatePerpetualPr
export type UpdateReferralProgram = { export type UpdateReferralProgram = {
__typename?: 'UpdateReferralProgram'; __typename?: 'UpdateReferralProgram';
changes: ReferralProgram; /** Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc. */
benefitTiers: Array<BenefitTier>;
/** Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled. */
endOfProgramTimestamp: Scalars['String'];
/**
* Defined staking tiers in increasing order. First element will give Tier 1,
* second element will give Tier 2, and so on. Determines the level of
* benefit a party can expect based on their staking.
*/
stakingTiers: Array<StakingTier>;
/** Number of epochs over which to evaluate a referral set's running volume. */
windowLength: Scalars['Int'];
}; };
/** Update an existing spot market on Vega */ /** Update an existing spot market on Vega */
@ -6175,11 +6192,7 @@ export type UpdateVolumeDiscountProgram = {
benefitTiers: Array<VolumeBenefitTier>; benefitTiers: Array<VolumeBenefitTier>;
/** The end time of the program */ /** The end time of the program */
endOfProgramTimestamp: Scalars['Timestamp']; endOfProgramTimestamp: Scalars['Timestamp'];
/** ID of the proposal that created the discount program */ /** The window length to consider for the volume discount program */
id: Scalars['ID'];
/** The current version of the volume discount program */
version: Scalars['Int'];
/** The window legnth to consider for the volume discount program */
windowLength: Scalars['Int']; windowLength: Scalars['Int'];
}; };