Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
8baeeba
fix: repay type select styling
defispartan Jun 28, 2022
027273c
fix: remove repay with collateral warning
defispartan Jun 28, 2022
41cad5a
feat: add slippage components
defispartan Jun 28, 2022
414420f
feat: add slippage select to tx modal
defispartan Jun 28, 2022
c99636f
feat: update asset input styling
defispartan Jun 28, 2022
516a943
feat: redesign repay with collateral modal
defispartan Jun 28, 2022
d114fec
run i18n
defispartan Jun 28, 2022
cfe2504
removed psp warning
foodaka Jun 28, 2022
04054dd
fix: paraswap icon
defispartan Jun 30, 2022
9587a49
fix: input box alignment
defispartan Jun 30, 2022
4ab7564
feat: add price impact tooltip
defispartan Jun 30, 2022
9f51a65
fix: slippage select styling
defispartan Jun 30, 2022
5957197
fix: update collateral repay modal styling
defispartan Jun 30, 2022
44c1610
Merge branch 'chore/remove-psp-warning' into feat/rwc-updated-design
defispartan Jun 30, 2022
9bc1ea3
fix: don't allow frozen assets to be used as collateral repay
grothem Jun 30, 2022
e961761
fix: match toggle button style from repay modal
grothem Jun 30, 2022
ee2470e
fix: match bridge and faucet button styles with emode button
grothem Jun 30, 2022
8555721
Merge branch 'main' into feat/rwc-updated-design
defispartan Jul 12, 2022
6ac923f
feat: update collateral swap modal up to design specs
defispartan Jul 12, 2022
475bcb4
chore: run i18n
defispartan Jul 12, 2022
118568c
Merge branch 'main' into feat/rwc-updated-design
grothem Jul 21, 2022
2916141
fix: handle collateral balance being less than the debt amount when t…
grothem Jul 25, 2022
2433dd9
Automated cache update [skip cypress]
Jul 22, 2022
828c822
Automated cache update [skip cypress]
Jul 23, 2022
edc9763
Automated cache update [skip cypress]
Jul 25, 2022
1bab3ba
fix: remove weird stuff (#958)
sakulstra Jul 25, 2022
3cc14bf
fix: switch default env from staging to prod (#961)
defispartan Jul 25, 2022
6d08065
fix: token click area (#963)
sakulstra Jul 25, 2022
f100234
cleanup: remove caching service for stake (#937)
sakulstra Jul 25, 2022
aaa659f
fix: Use selected slippage when getting swap parameters instead of ha…
grothem Jul 25, 2022
b94ff80
Merge branch 'main' into feat/rwc-updated-design
grothem Jul 26, 2022
7426b0a
fix: handle repay collateral amount being less than the debt amount
grothem Jul 28, 2022
49d0a14
Merge branch 'main' into feat/rwc-updated-design
grothem Aug 16, 2022
76bd254
chore: i18n
grothem Aug 16, 2022
51eee55
Merge branch 'feat/rwc-updated-design' into feat/swap-updated-design
defispartan Aug 17, 2022
b2fc63e
fix: reverting changes, matching latest design
grothem Aug 18, 2022
b1d24a1
fix: remove exluded dexes for testing
grothem Aug 18, 2022
13ee0ee
fix: remove console log
grothem Aug 18, 2022
05cf934
fix: don't exclude any pools from paraswap
grothem Aug 18, 2022
1954f5e
Merge branch 'main' into feat/rwc-updated-design
grothem Aug 29, 2022
5259241
chore: i18n
grothem Aug 29, 2022
a07412f
fix: show correct asset name in collateral repay actions when approving
grothem Aug 29, 2022
79d4dd5
feat: wip
grothem Aug 30, 2022
552146d
feat: wip
grothem Aug 31, 2022
f16abba
feat: wip
grothem Aug 31, 2022
2dd8dbc
Merge branch 'main' into feat/rwc-updated-design
grothem Aug 31, 2022
19c063c
feat: separate component for tx details
defispartan Sep 9, 2022
f708086
feat: continuing with design updates
defispartan Sep 9, 2022
789fc37
chore: run i18n
defispartan Sep 9, 2022
d64370e
Merge branch 'main' into feat/swap-updated-design
defispartan Sep 9, 2022
9200067
feat: add supply balances after swap section
defispartan Sep 13, 2022
8c56f6e
feat: refactor collateral repay
grothem Aug 31, 2022
b0bad9e
feat: update warning text
defispartan Sep 14, 2022
18e3561
fix: warning styling
defispartan Sep 14, 2022
b15fe76
Merge branch 'main' into feat/rwc-updated-design
grothem Sep 14, 2022
dce1126
chore: i18n
grothem Sep 14, 2022
aefc1ea
Merge branch 'main' into feat/rwc-updated-design
grothem Sep 14, 2022
8cae43c
chore: i18n
grothem Sep 14, 2022
129e8f4
Merge branch 'feat/swap-updated-design' into feat/rwc-updated-design
grothem Sep 14, 2022
45a8043
chore: i18n
grothem Sep 14, 2022
c8445ee
fix: reset state when no there is invalid swap data
grothem Sep 14, 2022
38bb84a
fix: remove console log
grothem Sep 14, 2022
e50ee3e
fix: added change handler back in so we can reset the state on asset …
grothem Sep 14, 2022
aa45f06
fix: console logs
grothem Sep 14, 2022
0473df7
Merge branch 'main' into feat/rwc-updated-design
grothem Sep 14, 2022
1710b38
fix: cleanup swap/repay
grothem Sep 15, 2022
86e2f9d
Merge branch 'main' into feat/rwc-updated-design
grothem Sep 16, 2022
ca668c8
feat: refactor swap and repay logic
grothem Sep 16, 2022
331d415
chore: merge main (#1194)
grothem Oct 3, 2022
218afb6
fix: ui polish for 'exactIn' swap case
grothem Oct 3, 2022
28823f5
refactor: swap and collateral repay hooks
grothem Oct 4, 2022
077e512
chore: added jsdoc comments
grothem Oct 4, 2022
ed4dc72
fix: make sure input amount is valid, set correct slippage on swap
grothem Oct 4, 2022
7497a14
fix: error handling
grothem Oct 4, 2022
c63dbc2
Merge branch 'main' into feat/rwc-updated-design
defispartan Oct 11, 2022
6b940a2
fix: clean up merge files
defispartan Oct 11, 2022
b304304
fix: clean up merge files
defispartan Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"test:ci": "jest --ci"
},
"dependencies": {
"@aave/contract-helpers": "1.5.1",
"@aave/math-utils": "1.5.1",
"@aave/contract-helpers": "1.6.0",
"@aave/math-utils": "1.6.0",
"@apollo/client": "^3.5.10",
"@emotion/cache": "11.10.3",
"@emotion/react": "11.10.4",
Expand Down
1 change: 1 addition & 0 deletions public/icons/other/paraswap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 16 additions & 11 deletions src/components/transactions/AssetInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface AssetInputProps<T extends Asset = Asset> {
maxValue?: string;
isMaxSelected?: boolean;
inputTitle?: ReactNode;
balanceText?: string;
}

export const AssetInput = <T extends Asset = Asset>({
Expand All @@ -89,6 +90,7 @@ export const AssetInput = <T extends Asset = Asset>({
maxValue,
inputTitle,
isMaxSelected,
balanceText,
}: AssetInputProps<T>) => {
const handleSelect = (event: SelectChangeEvent) => {
const newAsset = assets.find((asset) => asset.symbol === event.target.value) as T;
Expand Down Expand Up @@ -198,6 +200,7 @@ export const AssetInput = <T extends Asset = Asset>({
'&.AssetInput__select .MuiOutlinedInput-notchedOutline': { display: 'none' },
'&.AssetInput__select .MuiSelect-icon': {
color: 'text.primary',
right: '0%',
},
}}
renderValue={(symbol) => {
Expand Down Expand Up @@ -248,15 +251,15 @@ export const AssetInput = <T extends Asset = Asset>({
compact
symbol="USD"
variant="secondary12"
color="text.disabled"
symbolsColor="text.disabled"
color="text.muted"
symbolsColor="text.muted"
flexGrow={1}
/>

{asset.balance && onChange && (
<>
<Typography component="div" variant="secondary12" color="text.secondary">
<Trans>Balance</Trans>{' '}
<Trans>{balanceText || 'Balance'}</Trans>{' '}
<FormattedNumber
value={asset.balance}
compact
Expand All @@ -265,14 +268,16 @@ export const AssetInput = <T extends Asset = Asset>({
symbolsColor="text.disabled"
/>
</Typography>
<Button
size="small"
sx={{ minWidth: 0, ml: '7px', p: 0 }}
onClick={() => onChange('-1')}
disabled={disabled || isMaxSelected}
>
<Trans>Max</Trans>
</Button>
{!disableInput && (
<Button
size="small"
sx={{ minWidth: 0, ml: '7px', p: 0 }}
onClick={() => onChange('-1')}
disabled={disabled || isMaxSelected}
>
<Trans>Max</Trans>
</Button>
)}
</>
)}
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/transactions/Borrow/BorrowModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const BorrowModeSwitch = ({
value={interestRateMode}
exclusive
onChange={(_, value) => setInterestRateMode(value)}
sx={{ width: '100%', mt: 0.5 }}
sx={{ width: '100%', height: '36px', p: '2px', mt: 0.5 }}
>
<StyledToggleButton
value={InterestRate.Variable}
Expand Down
36 changes: 24 additions & 12 deletions src/components/transactions/FlowCommons/TxModalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ import { GasStation } from '../GasStation/GasStation';

export interface TxModalDetailsProps {
gasLimit?: string;
slippageSelector?: ReactNode;
}

export const TxModalDetails: React.FC<TxModalDetailsProps> = ({ gasLimit, children }) => {
export const TxModalDetails: React.FC<TxModalDetailsProps> = ({
gasLimit,
slippageSelector,
children,
}) => {
return (
<Box sx={{ pt: 5 }}>
<Typography sx={{ mb: 1 }} color="text.secondary">
Expand All @@ -37,8 +42,10 @@ export const TxModalDetails: React.FC<TxModalDetailsProps> = ({ gasLimit, childr
>
{children}
</Box>

<GasStation gasLimit={parseUnits(gasLimit || '0', 'wei')} />
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
<GasStation gasLimit={parseUnits(gasLimit || '0', 'wei')} />
{slippageSelector}
</Box>
</Box>
);
};
Expand Down Expand Up @@ -87,6 +94,7 @@ interface DetailsNumberLineWithSubProps {
futureValueUSD: string;
hideSymbolSuffix?: boolean;
color?: string;
tokenIcon?: string;
}

export const DetailsNumberLineWithSub = ({
Expand All @@ -98,6 +106,7 @@ export const DetailsNumberLineWithSub = ({
futureValueUSD,
hideSymbolSuffix,
color,
tokenIcon,
}: DetailsNumberLineWithSubProps) => {
return (
<Row caption={description} captionVariant="description" mb={4} align="flex-start">
Expand All @@ -116,6 +125,7 @@ export const DetailsNumberLineWithSub = ({
</SvgIcon>
</>
)}
{tokenIcon && <TokenIcon symbol={tokenIcon} sx={{ mr: 1, fontSize: '14px' }} />}
<FormattedNumber value={futureValue} variant="secondary14" color={color} />
{!hideSymbolSuffix && (
<Typography ml={1} variant="secondary14">
Expand Down Expand Up @@ -209,15 +219,17 @@ export const DetailsIncentivesLine = ({
if (!incentives || incentives.filter((i) => i.incentiveAPR !== '0').length === 0) return null;
return (
<Row caption={<Trans>Rewards APR</Trans>} captionVariant="description" mb={4} minHeight={24}>
<IncentivesButton incentives={incentives} symbol={symbol} />
{futureSymbol && (
<>
<SvgIcon color="primary" sx={{ fontSize: '14px', mx: 1 }}>
<ArrowNarrowRightIcon />
</SvgIcon>
<IncentivesButton incentives={futureIncentives} symbol={futureSymbol} />
</>
)}
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<IncentivesButton incentives={incentives} symbol={symbol} />
{futureSymbol && (
<>
<SvgIcon color="primary" sx={{ fontSize: '14px', mx: 1 }}>
<ArrowNarrowRightIcon />
</SvgIcon>
<IncentivesButton incentives={futureIncentives} symbol={futureSymbol} />
</>
)}
</Box>
</Row>
);
};
Expand Down
28 changes: 6 additions & 22 deletions src/components/transactions/Repay/CollateralRepayActions.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { InterestRate } from '@aave/contract-helpers';
import { normalize } from '@aave/math-utils';
import { Trans } from '@lingui/macro';
import { BoxProps } from '@mui/material';
import { OptimalRate } from 'paraswap-core';
import { useTransactionHandler } from 'src/helpers/useTransactionHandler';
import { ComputedReserveData } from 'src/hooks/app-data-provider/useAppDataProvider';
import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext';
import { getRepayCallData } from 'src/hooks/useSwap';
import { useTxBuilderContext } from 'src/hooks/useTxBuilder';
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';

Expand All @@ -21,11 +17,11 @@ export interface RepayActionProps extends BoxProps {
isWrongNetwork: boolean;
customGasPrice?: string;
symbol: string;
priceRoute: OptimalRate | null;
repayAllDebt: boolean;
useFlashLoan: boolean;
blocked: boolean;
maxSlippage: number;
swapCallData: string;
augustus: string;
}

export const CollateralRepayActions = ({
Expand All @@ -37,36 +33,25 @@ export const CollateralRepayActions = ({
sx,
symbol,
rateMode,
priceRoute,
repayAllDebt,
useFlashLoan,
blocked,
maxSlippage,
swapCallData,
augustus,
...props
}: RepayActionProps) => {
const { lendingPool } = useTxBuilderContext();
const { currentChainId: chainId, currentNetworkConfig } = useProtocolDataContext();
const { currentAccount } = useWeb3Context();

const { approval, action, requiresApproval, loadingTxns, approvalTxState, mainTxState } =
useTransactionHandler({
handleGetTxns: async () => {
const { swapCallData, augustus, srcAmountWithSlippage } = await getRepayCallData({
srcToken: fromAssetData.underlyingAsset,
srcDecimals: fromAssetData.decimals,
destToken: poolReserve.underlyingAsset,
destDecimals: poolReserve.decimals,
user: currentAccount,
route: priceRoute as OptimalRate,
chainId: currentNetworkConfig.underlyingChainId || chainId,
maxSlippage,
});
return lendingPool.paraswapRepayWithCollateral({
user: currentAccount,
fromAsset: fromAssetData.underlyingAsset,
fromAToken: fromAssetData.aTokenAddress,
assetToRepay: poolReserve.underlyingAsset,
repayWithAmount: normalize(srcAmountWithSlippage, fromAssetData.decimals),
repayWithAmount,
repayAmount,
repayAllDebt,
rateMode,
Expand All @@ -79,7 +64,6 @@ export const CollateralRepayActions = ({
deps: [
repayWithAmount,
repayAmount,
priceRoute,
poolReserve.underlyingAsset,
fromAssetData.underlyingAsset,
repayAllDebt,
Expand All @@ -91,7 +75,7 @@ export const CollateralRepayActions = ({
return (
<TxActionsWrapper
preparingTransactions={loadingTxns}
symbol={poolReserve.symbol}
symbol={fromAssetData.symbol}
mainTxState={mainTxState}
approvalTxState={approvalTxState}
requiresAmount
Expand Down
Loading