@@ -547,11 +547,11 @@ export function calculateVolSpreadBN(
547547 . add ( oracleStd )
548548 . mul ( PERCENTAGE_PRECISION )
549549 . div ( reservePrice )
550- . div ( new BN ( 4 ) ) ;
550+ . div ( new BN ( 2 ) ) ;
551551 const volSpread = BN . max ( lastOracleConfPct , marketAvgStdPct . div ( new BN ( 2 ) ) ) ;
552552
553553 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 ) ) ;
555555
556556 const longVolSpreadFactor = clampBN (
557557 longIntensity . mul ( PERCENTAGE_PRECISION ) . div ( BN . max ( ONE , volume24H ) ) ,
@@ -568,7 +568,7 @@ export function calculateVolSpreadBN(
568568 let confComponent = lastOracleConfPct ;
569569
570570 if ( lastOracleConfPct . lte ( PRICE_PRECISION . div ( new BN ( 400 ) ) ) ) {
571- confComponent = lastOracleConfPct . div ( new BN ( 20 ) ) ;
571+ confComponent = lastOracleConfPct . div ( new BN ( 10 ) ) ;
572572 }
573573
574574 const longVolSpread = BN . max (
@@ -845,8 +845,28 @@ export function calculateSpread(
845845 amm . shortIntensityVolume ,
846846 amm . volume24H
847847 ) ;
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+ }
850870
851871 return [ longSpread , shortSpread ] ;
852872}
0 commit comments