fix: apollo in memory tradable instrument (#1036)

* fix: update appolo client and set key fields for instruments

* fix: use in-memory cache and tradable instrument id

* fix: revert switch case

* fix: add more info in gen  market list for home.cy.ts

* fix: instrument keyfield still false

* fix: revert simple trading app and explorer updates - fixing tests

* fix: remove id from instrument data provider in simple trading app

* fix: remove id from market selector market names query

* Update apps/trading-e2e/src/support/mocks/generate-market-list.ts

* Update apps/trading-e2e/src/support/mocks/generate-market-list.ts

* Update apps/trading-e2e/src/support/mocks/generate-market-list.ts

* Update apps/trading-e2e/src/support/mocks/generate-market-list.ts
This commit is contained in:
m.ray 2022-08-19 08:39:46 +02:00 committed by GitHub
parent b50b8091cf
commit 738c93606b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 87 additions and 10 deletions

View File

@ -65,7 +65,7 @@ describe('home', () => {
}
});
// the oldest market trading in continous mode shown at top of overlay table
// the oldest market trading in continuos mode shown at top of overlay table
cy.get('table tr')
.eq(1)
.within(() =>

View File

@ -18,14 +18,16 @@ export const generateMarketList = (
positionDecimalPlaces: 0,
state: MarketState.Active,
tradingMode: MarketTradingMode.Continuous,
positionDecimalPlaces: 2,
name: 'Market 0',
fees: {
factors: {
makerFee: '0.0002',
infrastructureFee: '0.0005',
liquidityFee: '0.001',
__typename: 'FeeFactors',
},
__typename: 'Fees',
factors: {
__typename: 'FeeFactors',
makerFee: '0.001',
liquidityFee: '0.001',
infrastructureFee: '0.001',
},
},
data: {
market: {
@ -33,6 +35,8 @@ export const generateMarketList = (
state: MarketState.Active,
tradingMode: MarketTradingMode.Continuous,
__typename: 'Market',
state: MarketState.Active,
tradingMode: MarketTradingMode.Continuous,
},
bestBidPrice: '2411432389',
bestOfferPrice: '2346732714',
@ -40,9 +44,21 @@ export const generateMarketList = (
trigger: AuctionTrigger.Price,
indicativeVolume: '1216',
__typename: 'MarketData',
bestBidPrice: '4612690058',
bestOfferPrice: '4612690058',
trigger: AuctionTrigger.Liquidity,
indicativeVolume: '0',
},
tradableInstrument: {
instrument: {
id: '10cd0a793ad2887b340940337fa6d97a212e0e517fe8e9eab2b5ef3a38633f35',
product: {
__typename: 'Future',
settlementAsset: {
__typename: 'Asset',
symbol: 'ETH',
},
},
name: 'BTC/USD Monthly',
code: 'BTCUSD.MF21',
metadata: {
@ -83,22 +99,48 @@ export const generateMarketList = (
positionDecimalPlaces: 0,
state: MarketState.Suspended,
tradingMode: MarketTradingMode.MonitoringAuction,
name: 'BTC/USD Monthly',
positionDecimalPlaces: 2,
fees: {
__typename: 'Fees',
factors: {
__typename: 'FeeFactors',
makerFee: '0.001',
liquidityFee: '0.001',
infrastructureFee: '0.001',
},
},
data: {
market: {
id: '34d95e10faa00c21d19d382d6d7e6fc9722a96985369f0caec041b0f44b775ed',
state: MarketState.Suspended,
tradingMode: MarketTradingMode.MonitoringAuction,
__typename: 'Market',
state: MarketState.Suspended,
tradingMode: MarketTradingMode.MonitoringAuction,
},
bestBidPrice: '17065127',
bestOfferPrice: '17017654',
markPrice: '8441',
indicativeVolume: '249',
__typename: 'MarketData',
bestBidPrice: '4612690058',
bestOfferPrice: '4612690058',
trigger: AuctionTrigger.Liquidity,
indicativeVolume: '0',
},
tradableInstrument: {
instrument: {
product: {
__typename: 'Future',
settlementAsset: {
__typename: 'Asset',
symbol: 'ETH',
},
},
name: 'SOL/USD',
id: '34d95e10faa00c21d19d382d6d7e6fc9722a96985369f0caec041b0f44b775ed',
code: 'SOLUSD',
metadata: {
__typename: 'InstrumentMetadata',

View File

@ -33,6 +33,12 @@ export function createClient(base?: string) {
Instrument: {
keyFields: false,
},
TradableInstrument: {
keyFields: ['instrument'],
},
Product: {
keyFields: ['settlementAsset', ['id']],
},
MarketData: {
keyFields: ['market', ['id']],
},

View File

@ -40,6 +40,7 @@ const MARKET_QUERY = gql`
}
tradableInstrument {
instrument {
id
name
code
metadata {

View File

@ -111,6 +111,10 @@ export interface Market_market_tradableInstrument_instrument_product {
export interface Market_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* Full and fairly descriptive name for the instrument
*/

View File

@ -39,6 +39,10 @@ export interface DealTicketQuery_market_tradableInstrument_instrument_product {
export interface DealTicketQuery_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
*/

View File

@ -15,6 +15,7 @@ const DEAL_TICKET_QUERY = gql`
tradingMode
tradableInstrument {
instrument {
id
product {
... on Future {
quoteName

View File

@ -103,6 +103,10 @@ export interface MarketList_markets_tradableInstrument_instrument_product {
export interface MarketList_markets_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* Full and fairly descriptive name for the instrument
*/

View File

@ -53,6 +53,7 @@ export const MARKET_LIST_QUERY = gql`
}
tradableInstrument {
instrument {
id
name
code
metadata {

View File

@ -23,6 +23,7 @@ export const generateOrder = (
tradableInstrument: {
__typename: 'TradableInstrument',
instrument: {
id: 'instrument-id',
__typename: 'Instrument',
code: 'instrument-code',
},

View File

@ -11,6 +11,10 @@ import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce }
export interface OrderFields_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/

View File

@ -11,6 +11,10 @@ import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce }
export interface OrderSub_orders_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/

View File

@ -11,6 +11,10 @@ import { Pagination, OrderType, Side, OrderStatus, OrderRejectionReason, OrderTi
export interface Orders_party_ordersConnection_edges_node_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/

View File

@ -24,6 +24,7 @@ const ORDER_FRAGMENT = gql`
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
}
}

View File

@ -120,12 +120,12 @@ export const OrderListTable = forwardRef<AgGridReact, OrderListTableProps>(
data,
}: {
data: Orders_party_ordersConnection_edges_node;
}) => data.side === Side.Buy,
}) => data?.side === Side.Buy,
'text-vega-red-dark dark:text-vega-red': ({
data,
}: {
data: Orders_party_ordersConnection_edges_node;
}) => data.side === Side.Sell,
}) => data?.side === Side.Sell,
}}
valueFormatter={({
value,
@ -136,7 +136,7 @@ export const OrderListTable = forwardRef<AgGridReact, OrderListTableProps>(
if (value === undefined || !data || !data.market) {
return undefined;
}
const prefix = data.side === Side.Buy ? '+' : '-';
const prefix = data ? (data.side === Side.Buy ? '+' : '-') : '';
return (
prefix + addDecimal(value, data.market.positionDecimalPlaces)
);