File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,9 @@ export abstract class PriceOracleBaseContract<
176176 * @param reserve use reserve price feed instead of main
177177 */
178178 public convertToUSD ( from : Address , amount : bigint , reserve = false ) : bigint {
179+ if ( amount === 0n ) {
180+ return 0n ;
181+ }
179182 const price = reserve ? this . reservePrice ( from ) : this . mainPrice ( from ) ;
180183 const scale = 10n ** BigInt ( this . tokensMeta . decimals ( from ) ) ;
181184 return ( amount * price ) / scale ;
@@ -188,6 +191,9 @@ export abstract class PriceOracleBaseContract<
188191 * @param reserve use reserve price feed instead of main
189192 */
190193 public convertFromUSD ( to : Address , amount : bigint , reserve = false ) : bigint {
194+ if ( amount === 0n ) {
195+ return 0n ;
196+ }
191197 const price = reserve ? this . reservePrice ( to ) : this . mainPrice ( to ) ;
192198 const scale = 10n ** BigInt ( this . tokensMeta . decimals ( to ) ) ;
193199 return ( amount * scale ) / price ;
You can’t perform that action at this time.
0 commit comments