* fix(#2171): remove user's pubkey from LP query * fix(#2171): add LP partyID in account events * fix(#2171): add LP partyID in account events * fix(#2200): handle NotFound GraphQL errors in async renderer * fix(#2200): data provider filter apollo graphQL not found error * fix(#2200): update apollo-client to not report not found error link * fix(#2200): fix log on not found error link * fix(#2200): fix set error in data provider * fix(#2200): extensions type access via index signature * fix: accounts-data-provider.spec.ts had missing partyId * fix: revert not found error commit * fix: revert and set error in data prov
This commit is contained in:
parent
787a8ea1b3
commit
de8e543bf4
@ -69,10 +69,7 @@ export const Liquidity = () => {
|
||||
} = useDataProvider({
|
||||
dataProvider: lpAggregatedDataProvider,
|
||||
update,
|
||||
variables: useMemo(
|
||||
() => ({ marketId, partyId: pubKey }),
|
||||
[marketId, pubKey]
|
||||
),
|
||||
variables: useMemo(() => ({ marketId }), [marketId]),
|
||||
});
|
||||
|
||||
// To be removed when liquidityProvision subscriptions are working
|
||||
|
@ -7,6 +7,9 @@ fragment AccountFields on AccountBalance {
|
||||
asset {
|
||||
id
|
||||
}
|
||||
party {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
query Accounts($partyId: ID!) {
|
||||
@ -22,11 +25,12 @@ query Accounts($partyId: ID!) {
|
||||
}
|
||||
}
|
||||
|
||||
subscription AccountEvents($partyId: ID!) {
|
||||
subscription AccountEvents($partyId: ID) {
|
||||
accounts(partyId: $partyId) {
|
||||
type
|
||||
balance
|
||||
assetId
|
||||
marketId
|
||||
partyId
|
||||
}
|
||||
}
|
||||
|
16
libs/accounts/src/lib/__generated__/Accounts.ts
generated
16
libs/accounts/src/lib/__generated__/Accounts.ts
generated
@ -3,21 +3,21 @@ import { Schema as Types } from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type AccountFieldsFragment = { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null, asset: { __typename?: 'Asset', id: string } };
|
||||
export type AccountFieldsFragment = { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null, asset: { __typename?: 'Asset', id: string }, party?: { __typename?: 'Party', id: string } | null };
|
||||
|
||||
export type AccountsQueryVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type AccountsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null, asset: { __typename?: 'Asset', id: string } } } | null> | null } | null } | null };
|
||||
export type AccountsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null, asset: { __typename?: 'Asset', id: string }, party?: { __typename?: 'Party', id: string } | null } } | null> | null } | null } | null };
|
||||
|
||||
export type AccountEventsSubscriptionVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
partyId?: Types.InputMaybe<Types.Scalars['ID']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: Array<{ __typename?: 'AccountUpdate', type: Types.AccountType, balance: string, assetId: string, marketId?: string | null }> };
|
||||
export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: Array<{ __typename?: 'AccountUpdate', type: Types.AccountType, balance: string, assetId: string, marketId?: string | null, partyId: string }> };
|
||||
|
||||
export const AccountFieldsFragmentDoc = gql`
|
||||
fragment AccountFields on AccountBalance {
|
||||
@ -29,6 +29,9 @@ export const AccountFieldsFragmentDoc = gql`
|
||||
asset {
|
||||
id
|
||||
}
|
||||
party {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const AccountsDocument = gql`
|
||||
@ -74,12 +77,13 @@ export type AccountsQueryHookResult = ReturnType<typeof useAccountsQuery>;
|
||||
export type AccountsLazyQueryHookResult = ReturnType<typeof useAccountsLazyQuery>;
|
||||
export type AccountsQueryResult = Apollo.QueryResult<AccountsQuery, AccountsQueryVariables>;
|
||||
export const AccountEventsDocument = gql`
|
||||
subscription AccountEvents($partyId: ID!) {
|
||||
subscription AccountEvents($partyId: ID) {
|
||||
accounts(partyId: $partyId) {
|
||||
type
|
||||
balance
|
||||
assetId
|
||||
marketId
|
||||
partyId
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -100,7 +104,7 @@ export const AccountEventsDocument = gql`
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useAccountEventsSubscription(baseOptions: Apollo.SubscriptionHookOptions<AccountEventsSubscription, AccountEventsSubscriptionVariables>) {
|
||||
export function useAccountEventsSubscription(baseOptions?: Apollo.SubscriptionHookOptions<AccountEventsSubscription, AccountEventsSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<AccountEventsSubscription, AccountEventsSubscriptionVariables>(AccountEventsDocument, options);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ describe('getId', () => {
|
||||
balance: '1',
|
||||
assetId: 'assetId',
|
||||
marketId: '',
|
||||
partyId: 'partyId',
|
||||
})
|
||||
);
|
||||
expect(
|
||||
@ -41,6 +42,7 @@ describe('getId', () => {
|
||||
balance: '1',
|
||||
assetId: 'assetId',
|
||||
marketId: 'testId',
|
||||
partyId: 'partyId',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -10,14 +10,14 @@ export type MarketLpQueryVariables = Types.Exact<{
|
||||
|
||||
export type MarketLpQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, name: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } }, data?: { __typename?: 'MarketData', marketTradingMode: Types.MarketTradingMode, suppliedStake?: string | null, openInterest: string, targetStake?: string | null, trigger: Types.AuctionTrigger, marketValueProxy: string, market: { __typename?: 'Market', id: string } } | null } | null };
|
||||
|
||||
export type LiquidityProvisionFieldsFragment = { __typename?: 'LiquidityProvision', createdAt: string, updatedAt?: string | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } };
|
||||
export type LiquidityProvisionFieldsFragment = { __typename?: 'LiquidityProvision', createdAt: any, updatedAt?: any | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } };
|
||||
|
||||
export type LiquidityProvisionsQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type LiquidityProvisionsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', liquidityProvisionsConnection?: { __typename?: 'LiquidityProvisionsConnection', edges?: Array<{ __typename?: 'LiquidityProvisionsEdge', node: { __typename?: 'LiquidityProvision', createdAt: string, updatedAt?: string | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } } } | null> | null } | null } | null };
|
||||
export type LiquidityProvisionsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', liquidityProvisionsConnection?: { __typename?: 'LiquidityProvisionsConnection', edges?: Array<{ __typename?: 'LiquidityProvisionsEdge', node: { __typename?: 'LiquidityProvision', createdAt: any, updatedAt?: any | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } } } | null> | null } | null } | null };
|
||||
|
||||
export type LiquidityProvisionsUpdateSubscriptionVariables = Types.Exact<{
|
||||
partyId?: Types.InputMaybe<Types.Scalars['ID']>;
|
||||
@ -25,7 +25,7 @@ export type LiquidityProvisionsUpdateSubscriptionVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type LiquidityProvisionsUpdateSubscription = { __typename?: 'Subscription', liquidityProvisions?: Array<{ __typename?: 'LiquidityProvisionUpdate', id?: string | null, partyID: string, createdAt: string, updatedAt?: string | null, marketID: string, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus }> | null };
|
||||
export type LiquidityProvisionsUpdateSubscription = { __typename?: 'Subscription', liquidityProvisions?: Array<{ __typename?: 'LiquidityProvisionUpdate', id?: string | null, partyID: string, createdAt: any, updatedAt?: any | null, marketID: string, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus }> | null };
|
||||
|
||||
export type LiquidityProviderFeeShareFieldsFragment = { __typename?: 'LiquidityProviderFeeShare', equityLikeShare: string, averageEntryValuation: string, party: { __typename?: 'Party', id: string } };
|
||||
|
||||
|
@ -189,6 +189,11 @@ export const getLiquidityProvision = (
|
||||
const market = marketLiquidity?.market;
|
||||
const feeShare = liquidityFeeShare.find((f) => f.party.id === lp.party.id);
|
||||
if (!feeShare) return lp;
|
||||
const bondAccounts = accounts?.filter(
|
||||
(a) =>
|
||||
a?.type === Schema.AccountType.ACCOUNT_TYPE_BOND &&
|
||||
(!a.party?.id || a.party?.id === lp.party.id)
|
||||
);
|
||||
const lpData: LiquidityProvisionData = {
|
||||
...lp,
|
||||
averageEntryValuation: feeShare?.averageEntryValuation,
|
||||
@ -196,8 +201,7 @@ export const getLiquidityProvision = (
|
||||
assetDecimalPlaces:
|
||||
market?.tradableInstrument.instrument.product.settlementAsset.decimals,
|
||||
balance:
|
||||
accounts
|
||||
?.filter((a) => a?.type === Schema.AccountType.ACCOUNT_TYPE_BOND)
|
||||
bondAccounts
|
||||
?.reduce(
|
||||
(acc, a) => acc.plus(new BigNumber(a.balance ?? 0)),
|
||||
new BigNumber(0)
|
||||
|
613
libs/types/src/__generated__/types.ts
generated
613
libs/types/src/__generated__/types.ts
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user