Vault721
Smart contract code: Vault721****
1. Summary
Vault721 is an ERC721 that mints NFT-Vaults and serves as an ODProxy factory and registry. Once the user builds their proxy, they can interact with the protocol. When a user opens a safe, a NFT-Vault is minted to their account, which controls the ownership and transferability of the safe, where the tokenId is equal to the safeId. Transferrence of an NFT-Vault equates to the transferrence of the corresponding safe.
Note: NFT-Vault is owned directly by user account, whereas the safe is owned by the user's proxy.
2. Contract Variables & Functions
Variables
safeManager- address of SafeManager that recieves calls from the ODProxygovernor- address of DAO governance
Data Structures
_proxyRegistry- mapping of proxy addresses to their owners_userRegistry- mapping of user addresses to their proxies
Functions
initialize()- sets safeManager on deploymentgetProxy(user: address)- returns proxy of a userbuild()- create a new ODProxy for callerbuild(user: address)- create a new ODProxy for usermint(proxy: address, safeId: uint)- called by the SafeManager onopenSAFE, mints NFT to user wallet that gate-keeps safeupdateImplementation(safeManager: address)- authed to governor, updates safeManager
Overrided / Inherited Functions: ERC721
safeTransferFrom(from: address, to: address, tokenId: uint)- transfer token, enforceonERC721Received_afterTokenTransfer- enforces SafeManager.transferSAFEOwnership
transferFrom(from: address, to: address, tokenId: uint)- transfer token_afterTokenTransfer- enforces SafeManager.transferSAFEOwnership
Events
CreateProxy- emitted on_build- user - address of user
- proxy - address of proxy owned by user
Transfer- emitted on_transfer- from - address of sender
- to - address of reciever
- tokenId - uint of NFT id
Approval- emitted on_approve- owner - address of sender
- approved - address of approved account
- tokenId - uint of approved NFT id
ApprovalForAll- emitted on_setApprovalForAll- owner - address of owner
- operator - address of operator
- approved - bool of operator approval