Skip to content

Commit

Permalink
Fix position listing in Portfolio page (#3958)
Browse files Browse the repository at this point in the history
* Fixed New swapped position is not listed in Portfolio page

* fixed type
  • Loading branch information
piotrwitek committed Jun 19, 2024
1 parent 6e89cba commit 4a41b1a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 6 additions & 3 deletions handlers/portfolio/positions/handlers/aave-like/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { isAaveLikeLendingProtocol, LendingProtocol } from 'lendingProtocols'
import { getAaveWstEthYield } from 'lendingProtocols/aave-v3/calculations/wstEthYield'

import { getRawPositionDetails } from './getRawPositionDetails'
import { mapDpmProtocolNameToUIName } from './mapDpmProtocolNameToUIName'

const getAaveLikeBorrowPosition: GetAaveLikePositionHandlerType = async ({
dpm,
Expand Down Expand Up @@ -421,9 +422,11 @@ export const aaveLikePositionsHandler: PortfolioPositionsHandler = async ({
positionsCount,
debug,
}) => {
const aaveLikeDpmList = dpmList.filter(({ protocol }) =>
[aaveLikeProtocolNames.aavev3, aaveLikeProtocolNames.sparkv3].includes(protocol),
)
const aaveLikeDpmList = dpmList
.map(mapDpmProtocolNameToUIName)
.filter(({ protocol }) =>
[aaveLikeProtocolNames.aavev3, aaveLikeProtocolNames.sparkv3].includes(protocol),
)
if (positionsCount) {
return {
positions: aaveLikeDpmList.map(({ vaultId }) => ({ positionId: vaultId })),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ProtocolName } from '@summer_fi/summerfi-sdk-common'
import { aaveLikeProtocolNames } from 'handlers/portfolio/positions/handlers/aave-like/helpers'
import type { DpmSubgraphData } from 'handlers/portfolio/positions/helpers/getAllDpmsForWallet'

// map SDK protocol name to the one hardcoded in the UI
export const mapDpmProtocolNameToUIName = (dpm: DpmSubgraphData): DpmSubgraphData => {
if (dpm.protocol === ProtocolName.AaveV3) {
return {
...dpm,
protocol: aaveLikeProtocolNames.aavev3,
}
}
return dpm
}

0 comments on commit 4a41b1a

Please sign in to comment.