From 2be270a3275e0949880c9f424378aa91468cfa01 Mon Sep 17 00:00:00 2001 From: davirds Date: Tue, 20 Dec 2022 13:37:34 -0300 Subject: [PATCH] fix: dispute (#141) fix: settle for --- contracts/contracts/trade/src/contract.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/contracts/contracts/trade/src/contract.rs b/contracts/contracts/trade/src/contract.rs index 5d353861..ace4ae92 100644 --- a/contracts/contracts/trade/src/contract.rs +++ b/contracts/contracts/trade/src/contract.rs @@ -947,18 +947,17 @@ fn settle_dispute( // Pay arbitration fee let arbitration_fee_amount = trade.amount.mul(hub_config.arbitration_fee_pct); + let mut release_amount = trade.amount.sub(arbitration_fee_amount); + + // Only deducts fees from the release_amount if the maker (offer owner) is the buyer + if trade.buyer.eq(&offer.owner) { + release_amount = release_amount.sub(fee_info.total_fees()); + } // Send funds to winner and arbitrator let denom = denom_to_string(&trade.denom); let arbitration_fee = vec![Coin::new(arbitration_fee_amount.u128(), denom.clone())]; - let winner_amount = vec![Coin::new( - trade - .amount - .u128() - .sub(arbitration_fee_amount.u128()) - .sub(fee_info.total_fees().u128()), - denom.clone(), - )]; + let winner_amount = vec![Coin::new(release_amount.u128(), denom.clone())]; send_msgs.push(SubMsg::new(create_send_msg(winner.clone(), winner_amount))); send_msgs.push(SubMsg::new(create_send_msg( trade.arbitrator.clone(),