@@ -1024,7 +1024,11 @@ impl AggTakerSwapStateMachine {
10241024 }
10251025
10261026 /// Start nested atomic swap by calling lp_auto_buy. The actual volume is determined on previous states
1027+ /// The volume is always in the taker sell coins.
1028+ /// TODO: add slippage support
10271029 async fn start_lp_auto_buy ( & self , volume : MmNumber , _slippage : f32 ) -> MmResult < SellBuyResponse , LrSwapError > {
1030+ const TAKER_ACTION : TakerAction = TakerAction :: Sell ;
1031+
10281032 let base_coin = lp_coinfind_or_err ( & self . ctx , & self . atomic_swap . base )
10291033 . await
10301034 . map_mm_err ( ) ?;
@@ -1047,11 +1051,11 @@ impl AggTakerSwapStateMachine {
10471051 "{LOG_PREFIX} volume={} self.atomic_swap.price={} action={:?} base={} rel={}" ,
10481052 volume. to_decimal( ) ,
10491053 self . atomic_swap. price. to_decimal( ) ,
1050- self . atomic_swap . action ,
1054+ TAKER_ACTION ,
10511055 self . atomic_swap. base,
10521056 self . atomic_swap. rel
10531057 ) ;
1054- let ( taker_amount, sell_base, sell_rel) = match self . atomic_swap . action {
1058+ let ( taker_amount, sell_base, sell_rel) = match TAKER_ACTION {
10551059 TakerAction :: Buy => ( & volume * & self . atomic_swap . price , rel_coin. clone ( ) , base_coin. clone ( ) ) ,
10561060 TakerAction :: Sell => ( volume. clone ( ) , base_coin. clone ( ) , rel_coin. clone ( ) ) ,
10571061 } ;
@@ -1077,15 +1081,15 @@ impl AggTakerSwapStateMachine {
10771081 "{LOG_PREFIX} starting atomic swap for {}/{}, action {:?}, amount {}" ,
10781082 self . atomic_swap. base,
10791083 self . atomic_swap. rel,
1080- self . atomic_swap . action ,
1084+ TAKER_ACTION ,
10811085 volume. to_decimal( )
10821086 ) ;
10831087 let sell_buy_req = lr_helpers:: make_atomic_swap_request (
10841088 self . atomic_swap . base . clone ( ) ,
10851089 self . atomic_swap . rel . clone ( ) ,
10861090 self . atomic_swap . price . clone ( ) ,
10871091 volume,
1088- self . atomic_swap . action . clone ( ) ,
1092+ TAKER_ACTION ,
10891093 self . atomic_swap . match_by . clone ( ) ,
10901094 self . atomic_swap . order_type . clone ( ) ,
10911095 ) ;
@@ -1196,8 +1200,8 @@ impl AggTakerSwapStateMachine {
11961200 let dex_fee_rate = DexFee :: dex_fee_rate ( & taker_ticker, & maker_ticker) ;
11971201 // Recalculate swap_volume with the tarde fees removed:
11981202 let taker_volume = volume_with_fees. clone ( ) / ( MmNumber :: from ( "1" ) + dex_fee_rate) ;
1199- println ! (
1200- "deduct_fees volume_with_fees={volume_with_fees} taker_volume={taker_volume} dex_fee_diff={}" ,
1203+ debug ! (
1204+ "{maker_ticker}/{taker_ticker} deduct_fees volume_with_fees={volume_with_fees} taker_volume={taker_volume} dex_fee_diff={}" ,
12011205 & volume_with_fees - & taker_volume
12021206 ) ;
12031207
0 commit comments