@@ -280,16 +280,11 @@ function getFixedInputSwapQuote({
280280 convertFromBaseUnits ( decimals . assetOut , Number ( assetOutAmount ) ) /
281281 convertFromBaseUnits ( decimals . assetIn , Number ( assetInAmount ) ) ;
282282
283- const swapPrice = 1 / rate ;
284-
285283 const poolPrice =
286- convertFromBaseUnits ( decimals . assetIn , Number ( inputSupply ) ) /
287- convertFromBaseUnits ( decimals . assetOut , Number ( outputSupply ) ) ;
284+ convertFromBaseUnits ( decimals . assetOut , Number ( outputSupply ) ) /
285+ convertFromBaseUnits ( decimals . assetIn , Number ( inputSupply ) ) ;
288286
289- const priceImpact = roundNumber (
290- { decimalPlaces : 5 } ,
291- Math . abs ( swapPrice / poolPrice - 1 )
292- ) ;
287+ const priceImpact = roundNumber ( { decimalPlaces : 5 } , Math . abs ( rate / poolPrice - 1 ) ) ;
293288
294289 return {
295290 round : reserves . round ,
@@ -441,16 +436,11 @@ function getFixedOutputSwapQuote({
441436 convertFromBaseUnits ( decimals . assetOut , Number ( assetOutAmount ) ) /
442437 convertFromBaseUnits ( decimals . assetIn , Number ( assetInAmount ) ) ;
443438
444- const swapPrice = 1 / rate ;
445-
446439 const poolPrice =
447- convertFromBaseUnits ( decimals . assetIn , Number ( inputSupply ) ) /
448- convertFromBaseUnits ( decimals . assetOut , Number ( outputSupply ) ) ;
440+ convertFromBaseUnits ( decimals . assetOut , Number ( outputSupply ) ) /
441+ convertFromBaseUnits ( decimals . assetIn , Number ( inputSupply ) ) ;
449442
450- const priceImpact = roundNumber (
451- { decimalPlaces : 5 } ,
452- Math . abs ( swapPrice / poolPrice - 1 )
453- ) ;
443+ const priceImpact = roundNumber ( { decimalPlaces : 5 } , Math . abs ( rate / poolPrice - 1 ) ) ;
454444
455445 return {
456446 round : reserves . round ,
0 commit comments