@@ -88,6 +88,13 @@ const setPrices = async (options) => {
8888 // Base asset decimals used to scale aggregator quote amounts. Legacy ARM
8989 // configs don't expose baseAssetDecimals as all their assets are 18 decimals.
9090 const baseDecimals = Number ( config . baseAssetDecimals ?? 18 ) ;
91+ const liquidityDecimals = Number (
92+ await new Contract (
93+ liquidityAddress ,
94+ [ "function decimals() view returns (uint8)" ] ,
95+ signer ,
96+ ) . decimals ( ) ,
97+ ) ;
9198
9299 log ( `Getting current ARM prices:` ) ;
93100 log ( `base asset : ${ baseSymbol } ` ) ;
@@ -111,17 +118,6 @@ const setPrices = async (options) => {
111118 ? 10n
112119 : 30n ;
113120
114- // The liquidity asset decimals are not in the base asset config so read
115- // them on-chain. Can differ from the base asset decimals, eg an 18
116- // decimals base asset over a 6 decimals USDC liquidity asset.
117- const liquidityDecimals = Number (
118- await new Contract (
119- liquidityAddress ,
120- [ "function decimals() view returns (uint8)" ] ,
121- signer ,
122- ) . decimals ( ) ,
123- ) ;
124-
125121 // 2.1 Get reference prices
126122 let referencePrices ;
127123 if ( midPrice ) {
@@ -361,8 +357,8 @@ const setPrices = async (options) => {
361357 const toleranceScaled = parseUnits ( tolerance . toString ( ) , 36 - 4 ) ;
362358 log ( `tolerance : ${ formatUnits ( toleranceScaled , 32 ) } basis points` ) ;
363359
364- const targetBuyAmount = parseSwapCap ( buyAmount ) ;
365- const targetSellAmount = parseSwapCap ( sellAmount ) ;
360+ const targetBuyAmount = parseSwapCap ( buyAmount , liquidityDecimals ) ;
361+ const targetSellAmount = parseSwapCap ( sellAmount , baseDecimals ) ;
366362 const swapCapsChanged = haveSwapCapsChanged (
367363 baseContext ,
368364 targetBuyAmount ,
0 commit comments