From 29017d97f9d662f8a9d415ac0a07d514cae2d734 Mon Sep 17 00:00:00 2001 From: bonomat Date: Wed, 8 Dec 2021 07:57:53 +1100 Subject: [PATCH 1/6] Fix reference price being undefined sometimes --- taker-frontend/src/App.tsx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/taker-frontend/src/App.tsx b/taker-frontend/src/App.tsx index 8c2cf55..8638ebc 100644 --- a/taker-frontend/src/App.tsx +++ b/taker-frontend/src/App.tsx @@ -43,22 +43,17 @@ export const App = () => { const toast = useToast(); useBackendMonitor(toast, 5000, "Please start the taker again to reconnect..."); // 5s timeout - const { - lastMessage, - readyState, - } = useWebSocket("wss://www.bitmex.com/realtime?subscribe=instrument:.BXBT", { - // Will attempt to reconnect on all close events, such as server shutting down + let [referencePrice, setReferencePrice] = useState(); + useWebSocket("wss://www.bitmex.com/realtime?subscribe=instrument:.BXBT", { shouldReconnect: () => true, + onMessage: (message) => { + const data: BXBTData[] = JSON.parse(message.data).data; + if (data && data[0]?.markPrice) { + setReferencePrice(data[0].markPrice); + } + }, }); - let referencePrice; - if (readyState === 1 && lastMessage) { - const data: BXBTData[] = JSON.parse(lastMessage.data).data; - if (data && data[0]?.markPrice) { - referencePrice = data[0].markPrice; - } - } - let source = useEventSource({ source: "/api/feed" }); const walletInfo = useLatestEvent(source, "wallet"); const order = useLatestEvent(source, "order", intoOrder); From dcf57c6b177164d6ac03fef240de13ddebe89b34 Mon Sep 17 00:00:00 2001 From: bonomat Date: Wed, 8 Dec 2021 08:03:28 +1100 Subject: [PATCH 2/6] By moving the alertbox below the grid the size of the grid is not randomly expanding if the alertbox is shown --- taker-frontend/src/components/Trade.tsx | 248 ++++++++++++------------ 1 file changed, 125 insertions(+), 123 deletions(-) diff --git a/taker-frontend/src/components/Trade.tsx b/taker-frontend/src/components/Trade.tsx index 9373fa7..7d55402 100644 --- a/taker-frontend/src/components/Trade.tsx +++ b/taker-frontend/src/components/Trade.tsx @@ -156,133 +156,135 @@ export default function Trade({ } return ( -
- - -
- - - - - 0}> - {referencePrice} - - + +
+ + +
+ + + + + 0}> + {referencePrice} + + + - - -
-
- - - - - - - - - - -
- - - + +
+
+ + + + + + + + + + +
+ + + - - - - - Market buy {quantity} of BTC/USD @ {askPrice} - - - - - - By submitting, ₿{margin} will be locked on-chain in a contract. - - - - - - - - - - - - - - - -
Margin₿{margin}
Leverage{leverage}
Liquidation Price{liquidationPrice}
-
+ + + + + Market buy {quantity} of BTC/USD @ {askPrice} + + + + + + By submitting, ₿{margin} will be locked on-chain in a contract. + + + + + + + + + + + + + + + +
Margin₿{margin}
Leverage{leverage}
Liquidation Price{liquidationPrice}
+
- - - - - -
-
-
-
- {alertBox} -
-
-
+ let payload: CfdOrderRequestPayload = { + order_id: orderId!, + quantity: Number.parseFloat(quantityAsNumber), + }; + onLongSubmit(payload); + onClose(); + }} + > + Confirm + + + + + + +
+
+
+
+ {alertBox} + ); } From 59121cca9d292f2fdf02a97599e9f0c02a311eab Mon Sep 17 00:00:00 2001 From: bonomat Date: Wed, 8 Dec 2021 08:03:58 +1100 Subject: [PATCH 3/6] =?UTF-8?q?The=20taker=20enforces=20100=20increments?= =?UTF-8?q?=20but=20the=20default=20maker=20was=2010=20=F0=9F=A4=A6?= =?UTF-8?q?=E2=80=8D=E2=99=82=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maker-frontend/src/MakerApp.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maker-frontend/src/MakerApp.tsx b/maker-frontend/src/MakerApp.tsx index 4cbb8a1..2f18c14 100644 --- a/maker-frontend/src/MakerApp.tsx +++ b/maker-frontend/src/MakerApp.tsx @@ -47,8 +47,8 @@ export default function App() { const toast = useToast(); - let [minQuantity, setMinQuantity] = useState("10"); - let [maxQuantity, setMaxQuantity] = useState("100"); + let [minQuantity, setMinQuantity] = useState("100"); + let [maxQuantity, setMaxQuantity] = useState("1000"); let [orderPrice, setOrderPrice] = useState("0"); let [autoRefresh, setAutoRefresh] = useState(true); From a3206644ff28fbeaa38a03118ce35b7c2c2ca444 Mon Sep 17 00:00:00 2001 From: bonomat Date: Wed, 8 Dec 2021 08:09:29 +1100 Subject: [PATCH 4/6] Make the number input full width to not weirdly jump --- taker-frontend/src/components/Trade.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/taker-frontend/src/components/Trade.tsx b/taker-frontend/src/components/Trade.tsx index 7d55402..8b63b24 100644 --- a/taker-frontend/src/components/Trade.tsx +++ b/taker-frontend/src/components/Trade.tsx @@ -309,6 +309,7 @@ function Quantity({ min, max, onChange, quantity, quantityIncrement }: QuantityP step={quantityIncrement} onChange={onChange} value={quantity} + w={"100%"} > From 9d025025937d630a9ff08c44da1133965f4cb69b Mon Sep 17 00:00:00 2001 From: bonomat Date: Wed, 8 Dec 2021 08:16:42 +1100 Subject: [PATCH 5/6] Make button size fix Looks good until a quantity of 100_000_000 --- taker-frontend/src/components/Trade.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/taker-frontend/src/components/Trade.tsx b/taker-frontend/src/components/Trade.tsx index 8b63b24..3531665 100644 --- a/taker-frontend/src/components/Trade.tsx +++ b/taker-frontend/src/components/Trade.tsx @@ -214,13 +214,20 @@ export default function Trade({ padding="3" spacing="6" > - - + - {action} your position + {buttonTitle} your position - - This will {action.toLowerCase()} your position with the counterparty. The exchange rate at - - - - will determine your profit/losses. It is likely that the rate will change until then. - + {popoverBody} - {action} + {buttonTitle} diff --git a/taker-frontend/src/components/History.tsx b/taker-frontend/src/components/History.tsx index af2f2fb..faf3bb8 100644 --- a/taker-frontend/src/components/History.tsx +++ b/taker-frontend/src/components/History.tsx @@ -75,8 +75,14 @@ const CfdDetails = ({ cfd, connectedToMaker }: CfdDetailsProps) => { let [commit, isCommiting] = usePostRequest(`/api/cfd/${cfd.order_id}/commit`); const closeButton = connectedToMaker.online - ? - : ; + ? + : ; return (