@@ -1181,16 +1181,14 @@ pub mod pallet {
11811181 pool. quote_adjustment ,
11821182 remain_orders,
11831183 ) ?;
1184- if_std ! {
1185- println!(
1186- "
1187- 📕 Book Price => {:?},
1188- 🎯 Remain Orders => {:?},
1189- ✅ Max Swap Quantity => {:?}
1190- " ,
1191- orderbook_price, remain_orders, max_swap_quantity
1192- ) ;
1193- }
1184+ log:: info!(
1185+ "
1186+ 📕 Book Price => {:?},
1187+ 🎯 Remain Orders => {:?},
1188+ ✅ Max Swap Quantity => {:?}
1189+ " ,
1190+ orderbook_price, remain_orders, max_swap_quantity
1191+ ) ;
11941192 if remain_orders <= max_swap_quantity {
11951193 // All orders filled from pool
11961194 Self :: do_fill_pool (
@@ -1200,16 +1198,12 @@ pub mod pallet {
12001198 base_asset,
12011199 quote_asset,
12021200 ) ?;
1203- if_std ! {
1204- println!( "💦 Filled all {:?} orders from pool" , remain_orders)
1205- }
1201+ log:: info!( "💦 Filled all {:?} orders from pool" , remain_orders) ;
12061202 remain_orders = Zero :: zero ( ) ;
12071203 } else {
12081204 let is_pool: bool = max_swap_quantity != Zero :: zero ( ) ;
12091205 if is_pool {
1210- if_std ! {
1211- println!( "💦 Filled {:?} orders from Pool" , max_swap_quantity) ;
1212- }
1206+ log:: info!( "💦 Filled {:?} orders from Pool" , max_swap_quantity) ;
12131207 // Swap up to `max_swap_quantity` from pool
12141208 Self :: do_fill_pool (
12151209 is_bid,
@@ -1221,9 +1215,7 @@ pub mod pallet {
12211215 }
12221216 // Remain orders subsume the closest will be filled from Orderbook
12231217 remain_orders -= max_swap_quantity;
1224- if_std ! {
1225- println!( "📖 Filled {:?} orders from Book" , remain_orders) ;
1226- }
1218+ log:: info!( "📖 Filled {:?} orders from Book" , remain_orders) ;
12271219 Self :: do_fill_book (
12281220 is_bid,
12291221 pool,
@@ -1357,32 +1349,29 @@ pub mod pallet {
13571349 let mut swap_quantity: T :: Unit = Zero :: zero ( ) ;
13581350 while min < max {
13591351 let mid = ( min + max + One :: one ( ) ) / 2u32 . into ( ) ;
1352+ let unit: T :: Unit = One :: one ( ) ;
13601353 let pool_price = if is_bid {
13611354 // If it is bid order, get `amount_in` of `quote_asset` with given `amount_out`
13621355 // of `base_asset` quantity of `base_asset`
13631356 let amount_in = Self :: get_amount_in ( & mid, & q_r, & b_r) ?;
1364- if_std ! { println! ( "Bid order: amount_in => {:?}, K = {:?}" , amount_in, ( ( b_r-mid) * ( q_r+amount_in) ) ) ; }
1357+ log :: info! ( "Bid order: amount_in => {:?}, K = {:?}" , amount_in, ( ( b_r-mid) * ( q_r+amount_in) ) ) ;
13651358 Self :: quote (
1366- & One :: one ( ) ,
1359+ & unit . normalize ( pool_decimals ) ,
13671360 & ( b_r - mid) . normalize ( base_decimals_adjustment) ,
13681361 & ( q_r + amount_in) . normalize ( quote_decimals_adjustment) ,
13691362 ) ?
1370- . normalize ( pool_decimals)
13711363 } else {
13721364 // If it is ask order, get `amount_out` of `quote_asset` with given `amount_in`
13731365 // of `base_asset`
13741366 let amount_out = Self :: get_amount_out ( & mid, & b_r, & q_r) ?;
1375- if_std ! { println! ( "Ask order: amount_out => {:?}" , amount_out) ; }
1367+ log :: info! ( "Ask order: amount_out => {:?}" , amount_out) ;
13761368 Self :: quote (
1377- & One :: one ( ) ,
1369+ & unit . normalize ( pool_decimals ) ,
13781370 & ( b_r + mid) . normalize ( base_decimals_adjustment) ,
13791371 & ( q_r - amount_out) . normalize ( quote_decimals_adjustment) ,
13801372 ) ?
1381- . normalize ( pool_decimals)
13821373 } ;
1383- if_std ! {
1384- println!( "Pool Price => {:?}, Mid => {:?}" , pool_price, mid) ;
1385- }
1374+ log:: info!( "Pool Price => {:?}, Mid => {:?}" , pool_price, mid) ;
13861375 // Return immediately when pool price after swap is equal to orderbook price
13871376 if pool_price == target {
13881377 return Ok ( mid) ;
0 commit comments