From 144d92bf7247cc8c552db8ef21b744f59506e88e Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 6 Oct 2023 15:27:45 +0200 Subject: [PATCH] fix: decrease amounts on order acceptance and delete accepted order from correct mapping --- contracts/bridge/src/btc_marketplace.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/bridge/src/btc_marketplace.sol b/contracts/bridge/src/btc_marketplace.sol index b31a01d1..d616ea0f 100644 --- a/contracts/bridge/src/btc_marketplace.sol +++ b/contracts/bridge/src/btc_marketplace.sol @@ -127,6 +127,9 @@ contract BtcMarketPlace { uint sellAmount = (amountBtc * order.askingAmount) / order.amountBtc; assert(sellAmount > 0); + assert(order.askingAmount >= sellAmount); + order.askingAmount -= sellAmount; + order.amountBtc -= amountBtc; // "lock" selling token by transferring to contract IERC20(order.askingToken).safeTransferFrom( @@ -199,7 +202,7 @@ contract BtcMarketPlace { // give accepter its tokens back IERC20(order.ercToken).safeTransfer(msg.sender, order.ercAmount); - delete btcSellOrders[id]; + delete acceptedBtcSellOrders[id]; emit cancelAcceptedBtcSellOrderEvent(id); }