Skip to content

Commit d6c4858

Browse files
authored
feat: Aave Shield (#2900)
1 parent 02ab755 commit d6c4858

26 files changed

Lines changed: 233 additions & 20 deletions

‎src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaCoWAdapters.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
areActionsBlocked,
2929
ExpiryToSecondsMap,
3030
isCowProtocolRates,
31+
isShieldBlocked,
3132
OrderType,
3233
SwapParams,
3334
SwapState,
@@ -360,6 +361,7 @@ export const CollateralSwapActionsViaCowAdapters = ({
360361
}}
361362
fetchingData={state.actionsLoading || loadingPermitData}
362363
blocked={areActionsBlocked(state) || !precalculatedInstanceAddress}
364+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
363365
tryPermit={tryPermit}
364366
permitInUse={disablePermitDueToActiveOrder}
365367
/>

‎src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaParaswapAdapters.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
areActionsBlocked,
1919
isParaswapRates,
2020
isProtocolSwapState,
21+
isShieldBlocked,
2122
SwapParams,
2223
SwapState,
2324
} from '../../types';
@@ -286,6 +287,7 @@ export const CollateralSwapActionsViaParaswapAdapters = ({
286287
requiresAmount
287288
amount={state.processedSide === 'sell' ? state.sellAmountFormatted : state.buyAmountFormatted}
288289
blocked={areActionsBlocked(state) || approvalTxState.loading}
290+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
289291
handleApproval={approval}
290292
requiresApproval={requiresApproval}
291293
actionText={

‎src/components/transactions/Swap/actions/DebtSwap/DebtSwapActionsViaCoW.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
ExpiryToSecondsMap,
3535
isCowProtocolRates,
3636
isProtocolSwapState,
37+
isShieldBlocked,
3738
OrderType,
3839
SwapParams,
3940
SwapState,
@@ -387,6 +388,7 @@ export const DebtSwapActionsViaCoW = ({
387388
}}
388389
fetchingData={state.actionsLoading || loadingPermitData}
389390
blocked={areActionsBlocked(state) || !precalculatedInstanceAddress}
391+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
390392
tryPermit={tryPermit}
391393
permitInUse={disablePermitDueToActiveOrder}
392394
/>

‎src/components/transactions/Swap/actions/DebtSwap/DebtSwapActionsViaParaswap.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { useSwapGasEstimation } from '../../hooks/useSwapGasEstimation';
1818
import {
1919
areActionsBlocked,
2020
isParaswapRates,
21+
isShieldBlocked,
2122
ProtocolSwapParams,
2223
ProtocolSwapState,
2324
SwapState,
@@ -255,6 +256,7 @@ export const DebtSwapActionsViaParaswap = ({
255256
handleClick: action,
256257
}}
257258
blocked={areActionsBlocked(state)}
259+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
258260
tryPermit={tryPermit}
259261
/>
260262
);

‎src/components/transactions/Swap/actions/RepayWithCollateral/RepayWithCollateralActionsViaCoW.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
areActionsBlocked,
3333
ExpiryToSecondsMap,
3434
isCowProtocolRates,
35+
isShieldBlocked,
3536
OrderType,
3637
SwapParams,
3738
SwapState,
@@ -391,6 +392,7 @@ export const RepayWithCollateralActionsViaCoW = ({
391392
}}
392393
fetchingData={state.actionsLoading || loadingPermitData}
393394
blocked={areActionsBlocked(state) || !precalculatedInstanceAddress}
395+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
394396
tryPermit={tryPermit}
395397
permitInUse={disablePermitDueToActiveOrder}
396398
/>

‎src/components/transactions/Swap/actions/RepayWithCollateral/RepayWithCollateralActionsViaParaswap.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { useSwapGasEstimation } from '../../hooks/useSwapGasEstimation';
1818
import {
1919
areActionsBlocked,
2020
isParaswapRates,
21+
isShieldBlocked,
2122
ProtocolSwapParams,
2223
ProtocolSwapState,
2324
SwapState,
@@ -279,6 +280,7 @@ export const RepayWithCollateralActionsViaParaswap = ({
279280
requiresApproval={requiresApproval}
280281
isWrongNetwork={state.isWrongNetwork}
281282
blocked={areActionsBlocked(state)}
283+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
282284
handleAction={action}
283285
handleApproval={approval}
284286
actionText={<Trans>Repay {state.sourceReserve.reserve.symbol}</Trans>}

‎src/components/transactions/Swap/actions/SwapActions/SwapActionsViaCoW.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
areActionsBlocked,
3636
ExpiryToSecondsMap,
3737
isCowProtocolRates,
38+
isShieldBlocked,
3839
OrderType,
3940
SwapParams,
4041
SwapState,
@@ -422,6 +423,7 @@ export const SwapActionsViaCoW = ({
422423
}}
423424
fetchingData={state.actionsLoading || loadingPermitData}
424425
blocked={areActionsBlocked(state)}
426+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
425427
tryPermit={tryPermit}
426428
permitInUse={disablePermitDueToActiveOrder}
427429
/>

‎src/components/transactions/Swap/actions/SwapActions/SwapActionsViaParaswap.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ import { useShallow } from 'zustand/shallow';
1212
import { TrackAnalyticsHandlers } from '../../analytics/useTrackAnalytics';
1313
import { APP_CODE_PER_SWAP_TYPE } from '../../constants/shared.constants';
1414
import { useSwapGasEstimation } from '../../hooks/useSwapGasEstimation';
15-
import { areActionsBlocked, isParaswapRates, SwapParams, SwapState } from '../../types';
15+
import {
16+
areActionsBlocked,
17+
isParaswapRates,
18+
isShieldBlocked,
19+
SwapParams,
20+
SwapState,
21+
} from '../../types';
1622
import { useSwapTokenApproval } from '../approval/useSwapTokenApproval';
1723

1824
/**
@@ -237,6 +243,7 @@ export const SwapActionsViaParaswap = ({
237243
}}
238244
fetchingData={state.actionsLoading || loadingPermitData}
239245
blocked={areActionsBlocked(state)}
246+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
240247
tryPermit={tryPermit}
241248
/>
242249
);

‎src/components/transactions/Swap/actions/WithdrawAndSwap/WithdrawAndSwapActionsViaParaswap.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useSwapGasEstimation } from '../../hooks/useSwapGasEstimation';
1717
import {
1818
areActionsBlocked,
1919
isParaswapRates,
20+
isShieldBlocked,
2021
ProtocolSwapParams,
2122
ProtocolSwapState,
2223
SwapState,
@@ -231,6 +232,7 @@ export const WithdrawAndSwapActionsViaParaswap = ({
231232
}}
232233
fetchingData={state.actionsLoading || loadingPermitData}
233234
blocked={areActionsBlocked(state)}
235+
blockedText={isShieldBlocked(state) ? <Trans>Blocked by Shield</Trans> : undefined}
234236
tryPermit={tryPermit}
235237
/>
236238
);

‎src/components/transactions/Swap/types/state.types.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export enum ActionsBlockedReason {
2626
FLASH_LOAN_DISABLED = 'FLASH_LOAN_DISABLED',
2727
IS_LIQUIDATABLE = 'IS_LIQUIDATABLE',
2828
INSUFFICIENT_BORROW_POWER = 'INSUFFICIENT_BORROW_POWER',
29+
SHIELD_BLOCKED = 'SHIELD_BLOCKED',
2930
}
3031

3132
/**
@@ -186,6 +187,10 @@ export const actionsBlockedReasonsAmount = (state: SwapState): number => {
186187
return Object.values(state.actionsBlocked).filter((blocked) => blocked === true).length;
187188
};
188189

190+
export const isShieldBlocked = (state: SwapState): boolean => {
191+
return state.actionsBlocked[ActionsBlockedReason.SHIELD_BLOCKED] === true;
192+
};
193+
189194
/**
190195
* State for protocol-aware flows. Includes reserve context for computing
191196
* HF effects, borrow/collateral semantics, and determining flashloan usage.

0 commit comments

Comments
 (0)