@@ -8,6 +8,7 @@ import { SubTitle } from '@/components/DetailsMarket/styles'
8
8
import Box from '@/ui/Box'
9
9
import Chip from '@/ui/Typography/Chip'
10
10
import DetailInfo from '@/ui/DetailInfo'
11
+ import Icon from '@/ui/Icon'
11
12
12
13
const MarketParameters = ( {
13
14
rChainId,
@@ -18,6 +19,7 @@ const MarketParameters = ({
18
19
rOwmId : string
19
20
type : 'borrow' | 'supply'
20
21
} ) => {
22
+ const isAdvanceMode = useStore ( ( state ) => state . isAdvanceMode )
21
23
const owmData = useStore ( ( state ) => state . markets . owmDatasMapper [ rChainId ] ?. [ rOwmId ] )
22
24
const loanPricesResp = useStore ( ( state ) => state . markets . pricesMapper [ rChainId ] ?. [ rOwmId ] )
23
25
const parametersResp = useStore ( ( state ) => state . markets . statsParametersMapper [ rChainId ] ?. [ rOwmId ] )
@@ -29,14 +31,15 @@ const MarketParameters = ({
29
31
const { pricePerShare, error : pricePerShareError } = vaultPricePerShareResp ?? { }
30
32
31
33
// prettier-ignore
32
- const marketDetails : { label : string ; value : string | number | undefined ; formatOptions ?: NumberFormatOptions ; title ?: string ; isError : string ; isRow ?: boolean } [ ] [ ] = type === 'borrow' ?
34
+ const marketDetails : { label : string ; value : string | number | undefined ; formatOptions ?: NumberFormatOptions ; title ?: string ; isError : string ; isRow ?: boolean , isAdvance ?: boolean ; tooltip ?: string } [ ] [ ] = type === 'borrow' ?
33
35
[
34
36
[
35
37
{ label : t `AMM swap fee` , value : parameters ?. fee , formatOptions : { ...FORMAT_OPTIONS . PERCENT , maximumSignificantDigits : 3 } , isError : parametersError } ,
36
38
{ label : t `Admin fee` , value : parameters ?. admin_fee , formatOptions : { ...FORMAT_OPTIONS . PERCENT , maximumSignificantDigits : 3 } , isError : parametersError } ,
37
39
{ label : t `A` , value : parameters ?. A , formatOptions : { useGrouping : false } , isError : parametersError } ,
38
40
{ label : t `Loan discount` , value : parameters ?. loan_discount , formatOptions : { ...FORMAT_OPTIONS . PERCENT , maximumSignificantDigits : 2 } , isError : parametersError } ,
39
41
{ label : t `Liquidation discount` , value : parameters ?. liquidation_discount , formatOptions : { ...FORMAT_OPTIONS . PERCENT , maximumSignificantDigits : 2 } , isError : parametersError } ,
42
+ { label : t `Max LTV` , value : _getMaxLTV ( parameters ?. A , parameters ?. loan_discount ) , formatOptions : { ...FORMAT_OPTIONS . PERCENT , maximumSignificantDigits : 2 } , isError : parametersError , isAdvance : true , tooltip : t `Max possible loan at N=4` } ,
40
43
] ,
41
44
[
42
45
{ label : t `Base price` , value : prices ?. basePrice , formatOptions : { showAllFractionDigits : true } , title : t `Prices` , isError : pricesError } ,
@@ -59,24 +62,32 @@ const MarketParameters = ({
59
62
const isError = ( idx === 0 && ! ! parametersError ) || ( idx === 1 && pricesError )
60
63
return (
61
64
< div key = { `details-${ idx } ` } >
62
- { details . map ( ( { label, value, formatOptions, title, isError, isRow } ) => {
65
+ { details . map ( ( { label, value, formatOptions, title, isError, isRow, isAdvance, tooltip } ) => {
66
+ const show = typeof isAdvance === 'undefined' || ( isAdvance && isAdvanceMode )
63
67
return (
64
68
< React . Fragment key = { label } >
65
- { title && < SubTitle > { title } </ SubTitle > }
66
- { isRow ? (
67
- < Box grid >
68
- < Chip isBold > { label } :</ Chip >
69
- < strong > { formatNumber ( value , { ...( formatOptions ?? { } ) , defaultValue : '-' } ) } </ strong >
70
- </ Box >
71
- ) : (
72
- < DetailInfo key = { label } label = { label } >
73
- { isError ? (
74
- '?'
69
+ { show ? (
70
+ < >
71
+ { title && < SubTitle > { title } </ SubTitle > }
72
+ { isRow ? (
73
+ < Box grid >
74
+ < Chip isBold > { label } :</ Chip >
75
+ < strong > { formatNumber ( value , { ...( formatOptions ?? { } ) , defaultValue : '-' } ) } </ strong >
76
+ </ Box >
75
77
) : (
76
- < strong > { formatNumber ( value , { ...( formatOptions ?? { } ) , defaultValue : '-' } ) } </ strong >
78
+ < DetailInfo key = { label } label = { label } >
79
+ { isError ? (
80
+ '?'
81
+ ) : (
82
+ < Chip { ...( tooltip ? { tooltip, tooltipProps : { noWrap : true } } : { } ) } isBold >
83
+ { formatNumber ( value , { ...( formatOptions ?? { } ) , defaultValue : '-' } ) }
84
+ { tooltip && < Icon className = "svg-tooltip" name = "InformationSquare" size = { 16 } /> }
85
+ </ Chip >
86
+ ) }
87
+ </ DetailInfo >
77
88
) }
78
- </ DetailInfo >
79
- ) }
89
+ </ >
90
+ ) : null }
80
91
</ React . Fragment >
81
92
)
82
93
} ) }
@@ -87,4 +98,14 @@ const MarketParameters = ({
87
98
)
88
99
}
89
100
101
+ // In [1]: ltv = lambda x: ((x[0] - 1) / x[0])**2 * (1 - x[1])
102
+ // In [2]: ltv((30, 0.11))
103
+ // Out[2]: 0.8316555555555556
104
+ // where x[0] is A, x[1] is loan discount normalised between 0 and 1 (so 11% is 0.11). multiply ltv by 100 to show percentage.
105
+ // always show 'max ltv' which is the max possible loan at N=4 (not advisable but hey it exists!).
106
+ function _getMaxLTV ( a : string | undefined , loanDiscount : string | undefined ) {
107
+ if ( typeof a === 'undefined' || typeof loanDiscount === 'undefined' ) return ''
108
+ return ( ( + a - 1 ) / + a ) ** 2 * ( 1 - + loanDiscount / 100 ) * 100
109
+ }
110
+
90
111
export default MarketParameters
0 commit comments