Skip to content

Commit

Permalink
Aavelike flow state filter adjustment (#3989)
Browse files Browse the repository at this point in the history
  • Loading branch information
piekczyk committed Jul 12, 2024
1 parent 9a9d188 commit 50e2051
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { AaveV3SupportedNetwork } from 'blockchain/aave-v3/aave-v3-supporte
import type { NetworkIds } from 'blockchain/networks'
import type { SparkV3SupportedNetwork } from 'blockchain/spark-v3'
import { getSparkV3UserAccountData } from 'blockchain/spark-v3'
import { hasActiveOptimization, hasActiveProtection } from 'features/omni-kit/automation/helpers'
import type { OmniFlowStateFilterParams } from 'features/omni-kit/types'
import { getTriggersRequest } from 'helpers/lambda/triggers'
import { LendingProtocol } from 'lendingProtocols'
Expand Down Expand Up @@ -37,7 +38,11 @@ export async function aaveLikeFlowStateFilter({
})
// if there is triggers we should not allow
// the user to open a new position with this DPM
if (positionTriggers?.triggersCount && positionTriggers.triggersCount !== 0) {

if (
hasActiveOptimization({ positionTriggers, protocol }) ||
hasActiveProtection({ positionTriggers, protocol })
) {
return Promise.resolve(!filterConsumed)
}

Expand All @@ -57,6 +62,7 @@ export async function aaveLikeFlowStateFilter({
networkId: networkId as SparkV3SupportedNetwork,
})
const filterValue = userData.totalDebtBase.isZero()

return filterConsumed ? filterValue : !filterValue
}

Expand Down
3 changes: 2 additions & 1 deletion features/omni-kit/views/OmniFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export function OmniFormView({
.filter(
(event) =>
event.collateralTokenAddress.toLowerCase() === collateralAddress.toLowerCase() &&
event.debtTokenAddress.toLowerCase() === quoteAddress.toLowerCase(),
event.debtTokenAddress.toLowerCase() === quoteAddress.toLowerCase() &&
event.protocol === protocol,
)

if (!hasDupePosition && filteredEvents.length) {
Expand Down

0 comments on commit 50e2051

Please sign in to comment.