Skip to content

Commit

Permalink
Fix open instant swap rays
Browse files Browse the repository at this point in the history
  • Loading branch information
piekczyk committed Jun 20, 2024
1 parent 2aa6159 commit 64bd267
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
20 changes: 13 additions & 7 deletions features/omni-kit/helpers/getOmniSidebarRaysBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { OmniMultiplyPanel, OmniProductType } from 'features/omni-kit/types'
import { RAYS_OPTIMIZATION_BOOST, RAYS_PROTECTION_BOOST } from 'features/rays/consts'
import { getAutomationBoost } from 'features/rays/getAutomationBoost'
import { getProtocolBoost } from 'features/rays/getProtocolBoost'
import { getRaysMultiplyMultipliers } from 'features/rays/getRaysMultiplyMultipliers'
import { getRaysNextProtocolBonus } from 'features/rays/getRaysNextProtocolBonus'
import { getSwapBoost } from 'features/rays/getSwapBoost'
import type { PositionRaysMultipliersData } from 'features/rays/types'
Expand Down Expand Up @@ -83,26 +84,31 @@ export const getOmniSidebarRaysBanner = ({
}

// if user already have position on currently used protocol, use current protocol boost
const raysPerYear = positionRaysMultipliersData.allUserProtocols.includes(protocol)
const simulatedRaysPerYear = positionRaysMultipliersData.allUserProtocols.includes(protocol)
? simulatedBaseRaysPerYear * protocolBoost
: simulatedBaseRaysPerYear * getRaysNextProtocolBonus(protocolBoost, simulationNetValue)

let rays
let instantRays

if (swapData?.minToTokenAmount) {
rays = formatCryptoBalance(swapData.minToTokenAmount.times(swapBoost))
const swapRaysPerYear = new BigNumber(
getPointsPerYear(swapData.minToTokenAmount.times(collateralPrice).toNumber()),
)
const multiplyMultipliers = getRaysMultiplyMultipliers(isYieldLoop)

instantRays = formatCryptoBalance(swapRaysPerYear.times(swapBoost).times(multiplyMultipliers))
} else {
rays = 'n/a'
instantRays = 'n/a'
}

return (
<RaysSidebarBanner
title={t(
`rays.sidebar.banner.${productType === OmniProductType.Multiply ? 'instant' : 'open-non-swap'}.title`,
{ rays },
{ rays: instantRays },
)}
description={t('rays.sidebar.banner.instant.description', {
raysPerYear: formatCryptoBalance(new BigNumber(raysPerYear)),
raysPerYear: formatCryptoBalance(new BigNumber(simulatedRaysPerYear)),
})}
/>
)
Expand Down Expand Up @@ -136,7 +142,7 @@ export const getOmniSidebarRaysBanner = ({
).times(collateralPrice)

const swapRaysPerYear = new BigNumber(getPointsPerYear(swapValue.toNumber()))
const multiplyMultipliers = isYieldLoop ? 0.06 : 0.2
const multiplyMultipliers = getRaysMultiplyMultipliers(isYieldLoop)

const instantRays = formatCryptoBalance(
swapRaysPerYear.times(swapBoost).times(multiplyMultipliers),
Expand Down
1 change: 1 addition & 0 deletions features/rays/getRaysMultiplyMultipliers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getRaysMultiplyMultipliers = (isYieldLoop: boolean) => (isYieldLoop ? 0.06 : 0.2)

0 comments on commit 64bd267

Please sign in to comment.