From d8512afb2b03762c4a24e28870d6a5006886545b Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Mon, 12 Sep 2022 14:28:07 +0100 Subject: [PATCH 1/6] fix: #1297 Order submission expiresAt is only available when the time in force is of type GTT (#1308) * fix: #1297 Order submission expires at is only available when the time in force is of type GTT * fix: add expires at visible in edit dialog * fix:#1297 add GTC and GTT tests for expires at --- .../components/deal-ticket/deal-ticket.tsx | 4 ++ .../order-list/order-edit-dialog.tsx | 9 ++++ .../lib/order-hooks/use-order-submit.spec.tsx | 42 ++++++++++++++++++- .../src/lib/order-hooks/use-order-submit.tsx | 11 +++-- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx index e0cb6ab4c..c1ed43607 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -60,6 +60,10 @@ export const DealTicket = ({ price: order.price && removeDecimal(order.price, market.decimalPlaces), size: removeDecimal(order.size, market.positionDecimalPlaces), + expiresAt: + order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT + ? order.expiresAt + : undefined, }); } }, diff --git a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx index 16eb1f998..0fb03e705 100644 --- a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx +++ b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx @@ -3,6 +3,7 @@ import { addDecimalsFormatNumber, toDecimal, Size, + getDateTimeFormat, } from '@vegaprotocol/react-helpers'; import { OrderType } from '@vegaprotocol/types'; import { @@ -13,6 +14,7 @@ import { Dialog, Icon, } from '@vegaprotocol/ui-toolkit'; +import { OrderTimeInForce } from '@vegaprotocol/types'; import { useForm } from 'react-hook-form'; import type { OrderFields } from '../order-data-provider'; @@ -77,6 +79,13 @@ export const OrderEditDialog = ({

