Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
lq0-github committed Jan 23, 2025
1 parent 66fb275 commit f8acf23
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
6 changes: 3 additions & 3 deletions screens/Trading/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const TradingTable = ({
const sortList = {
close_timestamp: "Close time",
open_timestamp: "Opening time",
pnl: "PNL & ROE",
pnl: "PNL",
};
return (
<div className="flex flex-col items-center justify-center lg:w-full xsm:w-[100vw] xsm:px-2">
Expand Down Expand Up @@ -339,7 +339,7 @@ const TradingTable = ({
<th>Entry Price</th>
<th>Index Price</th>
<th>Liq. Price</th>
<th>PNL & ROE</th>
<th>PNL</th>
<th>
<div
onClick={() => handleSort("open_ts")}
Expand Down Expand Up @@ -438,7 +438,7 @@ const TradingTable = ({
<th>Fee</th>
<th onClick={() => handleSortChange("pnl")}>
<div className="flex items-center cursor-pointer">
PNL & ROE
PNL
<SortHistoryButton
activeColor="rgba(192, 196, 233, 1)"
inactiveColor="rgba(192, 196, 233, 0.5)"
Expand Down
34 changes: 20 additions & 14 deletions screens/Trading/components/Table/HistoryRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ const HistoryRow = ({ key, index, record, assetP, assetD, assetC }) => {
return !isMobile ? (
<tr className="align-text-top">
<td className="py-5 pl-5">
{`${getSymbolById(assetP.token_id, assetP.metadata?.symbol)}/${getSymbolById(
assetD.token_id,
assetD.metadata?.symbol,
)}`}
{record.trend === "long"
? `${getSymbolById(assetP.token_id, assetP.metadata?.symbol)}/${getSymbolById(
assetD.token_id,
assetD.metadata?.symbol,
)}`
: `${getSymbolById(assetD.token_id, assetD.metadata?.symbol)}/${getSymbolById(
assetP.token_id,
assetP.metadata?.symbol,
)}`}
<div
className={
record.trend === "long"
Expand Down Expand Up @@ -49,6 +54,11 @@ const HistoryRow = ({ key, index, record, assetP, assetD, assetC }) => {
),
)
: null}
<span className="ml-0.5">
{record.trend === "long"
? `${getSymbolById(assetP.token_id, assetP.metadata?.symbol)}`
: `${getSymbolById(assetD.token_id, assetD.metadata?.symbol)}`}
</span>
</td>
<td>
{beautifyPrice(
Expand All @@ -74,17 +84,11 @@ const HistoryRow = ({ key, index, record, assetP, assetD, assetC }) => {
) : (
"-"
)}
<p className="text-gray-300 text-xs">
{getSymbolById(assetC.token_id, assetC.metadata?.symbol)}
</p>
</div>
</td>
<td>
<div className="flex items-start flex-col">
{record.price !== "0" ? <span>{beautifyPrice(Number(record.price))}</span> : "-"}
<p className="text-gray-300 text-xs">
{getSymbolById(assetC.token_id, assetC.metadata?.symbol)}
</p>
</div>
</td>
<td>
Expand All @@ -104,9 +108,6 @@ const HistoryRow = ({ key, index, record, assetP, assetD, assetC }) => {
{record.pnl !== "0"
? beautifyPrice(Math.abs(record.pnl * record.c_token_price), false, 3, 3)
: ""}
{/* <p className="text-gray-300 text-xs">
{getSymbolById(assetC.token_id, assetC.metadata?.symbol)}
</p> */}
</td>
<td>
<div className="text-sm">
Expand Down Expand Up @@ -194,6 +195,11 @@ const HistoryRow = ({ key, index, record, assetP, assetD, assetC }) => {
),
)
: null}
<span className="ml-0.5">
{record.trend === "long"
? `${getSymbolById(assetP.token_id, assetP.metadata?.symbol)}`
: `${getSymbolById(assetD.token_id, assetD.metadata?.symbol)}`}
</span>
</p>
</div>
<div className="flex items-center justify-between text-sm mb-[18px]">
Expand Down Expand Up @@ -267,7 +273,7 @@ const HistoryRow = ({ key, index, record, assetP, assetD, assetC }) => {
<p>{record.close_type}</p>
</div>
<div className="bg-dark-100 rounded-2xl flex items-center justify-center text-xs py-1 text-gray-300 mb-4">
PNL & ROE
PNL
<p
className={`ml-1 ${
record.pnl > 0 ? "text-green-150" : record.pnl < 0 ? "text-red-150" : ""
Expand Down
28 changes: 13 additions & 15 deletions screens/Trading/components/Table/PositionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const PositionRow = ({

const netValue = parseTokenValue(item.token_c_info.balance, decimalsC) * (priceC || 0);
const collateral = parseTokenValue(item.token_c_info.balance, decimalsC);
const assetLabel = positionType.label === "Long" ? symbolD : symbolP;
const assetLabel = positionType.label === "Long" ? symbolP : symbolD;
const indexPrice = positionType.label === "Long" ? priceP / priceD : priceD / priceP;
const openTime = new Date(Number(item.open_ts) / 1e6);
const uahpi: any = isMainStream
Expand Down Expand Up @@ -144,7 +144,10 @@ const PositionRow = ({
</td>
<td>
<div className="flex mr-4 items-start flex-col">
<p className=""> {beautifyPrice(size)}</p>
<p className="">
{" "}
{beautifyPrice(size)} {assetLabel}
</p>
<span className="text-gray-300 text-xs">({beautifyPrice(sizeValue, true, 3, 3)})</span>
</div>
</td>
Expand Down Expand Up @@ -174,14 +177,10 @@ const PositionRow = ({
) : (
<span className="text-gray-500">-</span>
)}
<span className="text-gray-300 text-xs">{assetLabel}</span>
</div>
</td>
<td>
<div className="flex items-start flex-col">
{beautifyPrice(indexPrice)}
<span className="text-gray-300 text-xs">{assetLabel}</span>
</div>
<div className="flex items-start flex-col">{beautifyPrice(indexPrice)}</div>
</td>
<td>${beautifyPrice(LiqPrice)}</td>
<td>
Expand Down Expand Up @@ -258,7 +257,10 @@ const PositionRow = ({
</div>
<div className="text-right">
<div className="flex items-center">
<p className="mr-2"> {beautifyPrice(size)}</p>
<p className="mr-2">
{" "}
{beautifyPrice(size)} {assetLabel}
</p>
<span className="text-gray-300 text-sm">({beautifyPrice(sizeValue, true, 3, 3)})</span>
</div>
<p className="text-xs text-gray-300">Size</p>
Expand Down Expand Up @@ -291,19 +293,15 @@ const PositionRow = ({
<p className="text-gray-300">Entry Price</p>
<p>
{entryPrice !== null ? (
<span>
{beautifyPrice(entryPrice)} {assetLabel}
</span>
<span>{beautifyPrice(entryPrice)}</span>
) : (
<span className="text-gray-500">-</span>
)}
</p>
</div>
<div className="flex items-center justify-between text-sm mb-[18px]">
<p className="text-gray-300">Index Price</p>
<p>
{beautifyPrice(indexPrice)} {assetLabel}
</p>
<p>{beautifyPrice(indexPrice)}</p>
</div>
<div className="flex items-center justify-between text-sm mb-[18px]">
<p className="text-gray-300">Liq. Price</p>
Expand All @@ -314,7 +312,7 @@ const PositionRow = ({
<p>{new Date(openTime).toLocaleString()}</p>
</div>
<div className="bg-dark-100 rounded-2xl flex items-center justify-center text-xs py-1 text-gray-300 mb-4">
PNL & ROE{" "}
PNL{" "}
<p
className={`ml-1 ${
pnl > 0 ? "text-green-150" : pnl < 0 ? "text-red-150" : "text-gray-400"
Expand Down

0 comments on commit f8acf23

Please sign in to comment.