In the divideNft
function inside the TokenDivider
contract, we can lock an NFT with specific token id to the contract, then get the specific amount of ERC20 token in return. Later on, anybody can claim the NFT by converting back the required amount of ERC20 token based on the data stored during divideNft
call.
This contract doesn't regard the NFT token id. So any token id sent to this contract, will be stored based on the NFT address. If anyone had the same NFT address with different token id called divideNft
again, the prior divideNft
stored data will be overriden with the newest one. And the previous NFT can't be claimed anymore.
In the dividenNft
function, once the NFT is transfered from the function caller to the TokenDivider contract, the contract then set some data onchain, importantly the NFT data:
as we can see, the nftToErc20Info
is an array or mapping that stores ERC20Info based on the NFT address. But an NFT address could have more than 1 token id. So by this logic, if we divide two different token id of the same NFT address, one will override the other.
A detailed test suite could be seen below:
if there already NFT stored inside the TokenDivider, any new divideNft
call will overrides the NFT information, including the ERC20 address, amount, and NFT token id. Which lead to the previously locked NFT will never be claimed because the ERC20 information is gone.
Foundry
There are 2 suggestions depends on the design,
If by design sponsor want to keep only 1 NFT token from same address at the same time, the divideNft
function should check if the ERC721 address already stored and an NFT is locked in the TokenDivider contract.
But if the sponsor want to accept multiple NFT tokens from same address at the same time, nftToErc20Info[nftAddress]
should be updated by either use array or mapping to store multiple token ids.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.