From a7dc5d15e62d5d4ace5899ed1c62f2589d2ae42e Mon Sep 17 00:00:00 2001 From: Pietro <74987028+pietro-maximoff@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:24:11 +0100 Subject: [PATCH] SOV-3802: Fix mismatch in collateral on margin trade positions (#2595) Co-authored-by: soulBit --- .../MarginTradePage/components/AddToMarginDialog/index.tsx | 4 ++-- .../MarginTradePage/components/ClosePositionDialog/index.tsx | 3 ++- .../components/ClosedPositionsTable/ClosedPositionRow.tsx | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/pages/MarginTradePage/components/AddToMarginDialog/index.tsx b/src/app/pages/MarginTradePage/components/AddToMarginDialog/index.tsx index b2f9a76909..17ac2faf46 100644 --- a/src/app/pages/MarginTradePage/components/AddToMarginDialog/index.tsx +++ b/src/app/pages/MarginTradePage/components/AddToMarginDialog/index.tsx @@ -48,10 +48,10 @@ export const AddToMarginDialog: React.FC = ({ trade, loanToken: { id: loanTokenId }, collateralToken: { id: collateralTokenId }, + positionSize: positionSizeItem, } = item; const entryLeverage = trade?.[0].entryLeverage || DEFAULT_TRADE.entryLeverage; - const positionSizeValue = - trade?.[0].positionSize || DEFAULT_TRADE.positionSize; + const positionSizeValue = positionSizeItem || DEFAULT_TRADE.positionSize; const tokenDetails = AssetsDictionary.getByTokenContractAddress( collateralTokenId, ); diff --git a/src/app/pages/MarginTradePage/components/ClosePositionDialog/index.tsx b/src/app/pages/MarginTradePage/components/ClosePositionDialog/index.tsx index 225250ee26..6639e3dd65 100644 --- a/src/app/pages/MarginTradePage/components/ClosePositionDialog/index.tsx +++ b/src/app/pages/MarginTradePage/components/ClosePositionDialog/index.tsx @@ -76,10 +76,11 @@ export const ClosePositionDialog: React.FC = ({ id, loanToken: { id: loanTokenId }, collateralToken: { id: collateralTokenId }, + positionSize: positionSizeValue, } = item; const entryLeverage = trade?.[0].entryLeverage || DEFAULT_TRADE.entryLeverage; - const positionSize = trade?.[0].positionSize || DEFAULT_TRADE.positionSize; + const positionSize = positionSizeValue || DEFAULT_TRADE.positionSize; const [collateral, setCollateral] = useState( assetByTokenAddress(collateralTokenId), ); diff --git a/src/app/pages/MarginTradePage/components/ClosedPositionsTable/ClosedPositionRow.tsx b/src/app/pages/MarginTradePage/components/ClosedPositionsTable/ClosedPositionRow.tsx index 1c75dcf28d..6945181e50 100644 --- a/src/app/pages/MarginTradePage/components/ClosedPositionsTable/ClosedPositionRow.tsx +++ b/src/app/pages/MarginTradePage/components/ClosedPositionsTable/ClosedPositionRow.tsx @@ -34,9 +34,10 @@ export const ClosedPositionRow: React.FC = ({ collateralToken: { id: collateralTokenId }, liquidates, closeWithSwaps, + positionSize: positionSizeValue, } = event; const entryLeverage = trade?.[0].entryLeverage || DEFAULT_TRADE.entryLeverage; - const positionSize = trade?.[0].positionSize || DEFAULT_TRADE.positionSize; + const positionSize = positionSizeValue || DEFAULT_TRADE.positionSize; const entryPrice = trade?.[0].entryPrice || DEFAULT_TRADE.entryPrice; const transaction = trade?.[0].transaction.id || DEFAULT_TRADE.transactionId; const loanAsset = assetByTokenAddress(loanTokenId);