Skip to content

Commit

Permalink
Bug: Margin info and buying power (#1230)
Browse files Browse the repository at this point in the history
fix margin info
  • Loading branch information
Tburm authored Aug 4, 2022
1 parent e1cf4a1 commit 61d360a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sections/futures/MarketInfoBox/MarketInfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const MarketInfoBox: React.FC = () => {
const availableMargin = position?.accessibleMargin ?? zeroBN;

const buyingPower =
position && position?.accessibleMargin.gt(zeroBN)
? position?.accessibleMargin?.mul(maxLeverage ?? zeroBN)
position && position?.remainingMargin.gt(zeroBN)
? maxLeverage.mul(position?.remainingMargin ?? zeroBN)
: zeroBN;

const marginUsage =
Expand Down Expand Up @@ -85,11 +85,14 @@ const MarketInfoBox: React.FC = () => {
};

const previewAvailableMargin = React.useMemo(() => {
const potentialAvailableMargin = getPotentialAvailableMargin(previewTrade, maxLeverage);
const potentialAvailableMargin = getPotentialAvailableMargin(
previewTrade,
marketInfo?.maxLeverage
);
return isNextPriceOrder
? potentialAvailableMargin?.sub(totalDeposit) ?? zeroBN
: potentialAvailableMargin;
}, [previewTrade, maxLeverage, isNextPriceOrder, totalDeposit]);
}, [previewTrade, marketInfo?.maxLeverage, isNextPriceOrder, totalDeposit]);

const previewTradeData = React.useMemo(() => {
const size = wei(tradeSize || zeroBN);
Expand Down

0 comments on commit 61d360a

Please sign in to comment.