+ {order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT && + order.expiresAt && ( +
+

{t(`Expires at`)}

+

{getDateTimeFormat().format(new Date(order.expiresAt))}

+
+ )}
diff --git a/libs/orders/src/lib/order-hooks/use-order-submit.spec.tsx b/libs/orders/src/lib/order-hooks/use-order-submit.spec.tsx index 1410a7a6f..04fb24207 100644 --- a/libs/orders/src/lib/order-hooks/use-order-submit.spec.tsx +++ b/libs/orders/src/lib/order-hooks/use-order-submit.spec.tsx @@ -142,7 +142,7 @@ function setup(context?: Partial) { } describe('useOrderSubmit', () => { - it('should submit a correctly formatted order', async () => { + it('should submit a correctly formatted order on GTT', async () => { const mockSendTx = jest.fn().mockReturnValue(Promise.resolve({})); const keypair = { pub: '0x123', @@ -175,7 +175,45 @@ describe('useOrderSubmit', () => { side: Side.SIDE_BUY, timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTT, price: '123456789', - expiresAt: order.expiresAt ? toNanoSeconds(order.expiresAt) : undefined, + expiresAt: toNanoSeconds(order.expiresAt), + }, + }); + }); + + it('should submit a correctly formatted order on GTC', async () => { + const mockSendTx = jest.fn().mockReturnValue(Promise.resolve({})); + const keypair = { + pub: '0x123', + } as VegaKeyExtended; + const { result } = setup({ + sendTx: mockSendTx, + keypairs: [keypair], + keypair, + }); + + const order = { + type: OrderType.TYPE_LIMIT, + size: '10', + timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Side.SIDE_BUY, + price: '123456789', + expiresAt: new Date('2022-01-01'), + }; + await act(async () => { + result.current.submit({ ...order, marketId: defaultMarket.id }); + }); + + expect(mockSendTx).toHaveBeenCalledWith({ + pubKey: keypair.pub, + propagate: true, + orderSubmission: { + type: OrderType.TYPE_LIMIT, + marketId: defaultMarket.id, + size: '10', + side: Side.SIDE_BUY, + timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + price: '123456789', + expiresAt: undefined, }, }); }); diff --git a/libs/orders/src/lib/order-hooks/use-order-submit.tsx b/libs/orders/src/lib/order-hooks/use-order-submit.tsx index b36f0beee..47507131c 100644 --- a/libs/orders/src/lib/order-hooks/use-order-submit.tsx +++ b/libs/orders/src/lib/order-hooks/use-order-submit.tsx @@ -6,7 +6,8 @@ import { determineId, toNanoSeconds } from '@vegaprotocol/react-helpers'; import { useVegaTransaction } from '@vegaprotocol/wallet'; import * as Sentry from '@sentry/react'; import { useOrderEvent } from './use-order-event'; -import type { OrderTimeInForce, Side } from '@vegaprotocol/types'; +import type { Side } from '@vegaprotocol/types'; +import { OrderTimeInForce } from '@vegaprotocol/types'; import { OrderType, OrderStatus } from '@vegaprotocol/types'; import { Icon, Intent } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/react-helpers'; @@ -131,9 +132,11 @@ export const useOrderSubmit = () => { order.type === OrderType.TYPE_LIMIT && order.price ? order.price : undefined, - expiresAt: order.expiresAt - ? toNanoSeconds(order.expiresAt) // Wallet expects timestamp in nanoseconds - : undefined, + expiresAt: + order.expiresAt && + order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT + ? toNanoSeconds(order.expiresAt) // Wallet expects timestamp in nanoseconds + : undefined, }, }); From f34edf1862800990daf2fe03e352db7cfb56a6f5 Mon Sep 17 00:00:00 2001 From: mattrussell36 Date: Mon, 12 Sep 2022 18:04:57 +0000 Subject: [PATCH 2/6] chore: update tranches Signed-off-by: github-actions[bot] --- apps/static/src/assets/mainnet-tranches.json | 47 ++++++++++++-------- apps/static/src/assets/testnet-tranches.json | 2 +- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/apps/static/src/assets/mainnet-tranches.json b/apps/static/src/assets/mainnet-tranches.json index b84e1853d..19e404cb2 100644 --- a/apps/static/src/assets/mainnet-tranches.json +++ b/apps/static/src/assets/mainnet-tranches.json @@ -232,7 +232,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "129999.45", "total_removed": "0", - "locked_amount": "106394.66488946230805625", + "locked_amount": "106335.413484289455510975", "deposits": [ { "amount": "129999.45", @@ -298,7 +298,7 @@ "tranche_end": "2023-09-03T00:00:00.000Z", "total_added": "52600", "total_removed": "0", - "locked_amount": "51230.43016869609472", + "locked_amount": "51194.43613013698976", "deposits": [ { "amount": "2600", @@ -682,7 +682,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "97499.58", "total_removed": "0", - "locked_amount": "47585.4567681301376248752", + "locked_amount": "47527.3366591736311428252", "deposits": [ { "amount": "97499.58", @@ -715,7 +715,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "135173.4239508", "total_removed": "0", - "locked_amount": "65041.104115645490107967157408", + "locked_amount": "64961.663960720168133509560356", "deposits": [ { "amount": "135173.4239508", @@ -748,7 +748,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "32499.86", "total_removed": "0", - "locked_amount": "20018.379905468400079546", + "locked_amount": "19993.929779310993153618", "deposits": [ { "amount": "32499.86", @@ -781,7 +781,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "10833.29", "total_removed": "0", - "locked_amount": "6515.788405469431257442", + "locked_amount": "6507.830126663603897055", "deposits": [ { "amount": "10833.29", @@ -889,7 +889,7 @@ "tranche_end": "2022-11-01T00:00:00.000Z", "total_added": "30000", "total_removed": "0", - "locked_amount": "8070.053970410628", + "locked_amount": "8029.330842391305", "deposits": [ { "amount": "7500", @@ -1006,7 +1006,7 @@ "tranche_end": "2023-06-02T00:00:00.000Z", "total_added": "1939928.38", "total_removed": "479504.6187210477481", - "locked_amount": "1395134.471749858441357522", + "locked_amount": "1393806.983975873425857912", "deposits": [ { "amount": "1852091.69", @@ -1292,7 +1292,7 @@ "tranche_end": "2023-02-01T00:00:00.000Z", "total_added": "42500", "total_removed": "0", - "locked_amount": "32682.576458081723", + "locked_amount": "32624.88536005434875", "deposits": [ { "amount": "12500", @@ -2159,7 +2159,7 @@ "tranche_end": "2022-09-30T00:00:00.000Z", "total_added": "60916.66666633337", "total_removed": "20696.25757434884556896", - "locked_amount": "2732.8670885613374625452081355872", + "locked_amount": "2693.8540998784246905956196508555", "deposits": [ { "amount": "2833.333333", @@ -22455,7 +22455,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "3732368.4671", "total_removed": "204390.7646836173642", - "locked_amount": "2168337.2735760661538675426", + "locked_amount": "2166297.38704960471950391605", "deposits": [ { "amount": "1998.95815", @@ -23323,7 +23323,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "15870102.715470999700000001", "total_removed": "203050.3452740934272444", - "locked_amount": "12988472.337182063502716333679636461712625", + "locked_amount": "12981239.0305324649112059509051105297445255", "deposits": [ { "amount": "16249.93", @@ -26440,7 +26440,7 @@ "tranche_end": "2023-05-05T00:00:00.000Z", "total_added": "14597706.0446472999", "total_removed": "2764683.361107610704396897", - "locked_amount": "6269429.503217293486664487151997355", + "locked_amount": "6262751.76070348203965915005868418", "deposits": [ { "amount": "129284.449", @@ -31599,8 +31599,8 @@ "tranche_start": "2021-10-05T00:00:00.000Z", "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "5778205.3912159303", - "total_removed": "1769795.462408277490426354", - "locked_amount": "2160186.110374920105452205502061688", + "total_removed": "1773434.744647395163801354", + "locked_amount": "2157547.69392106277665067936509808", "deposits": [ { "amount": "552496.6455", @@ -31759,6 +31759,11 @@ "user": "0x5565d64f29Ea17355106DF3bA5903Eb793B3e139", "tx": "0x0954f744fc48cdb36187ba72505a5ca1c053d05da816b41230b35d86069fdcb0" }, + { + "amount": "3639.282239117673375", + "user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90", + "tx": "0x2a7ebd8748742d3bf0ce4f1ee46c575aa744f0d83915583bbd262f504044d462" + }, { "amount": "8456.402651116281081", "user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90", @@ -32818,6 +32823,12 @@ } ], "withdrawals": [ + { + "amount": "3639.282239117673375", + "user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90", + "tranche_id": 4, + "tx": "0x2a7ebd8748742d3bf0ce4f1ee46c575aa744f0d83915583bbd262f504044d462" + }, { "amount": "8456.402651116281081", "user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90", @@ -32952,8 +32963,8 @@ } ], "total_tokens": "331498.5873", - "withdrawn_tokens": "203997.978690347971047", - "remaining_tokens": "127500.608609652028953" + "withdrawn_tokens": "207637.260929465644422", + "remaining_tokens": "123861.326370534355578" }, { "address": "0x16da609341ed67750A8BCC5AAa2005471006Cd77", @@ -33042,7 +33053,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "472355.6199999996", "total_removed": "3216.01601557326", - "locked_amount": "343585.43574240396939067269203448", + "locked_amount": "343262.2040617976027593156164384", "deposits": [ { "amount": "3000", diff --git a/apps/static/src/assets/testnet-tranches.json b/apps/static/src/assets/testnet-tranches.json index 38d7d4b69..1d706e101 100644 --- a/apps/static/src/assets/testnet-tranches.json +++ b/apps/static/src/assets/testnet-tranches.json @@ -89,7 +89,7 @@ "tranche_end": "2022-10-12T00:53:20.000Z", "total_added": "1010.000000000000000001", "total_removed": "668.4622323651", - "locked_amount": "81.72253456367329370008091340055809237", + "locked_amount": "81.0314903602232870000802291983764587", "deposits": [ { "amount": "1000", From 7b2e86f32e75f983844acc6bf1e4f1c6fdd12846 Mon Sep 17 00:00:00 2001 From: mattrussell36 Date: Tue, 13 Sep 2022 00:12:14 +0000 Subject: [PATCH 3/6] chore: update tranches Signed-off-by: github-actions[bot] --- apps/static/src/assets/mainnet-tranches.json | 64 +++++++++++++------- apps/static/src/assets/testnet-tranches.json | 2 +- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/apps/static/src/assets/mainnet-tranches.json b/apps/static/src/assets/mainnet-tranches.json index 19e404cb2..a9fdbbaba 100644 --- a/apps/static/src/assets/mainnet-tranches.json +++ b/apps/static/src/assets/mainnet-tranches.json @@ -232,7 +232,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "129999.45", "total_removed": "0", - "locked_amount": "106335.413484289455510975", + "locked_amount": "106274.90731117573702137", "deposits": [ { "amount": "129999.45", @@ -298,7 +298,7 @@ "tranche_end": "2023-09-03T00:00:00.000Z", "total_added": "52600", "total_removed": "0", - "locked_amount": "51194.43613013698976", + "locked_amount": "51157.67984525621438", "deposits": [ { "amount": "2600", @@ -682,7 +682,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "97499.58", "total_removed": "0", - "locked_amount": "47527.3366591736311428252", + "locked_amount": "47467.985739754037614122", "deposits": [ { "amount": "97499.58", @@ -715,7 +715,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "135173.4239508", "total_removed": "0", - "locked_amount": "64961.663960720168133509560356", + "locked_amount": "64880.541500382365386104128928", "deposits": [ { "amount": "135173.4239508", @@ -748,7 +748,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "32499.86", "total_removed": "0", - "locked_amount": "19993.929779310993153618", + "locked_amount": "19968.961872446731053772", "deposits": [ { "amount": "32499.86", @@ -781,7 +781,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "10833.29", "total_removed": "0", - "locked_amount": "6507.830126663603897055", + "locked_amount": "6499.703315262119449162", "deposits": [ { "amount": "10833.29", @@ -889,7 +889,7 @@ "tranche_end": "2022-11-01T00:00:00.000Z", "total_added": "30000", "total_removed": "0", - "locked_amount": "8029.330842391305", + "locked_amount": "7987.745320048308", "deposits": [ { "amount": "7500", @@ -1006,7 +1006,7 @@ "tranche_end": "2023-06-02T00:00:00.000Z", "total_added": "1939928.38", "total_removed": "479504.6187210477481", - "locked_amount": "1393806.983975873425857912", + "locked_amount": "1392451.383972383291331918", "deposits": [ { "amount": "1852091.69", @@ -1292,7 +1292,7 @@ "tranche_end": "2023-02-01T00:00:00.000Z", "total_added": "42500", "total_removed": "0", - "locked_amount": "32624.88536005434875", + "locked_amount": "32565.972536735103", "deposits": [ { "amount": "12500", @@ -2159,7 +2159,7 @@ "tranche_end": "2022-09-30T00:00:00.000Z", "total_added": "60916.66666633337", "total_removed": "20696.25757434884556896", - "locked_amount": "2693.8540998784246905956196508555", + "locked_amount": "2654.01493251951192104562359744575", "deposits": [ { "amount": "2833.333333", @@ -22455,7 +22455,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "3732368.4671", "total_removed": "204390.7646836173642", - "locked_amount": "2166297.38704960471950391605", + "locked_amount": "2164214.3018140336079083241", "deposits": [ { "amount": "1998.95815", @@ -23322,8 +23322,8 @@ "tranche_start": "2022-06-05T00:00:00.000Z", "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "15870102.715470999700000001", - "total_removed": "203050.3452740934272444", - "locked_amount": "12981239.0305324649112059509051105297445255", + "total_removed": "203258.7850094080512444", + "locked_amount": "12973852.5440339852469072887237507656745066", "deposits": [ { "amount": "16249.93", @@ -23852,6 +23852,11 @@ "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", "tx": "0xe0040011ab92c3d951d3449fa6159e095b1893639c47fdb1a72aa87c741bdf56" }, + { + "amount": "208.439735314624", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tx": "0xa2cf8d5f7caa97b4c6804c0bce8003115d61772edf6ab6f8c9b3de503eafd2f5" + }, { "amount": "305.8599694076328", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", @@ -24435,6 +24440,12 @@ "tranche_id": 2, "tx": "0xe0040011ab92c3d951d3449fa6159e095b1893639c47fdb1a72aa87c741bdf56" }, + { + "amount": "208.439735314624", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tranche_id": 2, + "tx": "0xa2cf8d5f7caa97b4c6804c0bce8003115d61772edf6ab6f8c9b3de503eafd2f5" + }, { "amount": "305.8599694076328", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", @@ -24893,8 +24904,8 @@ } ], "total_tokens": "259998.8875", - "withdrawn_tokens": "47135.599794757122", - "remaining_tokens": "212863.287705242878" + "withdrawn_tokens": "47344.039530071746", + "remaining_tokens": "212654.847969928254" }, { "address": "0x89051CAb67Bc7F8CC44F7e270c6EDaf1EC57676c", @@ -26439,8 +26450,8 @@ "tranche_start": "2021-11-05T00:00:00.000Z", "tranche_end": "2023-05-05T00:00:00.000Z", "total_added": "14597706.0446472999", - "total_removed": "2764683.361107610704396897", - "locked_amount": "6262751.76070348203965915005868418", + "total_removed": "2764972.018594596729147647", + "locked_amount": "6255932.6035312481472902008742964", "deposits": [ { "amount": "129284.449", @@ -26674,6 +26685,11 @@ "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", "tx": "0x5940c1d1266c4aee837eb2a10ea1a42f52182c5fb2d9f4ca10752ec099ddc239" }, + { + "amount": "288.65748698602475075", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tx": "0x0fb5472a41850ad312926ca6a39df1901579d075b0b8836459e2cd7f96353a8b" + }, { "amount": "551.363354573845008", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", @@ -28775,6 +28791,12 @@ "tranche_id": 3, "tx": "0x5940c1d1266c4aee837eb2a10ea1a42f52182c5fb2d9f4ca10752ec099ddc239" }, + { + "amount": "288.65748698602475075", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tranche_id": 3, + "tx": "0x0fb5472a41850ad312926ca6a39df1901579d075b0b8836459e2cd7f96353a8b" + }, { "amount": "551.363354573845008", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", @@ -30511,8 +30533,8 @@ } ], "total_tokens": "359123.469575", - "withdrawn_tokens": "204783.7136307165325265", - "remaining_tokens": "154339.7559442834674735" + "withdrawn_tokens": "205072.37111770255727725", + "remaining_tokens": "154051.09845729744272275" }, { "address": "0xBdd412797c1B78535Afc5F71503b91fAbD0160fB", @@ -31600,7 +31622,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "5778205.3912159303", "total_removed": "1773434.744647395163801354", - "locked_amount": "2157547.69392106277665067936509808", + "locked_amount": "2154853.403680393350625567930414999", "deposits": [ { "amount": "552496.6455", @@ -33053,7 +33075,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "472355.6199999996", "total_removed": "3216.01601557326", - "locked_amount": "343262.2040617976027593156164384", + "locked_amount": "342932.12729879854768674909081684", "deposits": [ { "amount": "3000", diff --git a/apps/static/src/assets/testnet-tranches.json b/apps/static/src/assets/testnet-tranches.json index 1d706e101..4b062d8c3 100644 --- a/apps/static/src/assets/testnet-tranches.json +++ b/apps/static/src/assets/testnet-tranches.json @@ -89,7 +89,7 @@ "tranche_end": "2022-10-12T00:53:20.000Z", "total_added": "1010.000000000000000001", "total_removed": "668.4622323651", - "locked_amount": "81.0314903602232870000802291983764587", + "locked_amount": "80.3257137874175240000795304096905124", "deposits": [ { "amount": "1000", From 4505e863634457c2eba6bf42915232e566032737 Mon Sep 17 00:00:00 2001 From: mattrussell36 Date: Tue, 13 Sep 2022 06:26:28 +0000 Subject: [PATCH 4/6] chore: update tranches Signed-off-by: github-actions[bot] --- apps/static/src/assets/mainnet-tranches.json | 52 ++++++++++++++------ apps/static/src/assets/testnet-tranches.json | 2 +- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/apps/static/src/assets/mainnet-tranches.json b/apps/static/src/assets/mainnet-tranches.json index a9fdbbaba..6d9246351 100644 --- a/apps/static/src/assets/mainnet-tranches.json +++ b/apps/static/src/assets/mainnet-tranches.json @@ -232,7 +232,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "129999.45", "total_removed": "0", - "locked_amount": "106274.90731117573702137", + "locked_amount": "106213.256196636749978685", "deposits": [ { "amount": "129999.45", @@ -298,7 +298,7 @@ "tranche_end": "2023-09-03T00:00:00.000Z", "total_added": "52600", "total_removed": "0", - "locked_amount": "51157.67984525621438", + "locked_amount": "51120.22803145611028", "deposits": [ { "amount": "2600", @@ -682,7 +682,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "97499.58", "total_removed": "0", - "locked_amount": "47467.985739754037614122", + "locked_amount": "47407.5117394524021021252", "deposits": [ { "amount": "97499.58", @@ -715,7 +715,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "135173.4239508", "total_removed": "0", - "locked_amount": "64880.541500382365386104128928", + "locked_amount": "64797.883982370617886030171276", "deposits": [ { "amount": "135173.4239508", @@ -748,7 +748,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "32499.86", "total_removed": "0", - "locked_amount": "19968.961872446731053772", + "locked_amount": "19943.521504849955184182", "deposits": [ { "amount": "32499.86", @@ -781,7 +781,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "10833.29", "total_removed": "0", - "locked_amount": "6499.703315262119449162", + "locked_amount": "6491.422722476852413578", "deposits": [ { "amount": "10833.29", @@ -889,7 +889,7 @@ "tranche_end": "2022-11-01T00:00:00.000Z", "total_added": "30000", "total_removed": "0", - "locked_amount": "7987.745320048308", + "locked_amount": "7945.3728864734298", "deposits": [ { "amount": "7500", @@ -1006,7 +1006,7 @@ "tranche_end": "2023-06-02T00:00:00.000Z", "total_added": "1939928.38", "total_removed": "479504.6187210477481", - "locked_amount": "1392451.383972383291331918", + "locked_amount": "1391070.132328404443679426", "deposits": [ { "amount": "1852091.69", @@ -1292,7 +1292,7 @@ "tranche_end": "2023-02-01T00:00:00.000Z", "total_added": "42500", "total_removed": "0", - "locked_amount": "32565.972536735103", + "locked_amount": "32505.94492250402725", "deposits": [ { "amount": "12500", @@ -2159,7 +2159,7 @@ "tranche_end": "2022-09-30T00:00:00.000Z", "total_added": "60916.66666633337", "total_removed": "20696.25757434884556896", - "locked_amount": "2654.01493251951192104562359744575", + "locked_amount": "2613.42189971663007907723962443745", "deposits": [ { "amount": "2833.333333", @@ -5892,7 +5892,7 @@ "tranche_id": 11, "tranche_start": "2021-09-03T00:00:00.000Z", "tranche_end": "2022-09-03T00:00:00.000Z", - "total_added": "35958.000000000000000003", + "total_added": "35960.000000000000000003", "total_removed": "17098.49537348884", "locked_amount": "0", "deposits": [ @@ -5911,6 +5911,11 @@ "user": "0xEED071df0b6f8C4088b9CfD9f2ADE131C8591613", "tx": "0x0d569e9b901099d43f017945635ad8c2b566ce2290abb2583b018e83df34642b" }, + { + "amount": "2", + "user": "0x60901F5a6a66BCaD910A97e85373A00996B361f5", + "tx": "0xa87cd2caf4f27d7a60443ec952b831b005a809803fc899c4bcc3ca12016299eb" + }, { "amount": "15", "user": "0xb4eE687f019A8e48F7087f4b4f8653208B8cc48f", @@ -12530,6 +12535,21 @@ "withdrawn_tokens": "0", "remaining_tokens": "2" }, + { + "address": "0x60901F5a6a66BCaD910A97e85373A00996B361f5", + "deposits": [ + { + "amount": "2", + "user": "0x60901F5a6a66BCaD910A97e85373A00996B361f5", + "tranche_id": 11, + "tx": "0xa87cd2caf4f27d7a60443ec952b831b005a809803fc899c4bcc3ca12016299eb" + } + ], + "withdrawals": [], + "total_tokens": "2", + "withdrawn_tokens": "0", + "remaining_tokens": "2" + }, { "address": "0xb4eE687f019A8e48F7087f4b4f8653208B8cc48f", "deposits": [ @@ -22455,7 +22475,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "3732368.4671", "total_removed": "204390.7646836173642", - "locked_amount": "2164214.3018140336079083241", + "locked_amount": "2162091.79893798351430427894", "deposits": [ { "amount": "1998.95815", @@ -23323,7 +23343,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "15870102.715470999700000001", "total_removed": "203258.7850094080512444", - "locked_amount": "12973852.5440339852469072887237507656745066", + "locked_amount": "12966326.2851132206444730663636805143254933", "deposits": [ { "amount": "16249.93", @@ -26451,7 +26471,7 @@ "tranche_end": "2023-05-05T00:00:00.000Z", "total_added": "14597706.0446472999", "total_removed": "2764972.018594596729147647", - "locked_amount": "6255932.6035312481472902008742964", + "locked_amount": "6248984.409351215960935111906418583", "deposits": [ { "amount": "129284.449", @@ -31622,7 +31642,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "5778205.3912159303", "total_removed": "1773434.744647395163801354", - "locked_amount": "2154853.403680393350625567930414999", + "locked_amount": "2152108.130137534146322763792771381", "deposits": [ { "amount": "552496.6455", @@ -33075,7 +33095,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "472355.6199999996", "total_removed": "3216.01601557326", - "locked_amount": "342932.12729879854768674909081684", + "locked_amount": "342595.80458534469382288375849824", "deposits": [ { "amount": "3000", diff --git a/apps/static/src/assets/testnet-tranches.json b/apps/static/src/assets/testnet-tranches.json index 4b062d8c3..ccce8c31d 100644 --- a/apps/static/src/assets/testnet-tranches.json +++ b/apps/static/src/assets/testnet-tranches.json @@ -89,7 +89,7 @@ "tranche_end": "2022-10-12T00:53:20.000Z", "total_added": "1010.000000000000000001", "total_removed": "668.4622323651", - "locked_amount": "80.3257137874175240000795304096905124", + "locked_amount": "79.60645389396243020007881827118214102", "deposits": [ { "amount": "1000", From 535bdb51837e24aa7434e9035899992cde318749 Mon Sep 17 00:00:00 2001 From: AndyWhiteVega <106072061+AndyWhiteVega@users.noreply.github.com> Date: Tue, 13 Sep 2022 08:43:40 +0100 Subject: [PATCH 5/6] Test/governance and wallet tweaks (#1309) * test: tweaks * test: lint * test: lint * test: remove unnessecary timeouts * test: lint * test: syntax tweak --- .../token-e2e/src/fixtures/proposals/freeform.json | 2 +- .../src/integration/flow/governance-flow.cy.js | 14 +++----------- .../token-e2e/src/support/wallet-vega.functions.js | 8 +++++++- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/apps/token-e2e/src/fixtures/proposals/freeform.json b/apps/token-e2e/src/fixtures/proposals/freeform.json index e3726769f..8643b7649 100644 --- a/apps/token-e2e/src/fixtures/proposals/freeform.json +++ b/apps/token-e2e/src/fixtures/proposals/freeform.json @@ -1,6 +1,6 @@ { "rationale": { - "title": "An example freeform proposal", + "title": "An example freeform proposal with unique number of: ", "description": "I propose that everyone evaluate the following IPFS document and vote Yes if they agree. [bafybeigwwctpv37xdcwacqxvekr6e4kaemqsrv34em6glkbiceo3fcy4si](https://dweb.link/ipfs/bafybeigwwctpv37xdcwacqxvekr6e4kaemqsrv34em6glkbiceo3fcy4si)" }, "terms": { diff --git a/apps/token-e2e/src/integration/flow/governance-flow.cy.js b/apps/token-e2e/src/integration/flow/governance-flow.cy.js index 37319f0ac..644f493d3 100644 --- a/apps/token-e2e/src/integration/flow/governance-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/governance-flow.cy.js @@ -196,11 +196,7 @@ context('Governance flow - with eth and vega wallets connected', function () { .then((proposalId) => { cy.get('[data-testid="set-proposals-filter-visible"]').click(); cy.get('[data-testid="filter-input"]').type(proposalId); - cy.get(`#${proposalId}`).should( - 'contain', - `Freeform proposal: ${proposalId}`, - txTimeout - ); + cy.get(`#${proposalId}`).should('contain', proposalId); }); }); @@ -230,11 +226,7 @@ context('Governance flow - with eth and vega wallets connected', function () { let proposalId = proposal.response.body.data.busEvents[0].event.id; cy.get('[data-testid="set-proposals-filter-visible"]').click(); cy.get('[data-testid="filter-input"]').type(proposerId); - cy.get(`#${proposalId}`).should( - 'contain', - `Freeform proposal: ${proposalId}`, - txTimeout - ); + cy.get(`#${proposalId}`).should('contain', proposalId); }); }); @@ -264,7 +256,7 @@ context('Governance flow - with eth and vega wallets connected', function () { .then((proposalId) => { cy.get(openProposals).within(() => { cy.get(`#${proposalId}`) - .should('contain', `Freeform proposal: ${proposalId}`, txTimeout) + .should('contain', proposalId) .and('contain', 'Open') .and('be.visible') .within(() => { diff --git a/apps/token-e2e/src/support/wallet-vega.functions.js b/apps/token-e2e/src/support/wallet-vega.functions.js index f77a2759d..883358645 100644 --- a/apps/token-e2e/src/support/wallet-vega.functions.js +++ b/apps/token-e2e/src/support/wallet-vega.functions.js @@ -1,5 +1,6 @@ const vegaWalletContainer = '[data-testid="vega-wallet"]'; const restConnectorForm = '[data-testid="rest-connector-form"]'; +const vegaWalletNameElement = '[data-testid="wallet-name"]'; const vegaWalletName = Cypress.env('vegaWalletName'); const vegaWalletLocation = Cypress.env('vegaWalletLocation'); const vegaWalletPassphrase = Cypress.env('vegaWalletPassphrase'); @@ -14,6 +15,11 @@ Cypress.Commands.add('vega_wallet_import', () => { cy.exec( `vegawallet service run --network DV --automatic-consent --home ${vegaWalletLocation}` ); + cy.exec(`vegawallet version`) + .its('stdout') + .then((output) => { + cy.log(output); + }); }); Cypress.Commands.add('vega_wallet_connect', () => { @@ -31,5 +37,5 @@ Cypress.Commands.add('vega_wallet_connect', () => { cy.get('#passphrase').click().type(vegaWalletPassphrase); cy.get('button').contains('Connect').click(); }); - cy.contains(`${vegaWalletName} key`, { timeout: 20000 }).should('be.visible'); + cy.get(vegaWalletNameElement).should('be.visible'); }); From 3ff5bbb5a77d46d51ea6c6523d159c00b1ae50ef Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 13 Sep 2022 01:19:41 -0700 Subject: [PATCH 6/6] chore: use trading header and tidy tailwind usage (#1313) * fix: border too thick, use grid head component * fix: unused and superfluous classes, define border color in one place * fix: tooltip should be on data not label --- .../trading-e2e/src/integration/markets.cy.ts | 2 +- apps/trading/.env | 2 +- apps/trading/components/footer/footer.tsx | 2 +- apps/trading/components/header/header.tsx | 19 +- apps/trading/components/icons/vega.tsx | 2 +- apps/trading/components/navbar/navbar.tsx | 4 +- .../vega-wallet-connect-button.tsx | 1 - apps/trading/pages/markets/trade-grid.tsx | 216 ++++++++---------- apps/trading/pages/styles.css | 4 + .../network-switcher/network-switcher.tsx | 13 +- libs/market-depth/src/lib/orderbook.tsx | 11 +- .../components/market-info/info-market.tsx | 2 +- .../lib/components/select-market-columns.tsx | 2 +- .../lib/components/select-market-table.tsx | 2 +- .../src/lib/components/select-market.tsx | 4 +- .../order-list/order-edit-dialog.tsx | 54 +++-- libs/positions/src/lib/positions.tsx | 4 +- .../src/components/button/button.tsx | 3 +- .../dropdown-menu/dropdown-menu.tsx | 2 +- .../src/components/popover/popover.tsx | 2 +- libs/ui-toolkit/src/components/tabs/tabs.tsx | 8 +- 21 files changed, 161 insertions(+), 198 deletions(-) diff --git a/apps/trading-e2e/src/integration/markets.cy.ts b/apps/trading-e2e/src/integration/markets.cy.ts index a4736732b..afc4ea06f 100644 --- a/apps/trading-e2e/src/integration/markets.cy.ts +++ b/apps/trading-e2e/src/integration/markets.cy.ts @@ -127,7 +127,7 @@ describe('markets table', () => { } function verifyMarketSummaryDisplayed() { - const marketSummaryBlock = 'market-summary'; + const marketSummaryBlock = 'header-summary'; const percentageValue = 'price-change-percentage'; const priceChangeValue = 'price-change'; const tradingVolume = 'trading-volume'; diff --git a/apps/trading/.env b/apps/trading/.env index 7bbc2ccfd..3fc6aca19 100644 --- a/apps/trading/.env +++ b/apps/trading/.env @@ -1,6 +1,6 @@ # App configuration variables NX_VEGA_ENV=TESTNET -NX_VEGA_URL=https://api.n09.testnet.vega.xyz/graphql +NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 NX_ETHERSCAN_URL=https://ropsten.etherscan.io NX_VEGA_NETWORKS={\"MAINNET\":\"https://alpha.console.vega.xyz\"} diff --git a/apps/trading/components/footer/footer.tsx b/apps/trading/components/footer/footer.tsx index 5d1b668f1..ad35d6906 100644 --- a/apps/trading/components/footer/footer.tsx +++ b/apps/trading/components/footer/footer.tsx @@ -1,6 +1,6 @@ export const Footer = () => { return ( -
-
+
{Object.keys(TradingViews).map((key) => { const isActive = view === key; const className = classNames('p-4 min-w-[100px] capitalize', { diff --git a/apps/trading/pages/styles.css b/apps/trading/pages/styles.css index 1fd222076..70459910c 100644 --- a/apps/trading/pages/styles.css +++ b/apps/trading/pages/styles.css @@ -18,3 +18,7 @@ html.dark { --focus-border: theme('colors.vega.yellow'); --separator-border: theme('colors.neutral.600'); } + +.border-default { + @apply border-neutral-300 dark:border-neutral-600; +} diff --git a/libs/environment/src/components/network-switcher/network-switcher.tsx b/libs/environment/src/components/network-switcher/network-switcher.tsx index bff6817a6..f933af496 100644 --- a/libs/environment/src/components/network-switcher/network-switcher.tsx +++ b/libs/environment/src/components/network-switcher/network-switcher.tsx @@ -69,11 +69,7 @@ const NetworkLabel = ({ ); -export const NetworkSwitcher = ({ - fixedBg, -}: { - fixedBg?: 'dark' | 'light'; -}) => { +export const NetworkSwitcher = ({ theme }: { theme?: 'dark' | 'light' }) => { const { VEGA_ENV, VEGA_NETWORKS } = useEnvironment(); const [isOpen, setOpen] = useState(false); const [isAdvancedView, setAdvancedView] = useState(false); @@ -88,10 +84,9 @@ export const NetworkSwitcher = ({ [setOpen, setAdvancedView] ); - const dropdownTriggerClasses = classNames('hover:!bg-neutral-700', { - 'dark:text-white dark:bg-black text-black bg-white': !fixedBg, - 'text-black bg-white': fixedBg === 'light', - 'text-white bg-black': fixedBg === 'dark', + const dropdownTriggerClasses = classNames({ + 'text-black hover:!bg-neutral-300': theme === 'light', + 'text-white hover:!bg-neutral-700': theme === 'dark', }); return ( diff --git a/libs/market-depth/src/lib/orderbook.tsx b/libs/market-depth/src/lib/orderbook.tsx index 01c48c081..809b77293 100644 --- a/libs/market-depth/src/lib/orderbook.tsx +++ b/libs/market-depth/src/lib/orderbook.tsx @@ -8,10 +8,11 @@ import { useState, useMemo, useCallback, + useContext, } from 'react'; import classNames from 'classnames'; -import { formatNumber, t, useThemeSwitcher } from '@vegaprotocol/react-helpers'; +import { formatNumber, t, ThemeContext } from '@vegaprotocol/react-helpers'; import { MarketTradingMode } from '@vegaprotocol/types'; import { OrderbookRow } from './orderbook-row'; import { createRow, getPriceLevel } from './orderbook-data'; @@ -27,7 +28,7 @@ interface OrderbookProps extends OrderbookData { const HorizontalLine = ({ top, testId }: { top: string; testId: string }) => (
@@ -106,7 +107,7 @@ export const Orderbook = ({ resolution, onResolutionChange, }: OrderbookProps) => { - const [theme] = useThemeSwitcher(); + const theme = useContext(ThemeContext); const scrollElement = useRef(null); // scroll offset for which rendered rows are selected, will change after user will scroll to margin of rendered data const [scrollOffset, setScrollOffset] = useState(0); @@ -320,7 +321,7 @@ export const Orderbook = ({ data-testid="scroll" >
{t('Bid vol')}
@@ -344,7 +345,7 @@ export const Orderbook = ({ )}
diff --git a/libs/market-info/src/components/market-info/info-market.tsx b/libs/market-info/src/components/market-info/info-market.tsx index c9ae55fd9..4f73571ee 100644 --- a/libs/market-info/src/components/market-info/info-market.tsx +++ b/libs/market-info/src/components/market-info/info-market.tsx @@ -335,7 +335,7 @@ export const Info = ({ market, onSelect }: InfoProps) => {

{t('Market data')}

-
+

{t('Market specification')}

diff --git a/libs/market-list/src/lib/components/select-market-columns.tsx b/libs/market-list/src/lib/components/select-market-columns.tsx index 89bb684d4..1db863775 100644 --- a/libs/market-list/src/lib/components/select-market-columns.tsx +++ b/libs/market-list/src/lib/components/select-market-columns.tsx @@ -24,7 +24,7 @@ import type { } from '../__generated__/MarketList'; import isNil from 'lodash/isNil'; -export const cellClassNames = 'px-0 py-1 first:text-left text-right'; +export const cellClassNames = 'py-1 first:text-left text-right'; const FeesInfo = () => { return ( diff --git a/libs/market-list/src/lib/components/select-market-table.tsx b/libs/market-list/src/lib/components/select-market-table.tsx index faa2991cd..3539d754f 100644 --- a/libs/market-list/src/lib/components/select-market-table.tsx +++ b/libs/market-list/src/lib/components/select-market-table.tsx @@ -7,7 +7,7 @@ export const SelectMarketTableHeader = ({ headers = columnHeaders, }) => { return ( - + {headers.map(({ value, className, onlyOnDetailed }, i) => { const thClass = classNames( 'font-normal text-neutral-500 dark:text-neutral-400', diff --git a/libs/market-list/src/lib/components/select-market.tsx b/libs/market-list/src/lib/components/select-market.tsx index bbfc0b778..33ebf1df5 100644 --- a/libs/market-list/src/lib/components/select-market.tsx +++ b/libs/market-list/src/lib/components/select-market.tsx @@ -76,7 +76,7 @@ export const SelectAllMarketsTableBody = ({ if (!data) return null; return ( <> - + {/* Border styles required to create space between tbody elements margin/padding dont work */} @@ -101,7 +101,7 @@ export const SelectMarketPopover = ({ onSelect: (id: string) => void; }) => { const triggerClasses = - 'sm:text-lg md:text-xl lg:text-2xl font-medium flex items-center gap-4 whitespace-nowrap my-3 hover:text-neutral-500 dark:hover:text-neutral-300'; + 'sm:text-lg md:text-xl lg:text-2xl flex items-center gap-2 whitespace-nowrap hover:text-neutral-500 dark:hover:text-neutral-300'; const { keypair } = useVegaWallet(); const [open, setOpen] = useState(false); const { data, loading: marketsLoading } = useMarketList(); diff --git a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx index 0fb03e705..8419e5faf 100644 --- a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx +++ b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx @@ -87,34 +87,32 @@ export const OrderEditDialog = ({
)} -
- - - - Number(value) > 0 - ? true - : t('The price cannot be negative'), - }, - })} - id="entryPrice" - /> - {errors.entryPrice?.message && ( - - {errors.entryPrice.message} - - )} - - - -
+
+ + + Number(value) > 0 ? true : t('The price cannot be negative'), + }, + })} + id="entryPrice" + /> + {errors.entryPrice?.message && ( + {errors.entryPrice.message} + )} + + +
); }; diff --git a/libs/positions/src/lib/positions.tsx b/libs/positions/src/lib/positions.tsx index 97e2a2ea8..0377e79ee 100644 --- a/libs/positions/src/lib/positions.tsx +++ b/libs/positions/src/lib/positions.tsx @@ -82,8 +82,8 @@ export const Positions = memo( }; return ( -
-

+
+

{assetSymbol} {t('markets')}

diff --git a/libs/ui-toolkit/src/components/button/button.tsx b/libs/ui-toolkit/src/components/button/button.tsx index 126107a4f..7a7ba1e22 100644 --- a/libs/ui-toolkit/src/components/button/button.tsx +++ b/libs/ui-toolkit/src/components/button/button.tsx @@ -22,7 +22,8 @@ const defaultClasses = [ 'border-black dark:border-white', 'bg-white dark:bg-black', 'enabled:hover:bg-neutral-200 dark:enabled:hover:bg-neutral-700', - 'enabled:active:bg-neutral-200 dark:enabled:active:bg-neutral-700 enabled:active:border-neutral-400 dark:enabled:active:border-neutral-400', + 'enabled:active:bg-neutral-200 dark:enabled:active:bg-neutral-700', + 'enabled:active:border-neutral-400', ]; const primary = [ 'text-black', diff --git a/libs/ui-toolkit/src/components/dropdown-menu/dropdown-menu.tsx b/libs/ui-toolkit/src/components/dropdown-menu/dropdown-menu.tsx index 305158a22..845fd0e39 100644 --- a/libs/ui-toolkit/src/components/dropdown-menu/dropdown-menu.tsx +++ b/libs/ui-toolkit/src/components/dropdown-menu/dropdown-menu.tsx @@ -29,7 +29,7 @@ export const DropdownMenuTrigger = forwardRef< className, 'text-sm py-1 px-2 rounded bg-transparent border border-neutral-500', 'focus:border-black dark:focus:border-white whitespace-nowrap', - 'hover:bg-neutral-100 dark:hover:bg-neutral-700' + 'hover:bg-neutral-200 dark:hover:bg-neutral-700' ); return ( { className="h-full grid grid-rows-[min-content_1fr]" onValueChange={(value) => setActiveTab(value)} > -
+
{ if (!isValidElement(child) || child.props.hidden) return null; const isActive = child.props.id === activeTab; const triggerClass = classNames( - 'relative px-4 py-2 border-r border-neutral-300 dark:border-neutral-600', + 'relative px-4 py-2 border-r border-default', 'uppercase', - 'inline-block after:content-[attr(data-testid)] after:block after:invisible after:overflow-hidden after:h-0 after:tracking-wider', { - 'text-neutral-400 dark:text-neutral-400 hover:text-neutral-500 dark:hover:text-neutral-300': + 'cursor-default': isActive, + 'text-neutral-400 hover:text-neutral-500 dark:hover:text-neutral-300': !isActive, } );