Skip to content
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

Fix omni kit DPM filtering + add aave/spark omni support for the link in modal #3749

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 15 additions & 1 deletion features/omni-kit/helpers/getOmniPositionUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { getOmniProtocolUrlMap } from 'features/omni-kit/helpers'
import { erc4626VaultsByName } from 'features/omni-kit/protocols/erc-4626/settings'
import { Erc4626PseudoProtocol } from 'features/omni-kit/protocols/morpho-blue/constants'
import type { OmniProductType } from 'features/omni-kit/types'
import type { LendingProtocol } from 'lendingProtocols'
import { getLocalAppConfig } from 'helpers/config'
import { LendingProtocol } from 'lendingProtocols'

interface GetOmniPositionUrlParams {
collateralAddress?: string
Expand Down Expand Up @@ -32,8 +33,21 @@ export function getOmniPositionUrl({
quoteAddress,
quoteToken,
}: GetOmniPositionUrlParams) {
const featureToggles = getLocalAppConfig('features')
const resolvedPositionId = positionId ? `/${positionId}` : ''

if (
featureToggles.UseOmniKitLinks &&
[LendingProtocol.AaveV3, LendingProtocol.SparkV3].includes(protocol)
) {
return `/${networkName}/omni/${
{
[LendingProtocol.AaveV3]: 'aave/v3',
[LendingProtocol.SparkV3]: 'spark',
}[protocol as LendingProtocol.SparkV3 | LendingProtocol.AaveV3]
}/${productType}/${collateralToken}-${quoteToken}`
}

if (pseudoProtocol === Erc4626PseudoProtocol && label) {
const { id } = erc4626VaultsByName[label]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export async function aaveLikeFlowStateFilter({
quoteAddress,
protocol,
networkId,
// we ignore filterConsumed because we dont want ANY positions with aave/spark debt
// so it doesnt matter if we're filtering all/used proxies
filterConsumed: _filterConsumed,
filterConsumed,
}: OmniFlowStateFilterParams & {
networkId: NetworkIds
}): Promise<boolean> {
Expand Down Expand Up @@ -43,7 +41,7 @@ export async function aaveLikeFlowStateFilter({
address: event.args.proxyAddress,
networkId: networkId as SparkV3SupportedNetwork,
})
return userData.totalDebtBase.isZero()
return !!filterConsumed && userData.totalDebtBase.isZero()
}
return Promise.resolve(false)
}
19 changes: 14 additions & 5 deletions features/omni-kit/views/OmniFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,21 @@ export function OmniFormView({
state,
quotePrecision,
}),
filterConsumedProxy: async (events) =>
(
await Promise.all(events.map((event) => omniProxyFilter({ event, filterConsumed: true })))
).every(Boolean),
filterConsumedProxy: async (events) => {
// leaving this all separate as its easier for debugging
const filterConsumedProxiesPromisesList = events.map((event) =>
omniProxyFilter({ event, filterConsumed: true }),
)
const filteredConsumedProxies = await Promise.all(filterConsumedProxiesPromisesList)
return filteredConsumedProxies.every(Boolean)
},
onProxiesAvailable: async (events, dpmAccounts) => {
const filteredEvents = await Promise.all(events.filter((event) => omniProxyFilter({ event })))
const filteredEventsBooleanMap = await Promise.all(
events.map((event) => omniProxyFilter({ event })),
)
const filteredEvents = events.filter(
(_event, eventIndex) => filteredEventsBooleanMap[eventIndex],
)
if (!hasDupePosition && filteredEvents.length) {
setHasDupePosition(true)
openModal(OmniDupePositionModal, {
Expand Down
Loading