diff --git a/src/Cally.sol b/src/Cally.sol index e8ca19a..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; @@ -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); } 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; 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" + ); } }