Skip to content

Commit

Permalink
fix: MigratorZap: handle punk transfers to V3 vault
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvlathey committed May 10, 2024
1 parent 8c80191 commit 0b08371
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/zaps/MigratorZap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -385,19 +385,37 @@ contract MigratorZap is Ownable {
)
{
vTokenV3 = v3NFTXFactory.vault(vaultIdV3);
address assetAddress = INFTXVaultV3(vTokenV3).assetAddress();
bool isCryptoPunk = (assetAddress == TransferLib.CRYPTO_PUNKS);

// random redeem v2 vTokens. Directly transferring to the v3 vault
uint256[] memory idsToRedeem;
uint256[] memory emptyArray;
uint256[] memory idsRedeemed = INFTXVaultV2(vTokenV2).redeemTo(
vTokenV2Balance / 1 ether,
idsToRedeem,
is1155 ? address(this) : vTokenV3
emptyArray,
is1155 ? address(this) : (isCryptoPunk ? address(this) : vTokenV3)

This comment has been minimized.

Copy link
@dmitriia

dmitriia Jun 7, 2024

What about CRYPTO_KITTIES? As far as I see they also don't support direct pushing:

NFTXVaultUpgradeableV3.sol#L971-L978

        if (assetAddr != CRYPTO_PUNKS && assetAddr != CRYPTO_KITTIES) {
            // Default
            // Allow other contracts to "push" into the vault, safely.
            // If we already have the token requested, make sure we don't have it in the list to prevent duplicate minting.
            if (
                IERC721Upgradeable(assetAddress).ownerOf(tokenId) ==
                address(this)
            ) {

NFTXVaultUpgradeableV3.sol#L1003-L1015

        } else {
            // CRYPTO_KITTIES
            data = abi.encodeWithSignature(
                "transferFrom(address,address,uint256)",
                msg.sender,
                address(this),
                tokenId
            );
        }

        (bool success, bytes memory resultData) = address(assetAddr).call(data);
        require(success, string(resultData));
    }

This comment has been minimized.

Copy link
@apoorvlathey

apoorvlathey Jun 10, 2024

Author Member

You're right. We wanted to have minimal changes and punks were the priority for migration.

Kitties holders can manually migrate without the zap.

);
if (isCryptoPunk) {
for (uint256 i; i < idsRedeemed.length; ) {
// from TransferLib._approveCryptoPunkERC721()
bytes memory data = abi.encodeWithSignature(
"offerPunkForSaleToAddress(uint256,uint256,address)",
idsRedeemed[i],
0,
vTokenV3 // to = v3 vault address
);
(bool success, bytes memory resultData) = TransferLib
.CRYPTO_PUNKS
.call(data);
require(success, string(resultData));

unchecked {
++i;
}
}
}
if (is1155) {
IERC1155(INFTXVaultV3(vTokenV3).assetAddress()).setApprovalForAll(
vTokenV3,
true
);
IERC1155(assetAddress).setApprovalForAll(vTokenV3, true);
}

// fractional portion of vToken would be left
Expand Down

0 comments on commit 0b08371

Please sign in to comment.