forked from DistributedCollective/sovryn-dapp
-
Notifications
You must be signed in to change notification settings - Fork 0
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
SAF-49 setup bob #29
Merged
Merged
SAF-49 setup bob #29
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
fae4355
cleanup
matzapata bc5e452
fixes
matzapata 0dc9628
fixes. Connect provider. Fix repay adding proper allowance. Fix switc…
matzapata f5de266
refetch user data based on blocknumber
matzapata 2a5aa31
fix modal closing on lending positions change plus style adjustments
matzapata 10993b7
fix withdraw modals
matzapata 63e6578
modal fixes
matzapata 4695ef1
fix calculation
matzapata 86e0b08
use memo items
matzapata b1561cf
fix dependencies
matzapata 3912232
data normalizers
matzapata a352bbb
Apply suggestions from code review
matzapata 42411cb
Update apps/frontend/src/app/5_pages/AavePage/components/LendAssetsLi…
matzapata cf37c05
Update apps/frontend/src/app/5_pages/AavePage/components/LendPosition…
matzapata e47f96e
wip refactor done. Missing hooks merge
matzapata 0db4ace
implementations and cleanup
matzapata e14f7b0
cleanup
matzapata 1fe9d8c
cleanup
matzapata a37eb53
math safety
matzapata 400af73
more math safety
matzapata d5318da
cleanup
matzapata 2a0c7b9
clenaup
matzapata 4c716a8
Merge branch 'develop' into SAF-49_SetupBob
matzapata 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 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 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 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,83 @@ | ||
import { Decimal } from '@sovryn/utils'; | ||
|
||
import { ReserveData } from '../../../hooks/aave/useAaveReservesData'; | ||
import { BorrowRateMode } from '../../../types/aave'; | ||
import { AaveUserReservesSummary } from '../../../utils/aave/AaveUserReservesSummary'; | ||
import { BorrowPosition } from './components/BorrowPositionsList/BorrowPositionsList.types'; | ||
import { LendPosition } from './components/LendPositionsList/LendPositionsList.types'; | ||
|
||
export function normalizeLendPositions( | ||
userReservesSummary: AaveUserReservesSummary, | ||
): LendPosition[] { | ||
return userReservesSummary.reserves | ||
.filter(r => r.supplied.gt(0)) | ||
.map(s => ({ | ||
asset: s.reserve.symbol, | ||
apy: Decimal.from(s.reserve.variableBorrowAPY), | ||
supplied: s.supplied, | ||
suppliedUSD: s.suppliedUSD, | ||
collateral: s.collateral, | ||
})); | ||
} | ||
|
||
export function normalizeBorrowPositions( | ||
userReservesSummary: AaveUserReservesSummary, | ||
): BorrowPosition[] { | ||
return userReservesSummary.reserves | ||
.filter(r => r.borrowed.gt(0)) | ||
.map(r => ({ | ||
asset: r.reserve.symbol, | ||
apy: Decimal.from( | ||
r.borrowRateMode === BorrowRateMode.STABLE | ||
? Decimal.from(r.reserve.stableBorrowAPY).mul(100) | ||
: Decimal.from(r.reserve.variableBorrowAPY).mul(100), | ||
), | ||
borrowed: r.borrowed, | ||
borrowedUSD: r.borrowedUSD, | ||
type: r.borrowRateMode, | ||
})); | ||
} | ||
|
||
export function normalizeBorrowPoolDetails( | ||
reserves: ReserveData, | ||
userReservesSummary: AaveUserReservesSummary, | ||
) { | ||
if (userReservesSummary.reserves.length === 0) { | ||
return reserves | ||
.filter(r => r.borrowingEnabled) | ||
.map(r => ({ | ||
asset: r.symbol, | ||
apy: Decimal.from(r.variableBorrowAPY).mul(100), | ||
})); | ||
} else { | ||
return reserves | ||
.filter(r => r.borrowingEnabled) | ||
.map(r => ({ | ||
asset: r.symbol, | ||
apy: Decimal.from(r.variableBorrowAPY).mul(100), | ||
available: userReservesSummary.borrowPower.div(r.priceInUSD), | ||
availableUSD: userReservesSummary.borrowPower, | ||
})); | ||
} | ||
} | ||
|
||
export function normalizeLendPoolDetails( | ||
reserves: ReserveData, | ||
userReservesSummary: AaveUserReservesSummary, | ||
) { | ||
if (userReservesSummary.reserves.length === 0) { | ||
return reserves.map(r => ({ | ||
asset: r.symbol, | ||
apy: Decimal.from(r.supplyAPY).mul(100), | ||
canBeCollateral: r.usageAsCollateralEnabled, | ||
walletBalance: Decimal.from(0), | ||
})); | ||
} else { | ||
return userReservesSummary.reserves.map(r => ({ | ||
asset: r.reserve.symbol, | ||
apy: Decimal.from(r.reserve.supplyAPY).mul(100), | ||
canBeCollateral: r.reserve.usageAsCollateralEnabled, | ||
walletBalance: r.walletBalance, | ||
})); | ||
} | ||
} |
This file contains 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onBorrowClick useCallback is useless because a new function is created on every render here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change prototype of
BorrowAssetDetails
to receive (asset) => void but it would be moving this elsewhere. Idk, any ideas? the whole useCallback for a one liner seems a bit too much for me hahaThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the type of the prop (mobileRender) but I think it is a function component instead of a useCallback.