From b1a27d9be6d75a7ac1cbcfe2e30d0565ab268c61 Mon Sep 17 00:00:00 2001 From: Nikola Date: Thu, 4 Nov 2021 11:36:58 +0100 Subject: [PATCH 1/6] Remove unused variable --- contracts/SwapKiwi.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/SwapKiwi.sol b/contracts/SwapKiwi.sol index 37464ff..61384f4 100644 --- a/contracts/SwapKiwi.sol +++ b/contracts/SwapKiwi.sol @@ -14,7 +14,6 @@ contract SwapKiwi is Ownable, IERC721Receiver { uint256 public fee; - mapping (address => uint256) private _balances; mapping (uint256 => Swap) private _swaps; struct Swap { From f353b89c24264ff7e022d67480d47d19f3eeda34 Mon Sep 17 00:00:00 2001 From: Nikola Date: Thu, 4 Nov 2021 11:37:20 +0100 Subject: [PATCH 2/6] Emit event when app fee changes --- contracts/SwapKiwi.sol | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contracts/SwapKiwi.sol b/contracts/SwapKiwi.sol index 61384f4..565f6b4 100644 --- a/contracts/SwapKiwi.sol +++ b/contracts/SwapKiwi.sol @@ -45,6 +45,9 @@ contract SwapKiwi is Ownable, IERC721Receiver { uint256[] nftIds, uint256 etherValue ); + event AppFeeChanged( + uint256 indexed fee + ); modifier onlyInitiator(uint256 swapId) { require(msg.sender == _swaps[swapId].initiator, @@ -67,8 +70,9 @@ contract SwapKiwi is Ownable, IERC721Receiver { super.transferOwnership(contractOwnerAddress); } - function setAppFee(uint newFee) public onlyOwner { + function setAppFee(uint newFee) external onlyOwner { fee = newFee; + emit AppFeeChanged(newFee); } /** From 2fc91716bfa119445352eba5dbdd39affa9d8eb3 Mon Sep 17 00:00:00 2001 From: Nikola Date: Thu, 4 Nov 2021 11:37:57 +0100 Subject: [PATCH 3/6] Fix accepting NFT+ETH swaps --- contracts/SwapKiwi.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contracts/SwapKiwi.sol b/contracts/SwapKiwi.sol index 565f6b4..2fe3791 100644 --- a/contracts/SwapKiwi.sol +++ b/contracts/SwapKiwi.sol @@ -183,11 +183,15 @@ contract SwapKiwi is Ownable, IERC721Receiver { if (_swaps[swapId].initiatorEtherValue != 0) { _etherLocked -= _swaps[swapId].initiatorEtherValue; - _swaps[swapId].secondUser.transfer(_swaps[swapId].initiatorEtherValue); + uint amountToTransfer = _swaps[swapId].initiatorEtherValue; + _swaps[swapId].initiatorEtherValue = 0; + _swaps[swapId].secondUser.transfer(amountToTransfer); } if (_swaps[swapId].secondUserEtherValue != 0) { _etherLocked -= _swaps[swapId].secondUserEtherValue; - _swaps[swapId].initiator.transfer(_swaps[swapId].secondUserEtherValue); + uint amountToTransfer = _swaps[swapId].secondUserEtherValue; + _swaps[swapId].secondUserEtherValue = 0; + _swaps[swapId].initiator.transfer(amountToTransfer); } emit SwapExecuted(_swaps[swapId].initiator, _swaps[swapId].secondUser, swapId); From f9a1e0cab38e51b691a0bbc8cb4a10e1fad42fa4 Mon Sep 17 00:00:00 2001 From: Nikola Date: Thu, 4 Nov 2021 14:28:05 +0100 Subject: [PATCH 4/6] Dont't index AppFeeChanged event --- contracts/SwapKiwi.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/SwapKiwi.sol b/contracts/SwapKiwi.sol index 2fe3791..cc8df81 100644 --- a/contracts/SwapKiwi.sol +++ b/contracts/SwapKiwi.sol @@ -46,7 +46,7 @@ contract SwapKiwi is Ownable, IERC721Receiver { uint256 etherValue ); event AppFeeChanged( - uint256 indexed fee + uint256 fee ); modifier onlyInitiator(uint256 swapId) { From e681ac6e07031b794a7cd42a183ab5f54083fe0a Mon Sep 17 00:00:00 2001 From: Nikola Date: Thu, 4 Nov 2021 15:07:05 +0100 Subject: [PATCH 5/6] Fix canceling NFT+ETH swaps --- contracts/SwapKiwi.sol | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contracts/SwapKiwi.sol b/contracts/SwapKiwi.sol index cc8df81..21b755f 100644 --- a/contracts/SwapKiwi.sol +++ b/contracts/SwapKiwi.sol @@ -230,14 +230,17 @@ contract SwapKiwi is Ownable, IERC721Receiver { if (_swaps[swapId].initiatorEtherValue != 0) { _etherLocked -= _swaps[swapId].initiatorEtherValue; - _swaps[swapId].initiator.transfer(_swaps[swapId].initiatorEtherValue); + uint amountToTransfer = _swaps[swapId].initiatorEtherValue; + _swaps[swapId].initiatorEtherValue = 0; + _swaps[swapId].initiator.transfer(amountToTransfer); } if (_swaps[swapId].secondUserEtherValue != 0) { _etherLocked -= _swaps[swapId].secondUserEtherValue; - _swaps[swapId].secondUser.transfer(_swaps[swapId].secondUserEtherValue); + uint amountToTransfer = _swaps[swapId].secondUserEtherValue; + _swaps[swapId].secondUserEtherValue = 0; + _swaps[swapId].secondUser.transfer(amountToTransfer); } - emit SwapCanceled(msg.sender, swapId); delete _swaps[swapId]; From 90dadce868bc116309e926fa4375f0b7723f5615 Mon Sep 17 00:00:00 2001 From: Nikola Date: Thu, 4 Nov 2021 15:09:34 +0100 Subject: [PATCH 6/6] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 30cca11..760882b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@niftyhorde/swap-kiwi-contracts", - "version": "0.5.0-beta", + "version": "0.6.0-beta", "private": false, "repository": { "url": "git@github.com:niftyhorde/swap.kiwi.git",