@@ -547,11 +547,11 @@ export function calculateVolSpreadBN(
547
547
. add ( oracleStd )
548
548
. mul ( PERCENTAGE_PRECISION )
549
549
. div ( reservePrice )
550
- . div ( new BN ( 4 ) ) ;
550
+ . div ( new BN ( 2 ) ) ;
551
551
const volSpread = BN . max ( lastOracleConfPct , marketAvgStdPct . div ( new BN ( 2 ) ) ) ;
552
552
553
553
const clampMin = PERCENTAGE_PRECISION . div ( new BN ( 100 ) ) ;
554
- const clampMax = PERCENTAGE_PRECISION ;
554
+ const clampMax = PERCENTAGE_PRECISION . mul ( new BN ( 16 ) ) . div ( new BN ( 10 ) ) ;
555
555
556
556
const longVolSpreadFactor = clampBN (
557
557
longIntensity . mul ( PERCENTAGE_PRECISION ) . div ( BN . max ( ONE , volume24H ) ) ,
@@ -568,7 +568,7 @@ export function calculateVolSpreadBN(
568
568
let confComponent = lastOracleConfPct ;
569
569
570
570
if ( lastOracleConfPct . lte ( PRICE_PRECISION . div ( new BN ( 400 ) ) ) ) {
571
- confComponent = lastOracleConfPct . div ( new BN ( 20 ) ) ;
571
+ confComponent = lastOracleConfPct . div ( new BN ( 10 ) ) ;
572
572
}
573
573
574
574
const longVolSpread = BN . max (
@@ -845,8 +845,28 @@ export function calculateSpread(
845
845
amm . shortIntensityVolume ,
846
846
amm . volume24H
847
847
) ;
848
- const longSpread = spreads [ 0 ] ;
849
- const shortSpread = spreads [ 1 ] ;
848
+ let longSpread = spreads [ 0 ] ;
849
+ let shortSpread = spreads [ 1 ] ;
850
+
851
+ if ( amm . ammSpreadAdjustment > 0 ) {
852
+ longSpread = Math . max (
853
+ longSpread + ( longSpread * amm . ammSpreadAdjustment ) / 100 ,
854
+ 1
855
+ ) ;
856
+ shortSpread = Math . max (
857
+ shortSpread + ( shortSpread * amm . ammSpreadAdjustment ) / 100 ,
858
+ 1
859
+ ) ;
860
+ } else if ( amm . ammSpreadAdjustment < 0 ) {
861
+ longSpread = Math . max (
862
+ longSpread - ( longSpread * - amm . ammSpreadAdjustment ) / 100 ,
863
+ 1
864
+ ) ;
865
+ shortSpread = Math . max (
866
+ shortSpread - ( shortSpread * - amm . ammSpreadAdjustment ) / 100 ,
867
+ 1
868
+ ) ;
869
+ }
850
870
851
871
return [ longSpread , shortSpread ] ;
852
872
}
0 commit comments