@@ -2,11 +2,7 @@ import BigNumber from 'bignumber.js'
2
2
import { InfoSection } from 'components/infoSection/InfoSection'
3
3
import { ItemValueWithIcon } from 'components/infoSection/ItemValueWithIcon'
4
4
import { useRefinanceContext } from 'features/refinance/contexts'
5
- import {
6
- formatCryptoBalance ,
7
- formatDecimalAsPercent ,
8
- formatLtvDecimalAsPercent ,
9
- } from 'helpers/formatters/format'
5
+ import { formatCryptoBalance , formatLtvDecimalAsPercent } from 'helpers/formatters/format'
10
6
import { useTranslation } from 'next-i18next'
11
7
import React from 'react'
12
8
import { Text } from 'theme-ui'
@@ -38,39 +34,43 @@ const getChangeVariant = (
38
34
export const RefinanceReviewChangesSection = ( ) => {
39
35
const { t } = useTranslation ( )
40
36
41
- const { poolData, position, simulation, automations } = useRefinanceContext ( )
37
+ const {
38
+ poolData,
39
+ position,
40
+ simulation,
41
+ automations,
42
+ form : {
43
+ state : { strategy } ,
44
+ } ,
45
+ } = useRefinanceContext ( )
42
46
43
47
const ltv = new BigNumber ( poolData . maxLtv . loanToValue )
44
48
const liquidationPrice = new BigNumber ( position . liquidationPrice )
45
49
const debt = new BigNumber ( position . debtTokenData . amount )
46
50
const debtToken = position . debtTokenData . token . symbol
47
51
48
- if ( ! simulation . refinanceSimulation ) {
52
+ if ( ! simulation . refinanceSimulation || ! strategy ?. maxLtv ) {
49
53
return null
50
54
}
51
55
const targetPosition = simulation . refinanceSimulation . targetPosition
52
56
53
57
const isAutomationEnabled = Object . values ( automations ) . some ( ( item ) => item . enabled )
54
58
55
- const afterLtv = new BigNumber (
56
- simulation . liquidationThreshold ? simulation . liquidationThreshold . toProportion ( ) : 0 ,
57
- )
59
+ const afterLtv = new BigNumber ( strategy . maxLtv )
58
60
59
61
const afterLiquidationPriceInUsd = simulation . liquidationPrice
60
62
const afterLiquidationPrice = new BigNumber ( afterLiquidationPriceInUsd )
61
63
const afterDebt = new BigNumber ( targetPosition . debtAmount . amount )
62
64
const afterDebtToken = targetPosition . debtAmount . token . symbol
63
65
64
- const ltvChange = afterLtv . minus ( ltv ) . div ( ltv )
65
- const liquidationPriceChange = afterLiquidationPrice . minus ( liquidationPrice ) . div ( liquidationPrice )
66
+ const ltvChange = afterLtv . minus ( ltv )
66
67
67
68
const formatted = {
68
69
ltv : formatLtvDecimalAsPercent ( ltv ) ,
69
70
afterLtv : formatLtvDecimalAsPercent ( afterLtv ) ,
70
71
ltvChange : formatLtvDecimalAsPercent ( ltvChange ) ,
71
72
liquidationPrice : formatCryptoBalance ( liquidationPrice ) ,
72
73
afterLiquidationPrice : formatCryptoBalance ( afterLiquidationPrice ) ,
73
- liquidationPriceChange : formatDecimalAsPercent ( liquidationPriceChange ) ,
74
74
debt : < ItemValueWithIcon tokens = { [ debtToken ] } > { formatCryptoBalance ( debt ) } </ ItemValueWithIcon > ,
75
75
afterDebt : (
76
76
< ItemValueWithIcon tokens = { [ afterDebtToken ] } >
@@ -89,14 +89,6 @@ export const RefinanceReviewChangesSection = () => {
89
89
label : t ( 'system.liq-price-short' ) ,
90
90
value : formatted . liquidationPrice ,
91
91
change : formatted . afterLiquidationPrice ,
92
- secondary : {
93
- value : formatted . liquidationPriceChange ,
94
- variant : getChangeVariant (
95
- 'liquidationPrice' ,
96
- liquidationPriceChange ,
97
- position . isShort ,
98
- ) ,
99
- } ,
100
92
} ,
101
93
{
102
94
label : t ( 'max-ltv' ) ,
0 commit comments