From 9aa927fa0b35c496e34999529e904a9f9a7835d2 Mon Sep 17 00:00:00 2001 From: outdoteth Date: Tue, 17 May 2022 12:32:03 +0100 Subject: [PATCH 1/3] Add additional assert --- test/units/BuyOption.t.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/units/BuyOption.t.sol b/test/units/BuyOption.t.sol index cffaa8f..4493928 100644 --- a/test/units/BuyOption.t.sol +++ b/test/units/BuyOption.t.sol @@ -250,5 +250,10 @@ contract TestBuyOption is Fixture { // assert assertEq(c.ownerOf(optionId), address(this), "Should have given option to buyer"); assertEq(c.ethBalance(babe), premium, "Should have credited premium ETH to babe"); + assertEq( + c.vaults(vaultId).currentExpiration, + block.timestamp + uint32(durationDays) * 1 days, + "Should have updated the curent expiration" + ); } } From c5889bf4029414ee2aaeccf950a810743195d601 Mon Sep 17 00:00:00 2001 From: outdoteth Date: Tue, 17 May 2022 12:38:56 +0100 Subject: [PATCH 2/3] Switch to use safeTransferFrom --- src/Cally.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cally.sol b/src/Cally.sol index e8ca19a..9c35244 100644 --- a/src/Cally.sol +++ b/src/Cally.sol @@ -223,7 +223,7 @@ contract Cally is CallyNft, ReentrancyGuard, Ownable { // transfer the NFTs or ERC20s to the contract vault.tokenType == TokenType.ERC721 - ? ERC721(vault.token).transferFrom(msg.sender, address(this), vault.tokenIdOrAmount) + ? ERC721(vault.token).safeTransferFrom(msg.sender, address(this), vault.tokenIdOrAmount) : ERC20(vault.token).safeTransferFrom(msg.sender, address(this), vault.tokenIdOrAmount); } @@ -319,7 +319,7 @@ contract Cally is CallyNft, ReentrancyGuard, Ownable { // transfer the NFTs or ERC20s to the exerciser vault.tokenType == TokenType.ERC721 - ? ERC721(vault.token).transferFrom(address(this), msg.sender, vault.tokenIdOrAmount) + ? ERC721(vault.token).safeTransferFrom(address(this), msg.sender, vault.tokenIdOrAmount) : ERC20(vault.token).safeTransfer(msg.sender, vault.tokenIdOrAmount); } @@ -368,7 +368,7 @@ contract Cally is CallyNft, ReentrancyGuard, Ownable { // transfer the NFTs or ERC20s back to the owner vault.tokenType == TokenType.ERC721 - ? ERC721(vault.token).transferFrom(address(this), msg.sender, vault.tokenIdOrAmount) + ? ERC721(vault.token).safeTransferFrom(address(this), msg.sender, vault.tokenIdOrAmount) : ERC20(vault.token).safeTransfer(msg.sender, vault.tokenIdOrAmount); } From 4cf9259770b52114fef7c96236abc355f1bdf860 Mon Sep 17 00:00:00 2001 From: outdoteth Date: Tue, 17 May 2022 12:48:59 +0100 Subject: [PATCH 3/3] Switch to use safeTransferFrom for ERC721 --- src/Cally.sol | 2 +- test/mocks/MockERC721.sol | 1 + test/shared/Fixture.t.sol | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Cally.sol b/src/Cally.sol index 9c35244..3fbfd6d 100644 --- a/src/Cally.sol +++ b/src/Cally.sol @@ -29,7 +29,7 @@ import "./CallyNft.sol"; /// @title Cally - https://cally.finance /// @author out.eth /// @notice NFT & ERC20 covered call vaults -contract Cally is CallyNft, ReentrancyGuard, Ownable { +contract Cally is CallyNft, ReentrancyGuard, Ownable, ERC721TokenReceiver { using SafeTransferLib for ERC20; using SafeTransferLib for address payable; diff --git a/test/mocks/MockERC721.sol b/test/mocks/MockERC721.sol index be7885c..37d3ad5 100644 --- a/test/mocks/MockERC721.sol +++ b/test/mocks/MockERC721.sol @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.13; + import "solmate/tokens/ERC721.sol"; contract MockERC721 is ERC721 { diff --git a/test/shared/Fixture.t.sol b/test/shared/Fixture.t.sol index d902ad4..13c1c18 100644 --- a/test/shared/Fixture.t.sol +++ b/test/shared/Fixture.t.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.0; import "forge-std/Test.sol"; +import "solmate/tokens/ERC721.sol"; import "../mocks/MockWeth.sol"; import "../mocks/MockERC721.sol"; @@ -9,7 +10,7 @@ import "../mocks/MockERC20.sol"; import "src/Cally.sol"; -abstract contract Fixture is Test { +abstract contract Fixture is Test, ERC721TokenReceiver { Cally internal c; MockERC721 internal bayc; MockERC20 internal link;