forked from aave/interface
-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/v2-v3-migration #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
satanworker
wants to merge
109
commits into
main
Choose a base branch
from
feature/v2-v3-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 106 commits
Commits
Show all changes
109 commits
Select commit
Hold shift + click to select a range
d328e69
cleanup: remove apollo caching fallback
sakulstra 971273b
feat: implement demo zustand
sakulstra 8ee2ef4
feat: add store for protocol data
sakulstra b9db77f
feat: migrate general stake data to zustand
sakulstra d3a0882
fix: some patches on store
sakulstra 95cb336
feat: replace protocolDataProvider
sakulstra 12b0524
feat: remove walletmodalcontext
sakulstra f27c88b
fix: fix rename miss
sakulstra 739bc0b
feat: finish stake migration
sakulstra 6809c59
feat: replace walletDataProvider with zustand
sakulstra 9c8406b
feat: migrate pool and incentive data
sakulstra 64fb9a3
feat: start with governance store
sakulstra 4aa2f61
feat: finish governance migration
sakulstra 5988980
fix: remove all graphql
sakulstra 434ae88
fix: remove persist
sakulstra 6bff562
fix: flatten store
sakulstra 761bd91
fix: merge getters
sakulstra 4326bed
fix: restore url parameter behavior
sakulstra cb5f408
fix: patch stake provider
sakulstra 5074fa9
feat: move staking to zustand
sakulstra e27f098
fix: add persist
sakulstra 6aae480
cleanup: remove rpc only flag
sakulstra a1bde72
fix: remove unncessary flag
sakulstra 9fe814e
fix: a batch of fixes
sakulstra 323e458
feat: migrate faucet
sakulstra 550d311
fix: fix type
sakulstra becdf08
fix: refactor withdraw
sakulstra 3df5f19
Feature immer minimal example with zustand
satanworker 5e5fab4
fix: fix immer usage
sakulstra 0b461c7
Feature remove computed() from poolSlice and walletSlice and introduc…
satanworker 62c1240
Merge branch 'main' into feat/zustand-selectors
satanworker cca4ac6
Merge pull request #5 from bgd-labs/feat/zustand-selectors
sakulstra 8d4428b
Fix eslint errors and contract-herlpers version bump
satanworker 7350587
fix: fix pacakge.json & lockfile
sakulstra 1da244c
fix: remove explicit deepmerge
sakulstra d1142fc
feat: lending pool methods migration to zustand pool slice (#7)
satanworker c664a55
fix: update utilities to version with shaking
sakulstra b8fba94
fix: simplify deprecated governanceDataProvider
sakulstra b478c8f
fix: some docs
sakulstra 6a6f11b
fix: update zustand
sakulstra 87bd9d6
fix: move claim rewards to zustand (#8)
satanworker bacfe4f
Merge branch 'main' into feat/zustand
sakulstra 136084c
fix: resolve merge issues
sakulstra d446e84
fix: only set valid market
sakulstra 4c8a951
fix: don't break localstorage
sakulstra 632f1b2
fix: commit the actual fix
sakulstra 8ee8374
fix: remove current account from pool actions
satanworker 94cafd2
fix: close wallet modal after wallet connect
satanworker 9a35903
fix: paraswap repay with collateral and swap collateral to use underl…
satanworker eb51ad3
fix: build error and omit current user from governance methods
satanworker ea94643
fix: move current account selection to stake slice
satanworker 0e04f5e
fix: build error
satanworker 4eca623
fix: add delay after wallet click in cypress test
satanworker 9551101
fix: merge branch 'main' into feat/zustand
satanworker 733bb29
fix: yarn lock update
satanworker 2e67b4d
fix: eslint import errors
satanworker c14c6c1
feat: allow multi signature transactions
sakulstra 3bed812
fix: revert change
sakulstra 3a2598f
feat: v3 migration started
satanworker 02c72f8
feat: m:erge branch 'main' into feature/v2-v3-migration
satanworker 7854b91
Merge branch 'feat/allow-multi-signature-txns' into feature/v2-v3-mig…
satanworker dc9f5b1
feat: migrator approval permit added
satanworker c335e4f
feat: migration service added
satanworker 061f6d8
feat: testing migration on a fork
satanworker 2407330
feat: v3 migration prototype continue
satanworker 5b3eaff
feat: supply and borrow position splitted approve flow working
satanworker 0697d17
feat: migrate no borrow with permits continue
satanworker 2a14e60
feat: loading for migratin actions added
satanworker 8b803a8
feat: migration components structure
Argeare5 1641f7d
feat: finished main migration screen
Argeare5 f19d814
feat: migration modal styles
Argeare5 8ed87a7
feat: migration with borrow
satanworker f6e3698
feat: merge branch 'feat/v3-migration-borrow' into feature/v2-v3-migr…
satanworker 4d71cd6
feat: migrate with borrow and permits continue
satanworker 5d314d7
feature: select current market v2 and v3 dynamic selectors added
satanworker 201ef6b
feat: health factor calculations added before and after migration
satanworker 8b38310
feat: migration continue wrong network hook added
satanworker c08266c
feat: merge branch 'main' into v2-v3-migration
satanworker 7896f15
fix: migrate screen top panel
Argeare5 92c93b8
fix: migrate navigation
Argeare5 5bfbdc1
feat: merge branch 'main' into feature/v2-v3-migration
satanworker dda5648
fix: health factor calculation based on increased amount
satanworker 837c5c1
Merge branch 'main' into feature/v2-v3-migration
defispartan 9b244bd
fix: calculate health factor based on scaled balance
satanworker cf58cab
Merge branch 'main' into chore/merge-updated-permit-flow
defispartan 4bad33a
fix: clear selected positions on v3 migration page
satanworker 5b965d4
chore: check null conditions in poolSelectors
defispartan 7e188bf
feat: enable permit in MigrateV3Actions
defispartan 2005038
Merge branch 'feature/v2-v3-migration' into chore/merge-updated-permi…
defispartan f57a343
fix: permit amount convert to wei
satanworker 4e615b9
fix: usage as collateral improvements for migration
satanworker b8fe477
fix: pass user emode category id for migration formatting summary
satanworker a457ae3
feat: migratio with isolation mode started
satanworker 3e86a06
fix: change selected assets to arary instead of map
satanworker 86c4233
feat: select definitive supply asset for migration based on v3 balance
satanworker 5357b50
feat: isolated dynamic mode active
satanworker 670374e
fix: permit order and health factor calculation for isolation mode
satanworker a1a88b4
fix: usage as collateral enabled by user respect v3 positions
satanworker 5629d64
fix: migration screen styles
Argeare5 34dec07
fix: dynamic isolation mode
satanworker f6fcf36
Merge pull request #10 from defispartan/chore/merge-updated-permit-flow
satanworker d0787c7
feat: emode integration for migration page
satanworker f6e195b
fix: new mobile styles merged
satanworker 5ebf8c6
feat: merge new mobile ui and isolation mode
satanworker f809aba
fix: rename pool data selectors and make v2 and v3 market data select…
satanworker 28d8a70
fix: eMode fixes and disabling assets for migration with different un…
satanworker 8b81447
fix: disabled for migration updates for emode and isolation mode
satanworker 519d062
fix: merge with latest @aave/main
satanworker 5cbd7d6
feat: stable and variable debt migration added
satanworker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,221 @@ | ||
| import { Trans } from '@lingui/macro'; | ||
| import { Box, Divider, useMediaQuery, useTheme } from '@mui/material'; | ||
| import { useCallback, 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 { useCurrentTimestamp } from 'src/hooks/useCurrentTimestamp'; | ||
| import { usePermissions } from 'src/hooks/usePermissions'; | ||
| 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 { selectCurrentChainIdV3PoolReserve } from 'src/store/poolSelectors'; | ||
| import { usePoolDataV3Subscription, useRootStore } from 'src/store/root'; | ||
| import { | ||
| selectUserReservesForMigration, | ||
| selectV2UserSummaryAfterMigration, | ||
| selectV3UserSummary, | ||
| selectV3UserSummaryAfterMigration, | ||
| } from 'src/store/v3MigrationSelectors'; | ||
|
|
||
| export default function V3Migration() { | ||
| const { loading } = useAppDataContext(); | ||
| const { currentAccount, loading: web3Loading } = useWeb3Context(); | ||
| const { isPermissionsLoading } = usePermissions(); | ||
| const theme = useTheme(); | ||
| const downToSM = useMediaQuery(theme.breakpoints.down('sm')); | ||
|
|
||
| const currentTimeStamp = useCurrentTimestamp(10); | ||
|
|
||
| const { | ||
| totalCollateralUSD, | ||
| totalBorrowsUSD, | ||
| supplyReserves, | ||
| borrowReserves, | ||
| healthFactor: v2HealthFactorBeforeMigration, | ||
| } = useRootStore( | ||
| useCallback( | ||
| (state) => selectUserReservesForMigration(state, currentTimeStamp), | ||
| [currentTimeStamp] | ||
| ) | ||
| ); | ||
|
|
||
| // health factor calculation | ||
| const { v3UserSummaryBeforeMigration, v2UserSummaryAfterMigration, poolReserveV3 } = useRootStore( | ||
| (state) => ({ | ||
| v2UserSummaryAfterMigration: selectV2UserSummaryAfterMigration(state, currentTimeStamp), | ||
| v3UserSummaryBeforeMigration: selectV3UserSummary(state, currentTimeStamp), | ||
| poolReserveV3: selectCurrentChainIdV3PoolReserve(state), | ||
| }) | ||
| ); | ||
|
|
||
| const v3UserSummaryAfterMigration = useRootStore( | ||
| useCallback( | ||
| (state) => selectV3UserSummaryAfterMigration(state, currentTimeStamp), | ||
| [currentTimeStamp] | ||
| ) | ||
| ); | ||
|
|
||
| // actions | ||
| const { | ||
| selectAllSupply, | ||
| selectAllBorrow, | ||
| toggleMigrationSelectedSupplyAsset: toggleSelectedSupplyPosition, | ||
| selectedMigrationSupplyAssets: selectedSupplyAssets, | ||
| toggleMigrationSelectedBorrowAsset: toggleSelectedBorrowPosition, | ||
| selectedMigrationBorrowAssets: selectedBorrowAssets, | ||
| resetMigrationSelectedAssets, | ||
| enforceAsCollateral, | ||
| } = useRootStore(); | ||
|
|
||
| useEffect(() => { | ||
| if (resetMigrationSelectedAssets) { | ||
| resetMigrationSelectedAssets(); | ||
| } | ||
| }, [resetMigrationSelectedAssets]); | ||
|
|
||
| usePoolDataV3Subscription(); | ||
|
|
||
| const enabledAsCollateral = (canBeEnforced: boolean, underlyingAsset: string) => { | ||
| if (canBeEnforced) { | ||
| enforceAsCollateral(underlyingAsset); | ||
| } | ||
| }; | ||
|
|
||
| const handleToggleAllSupply = () => { | ||
| selectAllSupply(currentTimeStamp); | ||
| }; | ||
|
|
||
| const handleToggleAllBorrow = () => { | ||
| selectAllBorrow(currentTimeStamp); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <MigrationTopPanel /> | ||
| {currentAccount && !isPermissionsLoading ? ( | ||
| <ContentContainer> | ||
| <MigrationLists | ||
| loading={loading} | ||
| totalSuppliesUSD={totalCollateralUSD} | ||
| totalBorrowsUSD={totalBorrowsUSD} | ||
| isSupplyPositionsAvailable={supplyReserves.length > 0} | ||
| isBorrowPositionsAvailable={borrowReserves.length > 0} | ||
| onSelectAllSupplies={handleToggleAllSupply} | ||
| onSelectAllBorrows={handleToggleAllBorrow} | ||
| emodeCategoryId={poolReserveV3?.userEmodeCategoryId} | ||
| suppliesPositions={ | ||
| <> | ||
| {loading ? ( | ||
| <> | ||
| <MigrationListItemLoader /> | ||
| <MigrationListItemLoader /> | ||
| </> | ||
| ) : supplyReserves.length > 0 ? ( | ||
| supplyReserves.map((reserve) => ( | ||
| <MigrationListItem | ||
| key={reserve.underlyingAsset} | ||
| checked={ | ||
| selectedSupplyAssets.findIndex( | ||
| (selectedAsset) => | ||
| selectedAsset.underlyingAsset == reserve.underlyingAsset | ||
| ) >= 0 | ||
| } | ||
| enableAsCollateral={() => | ||
| enabledAsCollateral(reserve.canBeEnforced, reserve.underlyingAsset) | ||
| } | ||
| canBeEnforced={ | ||
| v3UserSummaryBeforeMigration.totalCollateralMarketReferenceCurrency == | ||
| '0' && reserve.canBeEnforced | ||
| } | ||
| reserveIconSymbol={reserve.reserve.iconSymbol} | ||
| reserveName={reserve.reserve.name} | ||
| reserveSymbol={reserve.reserve.symbol} | ||
| amount={reserve.underlyingBalance} | ||
| amountInUSD={reserve.underlyingBalanceUSD} | ||
| onCheckboxClick={() => toggleSelectedSupplyPosition(reserve.underlyingAsset)} | ||
| enabledAsCollateral={reserve.usageAsCollateralEnabledOnUser} | ||
| isIsolated={reserve.isolatedOnV3} | ||
| /> | ||
| )) | ||
| ) : ( | ||
| <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}> | ||
| <DashboardContentNoData text={<Trans>Nothing supplied yet</Trans>} /> | ||
| </Box> | ||
| )} | ||
| </> | ||
| } | ||
| borrowsPositions={ | ||
| <> | ||
| {loading ? ( | ||
| <> | ||
| <MigrationListItemLoader /> | ||
| <MigrationListItemLoader /> | ||
| </> | ||
| ) : borrowReserves.length > 0 ? ( | ||
| borrowReserves.map((reserve) => ( | ||
| <MigrationListItem | ||
| key={reserve.underlyingAsset} | ||
| checked={ | ||
| !reserve.disabledForMigration && | ||
| selectedBorrowAssets.findIndex( | ||
| (selectedAsset) => | ||
| selectedAsset.underlyingAsset == reserve.underlyingAsset | ||
| ) >= 0 | ||
| } | ||
| reserveIconSymbol={reserve.reserve.iconSymbol} | ||
| reserveName={reserve.reserve.name} | ||
| reserveSymbol={reserve.reserve.symbol} | ||
| amount={reserve.totalBorrows} | ||
| amountInUSD={reserve.totalBorrowsUSD} | ||
| onCheckboxClick={() => toggleSelectedBorrowPosition(reserve.underlyingAsset)} | ||
| disabled={reserve.disabledForMigration} | ||
| enabledAsCollateral={reserve.usageAsCollateralEnabledOnUser} | ||
| /> | ||
| )) | ||
| ) : ( | ||
| <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}> | ||
| <DashboardContentNoData text={<Trans>Nothing borrowed yet</Trans>} /> | ||
| </Box> | ||
| )} | ||
| </> | ||
| } | ||
| /> | ||
|
|
||
| {!downToSM && <Divider sx={{ my: 10 }} />} | ||
|
|
||
| <MigrationBottomPanel | ||
| hfV2Current={v2HealthFactorBeforeMigration} | ||
| hfV2AfterChange={v2UserSummaryAfterMigration.healthFactor} | ||
| hfV3Current={v3UserSummaryBeforeMigration.healthFactor} | ||
| hfV3AfterChange={v3UserSummaryAfterMigration.healthFactor} | ||
| 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> | ||
| ); | ||
| }; | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.