Deploy the LikeRegistry with the current setup where userBalances are not updated.
Have two users like each other to create a match.
Check if the MultiSig wallet associated with this match receives any funds.
PoC Code:
```solidity
function testUserBalancesNotUpdated() public {
address user1 = address(0x123);
address user2 = address(0x456);
vm.deal(user1, 2 ether);
vm.deal(user2, 2 ether);
vm.prank(user1);
likeRegistry.likeUser{value: 1 ether}(user2);
vm.prank(user2);
likeRegistry.likeUser{value: 1 ether}(user1);
// Check if MultiSig wallet received any funds
address multiSigAddress = address(uint160(uint256(keccak256(abi.encodePacked(user1, user2)))));
assertEq(multiSigAddress.balance, 0, "MultiSig wallet should have zero balance since userBalances are not updated");
}
```
Explanation:
This PoC confirms that without updating userBalances in the likeUser function, no funds are transferred to the MultiSig wallet upon a match, showing the critical need to manage user balances correctly.
Ensure that userBalances are updated in the likeUser function to reflect each user's contribution:
```solidity
function likeUser(address liked) external payable {
require(msg.value == 1 ether, "Must send exactly 1 ETH");
// ... existing checks ...
userBalances[msg.sender] += msg.value; // Update this line to reflect payments
// ... rest of the function
}```
Here is how the matchRewards function might look with console logging for debugging:
```solidity
function matchRewards(address from, address to) internal {
uint256 matchUserOne = userBalances[from];
uint256 matchUserTwo = userBalances[to];
console.log("User1 balance:", matchUserOne);
console.log("User2 balance:", matchUserTwo);
userBalances[from] = 0;
userBalances[to] = 0;
uint256 totalRewards = matchUserOne + matchUserTwo;
uint256 matchingFees = (totalRewards * FIXEDFEE) / 100;
uint256 rewards = totalRewards - matchingFees;
totalFees += matchingFees;
console.log("Total rewards:", totalRewards);
console.log("Fees:", matchingFees);
console.log("Rewards to transfer:", rewards);
// Deploy a MultiSig contract for the matched users
MultiSigWallet multiSigWallet = new MultiSigWallet(from, to);
console.log("Attempting transfer to MultiSig wallet:", address(multiSigWallet), "with amount:", rewards);
(bool success,) = payable(address(multiSigWallet)).call{value: rewards}("");
require(success, "Transfer to MultiSig failed");
console.log("Transfer to MultiSig successful, new balance:", address(multiSigWallet).balance);
}
```