Skip to content

Commit

Permalink
Merge pull request #13 from bob-collective/peter/fix-btc-marketplace-…
Browse files Browse the repository at this point in the history
…sell-orders

fix: decrease amounts on order acceptance and delete accepted order f…
  • Loading branch information
sander2 authored Oct 6, 2023
2 parents e72a98d + 144d92b commit c090446
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contracts/bridge/src/btc_marketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit c090446

Please sign in to comment.