Vectorized / dn404

Implementation of a co-joined ERC20 and ERC721 pair.
MIT License
476 stars 158 forks source link

♻️ Invariant Suite Refactor #137

Closed GuardianAudits closed 6 months ago

GuardianAudits commented 6 months ago

Description

Increases coverage and adds numerous assertions for the invariant tests.

Invariant Status
Sum of Owned NFTs == Mirror Total Supply
Sum of Owned ERC20 == Token Total Supply
Mirror And Base Token Are Unchanged Post-Initialization
Burned Pool Length == Tail - Head
No User Owns type(uint32).max NFT
Allowance Matches Approved Amount
Owner Auxiliary Data Is Not Modified Upon Approval
Spender Auxiliary Data Is Not Modified Upon Approval
Direct Transfers Do Not Overlap With Burned Pool Upon Transfer
ERC20 Balance Changes By Amount For Sender And Receiver Upon Transfer
ERC20 Balance Remains The Same Upon Self-Transfer
ERC20 Total Supply Remains The Same Upon Transfer
Auxiliary Data Is Not Modified Upon Transfer
Direct Transfers Do Not Overlap With Burned Pool Upon TransferFrom
ERC20 Balance Changes By Amount For Sender And Receiver Upon TransferFrom
ERC20 Balance Is the Same Upon Self-Transfer Upon TransferFrom
Auxiliary Data Is Not Modified Upon TransferFrom
User Balance Increased By Mint Amount
Total ERC20 Supply Increased By Mint Amount
Total NFT Supply Post-Mint Is At Least Total NFT Supply Pre-Mint
Auxiliary Data Is Not Modified Upon Mint
User’s Owned NFTs Decreased Upon Burn
ERC20 Total Supply Decreased By Burn Amount
Total NFT Supply Post-Burn Is At Most Total NFT Supply Pre-Burn
Auxiliary Data Is Not Modified Upon Burn
Approved NFT Spender == Requested Approval
Owner Of NFT ID Is Not Modified Upon Approval Of NFT
Owner Auxiliary Data Is Not Modified Upon Approval
Spender Auxiliary Data Is Not Modified Upon Approval
NFT Balance Of Sender And Receiver Accurately Updated Upon TransferNFT
Sender/Receiver ERC20 Balance Decremented/Incremented By Unit
Receiver Address Is The Owner At The Sent NFT ID
Total NFT Supply Is Unchanged Upon NFT Transfer
Approval Is Reset Upon NFT Transfer
Sender Auxiliary Data Is Not Modified Upon NFT Transfer
Receiver Auxiliary Data Is Not Modified Upon NFT Transfer
Skip NFT Status Is Updated To Requested Status
Auxiliary Data Is Not Modified Upon Set Skip NFT
Set Approval For All Updated To Requested Status
Owner Auxiliary Data Is Not Modified Upon Set Approval For All
Spender Auxiliary Data Is Not Modified Upon Set Approval For All
Mint Next Does Not Overlap With Burned Pool
Mint Next Increases User’s Owned NFTs If NFT Minted
User Balance Increased By Mint Next Amount
Total ERC20 Supply Increased By Mint Next Amount
_ownerAt(id) Is Always The Same As NFT Holder

Checklist

Ensure you completed all of the steps below before submitting your pull request:

Pull requests with an incomplete checklist will be thrown out.