Browse Source

Make it clear what the payout is

Fixes #557.
debug-collab-settlement
Thomas Eizinger 3 years ago
parent
commit
efecc2eead
No known key found for this signature in database GPG Key ID: 651AC83A6C6C8B96
  1. 33
      taker-frontend/src/components/History.tsx

33
taker-frontend/src/components/History.tsx

@ -66,9 +66,12 @@ const CfdDetails = ({ cfd }: CfdDetailsProps) => {
const quantity = `$${cfd.quantity_usd}`; const quantity = `$${cfd.quantity_usd}`;
const margin = `${Math.round((cfd.margin) * 1_000_000) / 1_000_000}`; const margin = `${Math.round((cfd.margin) * 1_000_000) / 1_000_000}`;
const liquidationPrice = `$${cfd.liquidation_price}`; const liquidationPrice = `$${cfd.liquidation_price}`;
const pAndL = Math.round((cfd.profit_btc) * 1_000_000) / 1_000_000;
const pAndLNumber = Math.round((cfd.profit_btc) * 1_000_000) / 1_000_000;
const pAndL = pAndLNumber < 0 ? `-₿${Math.abs(pAndLNumber)}` : `${Math.abs(pAndLNumber)}`;
const expiry = cfd.expiry_timestamp; const expiry = cfd.expiry_timestamp;
const profit = Math.round((cfd.margin + cfd.profit_btc) * 1_000_000) / 1_000_000; const payout = `${Math.round((cfd.margin + cfd.profit_btc) * 1_000_000) / 1_000_000}`;
const txLock = cfd.details.tx_url_list.find((tx) => tx.label === TxLabel.Lock); const txLock = cfd.details.tx_url_list.find((tx) => tx.label === TxLabel.Lock);
const txCommit = cfd.details.tx_url_list.find((tx) => tx.label === TxLabel.Commit); const txCommit = cfd.details.tx_url_list.find((tx) => tx.label === TxLabel.Commit);
@ -82,36 +85,41 @@ const CfdDetails = ({ cfd }: CfdDetailsProps) => {
|| !(cfd.state.key === StateKey.OPEN); || !(cfd.state.key === StateKey.OPEN);
return ( return (
<HStack bg={useColorModeValue("gray.100", "gray.700")} rounded={5}> <HStack bg={useColorModeValue("gray.100", "gray.700")} rounded={5} padding={2}>
<Center h={"100%"}> <Center>
<Table variant="striped" colorScheme="gray" size="sm"> <Table variant="striped" colorScheme="gray" size="sm">
<Tbody> <Tbody>
<Tr> <Tr>
<Td><Text as={"b"}>Quantity</Text></Td> <Td><Text as={"b"}>Quantity</Text></Td>
<Td>{quantity}</Td> {/*TODO: Fix textAlign right hacks by using a grid instead ... */}
<Td textAlign="right">{quantity}</Td>
</Tr> </Tr>
<Tr> <Tr>
<Td><Text as={"b"}>Opening price</Text></Td> <Td><Text as={"b"}>Opening price</Text></Td>
<Td>{initialPrice}</Td> <Td textAlign="right">{initialPrice}</Td>
</Tr> </Tr>
<Tr> <Tr>
<Td><Text as={"b"}>Liquidation</Text></Td> <Td><Text as={"b"}>Liquidation</Text></Td>
<Td>{liquidationPrice}</Td> <Td textAlign="right">{liquidationPrice}</Td>
</Tr> </Tr>
<Tr> <Tr>
<Td><Text as={"b"}>Margin</Text></Td> <Td><Text as={"b"}>Margin</Text></Td>
<Td>{margin}</Td> <Td textAlign="right">{margin}</Td>
</Tr> </Tr>
<Tr> <Tr>
<Td><Text as={"b"}>Unrealized P/L</Text></Td> <Td><Text as={"b"}>Unrealized P/L</Text></Td>
<Td>{pAndL.toString()}</Td> <Td textAlign="right">{pAndL}</Td>
</Tr>
<Tr>
<Td><Text as={"b"}>Payout</Text></Td>
<Td textAlign="right">{payout}</Td>
</Tr> </Tr>
</Tbody> </Tbody>
</Table> </Table>
</Center> </Center>
<VStack> <VStack>
<Badge colorScheme={cfd.state.getColorScheme()}>{cfd.state.getLabel()}</Badge> <Badge colorScheme={cfd.state.getColorScheme()}>{cfd.state.getLabel()}</Badge>
<HStack w={"95%"}> <HStack>
<VStack> <VStack>
<TxIcon tx={txLock} /> <TxIcon tx={txLock} />
<Text>Lock</Text> <Text>Lock</Text>
@ -149,11 +157,6 @@ const CfdDetails = ({ cfd }: CfdDetailsProps) => {
</>} </>}
</HStack> </HStack>
<HStack> <HStack>
<Box w={"45%"}>
<Text fontSize={"sm"} align={"left"}>
At the current rate you would receive <b> {profit}</b>
</Text>
</Box>
<Box w={"45%"}> <Box w={"45%"}>
<Popover <Popover
placement="bottom" placement="bottom"

Loading…
Cancel
Save