Skip to content

Commit

Permalink
Rays pseudo protocol fix (#3987)
Browse files Browse the repository at this point in the history
  • Loading branch information
piekczyk committed Jul 11, 2024
1 parent a07d68a commit 5b238c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions features/omni-kit/helpers/getOmniSidebarRaysBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { LendingPosition, SupplyPosition } from '@oasisdex/dma-library'
import BigNumber from 'bignumber.js'
import { RaysSidebarBanner } from 'components/RaysSidebarBanner'
import { VaultViewMode } from 'components/vault/GeneralManageTabBar.types'
import { Erc4626PseudoProtocol } from 'features/omni-kit/protocols/morpho-blue/constants'
import type {
OmniMultiplyPanel,
OmniSidebarBorrowPanel,
Expand All @@ -26,7 +27,6 @@ import React from 'react'

export const getOmniSidebarRaysBanner = ({
isOpening,
// uiDropdown,
isSupportingOptimization,
isOptimizationActive,
isSupportingProtection,
Expand All @@ -38,6 +38,7 @@ export const getOmniSidebarRaysBanner = ({
swapData,
hidden,
protocol,
pseudoProtocol,
collateralPrice,
isYieldLoop,
}: {
Expand All @@ -54,6 +55,7 @@ export const getOmniSidebarRaysBanner = ({
swapData?: OmniSimulationSwap
hidden: boolean
protocol: LendingProtocol
pseudoProtocol?: string
collateralPrice: BigNumber
isYieldLoop: boolean
}) => {
Expand Down Expand Up @@ -137,10 +139,12 @@ export const getOmniSidebarRaysBanner = ({
const castedPosition = position as LendingPosition
const castedSimulation = simulation as LendingPosition | undefined

// fallback to true since we have a SupplyPositions that have optional swaps on deposit (Erc4626),
// handle pseudo protocol since we have a SupplyPositions that have optional swaps on deposit (Erc4626),
// but doesn't have on withdraw (if at some point we will add support, much complex handling will be required)
const withBuyingCollateral =
castedSimulation?.riskRatio?.loanToValue.gt(castedPosition.riskRatio.loanToValue) || true
pseudoProtocol === Erc4626PseudoProtocol
? true
: castedSimulation?.riskRatio?.loanToValue.gt(castedPosition.riskRatio.loanToValue)

const swapValue = (
withBuyingCollateral ? swapData.minToTokenAmount : swapData.fromTokenAmount
Expand Down
1 change: 1 addition & 0 deletions features/omni-kit/views/OmniFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ export function OmniFormView({
swapData: swap?.current,
hidden: isTxInProgress || isTxSuccess || isTxError,
protocol,
pseudoProtocol,
collateralPrice,
isYieldLoop,
})
Expand Down

0 comments on commit 5b238c2

Please sign in to comment.