Skip to content

Commit 92490bb

Browse files
committed
misc
1 parent c2fec96 commit 92490bb

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

src/components/transactions/Swap/errors/shared/InsufficientLiquidityBlockingGuard.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { ethers } from 'ethers';
55
import { Dispatch, useEffect } from 'react';
66

77
import { ActionsBlockedReason, ProtocolSwapState, SwapError, SwapState } from '../../types';
8+
import { isProtocolSwapState } from '../../types/state.types';
89
import { InsufficientLiquidityBlockingError } from './InsufficientLiquidityBlockingError';
910

1011
export const hasInsufficientLiquidity = (state: SwapState) => {
11-
if (!('destinationReserve' in state)) return false;
12-
const protocolState = state as ProtocolSwapState;
13-
const reserve = protocolState.destinationReserve?.reserve;
14-
const buyAmount = protocolState.buyAmountFormatted;
12+
if (!isProtocolSwapState(state)) return false;
13+
const reserve = state.isInvertedSwap
14+
? state.sourceReserve?.reserve
15+
: state.destinationReserve?.reserve;
16+
const buyAmount = state.buyAmountFormatted;
1517
if (!reserve || !buyAmount) return false;
1618

1719
const availableBorrowCap =
@@ -71,10 +73,17 @@ export const InsufficientLiquidityBlockingGuard = ({
7173
});
7274
}
7375
}
74-
}, [state.buyAmountFormatted, state.destinationReserve?.reserve?.formattedAvailableLiquidity]);
76+
}, [
77+
state.buyAmountFormatted,
78+
state.destinationReserve?.reserve?.formattedAvailableLiquidity,
79+
state.sourceReserve?.reserve?.formattedAvailableLiquidity,
80+
state.isInvertedSwap,
81+
]);
7582

7683
if (hasInsufficientLiquidity(state)) {
77-
const symbol = state.destinationReserve?.reserve?.symbol || '';
84+
const symbol = state.isInvertedSwap
85+
? state.sourceReserve?.reserve?.symbol
86+
: state.destinationReserve?.reserve?.symbol;
7887
return (
7988
<InsufficientLiquidityBlockingError
8089
symbol={symbol}

src/components/transactions/Swap/errors/shared/SupplyCapBlockingGuard.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { SxProps } from '@mui/material';
33
import { Dispatch, useEffect } from 'react';
44

55
import { ActionsBlockedReason, ProtocolSwapState, SwapError, SwapState } from '../../types';
6+
import { isProtocolSwapState } from '../../types/state.types';
67
import { SupplyCapBlockingError } from './SupplyCapBlockingError';
78

89
export const hasSupplyCapBlocking = (state: SwapState) => {
9-
if (!('destinationReserve' in state)) return false;
10-
const protocolState = state as ProtocolSwapState;
11-
const reserve = protocolState.destinationReserve?.reserve;
12-
const buyAmount = protocolState.buyAmountFormatted;
10+
if (!isProtocolSwapState(state)) return false;
11+
const reserve = state.isInvertedSwap
12+
? state.sourceReserve?.reserve
13+
: state.destinationReserve?.reserve;
14+
const buyAmount = state.buyAmountFormatted;
1315
if (!reserve || !buyAmount) return false;
1416

1517
if (reserve.supplyCap === '0') return false;
@@ -67,10 +69,17 @@ export const SupplyCapBlockingGuard = ({
6769
});
6870
}
6971
}
70-
}, [state.buyAmountFormatted, state.destinationReserve?.reserve?.totalLiquidity]);
72+
}, [
73+
state.buyAmountFormatted,
74+
state.destinationReserve?.reserve?.totalLiquidity,
75+
state.sourceReserve?.reserve?.totalLiquidity,
76+
state.isInvertedSwap,
77+
]);
7178

7279
if (hasSupplyCapBlocking(state)) {
73-
const symbol = state.destinationReserve?.reserve?.symbol || '';
80+
const symbol = state.isInvertedSwap
81+
? state.sourceReserve?.reserve?.symbol
82+
: state.destinationReserve?.reserve?.symbol;
7483
return (
7584
<SupplyCapBlockingError symbol={symbol} sx={{ mb: !isSwapFlowSelected ? 0 : 4, ...sx }} />
7685
);

src/components/transactions/Swap/helpers/paraswap/misc.helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const getParaswapSlippage = (
1212
const baseSlippage = inputGroup === outputGroup ? '0.10' : '0.20';
1313

1414
if (swapType === SwapType.DebtSwap) {
15-
return (Number(baseSlippage) * 1.5).toString();
15+
return (Number(baseSlippage) * 2).toString();
1616
}
1717

1818
return baseSlippage;

0 commit comments

Comments
 (0)