Skip to content
Draft
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
d328e69
cleanup: remove apollo caching fallback
sakulstra Jul 18, 2022
971273b
feat: implement demo zustand
sakulstra Jul 19, 2022
8ee2ef4
feat: add store for protocol data
sakulstra Jul 19, 2022
b9db77f
feat: migrate general stake data to zustand
sakulstra Jul 19, 2022
d3a0882
fix: some patches on store
sakulstra Jul 19, 2022
95cb336
feat: replace protocolDataProvider
sakulstra Jul 19, 2022
12b0524
feat: remove walletmodalcontext
sakulstra Jul 19, 2022
f27c88b
fix: fix rename miss
sakulstra Jul 19, 2022
739bc0b
feat: finish stake migration
sakulstra Jul 21, 2022
6809c59
feat: replace walletDataProvider with zustand
sakulstra Jul 21, 2022
9c8406b
feat: migrate pool and incentive data
sakulstra Jul 22, 2022
64fb9a3
feat: start with governance store
sakulstra Jul 22, 2022
4aa2f61
feat: finish governance migration
sakulstra Jul 22, 2022
5988980
fix: remove all graphql
sakulstra Jul 22, 2022
434ae88
fix: remove persist
sakulstra Jul 22, 2022
6bff562
fix: flatten store
sakulstra Jul 22, 2022
761bd91
fix: merge getters
sakulstra Jul 22, 2022
4326bed
fix: restore url parameter behavior
sakulstra Jul 25, 2022
cb5f408
fix: patch stake provider
sakulstra Jul 25, 2022
5074fa9
feat: move staking to zustand
sakulstra Jul 25, 2022
e27f098
fix: add persist
sakulstra Jul 25, 2022
6aae480
cleanup: remove rpc only flag
sakulstra Jul 26, 2022
a1bde72
fix: remove unncessary flag
sakulstra Jul 26, 2022
9fe814e
fix: a batch of fixes
sakulstra Jul 26, 2022
323e458
feat: migrate faucet
sakulstra Jul 26, 2022
550d311
fix: fix type
sakulstra Jul 26, 2022
becdf08
fix: refactor withdraw
sakulstra Jul 27, 2022
3df5f19
Feature immer minimal example with zustand
satanworker Aug 3, 2022
5e5fab4
fix: fix immer usage
sakulstra Aug 15, 2022
0b461c7
Feature remove computed() from poolSlice and walletSlice and introduc…
satanworker Oct 12, 2022
62c1240
Merge branch 'main' into feat/zustand-selectors
satanworker Oct 13, 2022
cca4ac6
Merge pull request #5 from bgd-labs/feat/zustand-selectors
sakulstra Oct 13, 2022
8d4428b
Fix eslint errors and contract-herlpers version bump
satanworker Oct 13, 2022
7350587
fix: fix pacakge.json & lockfile
sakulstra Oct 13, 2022
1da244c
fix: remove explicit deepmerge
sakulstra Oct 13, 2022
d1142fc
feat: lending pool methods migration to zustand pool slice (#7)
satanworker Oct 14, 2022
c664a55
fix: update utilities to version with shaking
sakulstra Oct 14, 2022
b8fba94
fix: simplify deprecated governanceDataProvider
sakulstra Oct 14, 2022
b478c8f
fix: some docs
sakulstra Oct 14, 2022
6a6f11b
fix: update zustand
sakulstra Oct 14, 2022
87bd9d6
fix: move claim rewards to zustand (#8)
satanworker Oct 18, 2022
bacfe4f
Merge branch 'main' into feat/zustand
sakulstra Oct 18, 2022
136084c
fix: resolve merge issues
sakulstra Oct 18, 2022
d446e84
fix: only set valid market
sakulstra Oct 19, 2022
4c8a951
fix: don't break localstorage
sakulstra Oct 19, 2022
632f1b2
fix: commit the actual fix
sakulstra Oct 19, 2022
8ee8374
fix: remove current account from pool actions
satanworker Oct 19, 2022
94cafd2
fix: close wallet modal after wallet connect
satanworker Oct 19, 2022
9a35903
fix: paraswap repay with collateral and swap collateral to use underl…
satanworker Oct 19, 2022
eb51ad3
fix: build error and omit current user from governance methods
satanworker Oct 19, 2022
ea94643
fix: move current account selection to stake slice
satanworker Oct 20, 2022
0e04f5e
fix: build error
satanworker Oct 20, 2022
4eca623
fix: add delay after wallet click in cypress test
satanworker Oct 20, 2022
9551101
fix: merge branch 'main' into feat/zustand
satanworker Oct 25, 2022
733bb29
fix: yarn lock update
satanworker Oct 25, 2022
2e67b4d
fix: eslint import errors
satanworker Oct 26, 2022
c14c6c1
feat: allow multi signature transactions
sakulstra Nov 10, 2022
3bed812
fix: revert change
sakulstra Nov 10, 2022
3a2598f
feat: v3 migration started
satanworker Nov 11, 2022
02c72f8
feat: m:erge branch 'main' into feature/v2-v3-migration
satanworker Nov 11, 2022
7854b91
Merge branch 'feat/allow-multi-signature-txns' into feature/v2-v3-mig…
satanworker Nov 11, 2022
dc9f5b1
feat: migrator approval permit added
satanworker Nov 11, 2022
c335e4f
feat: migration service added
satanworker Nov 25, 2022
061f6d8
feat: testing migration on a fork
satanworker Nov 27, 2022
2407330
feat: v3 migration prototype continue
satanworker Nov 27, 2022
5b3eaff
feat: supply and borrow position splitted approve flow working
satanworker Nov 29, 2022
0697d17
feat: migrate no borrow with permits continue
satanworker Nov 30, 2022
2a14e60
feat: loading for migratin actions added
satanworker Nov 30, 2022
8b803a8
feat: migration components structure
Argeare5 Nov 30, 2022
1641f7d
feat: finished main migration screen
Argeare5 Dec 1, 2022
f19d814
feat: migration modal styles
Argeare5 Dec 1, 2022
8ed87a7
feat: migration with borrow
satanworker Dec 2, 2022
f6e3698
feat: merge branch 'feat/v3-migration-borrow' into feature/v2-v3-migr…
satanworker Dec 2, 2022
4d71cd6
feat: migrate with borrow and permits continue
satanworker Dec 2, 2022
5d314d7
feature: select current market v2 and v3 dynamic selectors added
satanworker Dec 5, 2022
201ef6b
feat: health factor calculations added before and after migration
satanworker Dec 6, 2022
8b38310
feat: migration continue wrong network hook added
satanworker Dec 9, 2022
c08266c
feat: merge branch 'main' into v2-v3-migration
satanworker Dec 9, 2022
7896f15
fix: migrate screen top panel
Argeare5 Dec 9, 2022
92c93b8
fix: migrate navigation
Argeare5 Dec 9, 2022
5bfbdc1
feat: merge branch 'main' into feature/v2-v3-migration
satanworker Dec 9, 2022
dda5648
fix: health factor calculation based on increased amount
satanworker Dec 14, 2022
837c5c1
Merge branch 'main' into feature/v2-v3-migration
defispartan Dec 15, 2022
9b244bd
fix: calculate health factor based on scaled balance
satanworker Dec 15, 2022
cf58cab
Merge branch 'main' into chore/merge-updated-permit-flow
defispartan Dec 16, 2022
4bad33a
fix: clear selected positions on v3 migration page
satanworker Dec 16, 2022
5b965d4
chore: check null conditions in poolSelectors
defispartan Dec 16, 2022
7e188bf
feat: enable permit in MigrateV3Actions
defispartan Dec 16, 2022
2005038
Merge branch 'feature/v2-v3-migration' into chore/merge-updated-permi…
defispartan Dec 16, 2022
f57a343
fix: permit amount convert to wei
satanworker Dec 19, 2022
4e615b9
fix: usage as collateral improvements for migration
satanworker Dec 19, 2022
b8fe477
fix: pass user emode category id for migration formatting summary
satanworker Dec 20, 2022
a457ae3
feat: migratio with isolation mode started
satanworker Dec 22, 2022
3e86a06
fix: change selected assets to arary instead of map
satanworker Dec 22, 2022
86c4233
feat: select definitive supply asset for migration based on v3 balance
satanworker Dec 22, 2022
5357b50
feat: isolated dynamic mode active
satanworker Dec 23, 2022
670374e
fix: permit order and health factor calculation for isolation mode
satanworker Dec 23, 2022
a1a88b4
fix: usage as collateral enabled by user respect v3 positions
satanworker Dec 23, 2022
5629d64
fix: migration screen styles
Argeare5 Dec 23, 2022
34dec07
fix: dynamic isolation mode
satanworker Dec 26, 2022
f6fcf36
Merge pull request #10 from defispartan/chore/merge-updated-permit-flow
satanworker Dec 26, 2022
d0787c7
feat: emode integration for migration page
satanworker Dec 26, 2022
f6e195b
fix: new mobile styles merged
satanworker Dec 26, 2022
5ebf8c6
feat: merge new mobile ui and isolation mode
satanworker Dec 30, 2022
f809aba
fix: rename pool data selectors and make v2 and v3 market data select…
satanworker Jan 2, 2023
28d8a70
fix: eMode fixes and disabling assets for migration with different un…
satanworker Jan 4, 2023
8b81447
fix: disabled for migration updates for emode and isolation mode
satanworker Jan 5, 2023
519d062
fix: merge with latest @aave/main
satanworker Jan 5, 2023
5cbd7d6
feat: stable and variable debt migration added
satanworker Jan 7, 2023
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
2 changes: 2 additions & 0 deletions pages/_app.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CollateralChangeModal } from 'src/components/transactions/CollateralCha
import { EmodeModal } from 'src/components/transactions/Emode/EmodeModal';
import { FaucetModal } from 'src/components/transactions/Faucet/FaucetModal';
import { GasStationProvider } from 'src/components/transactions/GasStation/GasStationProvider';
import { MigrateV3Modal } from 'src/components/transactions/MigrateV3/MigrateV3Modal';
import { RateSwitchModal } from 'src/components/transactions/RateSwitch/RateSwitchModal';
import { RepayModal } from 'src/components/transactions/Repay/RepayModal';
import { SupplyModal } from 'src/components/transactions/Supply/SupplyModal';
Expand Down Expand Up @@ -85,6 +86,7 @@ export default function MyApp(props: MyAppProps) {
<EmodeModal />
<SwapModal />
<FaucetModal />
<MigrateV3Modal />
</GasStationProvider>
</AppDataProvider>
</BackgroundDataProvider>
Expand Down
151 changes: 151 additions & 0 deletions pages/v3-migration.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import { Trans } from '@lingui/macro';
import { Box, Divider } from '@mui/material';
import { useEffect } from 'react';
import { ConnectWalletPaper } from 'src/components/ConnectWalletPaper';
import { ContentContainer } from 'src/components/ContentContainer';
import { MigrateV3Modal } from 'src/components/transactions/MigrateV3/MigrateV3Modal';
import { useAppDataContext } from 'src/hooks/app-data-provider/useAppDataProvider';
import { usePermissions } from 'src/hooks/usePermissions';
import { useUserReserves } from 'src/hooks/useUserReserves';
import { MainLayout } from 'src/layouts/MainLayout';
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
import { DashboardContentNoData } from 'src/modules/dashboard/DashboardContentNoData';
import { MigrationBottomPanel } from 'src/modules/migration/MigrationBottomPanel';
import { MigrationListItem } from 'src/modules/migration/MigrationListItem';
import { MigrationListItemLoader } from 'src/modules/migration/MigrationListItemLoader';
import { MigrationLists } from 'src/modules/migration/MigrationLists';
import { MigrationTopPanel } from 'src/modules/migration/MigrationTopPanel';
import { usePoolDataV3Subscription, useRootStore } from 'src/store/root';

export default function V3Migration() {
const { loading } = useAppDataContext();
const { currentAccount, loading: web3Loading } = useWeb3Context();
const { isPermissionsLoading } = usePermissions();
const setCurrentMarketForMigration = useRootStore((state) => state.setCurrentMarketForMigration);

const { user, borrowPositions } = useUserReserves();

const {
toggleMigrationSelectedSupplyAsset: toggleSelectedSupplyPosition,
selectedMigrationSupplyAssets: selectedSupplyAssets,
toggleMigrationSelectedBorrowAsset: toggleSelectedBorrowPosition,
selectedMigrationBorrowAssets: selectedBorrowAssets,
} = useRootStore();

useEffect(() => {
if (setCurrentMarketForMigration) {
setCurrentMarketForMigration();
}
}, [setCurrentMarketForMigration]);

usePoolDataV3Subscription();

return (
<>
<MigrationTopPanel />

{currentAccount && !isPermissionsLoading ? (
<ContentContainer>
<MigrationLists
loading={loading}
totalSuppliesUSD={user.totalCollateralUSD}
totalBorrowsUSD={user.totalBorrowsUSD}
isSupplyPositionsAvailable={!!user.userReservesData.length}
isBorrowPositionsAvailable={!!borrowPositions.length}
onSelectAllSupplies={() =>
user.userReservesData.map((reserve) =>
toggleSelectedSupplyPosition(reserve.underlyingAsset)
)
}
onSelectAllBorrows={() =>
borrowPositions.map((reserve) =>
toggleSelectedBorrowPosition(reserve.underlyingAsset)
)
}
suppliesPositions={
<>
{loading ? (
<>
<MigrationListItemLoader />
<MigrationListItemLoader />
</>
) : !!user.userReservesData.length ? (
user.userReservesData.map((reserve) => (
<MigrationListItem
key={reserve.underlyingAsset}
checked={selectedSupplyAssets[reserve.underlyingAsset]}
reserveIconSymbol={reserve.reserve.iconSymbol}
reserveName={reserve.reserve.name}
reserveSymbol={reserve.reserve.symbol}
amount={reserve.underlyingBalance}
amountInUSD={reserve.underlyingBalanceUSD}
onCheckboxClick={() => toggleSelectedSupplyPosition(reserve.underlyingAsset)}
/>
))
) : (
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<DashboardContentNoData text={<Trans>Nothing supplied yet</Trans>} />
</Box>
)}
</>
}
borrowsPositions={
<>
{loading ? (
<>
<MigrationListItemLoader />
<MigrationListItemLoader />
</>
) : !!borrowPositions.length ? (
borrowPositions.map((reserve) => (
<MigrationListItem
key={reserve.underlyingAsset}
checked={selectedBorrowAssets[reserve.underlyingAsset]}
reserveIconSymbol={reserve.reserve.iconSymbol}
reserveName={reserve.reserve.name}
reserveSymbol={reserve.reserve.symbol}
amount={reserve.totalBorrows}
amountInUSD={reserve.totalBorrowsUSD}
onCheckboxClick={() => toggleSelectedBorrowPosition(reserve.underlyingAsset)}
/>
))
) : (
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<DashboardContentNoData text={<Trans>Nothing borrowed yet</Trans>} />
</Box>
)}
</>
}
/>

<Divider sx={{ my: 10 }} />

<MigrationBottomPanel
hfV2Current={'1.2'} // TODO: need value
hfV2AfterChange={'2'} // TODO: need value
hfV3Current={'1.2'} // TODO: need value
hfV3AfterChange={'2'} // TODO: need value
disableButton={
!Object.keys(selectedSupplyAssets).length && !Object.keys(selectedBorrowAssets).length
}
loading={loading}
/>
</ContentContainer>
) : (
<ConnectWalletPaper
loading={web3Loading}
description={<Trans> Please connect your wallet to see migration tool.</Trans>}
/>
)}
</>
);
}

V3Migration.getLayout = function getLayout(page: React.ReactElement) {
return (
<MainLayout>
{page}
<MigrateV3Modal />
</MainLayout>
);
};
6 changes: 4 additions & 2 deletions src/components/lists/ListHeaderTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface ListHeaderTitleProps {
sortKey?: string;
setSortName?: (value: string) => void;
setSortDesc?: (value: boolean) => void;
onClick?: () => void;
children: ReactNode;
}

Expand All @@ -16,6 +17,7 @@ export const ListHeaderTitle = ({
sortKey,
setSortName,
setSortDesc,
onClick,
children,
}: ListHeaderTitleProps) => {
const handleSorting = (name: string) => {
Expand All @@ -32,9 +34,9 @@ export const ListHeaderTitle = ({
variant="subheader2"
color="text.secondary"
noWrap
onClick={() => !!sortKey && handleSorting(sortKey)}
onClick={() => (!!onClick ? onClick() : !!sortKey && handleSorting(sortKey))}
sx={{
cursor: !!sortKey ? 'pointer' : 'default',
cursor: !!onClick || !!sortKey ? 'pointer' : 'default',
display: 'inline-flex',
alignItems: 'center',
}}
Expand Down
1 change: 1 addition & 0 deletions src/components/primitives/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const ROUTES = {
staking: '/staking',
governance: '/governance',
faucet: '/faucet',
migrationTool: '/v3-migration',
prerenderedProposal: (proposalId: number) => `/governance/proposal/${proposalId}`,
dynamicRenderedProposal: (proposalId: number) => `/governance/proposal?proposalId=${proposalId}`,
reserveOverview: (underlyingAsset: string, marketName: CustomMarket) =>
Expand Down
2 changes: 1 addition & 1 deletion src/components/primitives/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode } from 'react';

interface RowProps extends BoxProps {
caption?: ReactNode;
captionVariant?: 'secondary16' | 'description' | 'subheader1' | 'caption';
captionVariant?: 'secondary16' | 'description' | 'subheader1' | 'caption' | 'h3';
captionColor?: string;
align?: 'center' | 'flex-start';
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/transactions/Borrow/BorrowActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const BorrowActions = ({
handleAction={action}
actionText={<Trans>Borrow {symbol}</Trans>}
actionInProgressText={<Trans>Borrowing {symbol}</Trans>}
handleApproval={() => approval(amountToBorrow, poolAddress)}
handleApproval={() => approval([{ amount: amountToBorrow, underlyingAsset: poolAddress }])}
requiresApproval={requiresApproval}
preparingTransactions={loadingTxns}
sx={sx}
Expand Down
44 changes: 44 additions & 0 deletions src/components/transactions/MigrateV3/MigrateV3Actions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Trans } from '@lingui/macro';
import { useTransactionHandler } from 'src/helpers/useTransactionHandler';
import { useRootStore } from 'src/store/root';

import { TxActionsWrapper } from '../TxActionsWrapper';

export type MigrateV3ActionsProps = {
isWrongNetwork: boolean;
blocked: boolean;
};

export const MigrateV3Actions = ({ isWrongNetwork, blocked }: MigrateV3ActionsProps) => {
const migrateWithPermits = useRootStore((store) => store.migrateWithPermits);
const migrateWithoutPermits = useRootStore((store) => store.migrateWithoutPermits);
const getApprovePermitsForSelectedAssets = useRootStore(
(store) => store.getApprovePermitsForSelectedAssets
);
const { approval, action, loadingTxns, requiresApproval, mainTxState, approvalTxState } =
useTransactionHandler({
handleGetTxns: async () => migrateWithoutPermits(),
handleGetPermitTxns: async (signatures, deadline) => migrateWithPermits(signatures, deadline),
tryPermit: true,
});

const handleApproval = async () => {
const approvePermitsForSelectedAssets = await getApprovePermitsForSelectedAssets();
approval(approvePermitsForSelectedAssets);
};

return (
<TxActionsWrapper
requiresApproval={requiresApproval}
preparingTransactions={loadingTxns}
mainTxState={mainTxState}
approvalTxState={approvalTxState}
isWrongNetwork={isWrongNetwork}
handleAction={action}
handleApproval={handleApproval}
blocked={blocked}
actionText={<Trans>Migrate</Trans>}
actionInProgressText={<Trans>Migrating</Trans>}
/>
);
};
15 changes: 15 additions & 0 deletions src/components/transactions/MigrateV3/MigrateV3Modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { BasicModal } from 'src/components/primitives/BasicModal';
import { ModalType, useModalContext } from 'src/hooks/useModal';

import { MigrateV3ModalContent } from './MigrateV3ModalContent';

export const MigrateV3Modal = () => {
const { type, close } = useModalContext();

return (
<BasicModal open={type === ModalType.V3Migration} setOpen={close}>
<MigrateV3ModalContent />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using a different approach here? Checkout other modals - usually they do sth like:

<BasicModal open={type === ModalType.Swap} setOpen={close}>
      <ModalWrapper title={<Trans>Swap</Trans>} underlyingAsset={args.underlyingAsset}>
        {(params) => <SwapModalContent {...params} />}
      </ModalWrapper>
    </BasicModal>

Which will take care of layout & properly handle networkState

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I didn't understanad that part properly, will check

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I think I do understand, but it's again the same issue, why do we have wrong network state coupled with underlying asset and what is underlying asset in that case? If I'm reading correctly I need to adapt underlyingAsset to have an array instead of a single one, while it would be way simplier and usefull to expose switching network globally. Switching network and fetching balances are not exactly part of the same logic at least for migration.
Thiking how to adapty it

</BasicModal>
);
};
61 changes: 61 additions & 0 deletions src/components/transactions/MigrateV3/MigrateV3ModalAssetsList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Box, Typography } from '@mui/material';
import { ReactNode } from 'react';
import { FormattedNumber } from 'src/components/primitives/FormattedNumber';
import { Row } from 'src/components/primitives/Row';
import { TokenIcon } from 'src/components/primitives/TokenIcon';

export type Asset = {
underlyingAsset: string;
iconSymbol: string;
symbol: string;
amount: string;
amountInUSD: string;
};

interface MigrateV3ModalAssetsListProps {
caption: ReactNode;
assets: (Asset | undefined)[];
}

export const MigrateV3ModalAssetsList = ({ caption, assets }: MigrateV3ModalAssetsListProps) => {
return (
<Row
caption={caption}
captionVariant="description"
align="flex-start"
sx={{ mb: 6, '&:last-of-type': { mb: 0 } }}
>
{!!assets.length ? (
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-end' }}>
{assets.map((asset) =>
asset ? (
<Box
key={asset.underlyingAsset}
sx={{ mb: 2, display: 'flex', alignItems: 'flex-end', flexDirection: 'column' }}
>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<TokenIcon symbol={asset.symbol} sx={{ mr: 1, fontSize: '16px' }} />
<FormattedNumber value={asset.amount} variant="secondary14" compact />
<Typography ml={1} variant="secondary14">
{asset.symbol}
</Typography>
</Box>
<FormattedNumber
value={asset.amountInUSD}
variant="helperText"
compact
symbol="USD"
color="text.secondary"
/>
</Box>
) : (
<></>
)
)}
</Box>
) : (
<Typography>—</Typography>
)}
</Row>
);
};
Loading