@@ -41,6 +41,26 @@ function calcDefiApr(
4141 return [ start , end ] ;
4242}
4343
44+ function calcDualApr (
45+ apr : [ number , number ] ,
46+ investItem : InvestItem
47+ ) : [ start : number , end : number ] {
48+ let [ start , end ] = investItem . apr ;
49+ let [ _start , _end ] = apr ;
50+ // const apr = Number(defiinfo.apy);
51+ if ( start === 0 && _start !== 0 ) {
52+ start = _start ;
53+ } else if ( _start !== 0 && _start < start ) {
54+ start = _start ;
55+ }
56+ if ( end === 0 && _end !== 0 ) {
57+ end = _end ;
58+ } else if ( _end !== 0 && _end > end ) {
59+ end = _end ;
60+ }
61+ return [ start , end ] ;
62+ }
63+
4464const getInvestMapApi = async ( ) => {
4565 const { ammMap } = store . getState ( ) . amm . ammMap ;
4666 const { marketMap } = store . getState ( ) . invest . defiMap ;
@@ -150,7 +170,13 @@ const getInvestMapApi = async () => {
150170 let investItem = prev [ coinA ] [ InvestMapType . DUAL ] ;
151171 prev [ coinA ] . detail . durationType = InvestDuration . All ;
152172 if ( investItem ) {
153- investItem . apr = calcDefiApr ( dualInfo , investItem ) ;
173+ investItem . apr = calcDualApr (
174+ [
175+ ( dualInfo ?. baseTokenApy ?. min ?? 0 ) * 100 ,
176+ ( dualInfo ?. baseTokenApy ?. max ?? 0 ) * 100 ,
177+ ] ,
178+ investItem
179+ ) ;
154180 } else {
155181 prev [ coinA ] [ InvestMapType . DUAL ] = {
156182 // token: tokenMap[coinA],
@@ -195,7 +221,13 @@ const getInvestMapApi = async () => {
195221 let investItem = prev [ coinB ] [ InvestMapType . DUAL ] ;
196222 // prev[coinB].detail.durationType = InvestDuration.All;
197223 if ( investItem ) {
198- investItem . apr = calcDefiApr ( dualInfo , investItem ) ;
224+ investItem . apr = calcDualApr (
225+ [
226+ ( dualInfo ?. quoteTokenApy ?. min ?? 0 ) * 100 ,
227+ ( dualInfo ?. quoteTokenApy ?. max ?? 0 ) * 100 ,
228+ ] ,
229+ investItem
230+ ) ;
199231 } else {
200232 prev [ coinB ] [ InvestMapType . DUAL ] = {
201233 type : InvestMapType . DUAL ,
0 commit comments