Skip to content

Commit

Permalink
fix(app): incorrect allowance check on trade (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
avclarke authored Sep 27, 2023
1 parent e613efd commit 5a16dab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export default function TradeConfirmationModal({
const ethBalanceExceeded = useAppSelector(selectKeeperDepositExceedsBal)
const hasSlTp = useAppSelector(selectNewTradeHasSlTp)
const sltpValidity = useAppSelector(selectTradePanelSLTPValidity)
const swapToken = useAppSelector(selectSelectedSwapDepositToken)

const [overridePriceProtection, setOverridePriceProtection] = useState(false)
const [acceptedSLRisk, setAcceptedSLRisk] = useState(false)
Expand Down Expand Up @@ -147,7 +146,7 @@ export default function TradeConfirmationModal({

const buttonText = allowanceValid
? t(`futures.market.trade.confirmation.modal.confirm-order.${leverageSide}`)
: t(`futures.market.trade.confirmation.modal.approve-order`, { asset: swapToken })
: t(`futures.market.trade.confirmation.modal.approve-order`, { asset: 'sUSD' })

return (
<StyledBaseModal
Expand Down
3 changes: 1 addition & 2 deletions packages/app/src/state/futures/smartMargin/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,7 @@ export const selectSmartMarginAllowanceValid = createSelector(
selectSmartMarginBalanceInfo,
selectAvailableMarginInMarkets,
selectSmartMarginMarginDelta,
selectSwapDepositAllowance,
({ freeMargin }, idleInMarkets, marginDelta, allowance) => {
({ freeMargin, allowance }, idleInMarkets, marginDelta) => {
const totalIdleMargin = freeMargin.add(idleInMarkets)
const marginDeposit = marginDelta.sub(totalIdleMargin)
return totalIdleMargin.gte(marginDelta) || wei(allowance || 0).gte(marginDeposit)
Expand Down

0 comments on commit 5a16dab

Please sign in to comment.