Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db6a1f077b | ||
|
|
5389a429ab | ||
|
|
c1d51b84d6 | ||
|
|
153367b1f1 | ||
|
|
7833a6a5e7 | ||
|
|
5c5e30f7b8 | ||
|
|
44d842ff87 | ||
|
|
6cf9fcd11d | ||
|
|
fa7903580f | ||
|
|
6befe5d96f | ||
|
|
de86d1927d | ||
|
|
e34973cdee | ||
|
|
18dac4ea5e |
@@ -205,7 +205,7 @@ jobs:
|
||||
# run tests
|
||||
#----------------------------------------------
|
||||
- name: Run tests
|
||||
run: CONSOLE_IMAGE_NAME=ci/trading:local poetry run pytest -v --numprocesses 1 --dist loadfile --durations=45
|
||||
run: CONSOLE_IMAGE_NAME=ci/trading:local poetry run pytest -v -s --numprocesses 1 --dist loadfile --durations=45
|
||||
working-directory: apps/trading/e2e
|
||||
#----------------------------------------------
|
||||
# upload traces
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.rocks
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/stagnet1/vegawallet-stagnet1.toml
|
||||
NX_VEGA_ENV=STAGNET1
|
||||
@@ -8,6 +9,7 @@ NX_VEGA_WALLET_URL=http://localhost:1789
|
||||
NX_TENDERMINT_URL=https://tm.n01.stagnet1.vega.rocks
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket
|
||||
NX_BLOCK_EXPLORER=https://be.stagnet1.vega.rocks/rest
|
||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
||||
NX_VEGA_GOVERNANCE_URL=https://governance.stagnet1.vega.rocks
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV=CUSTOM
|
||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
||||
NX_VEGA_EXPLORER_URL=/
|
||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/devnet1/vegawallet-devnet1.toml
|
||||
NX_VEGA_ENV=DEVNET
|
||||
NX_BLOCK_EXPLORER=https://be.devnet1.vega.xyz/rest
|
||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_VEGA_GOVERNANCE_URL=https://dev.governance.vega.xyz
|
||||
NX_VEGA_URL=https://api.devnet1.vega.xyz/graphql
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/devnet1/vegawallet-devnet1.toml
|
||||
|
||||
@@ -4,6 +4,7 @@ NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/maste
|
||||
NX_VEGA_URL=https://api.vega.community/graphql
|
||||
NX_VEGA_ENV=MAINNET
|
||||
NX_BLOCK_EXPLORER=https://be.vega.community/rest
|
||||
NX_ETHERSCAN_URL=https://etherscan.io
|
||||
NX_VEGA_GOVERNANCE_URL=https://governance.vega.xyz
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.vega.xyz/
|
||||
|
||||
@@ -4,6 +4,7 @@ NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-inter
|
||||
NX_VEGA_URL=https://api.mainnet-mirror.vega.rocks/graphql
|
||||
NX_VEGA_ENV=MAINNET_MIRROR
|
||||
NX_BLOCK_EXPLORER=https://be.mainnet-mirror.vega.rocks/rest
|
||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_VEGA_GOVERNANCE_URL=https://governance.mainnet-mirror.vega.rocks
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.mainnet-mirror.vega.rocks/
|
||||
|
||||
@@ -4,6 +4,7 @@ NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-inter
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql
|
||||
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_VEGA_GOVERNANCE_URL=https://governance.fairground.wtf
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||
|
||||
@@ -4,6 +4,7 @@ NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/maste
|
||||
NX_VEGA_URL=https://api-validators-testnet.vega.rocks/graphql
|
||||
NX_VEGA_REST=https://api-validators-testnet.vega.rocks/
|
||||
NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||
|
||||
NX_BLOCK_EXPLORER=https://be.validators-testnet.vega.rocks/rest
|
||||
|
||||
@@ -3,6 +3,7 @@ NX_TENDERMINT_URL=http://localhost:26607/
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26607/websocket
|
||||
NX_VEGA_ENV=CUSTOM
|
||||
NX_BLOCK_EXPLORER=
|
||||
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
||||
NX_VEGA_EXPLORER_URL=/
|
||||
NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
|
||||
import { DATA_SOURCES } from '../../../config';
|
||||
import Hash from '../hash';
|
||||
|
||||
export enum EthExplorerLinkTypes {
|
||||
block = 'block',
|
||||
address = 'address',
|
||||
tx = 'tx',
|
||||
}
|
||||
|
||||
export type EthExplorerLinkProps = Partial<typeof HTMLAnchorElement> & {
|
||||
id: string;
|
||||
type: EthExplorerLinkTypes;
|
||||
};
|
||||
|
||||
export const EthExplorerLink = ({
|
||||
id,
|
||||
type,
|
||||
...props
|
||||
}: EthExplorerLinkProps) => {
|
||||
const link = `${DATA_SOURCES.ethExplorerUrl}/${type}/${id}`;
|
||||
return (
|
||||
<a
|
||||
className="underline external font-mono"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
{...props}
|
||||
href={link}
|
||||
>
|
||||
<Hash text={id} />
|
||||
</a>
|
||||
);
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
import type { ChainIdMapping } from './external-chain';
|
||||
import { SUPPORTED_CHAIN_IDS, SUPPORTED_CHAIN_LABELS } from './external-chain';
|
||||
|
||||
export const SUPPORTED_CHAIN_ICON_URLS: ChainIdMapping = {
|
||||
'1': '/assets/chain-eth-logo.svg',
|
||||
'100': '/assets/chain-gno-logo.svg',
|
||||
'42161': '/assets/chain-arb-logo.svg',
|
||||
'11155111': '/assets/chain-eth-logo.svg',
|
||||
};
|
||||
|
||||
export type ExternalChainIconProps = {
|
||||
chainId?: string;
|
||||
};
|
||||
|
||||
export const ExternalChainIcon = ({
|
||||
// If chainID is not provided, default to a non-existent chain
|
||||
chainId = '-1',
|
||||
}: ExternalChainIconProps) => {
|
||||
if (SUPPORTED_CHAIN_IDS.includes(chainId)) {
|
||||
const url = SUPPORTED_CHAIN_ICON_URLS[chainId];
|
||||
const alt = SUPPORTED_CHAIN_LABELS[chainId];
|
||||
|
||||
return (
|
||||
<img
|
||||
src={url}
|
||||
className="inline-block w-4 h-4 mr-1 dark:invert"
|
||||
alt={alt}
|
||||
title={alt}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
export type ChainIdMapping = {
|
||||
[K in typeof SUPPORTED_CHAIN_IDS[number]]: string;
|
||||
};
|
||||
export const SUPPORTED_CHAIN_IDS: string[] = ['1', '100', '42161', '11155111'];
|
||||
|
||||
export const SUPPORTED_CHAIN_LABELS: ChainIdMapping = {
|
||||
'1': 'Ethereum',
|
||||
'100': 'Gnosis',
|
||||
'42161': 'Arbitrum',
|
||||
'11155111': 'Sepolia',
|
||||
};
|
||||
|
||||
export function getExternalExplorerLink(chainId: string, type: string) {
|
||||
if (SUPPORTED_CHAIN_IDS.includes(chainId)) {
|
||||
switch (chainId) {
|
||||
case '1':
|
||||
return 'https://etherscan.io';
|
||||
case '100':
|
||||
return 'https://gnosisscan.io';
|
||||
case '42161':
|
||||
return 'https://arbiscan.io';
|
||||
case '11155111':
|
||||
return 'https://sepolia.etherscan.io';
|
||||
default:
|
||||
return '#';
|
||||
}
|
||||
} else {
|
||||
return '#';
|
||||
}
|
||||
}
|
||||
|
||||
export function getExternalChainLabel(chainId?: string) {
|
||||
if (chainId && SUPPORTED_CHAIN_IDS.includes(chainId)) {
|
||||
return SUPPORTED_CHAIN_LABELS[chainId];
|
||||
} else {
|
||||
return 'Custom Chain';
|
||||
}
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
import Hash from '../hash';
|
||||
import { getExternalExplorerLink } from './external-chain';
|
||||
import { ExternalChainIcon } from './external-chain-icon';
|
||||
|
||||
export enum EthExplorerLinkTypes {
|
||||
block = 'block',
|
||||
address = 'address',
|
||||
tx = 'tx',
|
||||
}
|
||||
|
||||
export type ExternalExplorerLinkProps = Partial<typeof HTMLAnchorElement> & {
|
||||
id: string;
|
||||
type: EthExplorerLinkTypes;
|
||||
// Defaults to Ethereum Mainnet, as chain support was added late
|
||||
chain?: string;
|
||||
code?: boolean;
|
||||
};
|
||||
|
||||
export const ExternalExplorerLink = ({
|
||||
id,
|
||||
type,
|
||||
chain = '1',
|
||||
code = false,
|
||||
...props
|
||||
}: ExternalExplorerLinkProps) => {
|
||||
const link = `${getExternalExplorerLink(chain, type)}/${type}/${id}${
|
||||
code ? '#code' : ''
|
||||
}`;
|
||||
return (
|
||||
<a
|
||||
className="underline external font-mono"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
{...props}
|
||||
href={link}
|
||||
>
|
||||
<ExternalChainIcon chainId={chain} />
|
||||
<Hash text={id} />
|
||||
</a>
|
||||
);
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import type { MarketInfoWithData } from '@vegaprotocol/markets';
|
||||
import {
|
||||
LiquidationStrategyInfoPanel,
|
||||
LiquidityPriceRangeInfoPanel,
|
||||
LiquiditySLAParametersInfoPanel,
|
||||
MarginScalingFactorsPanel,
|
||||
@@ -95,8 +94,6 @@ export const MarketDetails = ({ market }: { market: MarketInfoWithData }) => {
|
||||
</>
|
||||
)
|
||||
)}
|
||||
<h2 className={headerClassName}>{t('Liquidation strategy')}</h2>
|
||||
<LiquidationStrategyInfoPanel market={market} />
|
||||
<h2 className={headerClassName}>{t('Liquidity monitoring')}</h2>
|
||||
<LiquidityMonitoringParametersInfoPanel market={market} />
|
||||
<h2 className={headerClassName}>{t('Liquidity price range')}</h2>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { TableCell, TableRow } from '../../../table';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
import { getExternalChainLabel } from '../../../links/external-explorer-link/external-chain';
|
||||
} from '../../../links/eth-explorer-link/eth-explorer-link';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { defaultAbiCoder, base64 } from 'ethers/lib/utils';
|
||||
import { BigNumber } from 'ethers';
|
||||
@@ -45,10 +44,10 @@ export const TxDetailsContractCall = ({
|
||||
},
|
||||
});
|
||||
|
||||
if (!contractCall) {
|
||||
if (!contractCall || !contractCall.result) {
|
||||
return null;
|
||||
}
|
||||
const chainLabel = getExternalChainLabel(contractCall.sourceChainId);
|
||||
|
||||
return (
|
||||
<>
|
||||
{contractCall.specId && (
|
||||
@@ -65,12 +64,9 @@ export const TxDetailsContractCall = ({
|
||||
)}
|
||||
{contractCall.blockHeight && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('ETH block')}</TableCell>
|
||||
<TableCell>
|
||||
{chainLabel} {t('block')}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
chain={contractCall.sourceChainId}
|
||||
<EthExplorerLink
|
||||
id={contractCall.blockHeight}
|
||||
type={EthExplorerLinkTypes.block}
|
||||
/>
|
||||
@@ -79,24 +75,14 @@ export const TxDetailsContractCall = ({
|
||||
)}
|
||||
{data?.oracleSpec?.dataSourceSpec && (
|
||||
<OracleEthSource
|
||||
chain={contractCall.sourceChainId}
|
||||
sourceType={data.oracleSpec.dataSourceSpec.spec.data.sourceType}
|
||||
/>
|
||||
)}
|
||||
|
||||
{contractCall.error && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Call error')}</TableCell>
|
||||
<TableCell>{contractCall.error}</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
|
||||
{contractCall.result && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Result')}</TableCell>
|
||||
<TableCell>{decodeEthCallResult(contractCall.result)}</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Result')}</TableCell>
|
||||
<TableCell>{decodeEthCallResult(contractCall.result)}</TableCell>
|
||||
</TableRow>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
+3
-3
@@ -3,9 +3,9 @@ import { TableRow, TableCell } from '../../../table';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { AssetLink } from '../../../links';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../../links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface TxDetailsChainEventErc20AssetLimitsUpdatedProps {
|
||||
assetLimitsUpdated: components['schemas']['vegaERC20AssetLimitsUpdated'];
|
||||
@@ -42,7 +42,7 @@ export const TxDetailsChainEventErc20AssetLimitsUpdated = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('ERC20 asset')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={assetLimitsUpdated.sourceEthereumAddress}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -3,9 +3,9 @@ import { TableRow, TableCell } from '../../../table';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { AssetLink } from '../../../links';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../../links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface TxDetailsChainEventErc20AssetListProps {
|
||||
assetList: components['schemas']['vegaERC20AssetList'];
|
||||
@@ -32,7 +32,7 @@ export const TxDetailsChainEventErc20AssetList = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Source')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={assetList.assetSource}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -3,9 +3,9 @@ import { TableRow, TableCell } from '../../../table';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { AssetLink, PartyLink } from '../../../links';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../../links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface TxDetailsChainEventProps {
|
||||
deposit: components['schemas']['vegaERC20Deposit'];
|
||||
@@ -36,7 +36,7 @@ export const TxDetailsChainEventDeposit = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Source')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={deposit.sourceEthereumAddress}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -3,9 +3,9 @@ import { TableRow, TableCell } from '../../../table';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { AssetLink } from '../../../links';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../../links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface TxDetailsChainEventWithdrawalProps {
|
||||
withdrawal: components['schemas']['vegaERC20Withdrawal'];
|
||||
@@ -35,7 +35,7 @@ export const TxDetailsChainEventWithdrawal = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Recipient')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={withdrawal.targetEthereumAddress}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -3,9 +3,9 @@ import { TableRow, TableCell } from '../../../table';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { PartyLink } from '../../../links';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../../links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface TxDetailsChainEventStakeDepositProps {
|
||||
deposit: components['schemas']['vegaStakeDeposited'];
|
||||
@@ -39,7 +39,7 @@ export const TxDetailsChainEventStakeDeposit = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Source')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={deposit.ethereumAddress}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -3,9 +3,9 @@ import { TableRow, TableCell } from '../../../table';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { PartyLink } from '../../../links';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../../links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface TxDetailsChainEventStakeRemoveProps {
|
||||
remove: components['schemas']['vegaStakeRemoved'];
|
||||
@@ -39,7 +39,7 @@ export const TxDetailsChainEventStakeRemove = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Source')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={remove.ethereumAddress}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -3,9 +3,9 @@ import { t } from '@vegaprotocol/i18n';
|
||||
import { TableRow, TableCell } from '../../../table';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../../links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface TxDetailsChainEventStakeTotalSupplyProps {
|
||||
update: components['schemas']['vegaStakeTotalSupply'];
|
||||
@@ -38,7 +38,7 @@ export const TxDetailsChainEventStakeTotalSupply = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Source')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={update.tokenAddress}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -41,7 +41,6 @@ const AccountType: Record<AccountTypes, string> = {
|
||||
ACCOUNT_TYPE_REWARD_RETURN_VOLATILITY: 'Reward Return Volatility',
|
||||
ACCOUNT_TYPE_REWARD_VALIDATOR_RANKING: 'Reward Validator Ranking',
|
||||
ACCOUNT_TYPE_PENDING_FEE_REFERRAL_REWARD: 'Pending Fee Referral Reward',
|
||||
ACCOUNT_TYPE_ORDER_MARGIN: 'Order Margin',
|
||||
};
|
||||
|
||||
interface TransferParticipantsProps {
|
||||
|
||||
@@ -32,7 +32,6 @@ import { TxDetailsCreateReferralSet } from './tx-create-referral-set';
|
||||
import { TxDetailsApplyReferralCode } from './tx-apply-referral-code';
|
||||
import { TxDetailsUpdateReferralSet } from './tx-update-referral-set';
|
||||
import { TxDetailsJoinTeam } from './tx-join-team';
|
||||
import { TxDetailsUpdateMarginMode } from './tx-update-margin-mode';
|
||||
|
||||
interface TxDetailsWrapperProps {
|
||||
txData: BlockExplorerTransactionResult | undefined;
|
||||
@@ -134,8 +133,6 @@ function getTransactionComponent(txData?: BlockExplorerTransactionResult) {
|
||||
return TxDetailsApplyReferralCode;
|
||||
case 'Join Team':
|
||||
return TxDetailsJoinTeam;
|
||||
case 'Update Margin Mode':
|
||||
return TxDetailsUpdateMarginMode;
|
||||
default:
|
||||
return TxDetailsGeneric;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import { TxDetailsShared } from './shared/tx-details-shared';
|
||||
import { TableCell, TableRow, TableWithTbody } from '../../table';
|
||||
import type { components } from '../../../../types/explorer';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../links/eth-explorer-link/eth-explorer-link';
|
||||
import { BlockLink } from '../../links';
|
||||
|
||||
type EthKeyRotate = components['schemas']['v1EthereumKeyRotateSubmission'];
|
||||
@@ -46,7 +46,7 @@ export const TxDetailsEthKeyRotate = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Old Address')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
type={EthExplorerLinkTypes.address}
|
||||
id={k.currentAddress}
|
||||
/>
|
||||
@@ -57,7 +57,7 @@ export const TxDetailsEthKeyRotate = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('New Address')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
type={EthExplorerLinkTypes.address}
|
||||
id={k.newAddress}
|
||||
/>
|
||||
@@ -68,7 +68,7 @@ export const TxDetailsEthKeyRotate = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Submitter address')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
type={EthExplorerLinkTypes.address}
|
||||
id={k.submitterAddress}
|
||||
/>
|
||||
|
||||
@@ -6,9 +6,9 @@ import { TableRow, TableCell, TableWithTbody } from '../../table';
|
||||
|
||||
import type { components } from '../../../../types/explorer';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../links/eth-explorer-link/eth-explorer-link';
|
||||
import { NodeLink } from '../../links';
|
||||
|
||||
type Command = components['schemas']['v1IssueSignatures'];
|
||||
@@ -57,7 +57,7 @@ export const TxDetailsIssueSignatures = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('ETH key')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={cmd.submitter}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -6,9 +6,9 @@ import { TableRow, TableCell, TableWithTbody } from '../../table';
|
||||
|
||||
import type { components } from '../../../../types/explorer';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../links/eth-explorer-link/eth-explorer-link';
|
||||
import { PartyLink } from '../../links';
|
||||
import Hash from '../../links/hash';
|
||||
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||
@@ -72,7 +72,7 @@ export const TxDetailsNodeAnnounce = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Ethereum Address')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
type={EthExplorerLinkTypes.address}
|
||||
id={cmd.ethereumAddress}
|
||||
/>
|
||||
|
||||
@@ -8,9 +8,9 @@ import { useExplorerNodeVoteQuery } from './__generated__/Node-vote';
|
||||
import { PartyLink } from '../../links';
|
||||
import { Time } from '../../time';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface TxDetailsNodeVoteProps {
|
||||
txData: BlockExplorerTransactionResult | undefined;
|
||||
@@ -143,7 +143,7 @@ export function TxHash({ hash }: TxDetailsEthTxHashProps) {
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>Ethereum TX:</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink id={hash} type={EthExplorerLinkTypes.tx} />
|
||||
<EthExplorerLink id={hash} type={EthExplorerLinkTypes.tx} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ import GovernanceAssetBalance from '../../asset-balance/governance-asset-balance
|
||||
import type { components } from '../../../../types/explorer';
|
||||
|
||||
export const methodText: Record<
|
||||
components['schemas']['v1UndelegateSubmissionMethod'],
|
||||
components['schemas']['UndelegateSubmissionMethod'],
|
||||
string
|
||||
> = {
|
||||
METHOD_NOW: 'Immediate',
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import type { BlockExplorerTransactionResult } from '../../../routes/types/block-explorer-response';
|
||||
import type { TendermintBlocksResponse } from '../../../routes/blocks/tendermint-blocks-response';
|
||||
import { TxDetailsShared } from './shared/tx-details-shared';
|
||||
import { TableCell, TableRow, TableWithTbody } from '../../table';
|
||||
import type { components } from '../../../../types/explorer';
|
||||
import { MarketLink } from '../../links';
|
||||
|
||||
interface TxDetailsUpdateMarginModeProps {
|
||||
txData: BlockExplorerTransactionResult | undefined;
|
||||
pubKey: string | undefined;
|
||||
blockData: TendermintBlocksResponse | undefined;
|
||||
}
|
||||
|
||||
type Mode = components['schemas']['UpdateMarginModeMode'];
|
||||
|
||||
const MarginModeLabels: Record<Mode, string> = {
|
||||
MODE_CROSS_MARGIN: t('Cross margin'),
|
||||
MODE_ISOLATED_MARGIN: t('Isolated margin'),
|
||||
MODE_UNSPECIFIED: t('Unspecified'),
|
||||
};
|
||||
|
||||
export const TxDetailsUpdateMarginMode = ({
|
||||
txData,
|
||||
pubKey,
|
||||
blockData,
|
||||
}: TxDetailsUpdateMarginModeProps) => {
|
||||
if (!txData || !txData.command.updateMarginMode) {
|
||||
return <>{t('Awaiting Block Explorer transaction details')}</>;
|
||||
}
|
||||
|
||||
const u: components['schemas']['v1UpdateMarginMode'] =
|
||||
txData.command.updateMarginMode;
|
||||
|
||||
return (
|
||||
<TableWithTbody className="mb-8" allowWrap={true}>
|
||||
<TxDetailsShared txData={txData} pubKey={pubKey} blockData={blockData} />
|
||||
{u.marketId && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Market ID')}</TableCell>
|
||||
<TableCell>
|
||||
<MarketLink id={u.marketId} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{u.mode && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('New margin mode')}</TableCell>
|
||||
<TableCell>{MarginModeLabels[u.mode]}</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
{u.marginFactor && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Margin factor')}</TableCell>
|
||||
<TableCell>{u.marginFactor}</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableWithTbody>
|
||||
);
|
||||
};
|
||||
@@ -4,9 +4,9 @@ import type { TendermintBlocksResponse } from '../../../routes/blocks/tendermint
|
||||
import { TxDetailsShared } from './shared/tx-details-shared';
|
||||
import { TableCell, TableRow, TableWithTbody } from '../../table';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../links/external-explorer-link/external-explorer-link';
|
||||
} from '../../links/eth-explorer-link/eth-explorer-link';
|
||||
import { txSignatureToDeterministicId } from '../lib/deterministic-ids';
|
||||
import AssetBalance from '../../asset-balance/asset-balance';
|
||||
import { useScrollToLocation } from '../../../hooks/scroll-to-location';
|
||||
@@ -57,7 +57,7 @@ export const TxDetailsWithdrawSubmission = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell>{t('Recipient')}</TableCell>
|
||||
<TableCell>
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={w.ext.erc20.receiverAddress}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
|
||||
@@ -44,7 +44,6 @@ export type FilterOption =
|
||||
| 'Transfer Funds'
|
||||
| 'Undelegate'
|
||||
| 'Update Referral Set'
|
||||
| 'Update Margin Mode'
|
||||
| 'Validator Heartbeat'
|
||||
| 'Vote on Proposal'
|
||||
| 'Withdraw';
|
||||
@@ -60,7 +59,6 @@ export const filterOptions: Record<string, FilterOption[]> = {
|
||||
'Stop Orders Submission',
|
||||
'Stop Orders Cancellation',
|
||||
'Submit Order',
|
||||
'Update Margin Mode',
|
||||
],
|
||||
'Transfers and Withdrawals': [
|
||||
'Transfer Funds',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import type { components } from '../../../types/explorer';
|
||||
import { VoteIcon } from '../vote-icon/vote-icon';
|
||||
import { ExternalChainIcon } from '../links/external-explorer-link/external-chain-icon';
|
||||
|
||||
interface TxOrderTypeProps {
|
||||
orderType: string;
|
||||
@@ -189,9 +188,6 @@ export function getLabelForChainEvent(
|
||||
}
|
||||
return t('Multisig update');
|
||||
} else if (chainEvent.contractCall) {
|
||||
if (chainEvent.contractCall.error) {
|
||||
return t('Call error');
|
||||
}
|
||||
return t('Contract call');
|
||||
}
|
||||
return t('Chain Event');
|
||||
@@ -261,11 +257,6 @@ export const TxOrderType = ({ orderType, command }: TxOrderTypeProps) => {
|
||||
data-testid="tx-type"
|
||||
className={`text-sm rounded-md leading-tight px-2 inline-block whitespace-nowrap ${colours}`}
|
||||
>
|
||||
{command?.chainEvent && (
|
||||
<ExternalChainIcon
|
||||
chainId={command?.chainEvent?.contractCall?.sourceChainId}
|
||||
/>
|
||||
)}
|
||||
{type}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ export const ENV = {
|
||||
blockExplorerUrl: windowOrDefault('NX_BLOCK_EXPLORER'),
|
||||
tendermintUrl: windowOrDefault('NX_TENDERMINT_URL'),
|
||||
tendermintWebsocketUrl: windowOrDefault('NX_TENDERMINT_WEBSOCKET_URL'),
|
||||
ethExplorerUrl: windowOrDefault('NX_ETHERSCAN_URL'),
|
||||
governanceUrl: windowOrDefault('NX_VEGA_GOVERNANCE_URL'),
|
||||
vegaRepoUrl: windowOrDefault('NX_VEGA_REPO_URL'),
|
||||
},
|
||||
|
||||
@@ -78,7 +78,6 @@ fragment ExplorerOracleDataSource on OracleSpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceChainId
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
@@ -119,7 +118,6 @@ fragment ExplorerOracleDataSource on OracleSpec {
|
||||
address
|
||||
requiredConfirmations
|
||||
method
|
||||
sourceChainId
|
||||
filters {
|
||||
key {
|
||||
type
|
||||
|
||||
@@ -67,7 +67,6 @@ fragment ExplorerOracleDataSourceSpec on ExternalDataSourceSpec {
|
||||
sourceType {
|
||||
... on EthCallSpec {
|
||||
address
|
||||
sourceChainId
|
||||
}
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
|
||||
@@ -5,19 +5,19 @@ import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type ExplorerOracleDataConnectionFragment = { __typename?: 'OracleSpec', dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } };
|
||||
|
||||
export type ExplorerOracleDataSourceFragment = { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array<string> | null, args?: Array<string> | null, method: string, requiredConfirmations: number, address: string, sourceChainId: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } };
|
||||
export type ExplorerOracleDataSourceFragment = { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array<string> | null, args?: Array<string> | null, method: string, requiredConfirmations: number, address: string, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } };
|
||||
|
||||
export type ExplorerOracleSpecsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type ExplorerOracleSpecsQuery = { __typename?: 'Query', oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array<string> | null, args?: Array<string> | null, method: string, requiredConfirmations: number, address: string, sourceChainId: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null };
|
||||
export type ExplorerOracleSpecsQuery = { __typename?: 'Query', oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array<string> | null, args?: Array<string> | null, method: string, requiredConfirmations: number, address: string, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null };
|
||||
|
||||
export type ExplorerOracleSpecByIdQueryVariables = Types.Exact<{
|
||||
id: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type ExplorerOracleSpecByIdQuery = { __typename?: 'Query', oracleSpec?: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array<string> | null, args?: Array<string> | null, method: string, requiredConfirmations: number, address: string, sourceChainId: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } | null };
|
||||
export type ExplorerOracleSpecByIdQuery = { __typename?: 'Query', oracleSpec?: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array<string> | null, args?: Array<string> | null, method: string, requiredConfirmations: number, address: string, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array<string> | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } | null };
|
||||
|
||||
export const ExplorerOracleDataConnectionFragmentDoc = gql`
|
||||
fragment ExplorerOracleDataConnection on OracleSpec {
|
||||
@@ -101,7 +101,6 @@ export const ExplorerOracleDataSourceFragmentDoc = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceChainId
|
||||
filters {
|
||||
key {
|
||||
name
|
||||
@@ -142,7 +141,6 @@ export const ExplorerOracleDataSourceFragmentDoc = gql`
|
||||
address
|
||||
requiredConfirmations
|
||||
method
|
||||
sourceChainId
|
||||
filters {
|
||||
key {
|
||||
type
|
||||
|
||||
@@ -9,12 +9,12 @@ export type ExplorerOracleFutureFragment = { __typename?: 'Future', dataSourceSp
|
||||
|
||||
export type ExplorerOracleForMarketsMarketFragment = { __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Perpetual', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Spot' } } } };
|
||||
|
||||
export type ExplorerOracleDataSourceSpecFragment = { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } | { __typename?: 'EthCallSpec', address: string, sourceChainId: number } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } };
|
||||
export type ExplorerOracleDataSourceSpecFragment = { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } | { __typename?: 'EthCallSpec', address: string } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } };
|
||||
|
||||
export type ExplorerOracleFormMarketsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type ExplorerOracleFormMarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Perpetual', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Spot' } } } } }> } | null, oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } | { __typename?: 'EthCallSpec', address: string, sourceChainId: number } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null };
|
||||
export type ExplorerOracleFormMarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Perpetual', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Spot' } } } } }> } | null, oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } | { __typename?: 'EthCallSpec', address: string } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null };
|
||||
|
||||
export const ExplorerOracleFutureFragmentDoc = gql`
|
||||
fragment ExplorerOracleFuture on Future {
|
||||
@@ -90,7 +90,6 @@ export const ExplorerOracleDataSourceSpecFragmentDoc = gql`
|
||||
sourceType {
|
||||
... on EthCallSpec {
|
||||
address
|
||||
sourceChainId
|
||||
}
|
||||
... on DataSourceSpecConfiguration {
|
||||
signers {
|
||||
|
||||
@@ -28,7 +28,7 @@ export function isInternalSourceType(s: SourceType) {
|
||||
|
||||
export function getExternalType(s: SourceType) {
|
||||
if (s.sourceType.__typename === 'EthCallSpec') {
|
||||
return 'Contract Call';
|
||||
return 'Ethereum Contract Call';
|
||||
} else {
|
||||
return 'External Data';
|
||||
}
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
import { TableRow, TableCell, TableHeader } from '../../../components/table';
|
||||
import type { SourceType } from './oracle';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../components/links/external-explorer-link/external-explorer-link';
|
||||
import { getExternalChainLabel } from '../../../components/links/external-explorer-link/external-chain';
|
||||
import { t } from 'i18next';
|
||||
} from '../../../components/links/eth-explorer-link/eth-explorer-link';
|
||||
|
||||
interface OracleDetailsEthSourceProps {
|
||||
sourceType: SourceType;
|
||||
chain?: string;
|
||||
}
|
||||
/**
|
||||
* Given an Oracle that sources data from Ethereum, this component will render
|
||||
* a link to the smart contract and some basic details
|
||||
*/
|
||||
export function OracleEthSource({
|
||||
sourceType,
|
||||
chain = '1',
|
||||
}: OracleDetailsEthSourceProps) {
|
||||
export function OracleEthSource({ sourceType }: OracleDetailsEthSourceProps) {
|
||||
if (
|
||||
sourceType.__typename !== 'DataSourceDefinitionExternal' ||
|
||||
sourceType.sourceType.__typename !== 'EthCallSpec'
|
||||
@@ -32,20 +26,11 @@ export function OracleEthSource({
|
||||
return null;
|
||||
}
|
||||
|
||||
const chainLabel = getExternalChainLabel(chain);
|
||||
|
||||
return (
|
||||
<TableRow modifier="bordered">
|
||||
<TableHeader scope="row">
|
||||
{chainLabel} {t('Contract')}
|
||||
</TableHeader>
|
||||
<TableHeader scope="row">Ethereum Contract</TableHeader>
|
||||
<TableCell modifier="bordered">
|
||||
<ExternalExplorerLink
|
||||
chain={chain}
|
||||
id={address}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
code={true}
|
||||
/>
|
||||
<EthExplorerLink id={address} type={EthExplorerLinkTypes.address} />
|
||||
<span className="mx-3">⇒</span>
|
||||
<code>{sourceType.sourceType.method}</code>
|
||||
</TableCell>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { PartyLink } from '../../../components/links';
|
||||
import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../components/links/external-explorer-link/external-explorer-link';
|
||||
} from '../../../components/links/eth-explorer-link/eth-explorer-link';
|
||||
import { TableRow, TableCell, TableHeader } from '../../../components/table';
|
||||
import { remove0x } from '@vegaprotocol/utils';
|
||||
|
||||
@@ -37,15 +37,13 @@ export function getAddressLink(signer: Signer) {
|
||||
}
|
||||
|
||||
if (signer.__typename === 'ETHAddress') {
|
||||
return (
|
||||
<ExternalExplorerLink id={address} type={EthExplorerLinkTypes.address} />
|
||||
);
|
||||
return <EthExplorerLink id={address} type={EthExplorerLinkTypes.address} />;
|
||||
} else if (signer.__typename === 'PubKey' && address.length !== 64) {
|
||||
// This is a hack: some older oracles were submitted before proper checks stopped
|
||||
// ETH addresses being returned as Vega addresses
|
||||
// Hacky 0x prefixing as a bonus
|
||||
return (
|
||||
<ExternalExplorerLink
|
||||
<EthExplorerLink
|
||||
id={`0x${remove0x(address)}`}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
/>
|
||||
@@ -63,10 +61,7 @@ interface OracleDetailsSignersProps {
|
||||
|
||||
/**
|
||||
* Given an Oracle, this component will render either a link to Ethereum
|
||||
* or the Vega party depending on which type is specified.
|
||||
*
|
||||
* Note that this won't be shown for external contract calls as they do not
|
||||
* have a signer in the same way.
|
||||
* or the Vega party depending on which type is specified
|
||||
*/
|
||||
export function OracleSigners({ sourceType }: OracleDetailsSignersProps) {
|
||||
if (sourceType.__typename !== 'DataSourceDefinitionExternal') {
|
||||
|
||||
@@ -42,11 +42,6 @@ export const OracleDetails = ({
|
||||
dataConnection,
|
||||
}: OracleDetailsProps) => {
|
||||
const sourceType = dataSource.dataSourceSpec.spec.data.sourceType;
|
||||
const chain =
|
||||
dataSource.dataSourceSpec.spec.data.sourceType.sourceType.__typename ===
|
||||
'EthCallSpec'
|
||||
? dataSource.dataSourceSpec.spec.data.sourceType.sourceType.sourceChainId.toString()
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -65,7 +60,7 @@ export const OracleDetails = ({
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<OracleSigners sourceType={sourceType} />
|
||||
<OracleEthSource sourceType={sourceType} chain={chain} />
|
||||
<OracleEthSource sourceType={sourceType} />
|
||||
<OracleMarkets id={id} />
|
||||
<TableRow modifier="bordered">
|
||||
<TableHeader scope="row">{t('Filter')}</TableHeader>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns:xodm="http://www.corel.com/coreldraw/odm/2003" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 2500 2500" style="enable-background:new 0 0 2500 2500;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:none;}
|
||||
.st1{fill:#213147;}
|
||||
.st2{fill:#12AAFF;}
|
||||
.st3{fill:#9DCCED;}
|
||||
.st4{fill:#FFFFFF;}
|
||||
</style>
|
||||
<g id="Layer_x0020_1">
|
||||
<g id="_2405588477232">
|
||||
<rect class="st0" width="2500" height="2500"></rect>
|
||||
<g>
|
||||
<g>
|
||||
<path class="st1" d="M226,760v980c0,63,33,120,88,152l849,490c54,31,121,31,175,0l849-490c54-31,88-89,88-152V760 c0-63-33-120-88-152l-849-490c-54-31-121-31-175,0L314,608c-54,31-87,89-87,152H226z"></path>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<path class="st2" d="M1435,1440l-121,332c-3,9-3,19,0,29l208,571l241-139l-289-793C1467,1422,1442,1422,1435,1440z"></path>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st2" d="M1678,882c-7-18-32-18-39,0l-121,332c-3,9-3,19,0,29l341,935l241-139L1678,883V882z"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st3" d="M1250,155c6,0,12,2,17,5l918,530c11,6,17,18,17,30v1060c0,12-7,24-17,30l-918,530c-5,3-11,5-17,5 s-12-2-17-5l-918-530c-11-6-17-18-17-30V719c0-12,7-24,17-30l918-530c5-3,11-5,17-5l0,0V155z M1250,0c-33,0-65,8-95,25L237,555 c-59,34-95,96-95,164v1060c0,68,36,130,95,164l918,530c29,17,62,25,95,25s65-8,95-25l918-530c59-34,95-96,95-164V719 c0-68-36-130-95-164L1344,25c-29-17-62-25-95-25l0,0H1250z"></path>
|
||||
</g>
|
||||
<polygon class="st1" points="642,2179 727,1947 897,2088 738,2234 "></polygon>
|
||||
<g>
|
||||
<path class="st4" d="M1172,644H939c-17,0-33,11-39,27L401,2039l241,139l550-1507c5-14-5-28-19-28L1172,644z"></path>
|
||||
<path class="st4" d="M1580,644h-233c-17,0-33,11-39,27L738,2233l241,139l620-1701c5-14-5-28-19-28V644z"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.9 KiB |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><g fill="none" fill-rule="evenodd"><circle cx="16" cy="16" r="16" fill="#136485"/><path fill="#FFF" d="M10.436 31.006a16.008 16.008 0 0 1-5.604-3.548l.147-.257c2.388-3.773 4.533-7.678 6.148-11.85 1.713-4.425 3.084-8.967 4.39-13.527.117-.407.256-.807.384-1.21.138.158.188.305.23.454.82 2.926 1.613 5.86 2.464 8.776 1.55 5.313 3.73 10.353 6.617 15.077.337.55.91 1.472 1.72 2.762a15.988 15.988 0 0 1-6.035 3.554 4320.193 4320.193 0 0 0-5.002-15.17l-.154-.002c-1.166 3.277-2.934 8.257-5.305 14.941zM16.075.049h-.124L16 0l.075.049z"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 622 B |
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Creator: CorelDRAW 2019 (64-Bit) -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="100%" height="100%" version="1.1" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd"
|
||||
viewBox="0 0 784.37 1277.39"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xodm="http://www.corel.com/coreldraw/odm/2003">
|
||||
<g id="Layer_x0020_1">
|
||||
<metadata id="CorelCorpID_0Corel-Layer"/>
|
||||
<g id="_1421394342400">
|
||||
<g>
|
||||
<polygon fill="#343434" fill-rule="nonzero" points="392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 "/>
|
||||
<polygon fill="#8C8C8C" fill-rule="nonzero" points="392.07,0 -0,650.54 392.07,882.29 392.07,472.33 "/>
|
||||
<polygon fill="#3C3C3B" fill-rule="nonzero" points="392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 "/>
|
||||
<polygon fill="#8C8C8C" fill-rule="nonzero" points="392.07,1277.38 392.07,956.52 -0,724.89 "/>
|
||||
<polygon fill="#141414" fill-rule="nonzero" points="392.07,882.29 784.13,650.54 392.07,472.33 "/>
|
||||
<polygon fill="#393939" fill-rule="nonzero" points="0,650.54 392.07,882.29 392.07,472.33 "/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 26.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 428 428" style="enable-background:new 0 0 428 428;" xml:space="preserve">
|
||||
<path style="fill:#00193C;" d="M125.8,243.7c12.3,0,24.3-4.1,34-11.6l-78-78c-18.8,24.3-14.3,59.3,10,78.1
|
||||
C101.6,239.6,113.5,243.7,125.8,243.7L125.8,243.7z"/>
|
||||
<path style="fill:#00193C;" d="M357.8,188c0-12.3-4.1-24.3-11.6-34l-78,78c24.3,18.8,59.2,14.3,78-10
|
||||
C353.7,212.3,357.8,200.3,357.8,188z"/>
|
||||
<path style="fill:#00193C;" d="M397.1,103.1l-34.5,34.5c27.8,33.3,23.4,82.9-9.9,110.7c-29.2,24.4-71.6,24.4-100.8,0L214,286.2
|
||||
l-37.8-37.8c-33.3,27.8-82.9,23.4-110.7-9.9c-24.4-29.2-24.4-71.6,0-100.8L47.8,120L31,103.1C10.7,136.5,0,174.9,0,214
|
||||
c0,118.2,95.8,214,214,214s214-95.8,214-214C428.1,174.9,417.3,136.5,397.1,103.1z"/>
|
||||
<path style="fill:#00193C;" d="M368.8,66.3c-81.5-85.5-216.9-88.7-302.4-7.2c-2.5,2.4-4.9,4.8-7.2,7.2c-5.3,5.6-10.3,11.4-15,17.5
|
||||
L214,253.7L383.8,83.8C379.2,77.7,374.1,71.9,368.8,66.3z M214,28c50,0,96.6,19.3,131.6,54.5L214,214.1L82.4,82.5
|
||||
C117.4,47.3,164,28,214,28z"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
+33
-317
@@ -28,7 +28,7 @@ export interface paths {
|
||||
'/transactions': {
|
||||
/**
|
||||
* List transactions
|
||||
* @description List transactions from the Vega blockchain from the newest to the oldest transactions.
|
||||
* @description List transactions from the Vega blockchain
|
||||
*/
|
||||
get: operations['BlockExplorer_ListTransactions'];
|
||||
};
|
||||
@@ -117,31 +117,15 @@ export interface components {
|
||||
| 'EXPIRY_STRATEGY_CANCELS'
|
||||
| 'EXPIRY_STRATEGY_SUBMIT';
|
||||
/**
|
||||
* - SIZE_OVERRIDE_SETTING_UNSPECIFIED: Never valid
|
||||
* - SIZE_OVERRIDE_SETTING_NONE: No override, the size within the contained normal order submission will be used
|
||||
* - SIZE_OVERRIDE_SETTING_POSITION: Use the total position of the trader
|
||||
* @default SIZE_OVERRIDE_SETTING_UNSPECIFIED
|
||||
* @description - METHOD_NOW: Undelegate straight away, losing all rewards for the current epoch.
|
||||
* - METHOD_AT_END_OF_EPOCH: Undelegate at the end of an epoch, retaining all rewards for the current epoch.
|
||||
* @default METHOD_UNSPECIFIED
|
||||
* @enum {string}
|
||||
*/
|
||||
readonly StopOrderSizeOverrideSetting:
|
||||
| 'SIZE_OVERRIDE_SETTING_UNSPECIFIED'
|
||||
| 'SIZE_OVERRIDE_SETTING_NONE'
|
||||
| 'SIZE_OVERRIDE_SETTING_POSITION';
|
||||
readonly StopOrderSizeOverrideValue: {
|
||||
/** Scaling percentage of the current position’s size */
|
||||
readonly percentage?: string;
|
||||
};
|
||||
/**
|
||||
* - MODE_UNSPECIFIED: Never valid.
|
||||
* - MODE_CROSS_MARGIN: Cross margin mode - margin is dynamically acquired and released as a position is marked to market
|
||||
* - MODE_ISOLATED_MARGIN: Isolated margin mode - margin for any newly opened position volume is transferred to the margin account when the trade is executed
|
||||
* @default MODE_UNSPECIFIED
|
||||
* @enum {string}
|
||||
*/
|
||||
readonly UpdateMarginModeMode:
|
||||
| 'MODE_UNSPECIFIED'
|
||||
| 'MODE_CROSS_MARGIN'
|
||||
| 'MODE_ISOLATED_MARGIN';
|
||||
readonly UndelegateSubmissionMethod:
|
||||
| 'METHOD_UNSPECIFIED'
|
||||
| 'METHOD_NOW'
|
||||
| 'METHOD_AT_END_OF_EPOCH';
|
||||
readonly blockexplorerapiv1Transaction: {
|
||||
/**
|
||||
* Height of the block the transaction was found in
|
||||
@@ -323,30 +307,6 @@ export interface components {
|
||||
readonly stopOrdersSubmission?: readonly components['schemas']['v1StopOrdersSubmission'][];
|
||||
/** @description List of order submissions to be processed sequentially. */
|
||||
readonly submissions?: readonly components['schemas']['v1OrderSubmission'][];
|
||||
/** Update margin mode instruction */
|
||||
readonly updateMarginMode?: readonly components['schemas']['v1UpdateMarginMode'][];
|
||||
};
|
||||
/**
|
||||
* @description Command that allows a token holder to submit a batch governance proposal that can be voted on by any other token holders, and eventually enacted on the Vega network.
|
||||
* For example this command can be used to propose a new market and a network parameter change with it.
|
||||
*/
|
||||
readonly v1BatchProposalSubmission: {
|
||||
/** @description Rationale behind a proposal. */
|
||||
readonly rationale?: components['schemas']['vegaProposalRationale'];
|
||||
/** @description Arbitrary human-readable reference identifying the proposal. */
|
||||
readonly reference?: string;
|
||||
/** @description Proposal terms containing the type and details of the proposal, as well as time spans for voting and enactment. */
|
||||
readonly terms?: components['schemas']['v1BatchProposalSubmissionTerms'];
|
||||
};
|
||||
/** Terms for a batch governance proposal submission */
|
||||
readonly v1BatchProposalSubmissionTerms: {
|
||||
/** @description List of individual changes included in the batch proposal. */
|
||||
readonly changes?: readonly components['schemas']['vegaBatchProposalTermsChange'][];
|
||||
/**
|
||||
* Format: int64
|
||||
* @description Closing timestamp in Unix time; adheres to `minClose` and `maxClose` limits.
|
||||
*/
|
||||
readonly closingTimestamp?: string;
|
||||
};
|
||||
/** @description A validator command sent automatically that provides information of events that have happened on foreign chains. */
|
||||
readonly v1ChainEvent: {
|
||||
@@ -387,12 +347,6 @@ export interface components {
|
||||
readonly team?: components['schemas']['v1CreateReferralSetTeam'];
|
||||
};
|
||||
readonly v1CreateReferralSetTeam: {
|
||||
/**
|
||||
* @description List of public keys that are allowed to join the team.
|
||||
* Only applicable to closed teams. Removing a party from the allow list does not remove
|
||||
* the party from the team.
|
||||
*/
|
||||
readonly allowList?: readonly string[];
|
||||
/** @description External link to an avatar for the team. */
|
||||
readonly avatarUrl?: string;
|
||||
/** @description Whether or not the team is closed to new party members. */
|
||||
@@ -478,8 +432,6 @@ export interface components {
|
||||
readonly applyReferralCode?: components['schemas']['v1ApplyReferralCode'];
|
||||
/** @description Command to submit a batch of order instructions. */
|
||||
readonly batchMarketInstructions?: components['schemas']['v1BatchMarketInstructions'];
|
||||
/** @description Command to submit a batch governance proposal. */
|
||||
readonly batchProposalSubmission?: components['schemas']['v1BatchProposalSubmission'];
|
||||
/**
|
||||
* Format: uint64
|
||||
* @description Block height which has been used to calculate the transaction proof-of-work.
|
||||
@@ -497,8 +449,6 @@ export interface components {
|
||||
readonly ethereumKeyRotateSubmission?: components['schemas']['v1EthereumKeyRotateSubmission'];
|
||||
/** @description Command to request signatures to amend the multisig-control contract. */
|
||||
readonly issueSignatures?: components['schemas']['v1IssueSignatures'];
|
||||
/** @description Command to join a team. */
|
||||
readonly joinTeam?: components['schemas']['v1JoinTeam'];
|
||||
/** @description Validator command sent manually by a node operator to rotate their node's Vega keys. */
|
||||
readonly keyRotateSubmission?: components['schemas']['v1KeyRotateSubmission'];
|
||||
/** @description Command to amend a liquidity commitment. */
|
||||
@@ -539,10 +489,6 @@ export interface components {
|
||||
readonly transfer?: components['schemas']['commandsv1Transfer'];
|
||||
/** @description Command to remove tokens delegated to a validator. */
|
||||
readonly undelegateSubmission?: components['schemas']['v1UndelegateSubmission'];
|
||||
/** @description Command to update the margin mode of a party in a market. */
|
||||
readonly updateMarginMode?: components['schemas']['v1UpdateMarginMode'];
|
||||
/** @description Command to update a party's profile. */
|
||||
readonly updatePartyProfile?: components['schemas']['v1UpdatePartyProfile'];
|
||||
/** @description Command to update a referral set. */
|
||||
readonly updateReferralSet?: components['schemas']['v1UpdateReferralSet'];
|
||||
/** @description Validator command sent automatically to signal regular participation in the network. */
|
||||
@@ -579,11 +525,6 @@ export interface components {
|
||||
/** @description Node ID of the validator node that will be signed in or out of the smart contract. */
|
||||
readonly validatorNodeId?: string;
|
||||
};
|
||||
/** @description Command that allows the submitter to join a team or change teams if they are already a member of a team. */
|
||||
readonly v1JoinTeam: {
|
||||
/** @description ID of the team to join, this is the same as the referral code used to generate the team. */
|
||||
readonly id?: string;
|
||||
};
|
||||
/** @description A validator command sent manually that allows a node operator to indicate to the network that their node's Vega key will be rotated. */
|
||||
readonly v1KeyRotateSubmission: {
|
||||
/** @description Hash of the node's current Vega public key. */
|
||||
@@ -745,17 +686,6 @@ export interface components {
|
||||
readonly peggedReference?: components['schemas']['vegaPeggedReference'];
|
||||
/** @description New price for the order. This field is an unsigned integer scaled to the market's decimal places. */
|
||||
readonly price?: string;
|
||||
/**
|
||||
* Format: uint64
|
||||
* @description New size for the order.
|
||||
* Amending the size causes the size and remaining part of the order to be changed by the difference between the original and amended size.
|
||||
* - Specifying a size smaller than the current size leaves the order at its current order book position.
|
||||
* - Specifying a size larger than the current size removes and reinserts the order at the back of the price level.
|
||||
* - Specifying a size that results in the remaining part of the order being reduced to zero cancels the order.
|
||||
* This field is an unsigned integer scaled to the market's decimal places.
|
||||
* If specified, size_delta must be set to 0.
|
||||
*/
|
||||
readonly size?: string;
|
||||
/**
|
||||
* Format: int64
|
||||
* @description Amend the size for the order by the delta specified:
|
||||
@@ -763,7 +693,6 @@ export interface components {
|
||||
* - To increase the size from the current value, set a positive integer value
|
||||
* - To leave the size unchanged set a value of zero
|
||||
* This field needs to be scaled using the market's position decimal places.
|
||||
* If specified, size must not be set.
|
||||
*/
|
||||
readonly sizeDelta?: string;
|
||||
/** @description New time in force for the order. */
|
||||
@@ -934,10 +863,6 @@ export interface components {
|
||||
readonly orderSubmission?: components['schemas']['v1OrderSubmission'];
|
||||
/** @description Order will be submitted if the last traded price on the market breaches the given price. */
|
||||
readonly price?: string;
|
||||
/** Indicates if this order is linked to an order or position to derive the order size */
|
||||
readonly sizeOverrideSetting?: components['schemas']['StopOrderSizeOverrideSetting'];
|
||||
/** If this order is linked to a position, provide an optional scaling factor */
|
||||
readonly sizeOverrideValue?: components['schemas']['StopOrderSizeOverrideValue'];
|
||||
/** @description Order will be submitted if the last traded price has moved the given percent from the highest/lowest mark price since the stop order was submitted. */
|
||||
readonly trailingPercentOffset?: string;
|
||||
};
|
||||
@@ -984,42 +909,10 @@ export interface components {
|
||||
*/
|
||||
readonly amount?: string;
|
||||
/** @description Method of delegation. */
|
||||
readonly method?: components['schemas']['v1UndelegateSubmissionMethod'];
|
||||
readonly method?: components['schemas']['UndelegateSubmissionMethod'];
|
||||
/** @description Node ID to undelegate stake from. */
|
||||
readonly nodeId?: string;
|
||||
};
|
||||
/**
|
||||
* @description - METHOD_NOW: Undelegate straight away, losing all rewards for the current epoch.
|
||||
* - METHOD_AT_END_OF_EPOCH: Undelegate at the end of an epoch, retaining all rewards for the current epoch.
|
||||
* @default METHOD_UNSPECIFIED
|
||||
* @enum {string}
|
||||
*/
|
||||
readonly v1UndelegateSubmissionMethod:
|
||||
| 'METHOD_UNSPECIFIED'
|
||||
| 'METHOD_NOW'
|
||||
| 'METHOD_AT_END_OF_EPOCH';
|
||||
readonly v1UpdateMarginMode: {
|
||||
/** Margin factor to use for margin in isolated mode. It is a multiplier that defines how much margin needs to be set aside */
|
||||
readonly marginFactor?: string;
|
||||
/** @description Market to change margin mode for. */
|
||||
readonly marketId?: string;
|
||||
/** @description Margin mode to use. */
|
||||
readonly mode?: components['schemas']['UpdateMarginModeMode'];
|
||||
};
|
||||
/**
|
||||
* @description Command to associate metadata to a public key, known as a party ID.
|
||||
* Partial update is not supported, meaning previous values must be included in
|
||||
* the update, otherwise they are removed.
|
||||
*/
|
||||
readonly v1UpdatePartyProfile: {
|
||||
/** @description Alias given to the party. It must be unique network-wide. */
|
||||
readonly alias?: string;
|
||||
/**
|
||||
* @description Freeform data to associate to the party.
|
||||
* Support a maximum of 10 entries.
|
||||
*/
|
||||
readonly metadata?: readonly components['schemas']['vegaMetadata'][];
|
||||
};
|
||||
/**
|
||||
* @description A command that allows the referrer of a referral set to update team details for a referral set.
|
||||
* Any field that is left unset or has a default value indicates that this field on the original referral set will be left unchanged.
|
||||
@@ -1033,18 +926,9 @@ export interface components {
|
||||
readonly team?: components['schemas']['v1UpdateReferralSetTeam'];
|
||||
};
|
||||
readonly v1UpdateReferralSetTeam: {
|
||||
/**
|
||||
* @description List of public keys that are allowed to join the team.
|
||||
* Only applicable to closed teams. Removing a party from the allow list does not remove
|
||||
* the party from the team.
|
||||
*/
|
||||
readonly allowList?: readonly string[];
|
||||
/** @description New link to an avatar for the team. */
|
||||
readonly avatarUrl?: string;
|
||||
/**
|
||||
* @description Whether or not the team is closed to new party members. When closed, only parties specified in the allow list can
|
||||
* join the team.
|
||||
*/
|
||||
/** @description Whether or not the team is closed to new party members. */
|
||||
readonly closed?: boolean;
|
||||
/** @description New name of the team. */
|
||||
readonly name?: string;
|
||||
@@ -1130,7 +1014,6 @@ export interface components {
|
||||
* - ACCOUNT_TYPE_REWARD_RETURN_VOLATILITY: Per asset market reward account given for return volatility
|
||||
* - ACCOUNT_TYPE_REWARD_VALIDATOR_RANKING: Per asset market reward account given to validators by their ranking
|
||||
* - ACCOUNT_TYPE_PENDING_FEE_REFERRAL_REWARD: Per asset account for pending fee referral reward payouts
|
||||
* - ACCOUNT_TYPE_ORDER_MARGIN: Per asset market account for party in isolated margin mode
|
||||
* @default ACCOUNT_TYPE_UNSPECIFIED
|
||||
* @enum {string}
|
||||
*/
|
||||
@@ -1162,8 +1045,7 @@ export interface components {
|
||||
| 'ACCOUNT_TYPE_REWARD_RELATIVE_RETURN'
|
||||
| 'ACCOUNT_TYPE_REWARD_RETURN_VOLATILITY'
|
||||
| 'ACCOUNT_TYPE_REWARD_VALIDATOR_RANKING'
|
||||
| 'ACCOUNT_TYPE_PENDING_FEE_REFERRAL_REWARD'
|
||||
| 'ACCOUNT_TYPE_ORDER_MARGIN';
|
||||
| 'ACCOUNT_TYPE_PENDING_FEE_REFERRAL_REWARD';
|
||||
/** Vega representation of an external asset */
|
||||
readonly vegaAssetDetails: {
|
||||
/** @description Vega built-in asset. */
|
||||
@@ -1189,42 +1071,6 @@ export interface components {
|
||||
/** @description Minimum economically meaningful amount in the asset. */
|
||||
readonly quantum?: string;
|
||||
};
|
||||
/** Terms change for a batch governance proposal */
|
||||
readonly vegaBatchProposalTermsChange: {
|
||||
/** @description Proposal change to cancel a governance initiated transfe. */
|
||||
readonly cancelTransfer?: components['schemas']['vegaCancelTransfer'];
|
||||
/**
|
||||
* Format: int64
|
||||
* @description Timestamp as Unix time in seconds when proposal terms gets enacted if proposal passed the vote,
|
||||
* constrained by `minEnact` and `maxEnact` network parameters.
|
||||
*/
|
||||
readonly enactmentTimestamp?: string;
|
||||
/**
|
||||
* @description Proposal change for a freeform request, which can be voted on but does not change the behaviour of the system,
|
||||
* and can be used to gauge community sentiment.
|
||||
*/
|
||||
readonly newFreeform?: components['schemas']['vegaNewFreeform'];
|
||||
/** @description Proposal change for creating new futures market. */
|
||||
readonly newMarket?: components['schemas']['vegaNewMarket'];
|
||||
/** @description Proposal change for creating new spot market. */
|
||||
readonly newSpotMarket?: components['schemas']['vegaNewSpotMarket'];
|
||||
/** @description Proposal change for a governance initiated transfer. */
|
||||
readonly newTransfer?: components['schemas']['vegaNewTransfer'];
|
||||
/** @description Proposal change for updating an asset. */
|
||||
readonly updateAsset?: components['schemas']['vegaUpdateAsset'];
|
||||
/** @description Proposal change for modifying an existing futures market. */
|
||||
readonly updateMarket?: components['schemas']['vegaUpdateMarket'];
|
||||
/** @description Proposal change for updating the state of a market. */
|
||||
readonly updateMarketState?: components['schemas']['vegaUpdateMarketState'];
|
||||
/** @description Proposal change for updating Vega network parameters. */
|
||||
readonly updateNetworkParameter?: components['schemas']['vegaUpdateNetworkParameter'];
|
||||
/** @description Proposal change for updating the referral program. */
|
||||
readonly updateReferralProgram?: components['schemas']['vegaUpdateReferralProgram'];
|
||||
/** @description Proposal change for modifying an existing spot market. */
|
||||
readonly updateSpotMarket?: components['schemas']['vegaUpdateSpotMarket'];
|
||||
/** @description Proposal change for updating the volume discount program. */
|
||||
readonly updateVolumeDiscountProgram?: components['schemas']['vegaUpdateVolumeDiscountProgram'];
|
||||
};
|
||||
readonly vegaBenefitTier: {
|
||||
/**
|
||||
* @description Required number of epochs a party must have been in a referral set to
|
||||
@@ -1279,44 +1125,6 @@ export interface components {
|
||||
/** @description ID of the governance transfer proposal. */
|
||||
readonly transferId?: string;
|
||||
};
|
||||
/** @description Mark price configuration parameters. */
|
||||
readonly vegaCompositePriceConfiguration: {
|
||||
/** @description Cash amount, in asset decimals, used for the calculation of the mark price from the order book. */
|
||||
readonly cashAmount?: string;
|
||||
/** @description Which method is used for the calculation of the composite price for the market. */
|
||||
readonly compositePriceType?: components['schemas']['vegaCompositePriceType'];
|
||||
/** @description Additional price sources to be used for index price calculation. */
|
||||
readonly dataSourcesSpec?: readonly components['schemas']['vegaDataSourceDefinition'][];
|
||||
/** List of each price source and its corresponding binding */
|
||||
readonly dataSourcesSpecBinding?: readonly components['schemas']['vegaSpecBindingForCompositePrice'][];
|
||||
/**
|
||||
* Format: uint64
|
||||
* @description Decay power used for the calculation of mark price.
|
||||
*/
|
||||
readonly decayPower?: string;
|
||||
/** @description Decay weight used for calculation of mark price. */
|
||||
readonly decayWeight?: string;
|
||||
/**
|
||||
* @description For how long a price source is considered valid. One entry for each data source
|
||||
* such that the first is for the trade based mark price, the second is for the book based price
|
||||
* the third is for the first oracle, followed by more oracle data source staleness tolerance.
|
||||
*/
|
||||
readonly sourceStalenessTolerance?: readonly string[];
|
||||
/** @description Weights for each composite price data source. */
|
||||
readonly sourceWeights?: readonly string[];
|
||||
};
|
||||
/**
|
||||
* @description - COMPOSITE_PRICE_TYPE_WEIGHTED: Composite price is calculated as a weighted average of the underlying mark prices.
|
||||
* - COMPOSITE_PRICE_TYPE_MEDIAN: Composite price is calculated as a median of the underlying mark prices.
|
||||
* - COMPOSITE_PRICE_TYPE_LAST_TRADE: Composite price is calculated as the last trade price.
|
||||
* @default COMPOSITE_PRICE_TYPE_UNSPECIFIED
|
||||
* @enum {string}
|
||||
*/
|
||||
readonly vegaCompositePriceType:
|
||||
| 'COMPOSITE_PRICE_TYPE_UNSPECIFIED'
|
||||
| 'COMPOSITE_PRICE_TYPE_WEIGHTED'
|
||||
| 'COMPOSITE_PRICE_TYPE_MEDIAN'
|
||||
| 'COMPOSITE_PRICE_TYPE_LAST_TRADE';
|
||||
/**
|
||||
* @description Represents the top level object that handles data sources.
|
||||
* Data source definition can be external or internal, with whatever
|
||||
@@ -1389,17 +1197,21 @@ export interface components {
|
||||
readonly tradingTerminationProperty?: string;
|
||||
};
|
||||
/**
|
||||
* @description Describes which properties of the data source data is to be
|
||||
* used for settlement.
|
||||
* Describes which property of the data source data is to be
|
||||
* used as settlement data and which to use as the trading terminated trigger
|
||||
*/
|
||||
readonly vegaDataSourceSpecToPerpetualBinding: {
|
||||
/**
|
||||
* @description Name of the property in the source data that should be used for settlement data.
|
||||
* If it is set to "prices.BTC.value" for example, then the perpetual market will use the value of
|
||||
* this property to get settlement data.
|
||||
* @description Name of the property in the source data that should be used as settlement data.
|
||||
* If it is set to "prices.BTC.value", then the perpetual market will use the value of
|
||||
* this property as settlement data.
|
||||
*/
|
||||
readonly settlementDataProperty?: string;
|
||||
/** @description Name of the property in the source data that should be used to determine the perpetual's settlement schedule. */
|
||||
/**
|
||||
* @description Name of the property in the source data that should be used as settlement data.
|
||||
* If it is set to "prices.BTC.value", then the perpetual market will use the value of
|
||||
* this property as settlement data.
|
||||
*/
|
||||
readonly settlementScheduleProperty?: string;
|
||||
};
|
||||
/**
|
||||
@@ -1681,11 +1493,6 @@ export interface components {
|
||||
* Format: uint64
|
||||
*/
|
||||
readonly requiredConfirmations?: string;
|
||||
/**
|
||||
* Format: uint64
|
||||
* @description The ID of the EVM based chain which is to be used to source the oracle data.
|
||||
*/
|
||||
readonly sourceChainId?: string;
|
||||
/** @description Conditions for determining when to call the contract method. */
|
||||
readonly trigger?: components['schemas']['vegaEthCallTrigger'];
|
||||
};
|
||||
@@ -1712,11 +1519,6 @@ export interface components {
|
||||
* @description Result of contract call, packed according to the ABI stored in the associated data source spec.
|
||||
*/
|
||||
readonly result?: string;
|
||||
/**
|
||||
* Format: uint64
|
||||
* @description Source chain for this chain event.
|
||||
*/
|
||||
readonly sourceChainId?: string;
|
||||
/** @description ID of the data source spec that triggered this contract call. */
|
||||
readonly specId?: string;
|
||||
};
|
||||
@@ -1795,42 +1597,6 @@ export interface components {
|
||||
readonly tolerance?: string;
|
||||
readonly value?: components['schemas']['vegaStateVarValue'];
|
||||
};
|
||||
/** @description Liquidation strategy used when the network holds a position resulting from position resolution. */
|
||||
readonly vegaLiquidationStrategy: {
|
||||
/** @description Fraction of the open position the market will try to close in a single attempt; range 0 through 1. */
|
||||
readonly disposalFraction?: string;
|
||||
/**
|
||||
* Format: int64
|
||||
* @description Interval, in seconds, at which the network will attempt to close its position.
|
||||
*/
|
||||
readonly disposalTimeStep?: string;
|
||||
/**
|
||||
* Format: uint64
|
||||
* @description Size of the position that the network will try to close in a single attempt.
|
||||
*/
|
||||
readonly fullDisposalSize?: string;
|
||||
/** @description Max fraction of the total volume of the orderbook, within liquidity bounds, that the network can use to close its position; range 0 through 1. */
|
||||
readonly maxFractionConsumed?: string;
|
||||
};
|
||||
/** @description Market settings that describe how the liquidity fee is calculated. */
|
||||
readonly vegaLiquidityFeeSettings: {
|
||||
/** @description Constant liquidity fee used when using the constant fee method. */
|
||||
readonly feeConstant?: string;
|
||||
/** @description Method used to calculate the market's liquidity fee. */
|
||||
readonly method?: components['schemas']['vegaLiquidityFeeSettingsMethod'];
|
||||
};
|
||||
/**
|
||||
* @description - METHOD_MARGINAL_COST: Fee is the smallest value of all bids, such that liquidity providers with nominated fees less than or equal to this value still have sufficient commitment to fulfil the market's target stake.
|
||||
* - METHOD_WEIGHTED_AVERAGE: Fee is the weighted average of all liquidity providers' nominated fees, weighted by their committment.
|
||||
* - METHOD_CONSTANT: Fee is set by the market to a constant value irrespective of any liquidity provider's nominated fee.
|
||||
* @default METHOD_UNSPECIFIED
|
||||
* @enum {string}
|
||||
*/
|
||||
readonly vegaLiquidityFeeSettingsMethod:
|
||||
| 'METHOD_UNSPECIFIED'
|
||||
| 'METHOD_MARGINAL_COST'
|
||||
| 'METHOD_WEIGHTED_AVERAGE'
|
||||
| 'METHOD_CONSTANT';
|
||||
/** LiquidityMonitoringParameters contains settings used for liquidity monitoring */
|
||||
readonly vegaLiquidityMonitoringParameters: {
|
||||
/**
|
||||
@@ -1908,13 +1674,6 @@ export interface components {
|
||||
readonly vegaMatrixValue: {
|
||||
readonly value?: readonly components['schemas']['vegaVectorValue'][];
|
||||
};
|
||||
/** @description Generic structure holding a key/value pair. */
|
||||
readonly vegaMetadata: {
|
||||
/** @description Key of the metadata. */
|
||||
readonly key?: string;
|
||||
/** @description Value of the metadata. */
|
||||
readonly value?: string;
|
||||
};
|
||||
/** Represents a network parameter on Vega */
|
||||
readonly vegaNetworkParameter: {
|
||||
/** @description Unique key of the network parameter. */
|
||||
@@ -1949,10 +1708,6 @@ export interface components {
|
||||
readonly instrument?: components['schemas']['vegaInstrumentConfiguration'];
|
||||
/** @description Linear slippage factor is used to cap the slippage component of maintenance margin - it is applied to the slippage volume. */
|
||||
readonly linearSlippageFactor?: string;
|
||||
/** @description Liquidation strategy for this market. */
|
||||
readonly liquidationStrategy?: components['schemas']['vegaLiquidationStrategy'];
|
||||
/** @description Specifies how the liquidity fee for the market will be calculated. */
|
||||
readonly liquidityFeeSettings?: components['schemas']['vegaLiquidityFeeSettings'];
|
||||
/** @description Liquidity monitoring parameters. */
|
||||
readonly liquidityMonitoringParameters?: components['schemas']['vegaLiquidityMonitoringParameters'];
|
||||
/** Liquidity SLA parameters */
|
||||
@@ -1965,8 +1720,6 @@ export interface components {
|
||||
* price levels over which automated liquidity provisions will be deployed.
|
||||
*/
|
||||
readonly lpPriceRange?: string;
|
||||
/** @description Mark price configuration. */
|
||||
readonly markPriceConfiguration?: components['schemas']['vegaCompositePriceConfiguration'];
|
||||
/** @description Optional new futures market metadata, tags. */
|
||||
readonly metadata?: readonly string[];
|
||||
/**
|
||||
@@ -1997,8 +1750,6 @@ export interface components {
|
||||
readonly decimalPlaces?: string;
|
||||
/** @description New spot market instrument configuration. */
|
||||
readonly instrument?: components['schemas']['vegaInstrumentConfiguration'];
|
||||
/** @description Specifies how the liquidity fee for the market will be calculated. */
|
||||
readonly liquidityFeeSettings?: components['schemas']['vegaLiquidityFeeSettings'];
|
||||
/** @description Log normal risk model parameters, valid only if MODEL_LOG_NORMAL is selected. */
|
||||
readonly logNormal?: components['schemas']['vegaLogNormalRiskModel'];
|
||||
/** @description Optional new spot market metadata, tags. */
|
||||
@@ -2114,14 +1865,6 @@ export interface components {
|
||||
readonly dataSourceSpecForSettlementData?: components['schemas']['vegaDataSourceDefinition'];
|
||||
/** @description Data source spec describing the data source for settlement schedule. */
|
||||
readonly dataSourceSpecForSettlementSchedule?: components['schemas']['vegaDataSourceDefinition'];
|
||||
/** @description Lower bound for the funding-rate such that the funding-rate will never be lower than this value. */
|
||||
readonly fundingRateLowerBound?: string;
|
||||
/** @description Factor applied to funding-rates. This scales the impact that spot price deviations have on funding payments. */
|
||||
readonly fundingRateScalingFactor?: string;
|
||||
/** @description Upper bound for the funding-rate such that the funding-rate will never be higher than this value. */
|
||||
readonly fundingRateUpperBound?: string;
|
||||
/** @description Composite price configuration to drive the calculation of the index price used for funding payments. If undefined the default mark price of the market is used. */
|
||||
readonly indexPriceConfiguration?: components['schemas']['vegaCompositePriceConfiguration'];
|
||||
/** @description Continuously compounded interest rate used in funding rate calculation, in the range [-1, 1]. */
|
||||
readonly interestRate?: string;
|
||||
/** @description Controls how much the upcoming funding payment liability contributes to party's margin, in the range [0, 1]. */
|
||||
@@ -2299,14 +2042,6 @@ export interface components {
|
||||
*/
|
||||
readonly probabilityOfTrading?: number;
|
||||
};
|
||||
/**
|
||||
* @description Describes which property of the data source data is to be
|
||||
* used for price source.
|
||||
*/
|
||||
readonly vegaSpecBindingForCompositePrice: {
|
||||
/** @description The property name of price. */
|
||||
readonly priceSourceProperty?: string;
|
||||
};
|
||||
/** Spot product configuration */
|
||||
readonly vegaSpotProduct: {
|
||||
/** @description Base asset ID. */
|
||||
@@ -2437,8 +2172,6 @@ export interface components {
|
||||
readonly code?: string;
|
||||
/** @description Future. */
|
||||
readonly future?: components['schemas']['vegaUpdateFutureProduct'];
|
||||
/** Instrument name */
|
||||
readonly name?: string;
|
||||
/** @description Perpetual. */
|
||||
readonly perpetual?: components['schemas']['vegaUpdatePerpetualProduct'];
|
||||
};
|
||||
@@ -2455,10 +2188,6 @@ export interface components {
|
||||
readonly instrument?: components['schemas']['vegaUpdateInstrumentConfiguration'];
|
||||
/** @description Linear slippage factor is used to cap the slippage component of maintenance margin - it is applied to the slippage volume. */
|
||||
readonly linearSlippageFactor?: string;
|
||||
/** Liquidation strategy parameters */
|
||||
readonly liquidationStrategy?: components['schemas']['vegaLiquidationStrategy'];
|
||||
/** @description Specifies how the liquidity fee for the market will be calculated. */
|
||||
readonly liquidityFeeSettings?: components['schemas']['vegaLiquidityFeeSettings'];
|
||||
/** @description Liquidity monitoring parameters. */
|
||||
readonly liquidityMonitoringParameters?: components['schemas']['vegaLiquidityMonitoringParameters'];
|
||||
/** Liquidity SLA parameters */
|
||||
@@ -2471,8 +2200,6 @@ export interface components {
|
||||
* price levels over which automated liquidity provisions will be deployed.
|
||||
*/
|
||||
readonly lpPriceRange?: string;
|
||||
/** @description Mark price configuration. */
|
||||
readonly markPriceConfiguration?: components['schemas']['vegaCompositePriceConfiguration'];
|
||||
/** @description Optional futures market metadata, tags. */
|
||||
readonly metadata?: readonly string[];
|
||||
/** @description Price monitoring parameters. */
|
||||
@@ -2511,14 +2238,6 @@ export interface components {
|
||||
readonly dataSourceSpecForSettlementData?: components['schemas']['vegaDataSourceDefinition'];
|
||||
/** @description Data source spec describing the data source for settlement schedule. */
|
||||
readonly dataSourceSpecForSettlementSchedule?: components['schemas']['vegaDataSourceDefinition'];
|
||||
/** @description Lower bound for the funding-rate such that the funding-rate will never be lower than this value. */
|
||||
readonly fundingRateLowerBound?: string;
|
||||
/** @description Factor applied to funding-rates. This scales the impact that spot price deviations have on funding payments. */
|
||||
readonly fundingRateScalingFactor?: string;
|
||||
/** @description Upper bound for the funding-rate such that the funding-rate will never be higher than this value. */
|
||||
readonly fundingRateUpperBound?: string;
|
||||
/** @description Configuration for the index price used in funding payment calculation. */
|
||||
readonly indexPriceConfiguration?: components['schemas']['vegaCompositePriceConfiguration'];
|
||||
/** @description Continuously compounded interest rate used in funding rate calculation, in the range [-1, 1]. */
|
||||
readonly interestRate?: string;
|
||||
/** @description Controls how much the upcoming funding payment liability contributes to party's margin, in the range [0, 1]. */
|
||||
@@ -2539,8 +2258,6 @@ export interface components {
|
||||
};
|
||||
/** Configuration to update a spot market on Vega */
|
||||
readonly vegaUpdateSpotMarketConfiguration: {
|
||||
/** @description Specifies how the liquidity fee for the market will be calculated. */
|
||||
readonly liquidityFeeSettings?: components['schemas']['vegaLiquidityFeeSettings'];
|
||||
/** @description Log normal risk model parameters, valid only if MODEL_LOG_NORMAL is selected. */
|
||||
readonly logNormal?: components['schemas']['vegaLogNormalRiskModel'];
|
||||
/** @description Optional spot market metadata, tags. */
|
||||
@@ -2639,14 +2356,19 @@ export interface operations {
|
||||
};
|
||||
/**
|
||||
* List transactions
|
||||
* @description List transactions from the Vega blockchain from the newest to the oldest transactions.
|
||||
* @description List transactions from the Vega blockchain
|
||||
*/
|
||||
BlockExplorer_ListTransactions: {
|
||||
parameters: {
|
||||
query?: {
|
||||
/** @description Cursor to paginate the request. It can be used in conjunction with the `after` cursor. */
|
||||
/**
|
||||
* @description Number of transactions to be returned from the blockchain.
|
||||
* This is deprecated, use first and last instead.
|
||||
*/
|
||||
limit?: number;
|
||||
/** @description Optional cursor to paginate the request. */
|
||||
before?: string;
|
||||
/** @description Cursor to paginate the request. It can be used in conjunction with the `before` cursor. */
|
||||
/** @description Optional cursor to paginate the request. */
|
||||
after?: string;
|
||||
/** @description Transaction command types filter, for listing transactions with specified command types. */
|
||||
cmdTypes?: readonly string[];
|
||||
@@ -2655,19 +2377,13 @@ export interface operations {
|
||||
/** @description Party IDs filter, can be sender or receiver. */
|
||||
parties?: readonly string[];
|
||||
/**
|
||||
* @description Number of transactions to be returned from the blockchain.
|
||||
* Use in conjunction with the `after` cursor to paginate forwards. Paginating forwards means toward the most recent
|
||||
* transactions.
|
||||
* It cannot be used in conjunction with the `before` cursor.
|
||||
* On its own, this will return the `first` most recent transactions.
|
||||
* @description Number of transactions to be returned from the blockchain. Use in conjunction with the `after` cursor to paginate forwards.
|
||||
* On its own, this will return the first `first` transactions.
|
||||
*/
|
||||
first?: number;
|
||||
/**
|
||||
* @description Number of transactions to be returned from the blockchain.
|
||||
* Use in conjunction with the `before` cursor to paginate backwards. Paginating forwards means toward the least recent
|
||||
* transactions.
|
||||
* It cannot be used in conjunction with the `after` cursor.
|
||||
* On its own, this will return the `last` oldest transactions.
|
||||
* @description Number of transactions to be returned from the blockchain. Use in conjunction with the `before` cursor to paginate backwards.
|
||||
* On its own, this will return the last `last` transactions.
|
||||
*/
|
||||
last?: number;
|
||||
};
|
||||
|
||||
@@ -215,7 +215,7 @@ context(
|
||||
});
|
||||
|
||||
// 3003-PMAN-001
|
||||
it.skip(
|
||||
it(
|
||||
'Able to submit valid new market proposal',
|
||||
// @ts-ignore clash between jest and cypress
|
||||
{ tags: '@smoke' },
|
||||
|
||||
+1
@@ -266,6 +266,7 @@ export const ProposalMarketData = ({
|
||||
/>
|
||||
</>
|
||||
))}
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Liquidity monitoring parameters')}
|
||||
</h2>
|
||||
|
||||
@@ -26,7 +26,6 @@ NX_ICEBERG_ORDERS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
NX_REFERRALS=true
|
||||
# NX_DISABLE_CLOSE_POSITION=false
|
||||
NX_TEAM_COMPETITION=true
|
||||
|
||||
NX_TENDERMINT_URL=https://be.vega.community
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket
|
||||
|
||||
@@ -28,8 +28,3 @@ NX_REFERRALS=true
|
||||
|
||||
NX_TENDERMINT_URL=https://tm.be.devnet1.vega.xyz/
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.devnet1.vega.xyz/websocket
|
||||
|
||||
NX_TEAM_COMPETITION=true
|
||||
|
||||
NX_CHARTING_LIBRARY_PATH=https://assets.vega.community/trading-view-bundle/v0.0.1/
|
||||
NX_CHARTING_LIBRARY_HASH=PDjWaqPFndDp+LCvqbKvntWriaqNzNpZ5i9R/BULzCg=
|
||||
|
||||
@@ -26,7 +26,6 @@ NX_ICEBERG_ORDERS=true
|
||||
# NX_PRODUCT_PERPETUALS
|
||||
NX_METAMASK_SNAPS=true
|
||||
NX_REFERRALS=true
|
||||
NX_TEAM_COMPETITION=true
|
||||
|
||||
NX_CHARTING_LIBRARY_PATH=https://assets.vega.community/trading-view-bundle/v0.0.1/
|
||||
NX_CHARTING_LIBRARY_HASH=PDjWaqPFndDp+LCvqbKvntWriaqNzNpZ5i9R/BULzCg=
|
||||
|
||||
@@ -26,7 +26,6 @@ NX_ISOLATED_MARGIN=true
|
||||
NX_ICEBERG_ORDERS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
NX_REFERRALS=true
|
||||
NX_TEAM_COMPETITION=true
|
||||
|
||||
NX_TENDERMINT_URL=https://tm.be.testnet.vega.xyz
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket
|
||||
|
||||
@@ -1,9 +1,28 @@
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { Intent, TradingAnchorButton } from '@vegaprotocol/ui-toolkit';
|
||||
import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet';
|
||||
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import {
|
||||
Intent,
|
||||
TextArea,
|
||||
TradingAnchorButton,
|
||||
TradingButton,
|
||||
TradingCheckbox,
|
||||
TradingFormGroup,
|
||||
TradingInput,
|
||||
TradingInputError,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import {
|
||||
useVegaWallet,
|
||||
type CreateReferralSet,
|
||||
type Status,
|
||||
useVegaWalletDialogStore,
|
||||
} from '@vegaprotocol/wallet';
|
||||
import {
|
||||
addDecimalsFormatNumber,
|
||||
isValidVegaPublicKey,
|
||||
URL_REGEX,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { useT } from '../../lib/use-t';
|
||||
import { useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction';
|
||||
import { useCreateReferralSet } from '../../lib/hooks/use-create-referral-set';
|
||||
import { DApp, TokenStaticLinks, useLinks } from '@vegaprotocol/environment';
|
||||
import { RainbowButton } from '../../components/rainbow-button';
|
||||
import { usePageTitle } from '../../lib/hooks/use-page-title';
|
||||
@@ -11,7 +30,14 @@ import { ErrorBoundary } from '../../components/error-boundary';
|
||||
import { Box } from '../../components/competitions/box';
|
||||
import { LayoutWithGradient } from '../../components/layouts-inner';
|
||||
import { Links } from '../../lib/links';
|
||||
import { TeamForm, TransactionType } from './team-form';
|
||||
|
||||
interface FormFields {
|
||||
name: string;
|
||||
url: string;
|
||||
avatarUrl: string;
|
||||
private: boolean;
|
||||
allowList: string;
|
||||
}
|
||||
|
||||
export const CompetitionsCreateTeam = () => {
|
||||
const [searchParams] = useSearchParams();
|
||||
@@ -31,7 +57,7 @@ export const CompetitionsCreateTeam = () => {
|
||||
<div className="mx-auto md:w-2/3 max-w-xl">
|
||||
<Box className="flex flex-col gap-4">
|
||||
<h1 className="calt text-2xl lg:text-3xl xl:text-4xl">
|
||||
{isSolo ? t('Create solo team') : t('Create a team')}
|
||||
{t('Create a team')}
|
||||
</h1>
|
||||
{pubKey && !isReadOnly ? (
|
||||
<CreateTeamFormContainer isSolo={isSolo} />
|
||||
@@ -59,7 +85,7 @@ const CreateTeamFormContainer = ({ isSolo }: { isSolo: boolean }) => {
|
||||
const createLink = useLinks(DApp.Governance);
|
||||
|
||||
const { err, status, code, isEligible, requiredStake, onSubmit } =
|
||||
useReferralSetTransaction({
|
||||
useCreateReferralSet({
|
||||
onSuccess: (code) => {
|
||||
// For some reason team creation takes a long time, too long even to make
|
||||
// polling viable, so its not feasible to navigate to the team page
|
||||
@@ -120,12 +146,188 @@ const CreateTeamFormContainer = ({ isSolo }: { isSolo: boolean }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<TeamForm
|
||||
type={TransactionType.CreateReferralSet}
|
||||
<CreateTeamForm
|
||||
onSubmit={onSubmit}
|
||||
status={status}
|
||||
err={err}
|
||||
isCreatingSoloTeam={isSolo}
|
||||
isSolo={isSolo}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const CreateTeamForm = ({
|
||||
status,
|
||||
err,
|
||||
isSolo,
|
||||
onSubmit,
|
||||
}: {
|
||||
status: ReturnType<typeof useCreateReferralSet>['status'];
|
||||
err: ReturnType<typeof useCreateReferralSet>['err'];
|
||||
isSolo: boolean;
|
||||
onSubmit: (tx: CreateReferralSet) => void;
|
||||
}) => {
|
||||
const t = useT();
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
control,
|
||||
watch,
|
||||
formState: { errors },
|
||||
} = useForm<FormFields>({
|
||||
defaultValues: {
|
||||
private: isSolo,
|
||||
},
|
||||
});
|
||||
|
||||
const isPrivate = watch('private');
|
||||
|
||||
const createTeam = (fields: FormFields) => {
|
||||
onSubmit({
|
||||
createReferralSet: {
|
||||
isTeam: true,
|
||||
team: {
|
||||
name: fields.name,
|
||||
teamUrl: fields.url,
|
||||
avatarUrl: fields.avatarUrl,
|
||||
closed: fields.private,
|
||||
allowList: fields.private ? parseAllowListText(fields.allowList) : [],
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(createTeam)}>
|
||||
<TradingFormGroup label={t('Team name')} labelFor="name">
|
||||
<TradingInput {...register('name', { required: t('Required') })} />
|
||||
{errors.name?.message && (
|
||||
<TradingInputError forInput="name">
|
||||
{errors.name.message}
|
||||
</TradingInputError>
|
||||
)}
|
||||
</TradingFormGroup>
|
||||
<TradingFormGroup
|
||||
label={t('URL')}
|
||||
labelFor="url"
|
||||
labelDescription={t(
|
||||
'Provide a link so users can learn more about your team'
|
||||
)}
|
||||
>
|
||||
<TradingInput
|
||||
{...register('url', {
|
||||
pattern: { value: URL_REGEX, message: t('Invalid URL') },
|
||||
})}
|
||||
/>
|
||||
{errors.url?.message && (
|
||||
<TradingInputError forInput="url">
|
||||
{errors.url.message}
|
||||
</TradingInputError>
|
||||
)}
|
||||
</TradingFormGroup>
|
||||
<TradingFormGroup
|
||||
label={t('Avatar URL')}
|
||||
labelFor="avatarUrl"
|
||||
labelDescription={t('Provide a URL to a hosted image')}
|
||||
>
|
||||
<TradingInput
|
||||
{...register('avatarUrl', {
|
||||
pattern: {
|
||||
value: URL_REGEX,
|
||||
message: t('Invalid image URL'),
|
||||
},
|
||||
})}
|
||||
/>
|
||||
{errors.avatarUrl?.message && (
|
||||
<TradingInputError forInput="avatarUrl">
|
||||
{errors.avatarUrl.message}
|
||||
</TradingInputError>
|
||||
)}
|
||||
</TradingFormGroup>
|
||||
<TradingFormGroup
|
||||
label={t('Make team private')}
|
||||
labelFor="private"
|
||||
hideLabel={true}
|
||||
>
|
||||
<Controller
|
||||
name="private"
|
||||
control={control}
|
||||
render={({ field }) => {
|
||||
return (
|
||||
<TradingCheckbox
|
||||
label={t('Make team private')}
|
||||
checked={field.value}
|
||||
onCheckedChange={(value) => {
|
||||
field.onChange(value);
|
||||
}}
|
||||
disabled={isSolo}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</TradingFormGroup>
|
||||
{isPrivate && (
|
||||
<TradingFormGroup
|
||||
label={t('Public key allow list')}
|
||||
labelFor="allowList"
|
||||
labelDescription={t(
|
||||
'Use a comma separated list to allow only specific public keys to join the team'
|
||||
)}
|
||||
>
|
||||
<TextArea
|
||||
{...register('allowList', {
|
||||
required: t('Required'),
|
||||
disabled: isSolo,
|
||||
validate: {
|
||||
allowList: (value) => {
|
||||
const publicKeys = parseAllowListText(value);
|
||||
if (publicKeys.every((pk) => isValidVegaPublicKey(pk))) {
|
||||
return true;
|
||||
}
|
||||
return t('Invalid public key found in allow list');
|
||||
},
|
||||
},
|
||||
})}
|
||||
/>
|
||||
{errors.allowList?.message && (
|
||||
<TradingInputError forInput="avatarUrl">
|
||||
{errors.allowList.message}
|
||||
</TradingInputError>
|
||||
)}
|
||||
</TradingFormGroup>
|
||||
)}
|
||||
{err && (
|
||||
<p className="text-danger text-xs mb-4 first-letter:capitalize">
|
||||
{err}
|
||||
</p>
|
||||
)}
|
||||
<SubmitButton status={status} />
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
const SubmitButton = ({ status }: { status: Status }) => {
|
||||
const t = useT();
|
||||
const disabled = status === 'pending' || status === 'requested';
|
||||
|
||||
let text = t('Create');
|
||||
|
||||
if (status === 'requested') {
|
||||
text = t('Confirm in wallet...');
|
||||
} else if (status === 'pending') {
|
||||
text = t('Confirming transaction...');
|
||||
}
|
||||
|
||||
return (
|
||||
<TradingButton type="submit" intent={Intent.Info} disabled={disabled}>
|
||||
{text}
|
||||
</TradingButton>
|
||||
);
|
||||
};
|
||||
|
||||
const parseAllowListText = (str: string) => {
|
||||
return str
|
||||
.split(',')
|
||||
.map((v) => v.trim())
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ErrorBoundary } from '@sentry/react';
|
||||
import { CompetitionsHeader } from '../../components/competitions/competitions-header';
|
||||
import { Intent, Loader, TradingButton } from '@vegaprotocol/ui-toolkit';
|
||||
|
||||
import { useGames } from '../../lib/hooks/use-games';
|
||||
import { useGames } from './hooks/use-games';
|
||||
import { useCurrentEpochInfoQuery } from '../referrals/hooks/__generated__/Epoch';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { Links } from '../../lib/links';
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from '../../components/competitions/competitions-cta';
|
||||
import { GamesContainer } from '../../components/competitions/games-container';
|
||||
import { CompetitionsLeaderboard } from '../../components/competitions/competitions-leaderboard';
|
||||
import { useTeams } from '../../lib/hooks/use-teams';
|
||||
import { useTeams } from './hooks/use-teams';
|
||||
import take from 'lodash/take';
|
||||
import { usePageTitle } from '../../lib/hooks/use-page-title';
|
||||
|
||||
@@ -31,7 +31,10 @@ export const CompetitionsHome = () => {
|
||||
currentEpoch,
|
||||
});
|
||||
|
||||
const { data: teamsData, loading: teamsLoading } = useTeams();
|
||||
const { data: teamsData, loading: teamsLoading } = useTeams({
|
||||
sortByField: ['totalQuantumRewards'],
|
||||
order: 'desc',
|
||||
});
|
||||
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
|
||||
@@ -22,7 +22,6 @@ import { ErrorBoundary } from '../../components/error-boundary';
|
||||
import { LayoutWithGradient } from '../../components/layouts-inner';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import { JoinTeam } from './join-team';
|
||||
import { UpdateTeamButton } from './update-team-button';
|
||||
|
||||
export const CompetitionsTeam = () => {
|
||||
const t = useT();
|
||||
@@ -38,11 +37,12 @@ export const CompetitionsTeam = () => {
|
||||
const TeamPageContainer = ({ teamId }: { teamId: string | undefined }) => {
|
||||
const t = useT();
|
||||
const { pubKey } = useVegaWallet();
|
||||
const { data, team, partyTeam, stats, members, games, loading, refetch } =
|
||||
useTeam(teamId, pubKey || undefined);
|
||||
const { team, partyTeam, stats, members, games, loading, refetch } = useTeam(
|
||||
teamId,
|
||||
pubKey || undefined
|
||||
);
|
||||
|
||||
// only show spinner on first load so when users join teams its smoother
|
||||
if (!data && loading) {
|
||||
if (loading) {
|
||||
return (
|
||||
<Splash>
|
||||
<Loader />
|
||||
@@ -99,10 +99,7 @@ const TeamPage = ({
|
||||
>
|
||||
{team.name}
|
||||
</h1>
|
||||
<div className="flex gap-2">
|
||||
<JoinTeam team={team} partyTeam={partyTeam} refetch={refetch} />
|
||||
<UpdateTeamButton team={team} />
|
||||
</div>
|
||||
<JoinTeam team={team} partyTeam={partyTeam} refetch={refetch} />
|
||||
</div>
|
||||
</header>
|
||||
<TeamStats stats={stats} members={members} games={games} />
|
||||
@@ -145,22 +142,16 @@ const Games = ({ games }: { games?: TeamGame[] }) => {
|
||||
{
|
||||
name: 'epoch',
|
||||
displayName: t('Epoch'),
|
||||
headerClassName: 'hidden md:table-cell',
|
||||
className: 'hidden md:table-cell',
|
||||
headerClassName: 'hidden md:block',
|
||||
className: 'hidden md:block',
|
||||
},
|
||||
{ name: 'type', displayName: t('Type') },
|
||||
{ name: 'amount', displayName: t('Amount earned') },
|
||||
{
|
||||
name: 'participatingTeams',
|
||||
name: 'teams',
|
||||
displayName: t('No. of participating teams'),
|
||||
headerClassName: 'hidden md:table-cell',
|
||||
className: 'hidden md:table-cell',
|
||||
},
|
||||
{
|
||||
name: 'participatingMembers',
|
||||
displayName: t('No. of participating members'),
|
||||
headerClassName: 'hidden md:table-cell',
|
||||
className: 'hidden md:table-cell',
|
||||
headerClassName: 'hidden md:block',
|
||||
className: 'hidden md:block',
|
||||
},
|
||||
]}
|
||||
data={games.map((game) => ({
|
||||
@@ -168,8 +159,7 @@ const Games = ({ games }: { games?: TeamGame[] }) => {
|
||||
epoch: game.epoch,
|
||||
type: DispatchMetricLabels[game.team.rewardMetric as DispatchMetric],
|
||||
amount: formatNumber(game.team.totalRewardsEarned),
|
||||
participatingTeams: game.entities.length,
|
||||
participatingMembers: game.numberOfParticipants,
|
||||
teams: game.numberOfParticipants,
|
||||
}))}
|
||||
noCollapse={true}
|
||||
/>
|
||||
@@ -185,10 +175,7 @@ const Members = ({ members }: { members?: Member[] }) => {
|
||||
|
||||
const data = orderBy(
|
||||
members.map((m) => ({
|
||||
referee: <RefereeLink pubkey={m.referee} isCreator={m.isCreator} />,
|
||||
rewards: formatNumber(m.totalQuantumRewards),
|
||||
volume: formatNumber(m.totalQuantumVolume),
|
||||
gamesPlayed: formatNumber(m.totalGamesPlayed),
|
||||
referee: <RefereeLink pubkey={m.referee} />,
|
||||
joinedAt: getDateTimeFormat().format(new Date(m.joinedAt)),
|
||||
joinedAtEpoch: Number(m.joinedAtEpoch),
|
||||
})),
|
||||
@@ -199,10 +186,7 @@ const Members = ({ members }: { members?: Member[] }) => {
|
||||
return (
|
||||
<Table
|
||||
columns={[
|
||||
{ name: 'referee', displayName: t('Member ID') },
|
||||
{ name: 'rewards', displayName: t('Rewards earned') },
|
||||
{ name: 'volume', displayName: t('Total volume') },
|
||||
{ name: 'gamesPlayed', displayName: t('Games played') },
|
||||
{ name: 'referee', displayName: t('Referee') },
|
||||
{
|
||||
name: 'joinedAt',
|
||||
displayName: t('Joined at'),
|
||||
@@ -218,24 +202,14 @@ const Members = ({ members }: { members?: Member[] }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const RefereeLink = ({
|
||||
pubkey,
|
||||
isCreator,
|
||||
}: {
|
||||
pubkey: string;
|
||||
isCreator: boolean;
|
||||
}) => {
|
||||
const t = useT();
|
||||
const RefereeLink = ({ pubkey }: { pubkey: string }) => {
|
||||
const linkCreator = useLinks(DApp.Explorer);
|
||||
const link = linkCreator(EXPLORER_PARTIES.replace(':id', pubkey));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Link to={link} target="_blank" className="underline underline-offset-4">
|
||||
{truncateMiddle(pubkey)}
|
||||
</Link>{' '}
|
||||
<span className="text-muted text-xs">{isCreator ? t('Owner') : ''}</span>
|
||||
</>
|
||||
<Link to={link} target="_blank" className="underline underline-offset-4">
|
||||
{truncateMiddle(pubkey)}
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ErrorBoundary } from '@sentry/react';
|
||||
import { CompetitionsHeader } from '../../components/competitions/competitions-header';
|
||||
import { useRef, useState } from 'react';
|
||||
import { useT } from '../../lib/use-t';
|
||||
import { useTeams } from '../../lib/hooks/use-teams';
|
||||
import { useTeams } from './hooks/use-teams';
|
||||
import { CompetitionsLeaderboard } from '../../components/competitions/competitions-leaderboard';
|
||||
import {
|
||||
Input,
|
||||
@@ -17,7 +17,10 @@ export const CompetitionsTeams = () => {
|
||||
|
||||
usePageTitle([t('Competitions'), t('Teams')]);
|
||||
|
||||
const { data: teamsData, loading: teamsLoading } = useTeams();
|
||||
const { data: teamsData, loading: teamsLoading } = useTeams({
|
||||
sortByField: ['totalQuantumRewards'],
|
||||
order: 'desc',
|
||||
});
|
||||
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const [filter, setFilter] = useState<string | null | undefined>(undefined);
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
import { ErrorBoundary } from '../../components/error-boundary';
|
||||
import { usePageTitle } from '../../lib/hooks/use-page-title';
|
||||
import { Box } from '../../components/competitions/box';
|
||||
import { useT } from '../../lib/use-t';
|
||||
import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet';
|
||||
import { Loader, Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import { RainbowButton } from '../../components/rainbow-button';
|
||||
import { Link, Navigate, useParams } from 'react-router-dom';
|
||||
import { Links } from '../../lib/links';
|
||||
import { useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction';
|
||||
import { type FormFields, TeamForm, TransactionType } from './team-form';
|
||||
import { useTeam } from '../../lib/hooks/use-team';
|
||||
import { LayoutWithGradient } from '../../components/layouts-inner';
|
||||
|
||||
export const CompetitionsUpdateTeam = () => {
|
||||
const t = useT();
|
||||
usePageTitle([t('Competitions'), t('Update a team')]);
|
||||
const { pubKey, isReadOnly } = useVegaWallet();
|
||||
const openWalletDialog = useVegaWalletDialogStore(
|
||||
(store) => store.openVegaWalletDialog
|
||||
);
|
||||
const { teamId } = useParams<{ teamId: string }>();
|
||||
if (!teamId) {
|
||||
return <Navigate to={Links.COMPETITIONS()} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ErrorBoundary feature="update-team">
|
||||
<LayoutWithGradient>
|
||||
<div className="mx-auto md:w-2/3 max-w-xl">
|
||||
<Box className="flex flex-col gap-4">
|
||||
<h1 className="calt text-2xl lg:text-3xl xl:text-5xl">
|
||||
{t('Update a team')}
|
||||
</h1>
|
||||
{pubKey && !isReadOnly ? (
|
||||
<UpdateTeamFormContainer teamId={teamId} pubKey={pubKey} />
|
||||
) : (
|
||||
<>
|
||||
<p>{t('Connect to update the details of your team.')}</p>
|
||||
<RainbowButton variant="border" onClick={openWalletDialog}>
|
||||
{t('Connect wallet')}
|
||||
</RainbowButton>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</div>
|
||||
</LayoutWithGradient>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
const UpdateTeamFormContainer = ({
|
||||
teamId,
|
||||
pubKey,
|
||||
}: {
|
||||
teamId: string;
|
||||
pubKey: string;
|
||||
}) => {
|
||||
const t = useT();
|
||||
const { team, loading, error } = useTeam(teamId, pubKey);
|
||||
|
||||
const { err, status, onSubmit } = useReferralSetTransaction({
|
||||
onSuccess: () => {
|
||||
// NOOP
|
||||
},
|
||||
});
|
||||
|
||||
if (loading) {
|
||||
return <Loader size="small" />;
|
||||
}
|
||||
if (error) {
|
||||
return (
|
||||
<Splash className="gap-1">
|
||||
<span>{t('Something went wrong.')}</span>
|
||||
<Link to={Links.COMPETITIONS_TEAM(teamId)} className="underline">
|
||||
{t("Go back to the team's profile")}
|
||||
</Link>
|
||||
</Splash>
|
||||
);
|
||||
}
|
||||
|
||||
const isMyTeam = team?.referrer === pubKey;
|
||||
if (!isMyTeam) {
|
||||
return <Navigate to={Links.COMPETITIONS_TEAM(teamId)} />;
|
||||
}
|
||||
|
||||
const defaultValues: FormFields = {
|
||||
id: team.teamId,
|
||||
name: team.name,
|
||||
url: team.teamUrl,
|
||||
avatarUrl: team.avatarUrl,
|
||||
private: team.closed,
|
||||
allowList: team.allowList.join(','),
|
||||
};
|
||||
|
||||
return (
|
||||
<TeamForm
|
||||
type={TransactionType.UpdateReferralSet}
|
||||
status={status}
|
||||
err={err}
|
||||
isCreatingSoloTeam={team.closed}
|
||||
onSubmit={onSubmit}
|
||||
defaultValues={defaultValues}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
import compact from 'lodash/compact';
|
||||
import { useActiveRewardsQuery } from '../../../components/rewards-container/__generated__/Rewards';
|
||||
import { isActiveReward } from '../../../components/rewards-container/active-rewards';
|
||||
import { EntityScope, type TransferNode } from '@vegaprotocol/types';
|
||||
|
||||
const isScopedToTeams = (node: TransferNode) =>
|
||||
node.transfer.kind.__typename === 'RecurringTransfer' &&
|
||||
node.transfer.kind.dispatchStrategy?.entityScope ===
|
||||
EntityScope.ENTITY_SCOPE_TEAMS;
|
||||
|
||||
export const useGames = ({
|
||||
currentEpoch,
|
||||
onlyActive,
|
||||
}: {
|
||||
currentEpoch: number;
|
||||
onlyActive: boolean;
|
||||
}) => {
|
||||
const { data, loading, error } = useActiveRewardsQuery({
|
||||
variables: {
|
||||
isReward: true,
|
||||
},
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
const games = compact(data?.transfersConnection?.edges?.map((n) => n?.node))
|
||||
.map((n) => n as TransferNode)
|
||||
.filter((node) => {
|
||||
const recurring = node.transfer.kind.__typename !== 'RecurringTransfer';
|
||||
const active = onlyActive ? isActiveReward(node, currentEpoch) : true;
|
||||
return active && recurring && isScopedToTeams(node);
|
||||
});
|
||||
|
||||
return {
|
||||
data: games,
|
||||
loading,
|
||||
error,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
import { useMemo } from 'react';
|
||||
import { type TeamsQuery, useTeamsQuery } from './__generated__/Teams';
|
||||
import {
|
||||
type TeamsStatisticsQuery,
|
||||
useTeamsStatisticsQuery,
|
||||
} from './__generated__/TeamsStatistics';
|
||||
import compact from 'lodash/compact';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
import { type ArrayElement } from 'type-fest/source/internal';
|
||||
|
||||
type SortableField = keyof Omit<
|
||||
ArrayElement<NonNullable<TeamsQuery['teams']>['edges']>['node'] &
|
||||
ArrayElement<
|
||||
NonNullable<TeamsStatisticsQuery['teamsStatistics']>['edges']
|
||||
>['node'],
|
||||
'__typename'
|
||||
>;
|
||||
|
||||
type UseTeamsArgs = {
|
||||
aggregationEpochs?: number;
|
||||
sortByField?: SortableField[];
|
||||
order?: 'asc' | 'desc';
|
||||
};
|
||||
|
||||
const DEFAULT_AGGREGATION_EPOCHS = 10;
|
||||
|
||||
export const useTeams = ({
|
||||
aggregationEpochs = DEFAULT_AGGREGATION_EPOCHS,
|
||||
sortByField = ['createdAtEpoch'],
|
||||
order = 'asc',
|
||||
}: UseTeamsArgs) => {
|
||||
const {
|
||||
data: teamsData,
|
||||
loading: teamsLoading,
|
||||
error: teamsError,
|
||||
} = useTeamsQuery({
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
const {
|
||||
data: statsData,
|
||||
loading: statsLoading,
|
||||
error: statsError,
|
||||
} = useTeamsStatisticsQuery({
|
||||
variables: {
|
||||
aggregationEpochs,
|
||||
},
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
const teams = compact(teamsData?.teams?.edges).map((e) => e.node);
|
||||
const stats = compact(statsData?.teamsStatistics?.edges).map((e) => e.node);
|
||||
|
||||
const data = useMemo(() => {
|
||||
const data = teams.map((t) => ({
|
||||
...t,
|
||||
...stats.find((s) => s.teamId === t.teamId),
|
||||
}));
|
||||
|
||||
const sorted = sortBy(data, sortByField);
|
||||
if (order === 'desc') {
|
||||
return sorted.reverse();
|
||||
}
|
||||
return sorted;
|
||||
}, [teams, sortByField, order, stats]);
|
||||
|
||||
return {
|
||||
data,
|
||||
loading: teamsLoading && statsLoading,
|
||||
error: teamsError || statsError,
|
||||
};
|
||||
};
|
||||
@@ -6,7 +6,11 @@ import {
|
||||
VegaIcon,
|
||||
VegaIconNames,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { useSimpleTransaction, useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import {
|
||||
useSimpleTransaction,
|
||||
useVegaWallet,
|
||||
type Status,
|
||||
} from '@vegaprotocol/wallet';
|
||||
import { useT } from '../../lib/use-t';
|
||||
import { type Team } from '../../lib/hooks/use-team';
|
||||
import { useState } from 'react';
|
||||
@@ -23,8 +27,19 @@ export const JoinTeam = ({
|
||||
refetch: () => void;
|
||||
}) => {
|
||||
const { pubKey, isReadOnly } = useVegaWallet();
|
||||
const { send, status } = useSimpleTransaction({
|
||||
onSuccess: refetch,
|
||||
});
|
||||
const [confirmDialog, setConfirmDialog] = useState<JoinType>();
|
||||
|
||||
const joinTeam = () => {
|
||||
send({
|
||||
joinTeam: {
|
||||
id: team.teamId,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<JoinButton
|
||||
@@ -41,10 +56,11 @@ export const JoinTeam = ({
|
||||
{confirmDialog !== undefined && (
|
||||
<DialogContent
|
||||
type={confirmDialog}
|
||||
status={status}
|
||||
team={team}
|
||||
partyTeam={partyTeam}
|
||||
onConfirm={joinTeam}
|
||||
onCancel={() => setConfirmDialog(undefined)}
|
||||
refetch={refetch}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
@@ -94,7 +110,7 @@ export const JoinButton = ({
|
||||
// Not creator of the team, but still can't switch because
|
||||
// creators cannot leave their own team
|
||||
return (
|
||||
<Tooltip description={t('As a team creator, you cannot switch teams')}>
|
||||
<Tooltip description="As a team creator, you cannot switch teams">
|
||||
<Button intent={Intent.Primary} disabled={true}>
|
||||
{t('Switch team')}{' '}
|
||||
</Button>
|
||||
@@ -133,39 +149,21 @@ export const JoinButton = ({
|
||||
|
||||
const DialogContent = ({
|
||||
type,
|
||||
status,
|
||||
team,
|
||||
partyTeam,
|
||||
onConfirm,
|
||||
onCancel,
|
||||
refetch,
|
||||
}: {
|
||||
type: JoinType;
|
||||
status: Status;
|
||||
team: Team;
|
||||
partyTeam?: Team;
|
||||
onConfirm: () => void;
|
||||
onCancel: () => void;
|
||||
refetch: () => void;
|
||||
}) => {
|
||||
const t = useT();
|
||||
|
||||
const { send, status, error } = useSimpleTransaction({
|
||||
onSuccess: refetch,
|
||||
});
|
||||
|
||||
const joinTeam = () => {
|
||||
send({
|
||||
joinTeam: {
|
||||
id: team.teamId,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<p className="text-vega-red break-words first-letter:capitalize">
|
||||
{error}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
if (status === 'requested') {
|
||||
return <p>{t('Confirm in wallet...')}</p>;
|
||||
}
|
||||
@@ -215,7 +213,7 @@ const DialogContent = ({
|
||||
</>
|
||||
)}
|
||||
<div className="flex justify-between gap-2">
|
||||
<Button onClick={joinTeam} intent={Intent.Success}>
|
||||
<Button onClick={onConfirm} intent={Intent.Success}>
|
||||
{t('Confirm')}
|
||||
</Button>
|
||||
<Button onClick={onCancel} intent={Intent.Danger}>
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
import {
|
||||
TradingFormGroup,
|
||||
TradingInput,
|
||||
TradingInputError,
|
||||
TradingCheckbox,
|
||||
TextArea,
|
||||
TradingButton,
|
||||
Intent,
|
||||
VegaIcon,
|
||||
VegaIconNames,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { URL_REGEX, isValidVegaPublicKey } from '@vegaprotocol/utils';
|
||||
|
||||
import { type useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction';
|
||||
import { useT } from '../../lib/use-t';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import type {
|
||||
CreateReferralSet,
|
||||
UpdateReferralSet,
|
||||
Status,
|
||||
} from '@vegaprotocol/wallet';
|
||||
import classNames from 'classnames';
|
||||
import { useLayoutEffect, useState } from 'react';
|
||||
|
||||
export type FormFields = {
|
||||
id: string;
|
||||
name: string;
|
||||
url: string;
|
||||
avatarUrl: string;
|
||||
private: boolean;
|
||||
allowList: string;
|
||||
};
|
||||
|
||||
export enum TransactionType {
|
||||
CreateReferralSet = 'CreateReferralSet',
|
||||
UpdateReferralSet = 'UpdateReferralSet',
|
||||
}
|
||||
|
||||
const prepareTransaction = (
|
||||
type: TransactionType,
|
||||
fields: FormFields
|
||||
): CreateReferralSet | UpdateReferralSet => {
|
||||
switch (type) {
|
||||
case TransactionType.CreateReferralSet:
|
||||
return {
|
||||
createReferralSet: {
|
||||
isTeam: true,
|
||||
team: {
|
||||
name: fields.name,
|
||||
teamUrl: fields.url,
|
||||
avatarUrl: fields.avatarUrl,
|
||||
closed: fields.private,
|
||||
allowList: fields.private
|
||||
? parseAllowListText(fields.allowList)
|
||||
: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
case TransactionType.UpdateReferralSet:
|
||||
return {
|
||||
updateReferralSet: {
|
||||
id: fields.id,
|
||||
isTeam: true,
|
||||
team: {
|
||||
name: fields.name,
|
||||
teamUrl: fields.url,
|
||||
avatarUrl: fields.avatarUrl,
|
||||
closed: fields.private,
|
||||
allowList: fields.private
|
||||
? parseAllowListText(fields.allowList)
|
||||
: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const TeamForm = ({
|
||||
type,
|
||||
status,
|
||||
err,
|
||||
isCreatingSoloTeam,
|
||||
onSubmit,
|
||||
defaultValues,
|
||||
}: {
|
||||
type: TransactionType;
|
||||
status: ReturnType<typeof useReferralSetTransaction>['status'];
|
||||
err: ReturnType<typeof useReferralSetTransaction>['err'];
|
||||
isCreatingSoloTeam: boolean;
|
||||
onSubmit: ReturnType<typeof useReferralSetTransaction>['onSubmit'];
|
||||
defaultValues?: FormFields;
|
||||
}) => {
|
||||
const t = useT();
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
control,
|
||||
watch,
|
||||
formState: { errors },
|
||||
} = useForm<FormFields>({
|
||||
defaultValues: {
|
||||
private: isCreatingSoloTeam,
|
||||
...defaultValues,
|
||||
},
|
||||
});
|
||||
|
||||
const isPrivate = watch('private');
|
||||
|
||||
const sendTransaction = (fields: FormFields) => {
|
||||
onSubmit(prepareTransaction(type, fields));
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(sendTransaction)}>
|
||||
<input type="hidden" {...register('id')} />
|
||||
<TradingFormGroup label={t('Team name')} labelFor="name">
|
||||
<TradingInput {...register('name', { required: t('Required') })} />
|
||||
{errors.name?.message && (
|
||||
<TradingInputError forInput="name">
|
||||
{errors.name.message}
|
||||
</TradingInputError>
|
||||
)}
|
||||
</TradingFormGroup>
|
||||
<TradingFormGroup
|
||||
label={t('URL')}
|
||||
labelFor="url"
|
||||
labelDescription={t(
|
||||
'Provide a link so users can learn more about your team'
|
||||
)}
|
||||
>
|
||||
<TradingInput
|
||||
{...register('url', {
|
||||
pattern: { value: URL_REGEX, message: t('Invalid URL') },
|
||||
})}
|
||||
/>
|
||||
{errors.url?.message && (
|
||||
<TradingInputError forInput="url">
|
||||
{errors.url.message}
|
||||
</TradingInputError>
|
||||
)}
|
||||
</TradingFormGroup>
|
||||
<TradingFormGroup
|
||||
label={t('Avatar URL')}
|
||||
labelFor="avatarUrl"
|
||||
labelDescription={t('Provide a URL to a hosted image')}
|
||||
>
|
||||
<TradingInput
|
||||
{...register('avatarUrl', {
|
||||
pattern: {
|
||||
value: URL_REGEX,
|
||||
message: t('Invalid image URL'),
|
||||
},
|
||||
})}
|
||||
/>
|
||||
{errors.avatarUrl?.message && (
|
||||
<TradingInputError forInput="avatarUrl">
|
||||
{errors.avatarUrl.message}
|
||||
</TradingInputError>
|
||||
)}
|
||||
</TradingFormGroup>
|
||||
{
|
||||
// allow changing to private/public if editing, but don't show these options if making a solo team
|
||||
(type === TransactionType.UpdateReferralSet || !isCreatingSoloTeam) && (
|
||||
<>
|
||||
<TradingFormGroup
|
||||
label={t('Make team private')}
|
||||
labelFor="private"
|
||||
hideLabel={true}
|
||||
>
|
||||
<Controller
|
||||
name="private"
|
||||
control={control}
|
||||
render={({ field }) => {
|
||||
return (
|
||||
<TradingCheckbox
|
||||
label={t('Make team private')}
|
||||
checked={field.value}
|
||||
onCheckedChange={(value) => {
|
||||
field.onChange(value);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</TradingFormGroup>
|
||||
{isPrivate && (
|
||||
<TradingFormGroup
|
||||
label={t('Public key allow list')}
|
||||
labelFor="allowList"
|
||||
labelDescription={t(
|
||||
'Use a comma separated list to allow only specific public keys to join the team'
|
||||
)}
|
||||
>
|
||||
<TextArea
|
||||
{...register('allowList', {
|
||||
required: t('Required'),
|
||||
validate: {
|
||||
allowList: (value) => {
|
||||
const publicKeys = parseAllowListText(value);
|
||||
if (
|
||||
publicKeys.every((pk) => isValidVegaPublicKey(pk))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return t('Invalid public key found in allow list');
|
||||
},
|
||||
},
|
||||
})}
|
||||
/>
|
||||
{errors.allowList?.message && (
|
||||
<TradingInputError forInput="avatarUrl">
|
||||
{errors.allowList.message}
|
||||
</TradingInputError>
|
||||
)}
|
||||
</TradingFormGroup>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
{err && (
|
||||
<p className="text-danger text-xs mb-4 first-letter:capitalize">
|
||||
{err}
|
||||
</p>
|
||||
)}
|
||||
<SubmitButton type={type} status={status} />
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
const SubmitButton = ({
|
||||
type,
|
||||
status,
|
||||
}: {
|
||||
type?: TransactionType;
|
||||
status: Status;
|
||||
}) => {
|
||||
const t = useT();
|
||||
const disabled = status === 'pending' || status === 'requested';
|
||||
|
||||
let text = t('Create');
|
||||
if (type === TransactionType.UpdateReferralSet) {
|
||||
text = t('Update');
|
||||
}
|
||||
|
||||
let confirmedText = t('Created');
|
||||
if (type === TransactionType.UpdateReferralSet) {
|
||||
confirmedText = t('Updated');
|
||||
}
|
||||
|
||||
if (status === 'requested') {
|
||||
text = t('Confirm in wallet...');
|
||||
} else if (status === 'pending') {
|
||||
text = t('Confirming transaction...');
|
||||
}
|
||||
|
||||
const [showConfirmed, setShowConfirmed] = useState<boolean>(false);
|
||||
useLayoutEffect(() => {
|
||||
let to: ReturnType<typeof setTimeout>;
|
||||
if (status === 'confirmed' && !showConfirmed) {
|
||||
to = setTimeout(() => {
|
||||
setShowConfirmed(true);
|
||||
}, 100);
|
||||
}
|
||||
return () => {
|
||||
clearTimeout(to);
|
||||
};
|
||||
}, [showConfirmed, status]);
|
||||
|
||||
const confirmed = (
|
||||
<span
|
||||
className={classNames('text-sm transition-opacity opacity-0', {
|
||||
'opacity-100': showConfirmed,
|
||||
})}
|
||||
>
|
||||
<VegaIcon
|
||||
name={VegaIconNames.TICK}
|
||||
size={18}
|
||||
className="text-vega-green-500"
|
||||
/>{' '}
|
||||
{confirmedText}
|
||||
</span>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="flex gap-2 items-baseline">
|
||||
<TradingButton type="submit" intent={Intent.Info} disabled={disabled}>
|
||||
{text}
|
||||
</TradingButton>
|
||||
{status === 'confirmed' && confirmed}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const parseAllowListText = (str: string = '') => {
|
||||
return str
|
||||
.split(',')
|
||||
.map((v) => v.trim())
|
||||
.filter(Boolean);
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import { type Team } from '../../lib/hooks/use-team';
|
||||
import { Intent, TradingAnchorButton } from '@vegaprotocol/ui-toolkit';
|
||||
import { Links } from '../../lib/links';
|
||||
import { useT } from '../../lib/use-t';
|
||||
|
||||
export const UpdateTeamButton = ({ team }: { team: Team }) => {
|
||||
const t = useT();
|
||||
const { pubKey, isReadOnly } = useVegaWallet();
|
||||
|
||||
if (pubKey && !isReadOnly && pubKey === team.referrer) {
|
||||
return (
|
||||
<TradingAnchorButton
|
||||
data-testid="update-team-button"
|
||||
href={Links.COMPETITIONS_UPDATE_TEAM(team.teamId)}
|
||||
intent={Intent.Info}
|
||||
>
|
||||
{t('Update team')}
|
||||
</TradingAnchorButton>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
@@ -21,7 +21,7 @@ import { useT } from '../../lib/use-t';
|
||||
import { Link, Navigate, useNavigate } from 'react-router-dom';
|
||||
import { Links, Routes } from '../../lib/links';
|
||||
import { useReferralProgram } from './hooks/use-referral-program';
|
||||
import { useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction';
|
||||
import { useCreateReferralSet } from '../../lib/hooks/use-create-referral-set';
|
||||
import { Trans } from 'react-i18next';
|
||||
|
||||
export const CreateCodeContainer = () => {
|
||||
@@ -155,7 +155,7 @@ const CreateCodeDialog = ({
|
||||
stakeAvailable: currentStakeAvailable,
|
||||
requiredStake,
|
||||
onSubmit,
|
||||
} = useReferralSetTransaction();
|
||||
} = useCreateReferralSet();
|
||||
|
||||
const { details: programDetails } = useReferralProgram();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import { getNumberFormat } from '@vegaprotocol/utils';
|
||||
import { type useTeams } from '../../lib/hooks/use-teams';
|
||||
import { type useTeams } from '../../client-pages/competitions/hooks/use-teams';
|
||||
import { useT } from '../../lib/use-t';
|
||||
import { Table } from '../table';
|
||||
import { Rank } from './graphics/rank';
|
||||
|
||||
@@ -46,7 +46,7 @@ export const TeamStats = ({
|
||||
value={
|
||||
stats
|
||||
? formatNumberRounded(
|
||||
new BigNumber(stats.totalQuantumVolume || 0),
|
||||
new BigNumber(stats.totalQuantumVolume),
|
||||
'1e3'
|
||||
)
|
||||
: 0
|
||||
@@ -58,12 +58,12 @@ export const TeamStats = ({
|
||||
value={
|
||||
stats
|
||||
? formatNumberRounded(
|
||||
new BigNumber(stats.totalQuantumRewards || 0),
|
||||
new BigNumber(stats.totalQuantumRewards),
|
||||
'1e3'
|
||||
)
|
||||
: 0
|
||||
}
|
||||
label={t('Rewards paid out')}
|
||||
label={t('Rewards paid')}
|
||||
tooltip={'Total amount of rewards paid out to this team in qUSD'}
|
||||
valueTestId="rewards-paid-stat"
|
||||
/>
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('ActiveRewards', () => {
|
||||
expect(
|
||||
screen.getByText(/Liquidity provision fees received/i)
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText('Individual scope')).toBeInTheDocument();
|
||||
expect(screen.getByText('Entity scope')).toBeInTheDocument();
|
||||
expect(screen.getByText('Average position')).toBeInTheDocument();
|
||||
expect(screen.getByText('Ends in')).toBeInTheDocument();
|
||||
expect(screen.getByText('115431 epochs')).toBeInTheDocument();
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
VegaIconNames,
|
||||
TradingInput,
|
||||
TinyScroll,
|
||||
truncateMiddle,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { IconNames } from '@blueprintjs/icons';
|
||||
import {
|
||||
@@ -31,9 +30,6 @@ import {
|
||||
DispatchMetricLabels,
|
||||
EntityScopeLabelMapping,
|
||||
MarketState,
|
||||
type DispatchStrategy,
|
||||
IndividualScopeMapping,
|
||||
IndividualScopeDescriptionMapping,
|
||||
} from '@vegaprotocol/types';
|
||||
import { Card } from '../card/card';
|
||||
import { useMemo, useState } from 'react';
|
||||
@@ -312,9 +308,6 @@ export const ActiveRewardCard = ({
|
||||
MarketState.STATE_CLOSED,
|
||||
].includes(m.state)
|
||||
);
|
||||
if (marketSettled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const assetInSettledMarket =
|
||||
allMarkets &&
|
||||
@@ -333,6 +326,10 @@ export const ActiveRewardCard = ({
|
||||
return false;
|
||||
});
|
||||
|
||||
if (marketSettled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Gray out the cards that are related to suspended markets
|
||||
const suspended = transferNode.markets?.some(
|
||||
(m) =>
|
||||
@@ -362,7 +359,6 @@ export const ActiveRewardCard = ({
|
||||
: getGradientClasses(dispatchStrategy.dispatchMetric);
|
||||
|
||||
const entityScope = dispatchStrategy.entityScope;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
@@ -478,127 +474,83 @@ export const ActiveRewardCard = ({
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
{dispatchStrategy?.dispatchMetric && (
|
||||
<span className="text-muted text-sm h-[2rem]">
|
||||
{t(DispatchMetricDescription[dispatchStrategy?.dispatchMetric])}
|
||||
</span>
|
||||
)}
|
||||
|
||||
<span className="border-[0.5px] border-gray-700" />
|
||||
{kind.dispatchStrategy && (
|
||||
<RewardRequirements
|
||||
dispatchStrategy={kind.dispatchStrategy}
|
||||
assetDecimalPlaces={transfer.asset?.decimals}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="flex justify-between flex-wrap items-center gap-3 text-xs">
|
||||
<span className="flex flex-col gap-1">
|
||||
<span className="flex items-center gap-1 text-muted">
|
||||
{t('Entity scope')}{' '}
|
||||
</span>
|
||||
|
||||
<span className="flex items-center gap-1">
|
||||
{kind.dispatchStrategy?.teamScope && (
|
||||
<Tooltip
|
||||
description={
|
||||
<span>{kind.dispatchStrategy?.teamScope}</span>
|
||||
}
|
||||
>
|
||||
<span className="flex items-center p-1 rounded-full border border-gray-600">
|
||||
{<VegaIcon name={VegaIconNames.TEAM} size={16} />}
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
{kind.dispatchStrategy?.individualScope && (
|
||||
<Tooltip
|
||||
description={
|
||||
<span>{kind.dispatchStrategy?.individualScope}</span>
|
||||
}
|
||||
>
|
||||
<span className="flex items-center p-1 rounded-full border border-gray-600">
|
||||
{<VegaIcon name={VegaIconNames.MAN} size={16} />}
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
{/* Shows transfer status */}
|
||||
{/* <StatusIndicator
|
||||
status={transfer.status}
|
||||
reason={transfer.reason}
|
||||
/> */}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="flex flex-col gap-1">
|
||||
<span className="flex items-center gap-1 text-muted">
|
||||
{t('Staked VEGA')}{' '}
|
||||
</span>
|
||||
<span className="flex items-center gap-1">
|
||||
{addDecimalsFormatNumber(
|
||||
kind.dispatchStrategy?.stakingRequirement || 0,
|
||||
transfer.asset?.decimals || 0
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="flex flex-col gap-1">
|
||||
<span className="flex items-center gap-1 text-muted">
|
||||
{t('Average position')}{' '}
|
||||
</span>
|
||||
<span className="flex items-center gap-1">
|
||||
{addDecimalsFormatNumber(
|
||||
kind.dispatchStrategy
|
||||
?.notionalTimeWeightedAveragePositionRequirement || 0,
|
||||
transfer.asset?.decimals || 0
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const RewardRequirements = ({
|
||||
dispatchStrategy,
|
||||
assetDecimalPlaces = 0,
|
||||
}: {
|
||||
dispatchStrategy: DispatchStrategy;
|
||||
assetDecimalPlaces: number | undefined;
|
||||
}) => {
|
||||
const t = useT();
|
||||
|
||||
return (
|
||||
<dl className="flex justify-between flex-wrap items-center gap-3 text-xs">
|
||||
<div className="flex flex-col gap-1">
|
||||
<dt className="flex items-center gap-1 text-muted">
|
||||
{t('{{entity}} scope', {
|
||||
entity: EntityScopeLabelMapping[dispatchStrategy.entityScope],
|
||||
})}
|
||||
</dt>
|
||||
<dd className="flex items-center gap-1">
|
||||
<RewardEntityScope dispatchStrategy={dispatchStrategy} />
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-1">
|
||||
<dt className="flex items-center gap-1 text-muted">
|
||||
{t('Staked VEGA')}
|
||||
</dt>
|
||||
<dd className="flex items-center gap-1">
|
||||
{addDecimalsFormatNumber(
|
||||
dispatchStrategy?.stakingRequirement || 0,
|
||||
assetDecimalPlaces
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-1">
|
||||
<dt className="flex items-center gap-1 text-muted">
|
||||
{t('Average position')}
|
||||
</dt>
|
||||
<dd className="flex items-center gap-1">
|
||||
{addDecimalsFormatNumber(
|
||||
dispatchStrategy?.notionalTimeWeightedAveragePositionRequirement ||
|
||||
0,
|
||||
assetDecimalPlaces
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
);
|
||||
};
|
||||
|
||||
const RewardEntityScope = ({
|
||||
dispatchStrategy,
|
||||
}: {
|
||||
dispatchStrategy: DispatchStrategy;
|
||||
}) => {
|
||||
const t = useT();
|
||||
|
||||
if (dispatchStrategy.entityScope === EntityScope.ENTITY_SCOPE_TEAMS) {
|
||||
return (
|
||||
<Tooltip
|
||||
description={
|
||||
dispatchStrategy.teamScope?.length ? (
|
||||
<div className="text-xs">
|
||||
<p className="mb-1">{t('Eligible teams')}</p>
|
||||
<ul>
|
||||
{dispatchStrategy.teamScope.map((teamId) => {
|
||||
if (!teamId) return null;
|
||||
return <li key={teamId}>{truncateMiddle(teamId)}</li>;
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
) : (
|
||||
t('All teams are eligible')
|
||||
)
|
||||
}
|
||||
>
|
||||
<span>
|
||||
{dispatchStrategy.teamScope?.length
|
||||
? t('Some teams')
|
||||
: t('All teams')}
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
dispatchStrategy.entityScope === EntityScope.ENTITY_SCOPE_INDIVIDUALS &&
|
||||
dispatchStrategy.individualScope
|
||||
) {
|
||||
return (
|
||||
<Tooltip
|
||||
description={
|
||||
IndividualScopeDescriptionMapping[dispatchStrategy.individualScope]
|
||||
}
|
||||
>
|
||||
<span>{IndividualScopeMapping[dispatchStrategy.individualScope]}</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const getGradientClasses = (d: DispatchMetric | undefined) => {
|
||||
switch (d) {
|
||||
case DispatchMetric.DISPATCH_METRIC_AVERAGE_POSITION:
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { ActivityStreak } from './activity-streaks';
|
||||
|
||||
jest.mock('@vegaprotocol/network-parameters', () => ({
|
||||
...jest.requireActual('@vegaprotocol/network-parameters'),
|
||||
useNetworkParams: jest.fn(() => ({
|
||||
params: {
|
||||
rewards_activityStreak_inactivityLimit: '3',
|
||||
},
|
||||
loading: false,
|
||||
error: null,
|
||||
})),
|
||||
}));
|
||||
|
||||
describe('ActivityStreak', () => {
|
||||
it('renders null when streak is not active', () => {
|
||||
const tiers: {
|
||||
|
||||
@@ -3,10 +3,6 @@ import { useT } from '../../../lib/use-t';
|
||||
import classNames from 'classnames';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import type { PartyActivityStreak } from '@vegaprotocol/types';
|
||||
import {
|
||||
NetworkParams,
|
||||
useNetworkParams,
|
||||
} from '@vegaprotocol/network-parameters';
|
||||
|
||||
export const safeProgress = (
|
||||
i: number,
|
||||
@@ -73,12 +69,7 @@ export const ActivityStreak = ({
|
||||
}) => {
|
||||
const t = useT();
|
||||
const userTierIndex = useGetUserTier(tiers, streak?.activeFor);
|
||||
const { params } = useNetworkParams([
|
||||
NetworkParams.rewards_activityStreak_inactivityLimit,
|
||||
]);
|
||||
const remaining = new BigNumber(params.rewards_activityStreak_inactivityLimit)
|
||||
.minus(streak?.inactiveFor || 0)
|
||||
.toNumber();
|
||||
|
||||
if (!tiers || tiers.length === 0) return null;
|
||||
|
||||
const progressBarHeight = 'h-10';
|
||||
@@ -212,35 +203,12 @@ export const ActivityStreak = ({
|
||||
<VegaIcon name={VegaIconNames.STREAK} />
|
||||
|
||||
<span className="flex flex-col">
|
||||
{streak && (
|
||||
{streak?.isActive && (
|
||||
<span data-testid="epoch-streak">
|
||||
{streak.isActive
|
||||
? t(
|
||||
'userActive',
|
||||
'{{active}} trader: {{count}} epochs so far',
|
||||
{
|
||||
active: 'Active',
|
||||
count: streak.activeFor || 0,
|
||||
}
|
||||
)
|
||||
: remaining > 0
|
||||
? t(
|
||||
'userInactive',
|
||||
'{{active}} trader: {{count}} epochs so far, you will lose your streak in {{remaining}} epochs!',
|
||||
{
|
||||
active: 'Inactive',
|
||||
count: streak.inactiveFor || 0,
|
||||
remaining,
|
||||
}
|
||||
)
|
||||
: t(
|
||||
'userActive',
|
||||
'{{active}} trader: {{count}} epochs so far',
|
||||
{
|
||||
active: 'Inactive',
|
||||
count: streak.inactiveFor || 0,
|
||||
}
|
||||
)}{' '}
|
||||
{t('userActive', '{{active}} trader: {{count}} epochs so far', {
|
||||
active: streak?.isActive ? 'Active' : 'Inactive',
|
||||
count: streak?.activeFor || 0,
|
||||
})}{' '}
|
||||
{userTierIndex > 0 &&
|
||||
new BigNumber(
|
||||
tiers[0].minimum_activity_streak
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
CONSOLE_IMAGE_NAME=vegaprotocol/trading:latest
|
||||
VEGA_VERSION=v0.74.0-preview.8
|
||||
VEGA_VERSION=v0.74.0-preview.2
|
||||
LOCAL_SERVER=false
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
CONSOLE_IMAGE_NAME=vegaprotocol/trading:develop
|
||||
VEGA_VERSION=v0.74.0-preview.6
|
||||
VEGA_VERSION=v0.74.0-preview.2
|
||||
LOCAL_SERVER=false
|
||||
|
||||
Generated
+2
-2
@@ -1,4 +1,4 @@
|
||||
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "certifi"
|
||||
@@ -1161,7 +1161,7 @@ profile = ["pytest-profiling", "snakeviz"]
|
||||
type = "git"
|
||||
url = "https://github.com/vegaprotocol/vega-market-sim.git/"
|
||||
reference = "HEAD"
|
||||
resolved_reference = "026976549c21e59f6f9c48f06ab15a210c5a5bf3"
|
||||
resolved_reference = "4440abbb6ce0d3e80beba5cd01f20cd21983cbf8"
|
||||
|
||||
[[package]]
|
||||
name = "websocket-client"
|
||||
|
||||
@@ -38,7 +38,7 @@ def test_switch_cross_isolated_margin(
|
||||
expect(page.get_by_test_id("toast-content")).to_have_text(
|
||||
"ConfirmedYour transaction has been confirmedView in block explorerUpdate margin modeBTC:DAI_2023Isolated margin mode, leverage: 1.0x")
|
||||
expect(page.locator(margin_row).nth(1)
|
||||
).to_have_text("22,109.99996Isolated1.0x")
|
||||
).to_have_text("11,109.99996Isolated1.0x")
|
||||
# tbd - tooltip is not visible without this wait
|
||||
page.wait_for_timeout(1000)
|
||||
page.get_by_test_id(tab_positions).get_by_text("Isolated").hover()
|
||||
|
||||
@@ -11,34 +11,27 @@ place_order = "place-order"
|
||||
deal_ticket_warning_margin = "deal-ticket-warning-margin"
|
||||
deal_ticket_deposit_dialog_button = "deal-ticket-deposit-dialog-button"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
with init_vega(request) as vega:
|
||||
yield vega
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def continuous_market(vega):
|
||||
return setup_continuous_market(vega)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_should_display_info_and_button_for_deposit(continuous_market, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
page.get_by_test_id(order_size).fill("200000")
|
||||
page.get_by_test_id(order_price).fill("20")
|
||||
# 7002-SORD-060
|
||||
expect(page.get_by_test_id(deal_ticket_warning_margin)).to_have_text(
|
||||
"You may not have enough margin available to open this position.")
|
||||
expect(page.get_by_test_id(deal_ticket_warning_margin)).to_have_text("You may not have enough margin available to open this position.")
|
||||
page.get_by_test_id(deal_ticket_warning_margin).hover()
|
||||
expect(page.get_by_test_id("tooltip-content").nth(0)).to_have_text(
|
||||
"1,661,896.6317 tDAI is currently required.You have only 1,000,000.00.Deposit tDAI")
|
||||
expect(page.get_by_test_id("tooltip-content").nth(0)).to_have_text("1,661,896.6317 tDAI is currently required.You have only 1,000,000.00.Deposit tDAI")
|
||||
page.get_by_test_id(deal_ticket_deposit_dialog_button).nth(0).click()
|
||||
expect(page.get_by_test_id("sidebar-content")
|
||||
).to_contain_text("DepositFrom")
|
||||
|
||||
|
||||
expect(page.get_by_test_id("sidebar-content")).to_contain_text("DepositFrom")
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_should_show_an_error_if_your_balance_is_zero(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
@@ -49,6 +42,5 @@ def test_should_show_an_error_if_your_balance_is_zero(continuous_market, vega: V
|
||||
# 7002-SORD-060
|
||||
expect(page.get_by_test_id(place_order)).to_be_enabled()
|
||||
# 7002-SORD-003
|
||||
expect(page.get_by_test_id("deal-ticket-error-message-zero-balance")
|
||||
).to_have_text("You need tDAI in your wallet to trade in this market.Make a deposit")
|
||||
expect(page.get_by_test_id(deal_ticket_deposit_dialog_button)).to_be_visible()
|
||||
expect(page.get_by_test_id("deal-ticket-error-message-zero-balance")).to_have_text("You need tDAI in your wallet to trade in this market.Make a deposit")
|
||||
expect(page.get_by_test_id(deal_ticket_deposit_dialog_button)).to_be_visible()
|
||||
|
||||
@@ -10,18 +10,15 @@ import logging
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
def vega():
|
||||
with init_vega() as vega:
|
||||
yield vega
|
||||
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
def simple_market(vega: VegaServiceNull):
|
||||
return setup_simple_market(vega)
|
||||
|
||||
|
||||
class TestGetStarted:
|
||||
def test_get_started_interactive(self, vega: VegaServiceNull, page: Page):
|
||||
page.goto("/")
|
||||
@@ -33,8 +30,7 @@ class TestGetStarted:
|
||||
expect(page.locator(".list-none")).to_contain_text(
|
||||
"1.Connect2.Deposit funds3.Open a position"
|
||||
)
|
||||
# This is the default wallet name within VegaServiceNull and CANNOT be changed
|
||||
DEFAULT_WALLET_NAME = "MarketSim"
|
||||
DEFAULT_WALLET_NAME = "MarketSim" # This is the default wallet name within VegaServiceNull and CANNOT be changed
|
||||
|
||||
# Calling get_keypairs will internally call _load_tokens for the given wallet
|
||||
keypairs = vega.wallet.get_keypairs(DEFAULT_WALLET_NAME)
|
||||
@@ -141,8 +137,7 @@ class TestGetStarted:
|
||||
def test_get_started_seen_already(self, simple_market, page: Page):
|
||||
page.goto(f"/#/markets/{simple_market}")
|
||||
get_started_locator = page.get_by_test_id("connect-vega-wallet")
|
||||
page.wait_for_selector(
|
||||
'[data-testid="connect-vega-wallet"]', state="attached")
|
||||
page.wait_for_selector('[data-testid="connect-vega-wallet"]', state="attached")
|
||||
expect(get_started_locator).to_be_enabled
|
||||
expect(get_started_locator).to_be_visible
|
||||
# 0007-FUGS-015
|
||||
|
||||
@@ -36,19 +36,16 @@ def validate_info_section(page: Page, fields: [[str, str]]):
|
||||
for rowNumber, field in enumerate(fields):
|
||||
name, value = field
|
||||
expect(
|
||||
page.get_by_test_id(
|
||||
"key-value-table-row").nth(rowNumber).locator("dt")
|
||||
page.get_by_test_id("key-value-table-row").nth(rowNumber).locator("dt")
|
||||
).to_contain_text(name)
|
||||
expect(
|
||||
page.get_by_test_id(
|
||||
"key-value-table-row").nth(rowNumber).locator("dd")
|
||||
page.get_by_test_id("key-value-table-row").nth(rowNumber).locator("dd")
|
||||
).to_contain_text(value)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_current_fees(page: Page):
|
||||
# 6002-MDET-101
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Current fees").click()
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Current fees").click()
|
||||
fields = [
|
||||
["Maker Fee", "10%"],
|
||||
["Infrastructure Fee", "0.05%"],
|
||||
@@ -57,11 +54,10 @@ def test_market_info_current_fees(page: Page):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_market_price(page: Page):
|
||||
# 6002-MDET-102
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Market price").click()
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Market price").click()
|
||||
fields = [
|
||||
["Mark Price", "107.50"],
|
||||
["Best Bid Price", "101.50"],
|
||||
@@ -70,11 +66,10 @@ def test_market_info_market_price(page: Page):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_market_volume(page: Page):
|
||||
# 6002-MDET-103
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Market volume").click()
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Market volume").click()
|
||||
fields = [
|
||||
["24 Hour Volume", "-"],
|
||||
["Open Interest", "1"],
|
||||
@@ -85,32 +80,17 @@ def test_market_info_market_volume(page: Page):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
def test_market_info_liquidation_strategy(page: Page):
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Liquidation strategy").click()
|
||||
fields = [
|
||||
["Disposal Fraction", "1"],
|
||||
["Disposal Time Step", "1"],
|
||||
["Full Disposal Size", "1,000,000,000"],
|
||||
["Max Fraction Consumed", "0.5"],
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
def test_market_info_liquidation(page: Page):
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_insurance_pool(page: Page):
|
||||
# 6002-MDET-104
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Liquidations").click()
|
||||
fields = [["Insurance Pool Balance", "0.00 tDAI"]]
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Insurance pool").click()
|
||||
fields = [["Balance", "0.00 tDAI"]]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("core issue #5681")
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_key_details(page: Page, vega: VegaServiceNull):
|
||||
# 6002-MDET-201
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Key details").click()
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Key details").click()
|
||||
market_id = vega.find_market_id("BTC:DAI_2023")
|
||||
short_market_id = market_id[:6] + "…" + market_id[-4:]
|
||||
fields = [
|
||||
@@ -126,7 +106,7 @@ def test_market_info_key_details(page: Page, vega: VegaServiceNull):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_instrument(page: Page):
|
||||
# 6002-MDET-202
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Instrument").click()
|
||||
@@ -141,7 +121,7 @@ def test_market_info_instrument(page: Page):
|
||||
|
||||
# @pytest.mark.skip("oracle test to be fixed")
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_oracle(page: Page):
|
||||
# 6002-MDET-203
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Oracle").click()
|
||||
@@ -155,11 +135,10 @@ def test_market_info_oracle(page: Page):
|
||||
# "href", re.compile(rf'(\/oracles\/{vega.find_market_id("BTC:DAI_2023")})')
|
||||
# )
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_settlement_asset(page: Page, vega: VegaServiceNull):
|
||||
# 6002-MDET-206
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Settlement asset").click()
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Settlement asset").click()
|
||||
tdai_id = vega.find_asset_id("tDAI")
|
||||
tdai_id_short = tdai_id[:6] + "…" + tdai_id[-4:]
|
||||
fields = [
|
||||
@@ -176,7 +155,7 @@ def test_market_info_settlement_asset(page: Page, vega: VegaServiceNull):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_metadata(page: Page):
|
||||
# 6002-MDET-207
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Metadata").click()
|
||||
@@ -185,7 +164,7 @@ def test_market_info_metadata(page: Page):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_risk_model(page: Page):
|
||||
# 6002-MDET-208
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Risk model").click()
|
||||
@@ -196,7 +175,7 @@ def test_market_info_risk_model(page: Page):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_margin_scaling_factors(page: Page):
|
||||
# 6002-MDET-209
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
@@ -204,17 +183,17 @@ def test_market_info_margin_scaling_factors(page: Page):
|
||||
).click()
|
||||
fields = [
|
||||
["Linear Slippage Factor", "0.001"],
|
||||
["Quadratic Slippage Factor", "0"],
|
||||
["Search Level", "1.1"],
|
||||
["Initial Margin", "1.5"],
|
||||
["Collateral Release", "1.7"],
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_risk_factors(page: Page):
|
||||
# 6002-MDET-210
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Risk factors").click()
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Risk factors").click()
|
||||
fields = [
|
||||
["Long", "0.05153"],
|
||||
["Short", "0.05422"],
|
||||
@@ -225,7 +204,7 @@ def test_market_info_risk_factors(page: Page):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_price_monitoring_bounds(page: Page):
|
||||
# 6002-MDET-211
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
@@ -234,27 +213,27 @@ def test_market_info_price_monitoring_bounds(page: Page):
|
||||
expect(page.locator("p.col-span-1").nth(0)).to_contain_text(
|
||||
"99.9999% probability price bounds"
|
||||
)
|
||||
expect(page.locator("p.col-span-1").nth(1)
|
||||
).to_contain_text("Within 86,400 seconds")
|
||||
expect(page.locator("p.col-span-1").nth(1)).to_contain_text("Within 86,400 seconds")
|
||||
fields = [
|
||||
["Highest Price", "138.66685 BTC"],
|
||||
["Lowest Price", "83.11038 BTC"],
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_liquidity_monitoring_parameters(page: Page):
|
||||
# 6002-MDET-212
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Liquidity monitoring parameters"
|
||||
).click()
|
||||
fields = [
|
||||
["Triggering Ratio", "0.7"],
|
||||
["Time Window", "3,600"],
|
||||
["Scaling Factor", "1"],
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
# Liquidity resolves to 3 results
|
||||
def test_market_info_liquidit(page: Page):
|
||||
# 6002-MDET-213
|
||||
@@ -267,7 +246,7 @@ def test_market_info_liquidit(page: Page):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_liquidity_price_range(page: Page):
|
||||
# 6002-MDET-214
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
@@ -280,22 +259,19 @@ def test_market_info_liquidity_price_range(page: Page):
|
||||
]
|
||||
validate_info_section(page, fields)
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_proposal(page: Page, vega: VegaServiceNull):
|
||||
# 6002-MDET-301
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Proposal").click()
|
||||
first_link = (
|
||||
page.get_by_test_id(
|
||||
"accordion-content").get_by_test_id("external-link").first
|
||||
page.get_by_test_id("accordion-content").get_by_test_id("external-link").first
|
||||
)
|
||||
second_link = (
|
||||
page.get_by_test_id(
|
||||
"accordion-content").get_by_test_id("external-link").nth(1)
|
||||
page.get_by_test_id("accordion-content").get_by_test_id("external-link").nth(1)
|
||||
)
|
||||
expect(first_link).to_have_text("View governance proposal")
|
||||
expect(first_link).to_have_attribute(
|
||||
"href", re.compile(
|
||||
rf'(\/proposals\/{vega.find_market_id("BTC:DAI_2023")})')
|
||||
"href", re.compile(rf'(\/proposals\/{vega.find_market_id("BTC:DAI_2023")})')
|
||||
)
|
||||
expect(second_link).to_have_text("Propose a change to market")
|
||||
|
||||
@@ -304,14 +280,13 @@ def test_market_info_proposal(page: Page, vega: VegaServiceNull):
|
||||
"href", re.compile(r"(\/proposals\/propose\/update-market)")
|
||||
)
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd-market-sim")
|
||||
def test_market_info_succession_line(page: Page, vega: VegaServiceNull):
|
||||
page.get_by_test_id(market_title_test_id).get_by_text(
|
||||
"Succession line").click()
|
||||
page.get_by_test_id(market_title_test_id).get_by_text("Succession line").click()
|
||||
market_id = vega.find_market_id("BTC:DAI_2023")
|
||||
succession_line = page.get_by_test_id("succession-line-item")
|
||||
expect(succession_line.get_by_test_id(
|
||||
"external-link")).to_have_text("BTC:DAI_2023")
|
||||
expect(succession_line.get_by_test_id("external-link")).to_have_text("BTC:DAI_2023")
|
||||
expect(succession_line.get_by_test_id("external-link")).to_have_attribute(
|
||||
"href", re.compile(rf"(\/proposals\/{market_id})")
|
||||
)
|
||||
|
||||
@@ -128,11 +128,10 @@ def test_limit_order_trade_open_position(continuous_market, page: Page):
|
||||
position["leverage"]
|
||||
)
|
||||
|
||||
# need to ne check why it is not visible
|
||||
# liquidation = table.locator("[col-id='liquidationPrice']")
|
||||
# expect(liquidation.get_by_test_id("liquidation-price")).to_have_text(
|
||||
# position["liquidation"]
|
||||
# )
|
||||
liquidation = table.locator("[col-id='liquidationPrice']")
|
||||
expect(liquidation.get_by_test_id("liquidation-price")).to_have_text(
|
||||
position["liquidation"]
|
||||
)
|
||||
|
||||
realisedPNL = table.locator("[col-id='realisedPNL']")
|
||||
expect(realisedPNL).to_have_text(position["realised_pnl"])
|
||||
|
||||
@@ -46,9 +46,7 @@ def test_filtered_cards(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
side="SIDE_BUY",
|
||||
volume=1,
|
||||
)
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.goto("/#/rewards")
|
||||
next_epoch(vega=vega)
|
||||
|
||||
vega.update_market_state(
|
||||
market_id=continuous_market,
|
||||
@@ -57,9 +55,8 @@ def test_filtered_cards(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
forward_time_to_enactment=True,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
|
||||
page.reload()
|
||||
expect(page.locator(".from-vega-cdark-400")).to_be_visible(timeout=15000)
|
||||
page.goto("/#/rewards")
|
||||
expect(page.locator(".from-vega-cdark-400")).to_be_visible()
|
||||
governance.submit_oracle_data(
|
||||
wallet=vega.wallet,
|
||||
payload={"trading.terminated": "true"},
|
||||
|
||||
@@ -8,7 +8,7 @@ from actions.utils import next_epoch
|
||||
|
||||
market_banner = "market-banner"
|
||||
|
||||
|
||||
@pytest.mark.skip("tbd")
|
||||
@pytest.mark.usefixtures("risk_accepted")
|
||||
def test_succession_line(vega: VegaServiceNull, page: Page):
|
||||
parent_market_id = setup_continuous_market(vega)
|
||||
@@ -20,14 +20,12 @@ def test_succession_line(vega: VegaServiceNull, page: Page):
|
||||
expect(page.get_by_test_id(market_banner)).not_to_be_attached()
|
||||
|
||||
successor_name = "successor market name"
|
||||
successor_id = propose_successor(
|
||||
vega, parent_market_id, tdai_id, successor_name)
|
||||
successor_id = propose_successor(vega, parent_market_id, tdai_id, successor_name)
|
||||
|
||||
# Check that the banner notifying about the successor proposal is shown
|
||||
banner = page.get_by_test_id(market_banner)
|
||||
expect(banner).to_be_attached()
|
||||
expect(banner.get_by_text(
|
||||
"A successor to this market has been proposed")).to_be_visible()
|
||||
expect(banner.get_by_text("A successor to this market has been proposed")).to_be_visible()
|
||||
|
||||
next_epoch(vega)
|
||||
|
||||
@@ -47,6 +45,7 @@ def test_succession_line(vega: VegaServiceNull, page: Page):
|
||||
# the succession line
|
||||
page.reload()
|
||||
|
||||
#tbd issue - 5546
|
||||
page.get_by_test_id("Info").click()
|
||||
|
||||
page.get_by_role("button", name="Succession line").click()
|
||||
@@ -79,7 +78,6 @@ def test_succession_line(vega: VegaServiceNull, page: Page):
|
||||
page.wait_for_selector('[data-testid="market-banner"]', state="attached")
|
||||
expect(banner.get_by_text("This market has been succeeded")).to_be_visible()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("risk_accepted")
|
||||
def test_banners(vega: VegaServiceNull, page: Page):
|
||||
|
||||
@@ -93,9 +91,9 @@ def test_banners(vega: VegaServiceNull, page: Page):
|
||||
expect(page.get_by_test_id(market_banner)).not_to_be_attached()
|
||||
|
||||
vega.submit_termination_and_settlement_data(
|
||||
settlement_key=GOVERNANCE_WALLET.name,
|
||||
settlement_price=100,
|
||||
market_id=parent_market_id,
|
||||
settlement_key=GOVERNANCE_WALLET.name,
|
||||
settlement_price=100,
|
||||
market_id=parent_market_id,
|
||||
)
|
||||
|
||||
successor_name = "successor market name"
|
||||
@@ -110,7 +108,7 @@ def test_banners(vega: VegaServiceNull, page: Page):
|
||||
# Check that the banner notifying about the successor proposal and market has been settled are shown still after reload
|
||||
page.reload()
|
||||
expect(banner.get_by_text(banner_successor_text)).to_be_visible()
|
||||
expect(banner.get_by_text("1/2")).to_be_visible()
|
||||
expect(banner.get_by_text("1/2")).to_be_visible()
|
||||
# Check that the banner notifying about the successor proposal is not visible after close those banners
|
||||
banner.get_by_test_id("icon-cross").click()
|
||||
expect(banner.get_by_text("This market has been settled")).to_be_visible()
|
||||
@@ -121,8 +119,7 @@ def test_banners(vega: VegaServiceNull, page: Page):
|
||||
expect(page.get_by_test_id(market_banner)).not_to_be_attached()
|
||||
page.reload()
|
||||
expect(banner).to_be_attached()
|
||||
expect(banner.get_by_text(banner_successor_text)).to_be_visible()
|
||||
|
||||
expect(banner.get_by_text(banner_successor_text)).to_be_visible()
|
||||
|
||||
def propose_successor(
|
||||
vega: VegaServiceNull, parent_market_id, tdai_id, market_name
|
||||
@@ -140,7 +137,6 @@ def propose_successor(
|
||||
)
|
||||
return market_id
|
||||
|
||||
|
||||
def provide_successor_liquidity(
|
||||
vega: VegaServiceNull, market_id
|
||||
):
|
||||
|
||||
@@ -14,14 +14,6 @@ def vega(request):
|
||||
with init_vega(request) as vega:
|
||||
yield vega
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def team_page(vega, browser, request, setup_teams_and_games):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
team_id = setup_teams_and_games["team_id"]
|
||||
page.goto(f"/#/competitions/teams/{team_id}")
|
||||
yield page
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def setup_teams_and_games(vega: VegaServiceNull):
|
||||
@@ -60,16 +52,6 @@ def setup_teams_and_games(vega: VegaServiceNull):
|
||||
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
current_epoch = vega.statistics().epoch_seq
|
||||
game_start = current_epoch + 1
|
||||
game_end = current_epoch + 11
|
||||
|
||||
current_epoch = vega.statistics().epoch_seq
|
||||
print(f"[EPOCH: {current_epoch}] creating recurring transfer")
|
||||
print(f"Game start: {game_start}")
|
||||
print(f"Game game end: {game_end}")
|
||||
|
||||
vega.recurring_transfer(
|
||||
from_key_name=PARTY_A.name,
|
||||
from_account_type=vega_protos.vega.ACCOUNT_TYPE_GENERAL,
|
||||
@@ -82,39 +64,24 @@ def setup_teams_and_games(vega: VegaServiceNull):
|
||||
n_top_performers=1,
|
||||
amount=100,
|
||||
factor=1.0,
|
||||
start_epoch=game_start,
|
||||
end_epoch=game_end,
|
||||
window_length=10
|
||||
)
|
||||
|
||||
next_epoch(vega)
|
||||
print(f"[EPOCH: {vega.statistics().epoch_seq}] starting order activity")
|
||||
|
||||
# Team statistics will only return data when team has been active
|
||||
# for DEFAULT_AGGREGATION_EPOCHS epochs
|
||||
#
|
||||
# https://vegaprotocol.slack.com/archives/C02KVKMAE82/p1706635625851769?thread_ts=1706631542.576449&cid=C02KVKMAE82
|
||||
|
||||
# Create trading activity for 10 epochs (which is the default)
|
||||
for i in range(10):
|
||||
vega.submit_order(
|
||||
trading_key=PARTY_B.name,
|
||||
market_id=tDAI_market,
|
||||
order_type="TYPE_MARKET",
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
side="SIDE_BUY",
|
||||
volume=1,
|
||||
)
|
||||
vega.submit_order(
|
||||
trading_key=PARTY_A.name,
|
||||
market_id=tDAI_market,
|
||||
order_type="TYPE_MARKET",
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
side="SIDE_BUY",
|
||||
volume=1,
|
||||
)
|
||||
next_epoch(vega)
|
||||
print(f"[EPOCH: {vega.statistics().epoch_seq}] {i} epoch passed")
|
||||
vega.submit_order(
|
||||
trading_key=PARTY_B.name,
|
||||
market_id=tDAI_market,
|
||||
order_type="TYPE_MARKET",
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
side="SIDE_BUY",
|
||||
volume=1,
|
||||
)
|
||||
vega.submit_order(
|
||||
trading_key=PARTY_A.name,
|
||||
market_id=tDAI_market,
|
||||
order_type="TYPE_MARKET",
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
side="SIDE_BUY",
|
||||
volume=1,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
|
||||
return {
|
||||
"market_id": tDAI_market,
|
||||
@@ -136,24 +103,30 @@ def create_team(vega: VegaServiceNull):
|
||||
|
||||
return team_name
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def team_page(vega, browser, request, setup_teams_and_games):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
team_id = setup_teams_and_games["team_id"]
|
||||
page.goto(f"/#/competitions/teams/{team_id}")
|
||||
yield page
|
||||
|
||||
def test_team_page_games_table(team_page: Page):
|
||||
team_page.pause()
|
||||
team_page.get_by_test_id("games-toggle").click()
|
||||
expect(team_page.get_by_test_id("games-toggle")).to_have_text("Games (1)")
|
||||
expect(team_page.get_by_test_id("rank-0")).to_have_text("1")
|
||||
expect(team_page.get_by_test_id("epoch-0")).to_have_text("18")
|
||||
expect(team_page.get_by_test_id("epoch-0")).to_have_text("8")
|
||||
expect(team_page.get_by_test_id("type-0")).to_have_text("Price maker fees paid")
|
||||
expect(team_page.get_by_test_id("amount-0")).to_have_text("100,000,000")
|
||||
expect(team_page.get_by_test_id("participatingTeams-0")).to_have_text(
|
||||
"1"
|
||||
)
|
||||
expect(team_page.get_by_test_id("participatingMembers-0")).to_have_text(
|
||||
expect(team_page.get_by_test_id("amount-0")).to_have_text("10,000,000")
|
||||
expect(team_page.get_by_test_id("teams-0")).to_have_text(
|
||||
"2"
|
||||
)
|
||||
) # TODO I think this should be 1, confirm with devs
|
||||
|
||||
def test_team_page_members_table(team_page: Page):
|
||||
team_page.get_by_test_id("members-toggle").click()
|
||||
expect(team_page.get_by_test_id("members-toggle")).to_have_text("Members (4)")
|
||||
expect(team_page.get_by_test_id("members-toggle")).to_have_text("Members (3)")
|
||||
expect(team_page.get_by_test_id("referee-0")).to_be_visible()
|
||||
expect(team_page.get_by_test_id("joinedAt-0")).to_be_visible()
|
||||
expect(team_page.get_by_test_id("joinedAtEpoch-0")).to_have_text("8")
|
||||
@@ -162,40 +135,34 @@ def test_team_page_headline(team_page: Page, setup_teams_and_games
|
||||
):
|
||||
team_name = setup_teams_and_games["team_name"]
|
||||
expect(team_page.get_by_test_id("team-name")).to_have_text(team_name)
|
||||
expect(team_page.get_by_test_id("members-count-stat")).to_have_text("4")
|
||||
|
||||
expect(team_page.get_by_test_id("members-count-stat")).to_have_text("3")
|
||||
expect(team_page.get_by_test_id("total-games-stat")).to_have_text(
|
||||
"1"
|
||||
)
|
||||
|
||||
# TODO this still seems wrong as its always 0
|
||||
"0"
|
||||
) # TODO this should be 1, confirm with devs
|
||||
expect(team_page.get_by_test_id("total-volume-stat")).to_have_text(
|
||||
"0"
|
||||
)
|
||||
|
||||
) # TODO this should be 10,000,000, confirm with devs
|
||||
expect(team_page.get_by_test_id("rewards-paid-stat")).to_have_text(
|
||||
"100m"
|
||||
)
|
||||
"0"
|
||||
) # TODO this should be 100, confirm with devs
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def competitions_page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
auth_setup(vega, page)
|
||||
page.goto(f"/#/competitions/")
|
||||
yield page
|
||||
|
||||
def test_leaderboard(competitions_page: Page, setup_teams_and_games):
|
||||
team_name = setup_teams_and_games["team_name"]
|
||||
competitions_page.goto(f"/#/competitions/")
|
||||
expect(competitions_page.get_by_test_id("rank-0").locator(".text-yellow-300")).to_have_count(1)
|
||||
competitions_page.pause()
|
||||
expect(competitions_page.get_by_test_id("rank-0").locator("._text-yellow-300")).to_have_count(1)
|
||||
expect(competitions_page.get_by_test_id("team-0")).to_have_text(team_name)
|
||||
expect(competitions_page.get_by_test_id("status-0")).to_have_text("Open")
|
||||
|
||||
expect(competitions_page.get_by_test_id("earned-0")).to_have_text("100,000,000")
|
||||
expect(competitions_page.get_by_test_id("games-0")).to_have_text("1")
|
||||
|
||||
# TODO still odd that this is 0
|
||||
expect(competitions_page.get_by_test_id("volume-0")).to_have_text("-")
|
||||
expect(competitions_page.get_by_test_id("earned-0")).to_have_text("-") #TODO I think this should be 100, confirm with dev
|
||||
expect(competitions_page.get_by_test_id("games-0")).to_have_text("-") #TODO I think this should be 1, confirm with dev
|
||||
expect(competitions_page.get_by_test_id("status-0")).to_have_text("Open")
|
||||
expect(competitions_page.get_by_test_id("volume-0")).to_have_text("-") #TODO I think this should be 10,000,000, confirm with dev
|
||||
|
||||
#TODO def test_games(competitions_page: Page):
|
||||
#TODO currently no games appear which i think is a bug
|
||||
# TODO currently no games appear which i think is a bug
|
||||
@@ -7,7 +7,6 @@ fragment TeamFields on Team {
|
||||
createdAt
|
||||
createdAtEpoch
|
||||
closed
|
||||
allowList
|
||||
}
|
||||
|
||||
fragment TeamStatsFields on TeamStatistics {
|
||||
@@ -17,7 +16,7 @@ fragment TeamStatsFields on TeamStatistics {
|
||||
totalGamesPlayed
|
||||
quantumRewards {
|
||||
epoch
|
||||
totalQuantumRewards
|
||||
total_quantum_rewards
|
||||
}
|
||||
gamesPlayed
|
||||
}
|
||||
@@ -51,14 +50,7 @@ fragment TeamGameFields on Game {
|
||||
}
|
||||
}
|
||||
|
||||
fragment TeamMemberStatsFields on TeamMemberStatistics {
|
||||
partyId
|
||||
totalQuantumVolume
|
||||
totalQuantumRewards
|
||||
totalGamesPlayed
|
||||
}
|
||||
|
||||
query Team($teamId: ID!, $partyId: ID, $aggregationEpochs: Int) {
|
||||
query Team($teamId: ID!, $partyId: ID) {
|
||||
teams(teamId: $teamId) {
|
||||
edges {
|
||||
node {
|
||||
@@ -73,7 +65,7 @@ query Team($teamId: ID!, $partyId: ID, $aggregationEpochs: Int) {
|
||||
}
|
||||
}
|
||||
}
|
||||
teamsStatistics(teamId: $teamId, aggregationEpochs: $aggregationEpochs) {
|
||||
teamsStatistics(teamId: $teamId) {
|
||||
edges {
|
||||
node {
|
||||
...TeamStatsFields
|
||||
@@ -94,14 +86,4 @@ query Team($teamId: ID!, $partyId: ID, $aggregationEpochs: Int) {
|
||||
}
|
||||
}
|
||||
}
|
||||
teamMembersStatistics(
|
||||
teamId: $teamId
|
||||
aggregationEpochs: $aggregationEpochs
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
...TeamMemberStatsFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-30
@@ -3,26 +3,23 @@ import * as Types from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type TeamFieldsFragment = { __typename?: 'Team', teamId: string, referrer: string, name: string, teamUrl: string, avatarUrl: string, createdAt: any, createdAtEpoch: number, closed: boolean, allowList: Array<string> };
|
||||
export type TeamFieldsFragment = { __typename?: 'Team', teamId: string, referrer: string, name: string, teamUrl: string, avatarUrl: string, createdAt: any, createdAtEpoch: number, closed: boolean };
|
||||
|
||||
export type TeamStatsFieldsFragment = { __typename?: 'TeamStatistics', teamId: string, totalQuantumVolume: string, totalQuantumRewards: string, totalGamesPlayed: number, gamesPlayed: Array<string>, quantumRewards: Array<{ __typename?: 'QuantumRewardsPerEpoch', epoch: number, totalQuantumRewards: string }> };
|
||||
export type TeamStatsFieldsFragment = { __typename?: 'TeamStatistics', teamId: string, totalQuantumVolume: string, totalQuantumRewards: string, totalGamesPlayed: number, gamesPlayed: Array<string>, quantumRewards: Array<{ __typename?: 'QuantumRewardsPerEpoch', epoch: number, total_quantum_rewards: string }> };
|
||||
|
||||
export type TeamRefereeFieldsFragment = { __typename?: 'TeamReferee', teamId: string, referee: string, joinedAt: any, joinedAtEpoch: number };
|
||||
|
||||
export type TeamEntityFragment = { __typename?: 'TeamGameEntity', rank: number, volume: string, rewardMetric: Types.DispatchMetric, rewardEarned: string, totalRewardsEarned: string, team: { __typename?: 'TeamParticipation', teamId: string } };
|
||||
export type TeamEntityFragment = { __typename?: 'TeamGameEntity', rank: number, volume: string, rewardMetric: string, rewardEarned: string, totalRewardsEarned: string, team: { __typename?: 'TeamParticipation', teamId: string } };
|
||||
|
||||
export type TeamGameFieldsFragment = { __typename?: 'Game', id: string, epoch: number, numberOfParticipants: number, entities: Array<{ __typename?: 'IndividualGameEntity' } | { __typename?: 'TeamGameEntity', rank: number, volume: string, rewardMetric: Types.DispatchMetric, rewardEarned: string, totalRewardsEarned: string, team: { __typename?: 'TeamParticipation', teamId: string } }> };
|
||||
|
||||
export type TeamMemberStatsFieldsFragment = { __typename?: 'TeamMemberStatistics', partyId: string, totalQuantumVolume: string, totalQuantumRewards: string, totalGamesPlayed: number };
|
||||
export type TeamGameFieldsFragment = { __typename?: 'Game', id: string, epoch: number, numberOfParticipants: number, entities: Array<{ __typename?: 'IndividualGameEntity' } | { __typename?: 'TeamGameEntity', rank: number, volume: string, rewardMetric: string, rewardEarned: string, totalRewardsEarned: string, team: { __typename?: 'TeamParticipation', teamId: string } }> };
|
||||
|
||||
export type TeamQueryVariables = Types.Exact<{
|
||||
teamId: Types.Scalars['ID'];
|
||||
partyId?: Types.InputMaybe<Types.Scalars['ID']>;
|
||||
aggregationEpochs?: Types.InputMaybe<Types.Scalars['Int']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type TeamQuery = { __typename?: 'Query', teams?: { __typename?: 'TeamConnection', edges: Array<{ __typename?: 'TeamEdge', node: { __typename?: 'Team', teamId: string, referrer: string, name: string, teamUrl: string, avatarUrl: string, createdAt: any, createdAtEpoch: number, closed: boolean, allowList: Array<string> } }> } | null, partyTeams?: { __typename?: 'TeamConnection', edges: Array<{ __typename?: 'TeamEdge', node: { __typename?: 'Team', teamId: string, referrer: string, name: string, teamUrl: string, avatarUrl: string, createdAt: any, createdAtEpoch: number, closed: boolean, allowList: Array<string> } }> } | null, teamsStatistics?: { __typename?: 'TeamsStatisticsConnection', edges: Array<{ __typename?: 'TeamStatisticsEdge', node: { __typename?: 'TeamStatistics', teamId: string, totalQuantumVolume: string, totalQuantumRewards: string, totalGamesPlayed: number, gamesPlayed: Array<string>, quantumRewards: Array<{ __typename?: 'QuantumRewardsPerEpoch', epoch: number, totalQuantumRewards: string }> } }> } | null, teamReferees?: { __typename?: 'TeamRefereeConnection', edges: Array<{ __typename?: 'TeamRefereeEdge', node: { __typename?: 'TeamReferee', teamId: string, referee: string, joinedAt: any, joinedAtEpoch: number } }> } | null, games: { __typename?: 'GamesConnection', edges?: Array<{ __typename?: 'GameEdge', node: { __typename?: 'Game', id: string, epoch: number, numberOfParticipants: number, entities: Array<{ __typename?: 'IndividualGameEntity' } | { __typename?: 'TeamGameEntity', rank: number, volume: string, rewardMetric: Types.DispatchMetric, rewardEarned: string, totalRewardsEarned: string, team: { __typename?: 'TeamParticipation', teamId: string } }> } } | null> | null }, teamMembersStatistics?: { __typename?: 'TeamMembersStatisticsConnection', edges: Array<{ __typename?: 'TeamMemberStatisticsEdge', node: { __typename?: 'TeamMemberStatistics', partyId: string, totalQuantumVolume: string, totalQuantumRewards: string, totalGamesPlayed: number } }> } | null };
|
||||
export type TeamQuery = { __typename?: 'Query', teams?: { __typename?: 'TeamConnection', edges: Array<{ __typename?: 'TeamEdge', node: { __typename?: 'Team', teamId: string, referrer: string, name: string, teamUrl: string, avatarUrl: string, createdAt: any, createdAtEpoch: number, closed: boolean } }> } | null, partyTeams?: { __typename?: 'TeamConnection', edges: Array<{ __typename?: 'TeamEdge', node: { __typename?: 'Team', teamId: string, referrer: string, name: string, teamUrl: string, avatarUrl: string, createdAt: any, createdAtEpoch: number, closed: boolean } }> } | null, teamsStatistics?: { __typename?: 'TeamsStatisticsConnection', edges: Array<{ __typename?: 'TeamStatisticsEdge', node: { __typename?: 'TeamStatistics', teamId: string, totalQuantumVolume: string, totalQuantumRewards: string, totalGamesPlayed: number, gamesPlayed: Array<string>, quantumRewards: Array<{ __typename?: 'QuantumRewardsPerEpoch', epoch: number, total_quantum_rewards: string }> } }> } | null, teamReferees?: { __typename?: 'TeamRefereeConnection', edges: Array<{ __typename?: 'TeamRefereeEdge', node: { __typename?: 'TeamReferee', teamId: string, referee: string, joinedAt: any, joinedAtEpoch: number } }> } | null, games: { __typename?: 'GamesConnection', edges?: Array<{ __typename?: 'GameEdge', node: { __typename?: 'Game', id: string, epoch: number, numberOfParticipants: number, entities: Array<{ __typename?: 'IndividualGameEntity' } | { __typename?: 'TeamGameEntity', rank: number, volume: string, rewardMetric: string, rewardEarned: string, totalRewardsEarned: string, team: { __typename?: 'TeamParticipation', teamId: string } }> } } | null> | null } };
|
||||
|
||||
export const TeamFieldsFragmentDoc = gql`
|
||||
fragment TeamFields on Team {
|
||||
@@ -34,7 +31,6 @@ export const TeamFieldsFragmentDoc = gql`
|
||||
createdAt
|
||||
createdAtEpoch
|
||||
closed
|
||||
allowList
|
||||
}
|
||||
`;
|
||||
export const TeamStatsFieldsFragmentDoc = gql`
|
||||
@@ -45,7 +41,7 @@ export const TeamStatsFieldsFragmentDoc = gql`
|
||||
totalGamesPlayed
|
||||
quantumRewards {
|
||||
epoch
|
||||
totalQuantumRewards
|
||||
total_quantum_rewards
|
||||
}
|
||||
gamesPlayed
|
||||
}
|
||||
@@ -82,16 +78,8 @@ export const TeamGameFieldsFragmentDoc = gql`
|
||||
}
|
||||
}
|
||||
${TeamEntityFragmentDoc}`;
|
||||
export const TeamMemberStatsFieldsFragmentDoc = gql`
|
||||
fragment TeamMemberStatsFields on TeamMemberStatistics {
|
||||
partyId
|
||||
totalQuantumVolume
|
||||
totalQuantumRewards
|
||||
totalGamesPlayed
|
||||
}
|
||||
`;
|
||||
export const TeamDocument = gql`
|
||||
query Team($teamId: ID!, $partyId: ID, $aggregationEpochs: Int) {
|
||||
query Team($teamId: ID!, $partyId: ID) {
|
||||
teams(teamId: $teamId) {
|
||||
edges {
|
||||
node {
|
||||
@@ -106,7 +94,7 @@ export const TeamDocument = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
teamsStatistics(teamId: $teamId, aggregationEpochs: $aggregationEpochs) {
|
||||
teamsStatistics(teamId: $teamId) {
|
||||
edges {
|
||||
node {
|
||||
...TeamStatsFields
|
||||
@@ -127,19 +115,11 @@ export const TeamDocument = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
teamMembersStatistics(teamId: $teamId, aggregationEpochs: $aggregationEpochs) {
|
||||
edges {
|
||||
node {
|
||||
...TeamMemberStatsFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${TeamFieldsFragmentDoc}
|
||||
${TeamStatsFieldsFragmentDoc}
|
||||
${TeamRefereeFieldsFragmentDoc}
|
||||
${TeamGameFieldsFragmentDoc}
|
||||
${TeamMemberStatsFieldsFragmentDoc}`;
|
||||
${TeamGameFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useTeamQuery__
|
||||
@@ -155,7 +135,6 @@ ${TeamMemberStatsFieldsFragmentDoc}`;
|
||||
* variables: {
|
||||
* teamId: // value for 'teamId'
|
||||
* partyId: // value for 'partyId'
|
||||
* aggregationEpochs: // value for 'aggregationEpochs'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
|
||||
+3
-4
@@ -1,15 +1,14 @@
|
||||
import {
|
||||
useSimpleTransaction,
|
||||
type Options,
|
||||
type CreateReferralSet,
|
||||
type UpdateReferralSet,
|
||||
type Options,
|
||||
} from '@vegaprotocol/wallet';
|
||||
import { useStakeAvailable } from './use-stake-available';
|
||||
|
||||
/**
|
||||
* Manages state for creating a referral set or team
|
||||
*/
|
||||
export const useReferralSetTransaction = (opts?: Options) => {
|
||||
export const useCreateReferralSet = (opts?: Options) => {
|
||||
const { stakeAvailable, requiredStake, isEligible } = useStakeAvailable();
|
||||
|
||||
const { status, result, error, send } = useSimpleTransaction({
|
||||
@@ -17,7 +16,7 @@ export const useReferralSetTransaction = (opts?: Options) => {
|
||||
onError: opts?.onError,
|
||||
});
|
||||
|
||||
const onSubmit = (tx: CreateReferralSet | UpdateReferralSet) => {
|
||||
const onSubmit = (tx: CreateReferralSet) => {
|
||||
send(tx);
|
||||
};
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import compact from 'lodash/compact';
|
||||
import { useActiveRewardsQuery } from '../../components/rewards-container/__generated__/Rewards';
|
||||
import { isActiveReward } from '../../components/rewards-container/active-rewards';
|
||||
import {
|
||||
EntityScope,
|
||||
IndividualScope,
|
||||
type TransferNode,
|
||||
} from '@vegaprotocol/types';
|
||||
|
||||
const isScopedToTeams = (node: TransferNode) =>
|
||||
node.transfer.kind.__typename === 'RecurringTransfer' &&
|
||||
// scoped to teams
|
||||
(node.transfer.kind.dispatchStrategy?.entityScope ===
|
||||
EntityScope.ENTITY_SCOPE_TEAMS ||
|
||||
// or to individuals
|
||||
(node.transfer.kind.dispatchStrategy?.entityScope ===
|
||||
EntityScope.ENTITY_SCOPE_INDIVIDUALS &&
|
||||
// but they have to be in a team
|
||||
node.transfer.kind.dispatchStrategy.individualScope ===
|
||||
IndividualScope.INDIVIDUAL_SCOPE_IN_TEAM));
|
||||
|
||||
export const useGames = ({
|
||||
currentEpoch,
|
||||
onlyActive,
|
||||
}: {
|
||||
currentEpoch: number;
|
||||
onlyActive: boolean;
|
||||
}) => {
|
||||
const { data, loading, error } = useActiveRewardsQuery({
|
||||
variables: {
|
||||
isReward: true,
|
||||
},
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
const games = compact(data?.transfersConnection?.edges?.map((n) => n?.node))
|
||||
.map((n) => n as TransferNode)
|
||||
.filter((node) => {
|
||||
const active = onlyActive ? isActiveReward(node, currentEpoch) : true;
|
||||
return active && isScopedToTeams(node);
|
||||
});
|
||||
|
||||
return {
|
||||
data: games,
|
||||
loading,
|
||||
error,
|
||||
};
|
||||
};
|
||||
@@ -6,38 +6,22 @@ import {
|
||||
type TeamStatsFieldsFragment,
|
||||
type TeamRefereeFieldsFragment,
|
||||
type TeamEntityFragment,
|
||||
type TeamMemberStatsFieldsFragment,
|
||||
} from './__generated__/Team';
|
||||
import { DEFAULT_AGGREGATION_EPOCHS } from './use-teams';
|
||||
|
||||
export type Team = TeamFieldsFragment;
|
||||
export type TeamStats = TeamStatsFieldsFragment;
|
||||
export type Member = TeamRefereeFieldsFragment & {
|
||||
isCreator: boolean;
|
||||
totalGamesPlayed: number;
|
||||
totalQuantumVolume: string;
|
||||
totalQuantumRewards: string;
|
||||
};
|
||||
export type Member = TeamRefereeFieldsFragment;
|
||||
export type TeamEntity = TeamEntityFragment;
|
||||
export type TeamGame = ReturnType<typeof useTeam>['games'][number];
|
||||
export type MemberStats = TeamMemberStatsFieldsFragment;
|
||||
|
||||
export const useTeam = (teamId?: string, partyId?: string) => {
|
||||
const queryResult = useTeamQuery({
|
||||
variables: {
|
||||
teamId: teamId || '',
|
||||
partyId,
|
||||
aggregationEpochs: DEFAULT_AGGREGATION_EPOCHS,
|
||||
},
|
||||
const { data, loading, error, refetch } = useTeamQuery({
|
||||
variables: { teamId: teamId || '', partyId },
|
||||
skip: !teamId,
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
const { data } = queryResult;
|
||||
|
||||
const teamEdge = data?.teams?.edges.find((e) => e.node.teamId === teamId);
|
||||
const team = teamEdge?.node;
|
||||
|
||||
const partyTeam = data?.partyTeams?.edges?.length
|
||||
? data.partyTeams.edges[0].node
|
||||
: undefined;
|
||||
@@ -45,40 +29,9 @@ export const useTeam = (teamId?: string, partyId?: string) => {
|
||||
const teamStatsEdge = data?.teamsStatistics?.edges.find(
|
||||
(e) => e.node.teamId === teamId
|
||||
);
|
||||
|
||||
const memberStats = data?.teamMembersStatistics?.edges.length
|
||||
? data.teamMembersStatistics.edges.map((e) => e.node)
|
||||
: [];
|
||||
|
||||
const members: Member[] = data?.teamReferees?.edges.length
|
||||
? data.teamReferees.edges
|
||||
.filter((e) => e.node.teamId === teamId)
|
||||
.map((e) => {
|
||||
const member = e.node;
|
||||
const stats = memberStats.find((m) => m.partyId === member.referee);
|
||||
return {
|
||||
...member,
|
||||
isCreator: false,
|
||||
totalQuantumVolume: stats ? stats.totalQuantumVolume : '0',
|
||||
totalQuantumRewards: stats ? stats.totalQuantumRewards : '0',
|
||||
totalGamesPlayed: stats ? stats.totalGamesPlayed : 0,
|
||||
};
|
||||
})
|
||||
: [];
|
||||
|
||||
if (team) {
|
||||
const ownerStats = memberStats.find((m) => m.partyId === team.referrer);
|
||||
members.unshift({
|
||||
teamId: team.teamId,
|
||||
referee: team.referrer,
|
||||
joinedAt: team?.createdAt,
|
||||
joinedAtEpoch: team?.createdAtEpoch,
|
||||
isCreator: true,
|
||||
totalQuantumVolume: ownerStats ? ownerStats.totalQuantumVolume : '0',
|
||||
totalQuantumRewards: ownerStats ? ownerStats.totalQuantumRewards : '0',
|
||||
totalGamesPlayed: ownerStats ? ownerStats.totalGamesPlayed : 0,
|
||||
});
|
||||
}
|
||||
const members = data?.teamReferees?.edges
|
||||
.filter((e) => e.node.teamId === teamId)
|
||||
.map((e) => e.node);
|
||||
|
||||
// Find games where the current team participated in
|
||||
const gamesWithTeam = compact(data?.games.edges).map((edge) => {
|
||||
@@ -94,7 +47,6 @@ export const useTeam = (teamId?: string, partyId?: string) => {
|
||||
id: edge.node.id,
|
||||
epoch: edge.node.epoch,
|
||||
numberOfParticipants: edge.node.numberOfParticipants,
|
||||
entities: edge.node.entities,
|
||||
team: team as TeamEntity, // TS can't infer that all the game entities are teams
|
||||
};
|
||||
});
|
||||
@@ -102,9 +54,12 @@ export const useTeam = (teamId?: string, partyId?: string) => {
|
||||
const games = orderBy(compact(gamesWithTeam), 'epoch', 'desc');
|
||||
|
||||
return {
|
||||
...queryResult,
|
||||
data,
|
||||
loading,
|
||||
error,
|
||||
refetch,
|
||||
stats: teamStatsEdge?.node,
|
||||
team,
|
||||
team: teamEdge?.node,
|
||||
members,
|
||||
games,
|
||||
partyTeam,
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import orderBy from 'lodash/orderBy';
|
||||
import { useMemo } from 'react';
|
||||
import { useTeamsQuery } from './__generated__/Teams';
|
||||
import { useTeamsStatisticsQuery } from './__generated__/TeamsStatistics';
|
||||
import compact from 'lodash/compact';
|
||||
|
||||
// 192
|
||||
export const DEFAULT_AGGREGATION_EPOCHS = 192;
|
||||
|
||||
export const useTeams = (aggregationEpochs = DEFAULT_AGGREGATION_EPOCHS) => {
|
||||
const {
|
||||
data: teamsData,
|
||||
loading: teamsLoading,
|
||||
error: teamsError,
|
||||
} = useTeamsQuery({
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
const {
|
||||
data: statsData,
|
||||
loading: statsLoading,
|
||||
error: statsError,
|
||||
} = useTeamsStatisticsQuery({
|
||||
variables: {
|
||||
aggregationEpochs,
|
||||
},
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
const teams = compact(teamsData?.teams?.edges).map((e) => e.node);
|
||||
const stats = compact(statsData?.teamsStatistics?.edges).map((e) => e.node);
|
||||
|
||||
const data = useMemo(() => {
|
||||
const data = teams.map((t) => ({
|
||||
...t,
|
||||
...stats.find((s) => s.teamId === t.teamId),
|
||||
}));
|
||||
|
||||
return orderBy(data, (d) => Number(d.totalQuantumRewards || 0), 'desc');
|
||||
}, [teams, stats]);
|
||||
|
||||
return {
|
||||
data,
|
||||
loading: teamsLoading && statsLoading,
|
||||
error: teamsError || statsError,
|
||||
};
|
||||
};
|
||||
@@ -18,10 +18,9 @@ export const Routes = {
|
||||
REFERRALS_CREATE_CODE: '/referrals/create-code',
|
||||
COMPETITIONS: '/competitions',
|
||||
COMPETITIONS_TEAMS: '/competitions/teams',
|
||||
COMPETITIONS_TEAM: '/competitions/teams/:teamId',
|
||||
COMPETITIONS_CREATE_TEAM: '/competitions/teams/create',
|
||||
COMPETITIONS_CREATE_TEAM_SOLO: '/competitions/teams/create?solo=true',
|
||||
COMPETITIONS_UPDATE_TEAM: '/competitions/teams/:teamId/update',
|
||||
COMPETITIONS_TEAM: '/competitions/teams/:teamId',
|
||||
FEES: '/fees',
|
||||
REWARDS: '/rewards',
|
||||
} as const;
|
||||
@@ -48,12 +47,10 @@ export const Links: ConsoleLinks = {
|
||||
REFERRALS_CREATE_CODE: () => Routes.REFERRALS_CREATE_CODE,
|
||||
COMPETITIONS: () => Routes.COMPETITIONS,
|
||||
COMPETITIONS_TEAMS: () => Routes.COMPETITIONS_TEAMS,
|
||||
COMPETITIONS_TEAM: (teamId: string) =>
|
||||
Routes.COMPETITIONS_TEAM.replace(':teamId', teamId),
|
||||
COMPETITIONS_CREATE_TEAM: () => Routes.COMPETITIONS_CREATE_TEAM,
|
||||
COMPETITIONS_CREATE_TEAM_SOLO: () => Routes.COMPETITIONS_CREATE_TEAM_SOLO,
|
||||
COMPETITIONS_UPDATE_TEAM: (teamId: string) =>
|
||||
Routes.COMPETITIONS_UPDATE_TEAM.replace(':teamId', teamId),
|
||||
COMPETITIONS_TEAM: (teamId: string) =>
|
||||
Routes.COMPETITIONS_TEAM.replace(':teamId', teamId),
|
||||
FEES: () => Routes.FEES,
|
||||
REWARDS: () => Routes.REWARDS,
|
||||
};
|
||||
|
||||
@@ -32,7 +32,6 @@ import { CompetitionsHome } from '../client-pages/competitions/competitions-home
|
||||
import { CompetitionsTeams } from '../client-pages/competitions/competitions-teams';
|
||||
import { CompetitionsTeam } from '../client-pages/competitions/competitions-team';
|
||||
import { CompetitionsCreateTeam } from '../client-pages/competitions/competitions-create-team';
|
||||
import { CompetitionsUpdateTeam } from '../client-pages/competitions/competitions-update-team';
|
||||
|
||||
// These must remain dynamically imported as pennant cannot be compiled by nextjs due to ESM
|
||||
// Using dynamic imports is a workaround for this until pennant is published as ESM
|
||||
@@ -113,17 +112,13 @@ export const useRouterConfig = (): RouteObject[] => {
|
||||
],
|
||||
},
|
||||
// pages with blurred background
|
||||
{
|
||||
path: AppRoutes.COMPETITIONS_TEAM,
|
||||
element: <CompetitionsTeam />,
|
||||
},
|
||||
{
|
||||
path: AppRoutes.COMPETITIONS_CREATE_TEAM,
|
||||
element: <CompetitionsCreateTeam />,
|
||||
},
|
||||
{
|
||||
path: AppRoutes.COMPETITIONS_UPDATE_TEAM,
|
||||
element: <CompetitionsUpdateTeam />,
|
||||
path: AppRoutes.COMPETITIONS_TEAM,
|
||||
element: <CompetitionsTeam />,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ const BreakdownTable = forwardRef<AgGridReact, BreakdownTableProps>(
|
||||
{
|
||||
headerName: t('Market'),
|
||||
field: 'market.tradableInstrument.instrument.code',
|
||||
maxWidth: 150,
|
||||
width: 90,
|
||||
pinned: true,
|
||||
sort: 'desc',
|
||||
cellRenderer: ({
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { Account } from './accounts-data-provider';
|
||||
import * as Schema from '@vegaprotocol/types';
|
||||
|
||||
interface Props {
|
||||
accounts: Account[] | null;
|
||||
marketId: string;
|
||||
}
|
||||
|
||||
export const getMarketAccount = ({ accounts, marketId }: Props) =>
|
||||
accounts?.find((account) => {
|
||||
return (
|
||||
account.market?.id === marketId &&
|
||||
account.type === Schema.AccountType.ACCOUNT_TYPE_MARGIN
|
||||
);
|
||||
}) || null;
|
||||
@@ -6,7 +6,8 @@ export * from './accounts-manager';
|
||||
export * from './breakdown-table';
|
||||
export * from './use-account-balance';
|
||||
export * from './get-settlement-account';
|
||||
export * from './use-margin-account-balance';
|
||||
export * from './use-market-account-balance';
|
||||
export * from './__generated__/Margins';
|
||||
export { MarginHealthChart } from './margin-health-chart';
|
||||
export * from './margin-data-provider';
|
||||
export * from './transfer-container';
|
||||
|
||||
@@ -83,25 +83,3 @@ export const marketMarginDataProvider = makeDerivedDataProvider<
|
||||
(margin) => margin.market.id === marketId
|
||||
) || null
|
||||
);
|
||||
|
||||
export type MarginModeData = Pick<
|
||||
MarginFieldsFragment,
|
||||
'marginMode' | 'marginFactor'
|
||||
>;
|
||||
|
||||
export const marginModeDataProvider = makeDerivedDataProvider<
|
||||
MarginModeData,
|
||||
never,
|
||||
MarginsQueryVariables & { marketId: string }
|
||||
>([marketMarginDataProvider], ([data], variables, previousData) =>
|
||||
produce(previousData, (draft) => {
|
||||
if (!data) {
|
||||
return data;
|
||||
}
|
||||
const newData = {
|
||||
marginMode: (data as MarginFieldsFragment).marginMode,
|
||||
marginFactor: (data as MarginFieldsFragment).marginFactor,
|
||||
};
|
||||
return draft ? Object.assign(draft, newData) : newData;
|
||||
})
|
||||
);
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import { Tooltip, ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
import { marketMarginDataProvider } from './margin-data-provider';
|
||||
import { useAssetsMapProvider } from '@vegaprotocol/assets';
|
||||
import { useT, ns } from './use-t';
|
||||
import { useAccountBalance } from './use-account-balance';
|
||||
import { useMarketAccountBalance } from './use-market-account-balance';
|
||||
import { Trans } from 'react-i18next';
|
||||
|
||||
const MarginHealthChartTooltipRow = ({
|
||||
label,
|
||||
value,
|
||||
decimals,
|
||||
href,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
decimals: number;
|
||||
href?: string;
|
||||
}) => (
|
||||
<>
|
||||
<div
|
||||
className="float-left clear-left"
|
||||
key="label"
|
||||
data-testid="margin-health-tooltip-label"
|
||||
>
|
||||
{href ? (
|
||||
<ExternalLink href={href} target="_blank">
|
||||
{label}
|
||||
</ExternalLink>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className="float-right"
|
||||
key="value"
|
||||
data-testid="margin-health-tooltip-value"
|
||||
>
|
||||
{addDecimalsFormatNumber(value, decimals)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
export const MarginHealthChartTooltip = ({
|
||||
maintenanceLevel,
|
||||
searchLevel,
|
||||
initialLevel,
|
||||
collateralReleaseLevel,
|
||||
decimals,
|
||||
marginAccountBalance,
|
||||
}: {
|
||||
maintenanceLevel: string;
|
||||
searchLevel: string;
|
||||
initialLevel: string;
|
||||
collateralReleaseLevel: string;
|
||||
decimals: number;
|
||||
marginAccountBalance?: string;
|
||||
}) => {
|
||||
const t = useT();
|
||||
const tooltipContent = [
|
||||
<MarginHealthChartTooltipRow
|
||||
key={'maintenance'}
|
||||
label={t('maintenance level')}
|
||||
href="https://docs.vega.xyz/testnet/concepts/trading-on-vega/positions-margin#margin-level-maintenance"
|
||||
value={maintenanceLevel}
|
||||
decimals={decimals}
|
||||
/>,
|
||||
<MarginHealthChartTooltipRow
|
||||
key={'search'}
|
||||
label={t('search level')}
|
||||
href="https://docs.vega.xyz/testnet/concepts/trading-on-vega/positions-margin#margin-level-searching-for-collateral"
|
||||
value={searchLevel}
|
||||
decimals={decimals}
|
||||
/>,
|
||||
<MarginHealthChartTooltipRow
|
||||
key={'initial'}
|
||||
label={t('initial level')}
|
||||
href="https://docs.vega.xyz/testnet/concepts/trading-on-vega/positions-margin#margin-level-initial"
|
||||
value={initialLevel}
|
||||
decimals={decimals}
|
||||
/>,
|
||||
<MarginHealthChartTooltipRow
|
||||
key={'release'}
|
||||
label={t('release level')}
|
||||
href="https://docs.vega.xyz/testnet/concepts/trading-on-vega/positions-margin#margin-level-releasing-collateral"
|
||||
value={collateralReleaseLevel}
|
||||
decimals={decimals}
|
||||
/>,
|
||||
];
|
||||
|
||||
if (marginAccountBalance) {
|
||||
const balance = (
|
||||
<MarginHealthChartTooltipRow
|
||||
key={'balance'}
|
||||
label={t('balance')}
|
||||
value={marginAccountBalance}
|
||||
decimals={decimals}
|
||||
/>
|
||||
);
|
||||
if (BigInt(marginAccountBalance) < BigInt(searchLevel)) {
|
||||
tooltipContent.splice(1, 0, balance);
|
||||
} else if (BigInt(marginAccountBalance) < BigInt(initialLevel)) {
|
||||
tooltipContent.splice(2, 0, balance);
|
||||
} else if (BigInt(marginAccountBalance) < BigInt(collateralReleaseLevel)) {
|
||||
tooltipContent.splice(3, 0, balance);
|
||||
} else {
|
||||
tooltipContent.push(balance);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div className="overflow-hidden" data-testid="margin-health-tooltip">
|
||||
{tooltipContent}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const MarginHealthChart = ({
|
||||
marketId,
|
||||
assetId,
|
||||
}: {
|
||||
marketId: string;
|
||||
assetId: string;
|
||||
}) => {
|
||||
const { data: assetsMap } = useAssetsMapProvider();
|
||||
const { pubKey: partyId } = useVegaWallet();
|
||||
const { data } = useDataProvider({
|
||||
dataProvider: marketMarginDataProvider,
|
||||
variables: { marketId, partyId: partyId ?? '' },
|
||||
skip: !partyId,
|
||||
});
|
||||
const { accountBalance: rawGeneralAccountBalance } =
|
||||
useAccountBalance(assetId);
|
||||
const { accountBalance: rawMarginAccountBalance } =
|
||||
useMarketAccountBalance(marketId);
|
||||
const asset = assetsMap && assetsMap[assetId];
|
||||
if (!data || !asset) {
|
||||
return null;
|
||||
}
|
||||
const { decimals } = asset;
|
||||
|
||||
const collateralReleaseLevel = Number(data.collateralReleaseLevel);
|
||||
const initialLevel = Number(data.initialLevel);
|
||||
const maintenanceLevel = Number(data.maintenanceLevel);
|
||||
const searchLevel = Number(data.searchLevel);
|
||||
const marginAccountBalance = Number(rawMarginAccountBalance);
|
||||
const generalAccountBalance = Number(rawGeneralAccountBalance);
|
||||
const max = Math.max(
|
||||
marginAccountBalance + generalAccountBalance,
|
||||
collateralReleaseLevel
|
||||
);
|
||||
|
||||
const red = maintenanceLevel / max;
|
||||
const orange = (searchLevel - maintenanceLevel) / max;
|
||||
const yellow = ((searchLevel + initialLevel) / 2 - searchLevel) / max;
|
||||
const green = (collateralReleaseLevel - initialLevel) / max + yellow;
|
||||
const balanceMarker = marginAccountBalance / max;
|
||||
|
||||
const tooltip = (
|
||||
<MarginHealthChartTooltip
|
||||
maintenanceLevel={data.maintenanceLevel}
|
||||
searchLevel={data.searchLevel}
|
||||
initialLevel={data.initialLevel}
|
||||
collateralReleaseLevel={data.collateralReleaseLevel}
|
||||
marginAccountBalance={rawMarginAccountBalance}
|
||||
decimals={decimals}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div data-testid="margin-health-chart">
|
||||
<Trans
|
||||
defaults="{{balance}} above <0>maintenance level</0>"
|
||||
components={[
|
||||
<ExternalLink href="https://docs.vega.xyz/testnet/concepts/trading-on-vega/positions-margin#margin-level-maintenance">
|
||||
maintenance level
|
||||
</ExternalLink>,
|
||||
]}
|
||||
values={{
|
||||
balance: addDecimalsFormatNumber(
|
||||
(
|
||||
BigInt(marginAccountBalance) - BigInt(maintenanceLevel)
|
||||
).toString(),
|
||||
decimals
|
||||
),
|
||||
}}
|
||||
ns={ns}
|
||||
/>
|
||||
<Tooltip description={tooltip}>
|
||||
<div
|
||||
data-testid="margin-health-chart-track"
|
||||
className="relative bg-vega-green-650"
|
||||
style={{
|
||||
height: '6px',
|
||||
marginBottom: '1px',
|
||||
display: 'flex',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
data-testid="margin-health-chart-red"
|
||||
className="bg-vega-red-550"
|
||||
style={{
|
||||
height: '100%',
|
||||
width: `${red * 100}%`,
|
||||
}}
|
||||
></div>
|
||||
<div
|
||||
data-testid="margin-health-chart-orange"
|
||||
className="bg-vega-orange"
|
||||
style={{
|
||||
height: '100%',
|
||||
width: `${orange * 100}%`,
|
||||
}}
|
||||
></div>
|
||||
<div
|
||||
data-testid="margin-health-chart-yellow"
|
||||
className="bg-vega-yellow"
|
||||
style={{
|
||||
height: '100%',
|
||||
width: `${yellow * 100}%`,
|
||||
}}
|
||||
></div>
|
||||
<div
|
||||
data-testid="margin-health-chart-green"
|
||||
className="bg-vega-green-600"
|
||||
style={{
|
||||
height: '100%',
|
||||
width: `${green * 100}%`,
|
||||
}}
|
||||
></div>
|
||||
{balanceMarker > 0 && balanceMarker < 100 && (
|
||||
<div
|
||||
data-testid="margin-health-chart-balance"
|
||||
className="absolute bg-vega-blue"
|
||||
style={{
|
||||
height: '8px',
|
||||
width: '8px',
|
||||
top: '-1px',
|
||||
transform: 'translate(-4px, 0px)',
|
||||
borderRadius: '50%',
|
||||
border: '1px solid white',
|
||||
backgroundColor: 'blue',
|
||||
left: `${balanceMarker * 100}%`,
|
||||
}}
|
||||
></div>
|
||||
)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,158 @@
|
||||
import {
|
||||
MarginHealthChart,
|
||||
MarginHealthChartTooltip,
|
||||
} from './margin-health-chart';
|
||||
import { act, render, screen } from '@testing-library/react';
|
||||
import type { MarginFieldsFragment } from './__generated__/Margins';
|
||||
import type { AssetFieldsFragment } from '@vegaprotocol/assets';
|
||||
import { MarginMode } from '@vegaprotocol/types';
|
||||
|
||||
const asset: AssetFieldsFragment = {
|
||||
id: 'assetId',
|
||||
decimals: 2,
|
||||
} as AssetFieldsFragment;
|
||||
const margins: MarginFieldsFragment = {
|
||||
asset: {
|
||||
id: 'assetId',
|
||||
},
|
||||
collateralReleaseLevel: '1000',
|
||||
initialLevel: '800',
|
||||
searchLevel: '600',
|
||||
maintenanceLevel: '400',
|
||||
marginFactor: '',
|
||||
marginMode: MarginMode.MARGIN_MODE_CROSS_MARGIN,
|
||||
orderMarginLevel: '',
|
||||
market: {
|
||||
id: 'marketId',
|
||||
},
|
||||
};
|
||||
|
||||
const mockGetMargins = jest.fn(() => margins);
|
||||
const mockGetBalance = jest.fn(() => '0');
|
||||
|
||||
jest.mock('./margin-data-provider', () => ({}));
|
||||
|
||||
jest.mock('@vegaprotocol/assets', () => ({
|
||||
useAssetsMapProvider: () => {
|
||||
return {
|
||||
data: {
|
||||
assetId: asset,
|
||||
},
|
||||
};
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('@vegaprotocol/wallet', () => ({
|
||||
useVegaWallet: () => {
|
||||
return {
|
||||
pubKey: 'partyId',
|
||||
};
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('@vegaprotocol/data-provider', () => ({
|
||||
useDataProvider: () => {
|
||||
return {
|
||||
data: mockGetMargins(),
|
||||
};
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('./use-account-balance', () => ({
|
||||
useAccountBalance: () => {
|
||||
return {
|
||||
accountBalance: mockGetBalance(),
|
||||
};
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('./use-market-account-balance', () => ({
|
||||
useMarketAccountBalance: () => {
|
||||
return {
|
||||
accountBalance: '700',
|
||||
};
|
||||
},
|
||||
}));
|
||||
|
||||
describe('MarginHealthChart', () => {
|
||||
it('should render correct values', async () => {
|
||||
render(<MarginHealthChart marketId="marketId" assetId="assetId" />);
|
||||
const chart = screen.getByTestId('margin-health-chart');
|
||||
expect(chart).toHaveTextContent('3.00 above maintenance level');
|
||||
const red = screen.getByTestId('margin-health-chart-red');
|
||||
const orange = screen.getByTestId('margin-health-chart-orange');
|
||||
const yellow = screen.getByTestId('margin-health-chart-yellow');
|
||||
const green = screen.getByTestId('margin-health-chart-green');
|
||||
const balance = screen.getByTestId('margin-health-chart-balance');
|
||||
expect(parseInt(red.style.width)).toBe(40);
|
||||
expect(parseInt(orange.style.width)).toBe(20);
|
||||
expect(parseInt(yellow.style.width)).toBe(10);
|
||||
expect(parseInt(green.style.width)).toBe(30);
|
||||
expect(parseInt(balance.style.left)).toBe(70);
|
||||
});
|
||||
|
||||
it('should use correct scale', async () => {
|
||||
mockGetBalance.mockReturnValueOnce('1300');
|
||||
await act(async () => {
|
||||
render(<MarginHealthChart marketId="marketId" assetId="assetId" />);
|
||||
});
|
||||
await screen.findByTestId('margin-health-chart');
|
||||
const red = screen.getByTestId('margin-health-chart-red');
|
||||
expect(parseInt(red.style.width)).toBe(20);
|
||||
});
|
||||
});
|
||||
|
||||
describe('MarginHealthChartTooltip', () => {
|
||||
it('renders correct values and labels', async () => {
|
||||
await act(async () => {
|
||||
render(
|
||||
<MarginHealthChartTooltip
|
||||
{...margins}
|
||||
decimals={asset.decimals}
|
||||
marginAccountBalance="500"
|
||||
/>
|
||||
);
|
||||
});
|
||||
const labels = await screen.findAllByTestId('margin-health-tooltip-label');
|
||||
const expectedLabels = [
|
||||
'maintenance level',
|
||||
'balance',
|
||||
'search level',
|
||||
'initial level',
|
||||
'release level',
|
||||
];
|
||||
labels.forEach((value, i) => {
|
||||
expect(value).toHaveTextContent(expectedLabels[i]);
|
||||
});
|
||||
const values = await screen.findAllByTestId('margin-health-tooltip-value');
|
||||
const expectedValues = ['4.00', '5.00', '6.00', '8.00', '10.00'];
|
||||
values.forEach((value, i) => {
|
||||
expect(value).toHaveTextContent(expectedValues[i]);
|
||||
});
|
||||
});
|
||||
|
||||
it('renders balance in correct place', async () => {
|
||||
const { rerender } = render(
|
||||
<MarginHealthChartTooltip
|
||||
{...margins}
|
||||
decimals={asset.decimals}
|
||||
marginAccountBalance="700"
|
||||
/>
|
||||
);
|
||||
|
||||
let values = await screen.findAllByTestId('margin-health-tooltip-value');
|
||||
expect(values[2]).toHaveTextContent('7.00');
|
||||
|
||||
rerender(
|
||||
<MarginHealthChartTooltip
|
||||
{...margins}
|
||||
decimals={asset.decimals}
|
||||
marginAccountBalance="900"
|
||||
/>
|
||||
);
|
||||
|
||||
values = await screen.findAllByTestId('margin-health-tooltip-value');
|
||||
expect(values.length).toBe(5);
|
||||
expect(values[3]).toHaveTextContent('9.00');
|
||||
});
|
||||
});
|
||||
@@ -1,68 +0,0 @@
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
import { accountsDataProvider } from './accounts-data-provider';
|
||||
import type { Account } from './accounts-data-provider';
|
||||
import { AccountType } from '@vegaprotocol/types';
|
||||
|
||||
export const useMarginAccountBalance = (marketId: string) => {
|
||||
const { pubKey } = useVegaWallet();
|
||||
const [marginAccountBalance, setMarginAccountBalance] = useState<string>('');
|
||||
const [orderMarginAccountBalance, setOrderMarginAccountBalance] =
|
||||
useState<string>('');
|
||||
const [accountDecimals, setAccountDecimals] = useState<number | null>(null);
|
||||
const update = useCallback(
|
||||
({ data }: { data: Account[] | null }) => {
|
||||
const marginAccount = data?.find((account) => {
|
||||
return (
|
||||
account.market?.id === marketId &&
|
||||
account.type === AccountType.ACCOUNT_TYPE_MARGIN
|
||||
);
|
||||
});
|
||||
const orderMarginAccount = data?.find((account) => {
|
||||
return (
|
||||
account.market?.id === marketId &&
|
||||
account.type === AccountType.ACCOUNT_TYPE_ORDER_MARGIN
|
||||
);
|
||||
});
|
||||
if (marginAccount?.balance) {
|
||||
setMarginAccountBalance(marginAccount?.balance || '');
|
||||
}
|
||||
if (orderMarginAccount?.balance) {
|
||||
setOrderMarginAccountBalance(orderMarginAccount?.balance || '');
|
||||
}
|
||||
|
||||
const decimals =
|
||||
orderMarginAccount?.asset.decimals || marginAccount?.asset.decimals;
|
||||
if (decimals) {
|
||||
setAccountDecimals(decimals);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
[marketId]
|
||||
);
|
||||
const { loading, error } = useDataProvider({
|
||||
dataProvider: accountsDataProvider,
|
||||
variables: { partyId: pubKey || '' },
|
||||
skip: !pubKey || !marketId,
|
||||
update,
|
||||
});
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
marginAccountBalance: pubKey ? marginAccountBalance : '',
|
||||
orderMarginAccountBalance: pubKey ? orderMarginAccountBalance : '',
|
||||
accountDecimals: pubKey ? accountDecimals : null,
|
||||
loading,
|
||||
error,
|
||||
}),
|
||||
[
|
||||
marginAccountBalance,
|
||||
orderMarginAccountBalance,
|
||||
accountDecimals,
|
||||
pubKey,
|
||||
loading,
|
||||
error,
|
||||
]
|
||||
);
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user