File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -2096,16 +2096,17 @@ impl MakerOrder {
20962096 return OrderMatchResult :: NotMatched ;
20972097 }
20982098
2099+ let result_rel_amount = taker_base_amount * & self . price ;
2100+
20992101 if is_legacy {
21002102 // Legacy mode: use maker's price to calculate rel amount
2101- OrderMatchResult :: Matched ( ( taker_base_amount. clone ( ) , taker_base_amount * & self . price ) )
2103+ OrderMatchResult :: Matched ( ( taker_base_amount. clone ( ) , result_rel_amount ) )
21022104 } else {
21032105 // taker_rel_amount must cover the premium requested by maker
2104- let required_rel_amount =
2105- taker_base_amount * & self . price + self . premium . clone ( ) . unwrap_or_default ( ) ;
2106+ let required_rel_amount = result_rel_amount + self . premium . clone ( ) . unwrap_or_default ( ) ;
21062107 if taker_rel_amount >= & required_rel_amount {
2107- // TPU mode: treat buy as a limit order using taker's base and rel amounts
2108- OrderMatchResult :: Matched ( ( taker_base_amount. clone ( ) , taker_rel_amount . clone ( ) ) )
2108+ // TPU mode: treat buy as a limit order using taker's base amount and required_rel_amount
2109+ OrderMatchResult :: Matched ( ( taker_base_amount. clone ( ) , required_rel_amount ) )
21092110 } else {
21102111 OrderMatchResult :: NotMatched
21112112 }
Original file line number Diff line number Diff line change @@ -776,7 +776,8 @@ fn test_v2_swap_utxo_utxo() {
776776 premium : Some ( 0.007 ) ,
777777 taker_method : TakerMethod :: Buy ,
778778 expected_bob_locked_amount : "777.00001" ,
779- expected_alice_locked_amount : "778.00779" ,
779+ expected_alice_locked_amount :
780+ "778.0070190090090090090090090090090090090090090090090090090090090090090090090090090090090090090090090" ,
780781 } ) ;
781782}
782783
@@ -791,7 +792,7 @@ fn test_v2_swap_utxo_utxo_burnkey_as_alice() {
791792 premium : Some ( 0.007 ) ,
792793 taker_method : TakerMethod :: Buy ,
793794 expected_bob_locked_amount : "777.00001" ,
794- expected_alice_locked_amount : "777.00778 " , // no dex fee if dex pubkey is alice
795+ expected_alice_locked_amount : "777.00701 " , // no dex fee if dex pubkey is alice
795796 } ) ;
796797}
797798
You can’t perform that action at this time.
0 commit comments