CDP Manager
The DssCdpManager (aka manager) was created to enable a formalized process for Vaults to be transferred between owners, much like assets are transferred. It is recommended that all interactions with Vaults be done through the CDP Manager. Once unlocked collateral has been deposited into the Sky Protocol, users can make use of the following features:
- Multi Vault ownership and numerical identification (users can own N number of Vaults)
- Vault transferability
Contract Details
Section titled “Contract Details”Key Functionalities (as defined in the smart contract)
Section titled “Key Functionalities (as defined in the smart contract)”cdpAllow(uint cdp, address usr, uint ok): Allow/Disallow (ok) ausraddress to manage thecdp.urnAllow(address usr, uint ok): Allow/Disallow (ok) ausraddress to interact with an urn for the purposes of either entering (src) or quitting (dst).open(bytes32 ilk, address usr): Opens a new Vault forusrto be used for anilkcollateral type.give(uint cdp, address dst): Transferscdptodst.frob(uint cdp, int dink, int dart): Increments/decrements theinkamount of collateral locked and increments/decrements theartamount of debt in thecdpdepositing the generated DAI or collateral freed in thecdpaddress.frob(uint cdp, address dst, int dink, int dart): Increments/decrements theinkamount of collateral locked and increments/decrements theartamount of debt in thecdpdepositing the generated DAI or collateral freed into a specifieddstaddress.flux(bytes32 ilk, uint cdp, address dst, uint wad): Moveswad(precision 18) amount of collateralilkfromcdptodst.flux(uint cdp, address dst, uint wad): Moveswadamount ofcdpcollateral fromcdptodst.move(uint cdp, address dst, uint rad): Movesrad(precision 45) amount of DAI fromcdptodst.quit(uint cdp, address dst): Moves the collateral locked and debt generated fromcdptodst.
Note: dst refers to the destination address.
Storage Layout
Section titled “Storage Layout”vat: core contract address that holds the Vaults.cdpi: Auto incremental id.urns: MappingCDPId => UrnHandlerlist: MappingCDPId => Prev & Next CDPIds(double linked list)owns: MappingCDPId => Ownerilks: MappingCDPId => Ilk(collateral type)first: MappingOwner => First CDPIdlast: MappingOwner => Last CDPIdcount: MappingOwner => Amount of CDPsallows: MappingOwner => CDPId => Allowed Addr => True/False
Key Mechanisms & Concepts
Section titled “Key Mechanisms & Concepts”Summary
Section titled “Summary”The CDP Manager was created as a way to enable Vaults to be treated more like assets that can be exchanged. Originally, the dss core contracts did not have the functionality to enable transferring Vault positions. The CDP Manager was created to wrap this functionality and enable transferring between users.
High-level Purpose
Section titled “High-level Purpose”- The
managerreceives thevataddress in its creation and acts as an interface contract between it and the users. - The
managerkeeps an internal registry ofid => ownerandid => urnallowing for theownerto executevatfunctions for theirurnvia themanager. - The
managerkeeps a double linked list structure that allows the retrieval of all the Vaults that anownerhas via on-chain calls.- In short, this is what the
GetCdpsis for. This contract is a helper contract that allows the fetching of all the Vaults in just one call.
- In short, this is what the
CDP Manager Usage Example (common path):
Section titled “CDP Manager Usage Example (common path):”- A User executes
openand gets aCDPIdin return. - After this, the
CDPIdgets associated with anurnwithmanager.urns(cdpId)and thenjoin’s collateral to it. - The user can then execute
frobto choose whichdstaddress they want to use to send the generated DAI to. - If the user executes
frobwithoutdstthen the generated DAI will remain in the Vault’surn. In this case, the user canmoveit at a later point in time.- Note that this is the same process for collateral that is freed after
frob(for thefrobfunction that doesn’t require thedstaddress). The user canfluxit to another address at a later time.
- Note that this is the same process for collateral that is freed after
- In the case where a user wants to abandon the
manager, they can usequitas a way to migrate their position of their Vault to anotherdstaddress.
Gotchas (Potential source of user error)
Section titled “Gotchas (Potential source of user error)”- For the developers who want to integrate with the
manager, they will need to understand that the Vault actions are still in theurnenvironment. Regardless of this, themanagertries to abstract theurnusage by aCDPId. This means that developers will need to get theurn(urn = manager.urns(cdpId)) to allow thejoining of collateral to that Vault. - As the
managerassigns a specificilkperCDPIdand doesn’t allow others to use it for theirs, there is a secondfluxfunction which expects anilkparameter. This function has the simple purpose of taking out collateral that was wrongly sent to a Vault that can’t handle it/is incompatible. - Frob Function(s):
- When you
frobin the CDP manager, you generate new DAI in thevatvia the CDP manager which is then deposited in theurnthat the CDP manager manages. This process depends on whichfrobfunction you use (there exist twofrobfunctions). In short, one allows a destination address and the other doesn’t require it. - If you use the
frobfunction that has the destiny (dst) address, you are saying that you can send any Dai generated or collateral that has been freed. The secondfrobfunction is meant for leaving the collateral in theurnaddress because theurnis owned by the CDP manager. In this case, you would need to manually use thefluxormovefunctions to get the DAI or collateral out. These functions (fluxandmove) may be more beneficial for a developer working with the proxy function, as it allows for more flexibility. For example, by using these functions you can move a specific amount of collateral and can use the other functions to do it. Overall, it can make working with it a little more flexible on specific developer needs.
- When you
- As mentioned above in the summary, the dss core contracts originally did not have the functionality to enable the transfer of Vault positions. Since then, the core contracts have also implemented a native transfer functionality called
forkwhich allows the transferring of a Vault to another address. However, there is a restriction, which is that the address owner that will be receiving the Vault needs to provide authorization that they do in fact want to receive it. This was created for the situation when a user is transferring the collateral that is locked as well as the debt generated. If you are simply moving collateral to another address, there is no issue but in the case that you are also transferring the debt generated, there is a chance of putting a perfectly safe Vault in a risky position. This makes the contract functionality a little more restrictive. Therefore, the CDP manager is a good option to keep a simple way of transferring Vaults and recognizing them via a numeric ID.
Failure Modes (Bounds on Operating Conditions & External Risk Factors)
Section titled “Failure Modes (Bounds on Operating Conditions & External Risk Factors)”Potential Issues around Chain Reorganization
Section titled “Potential Issues around Chain Reorganization”When open is executed, a new urn is created and a cdpId is assigned to it for a specific owner. If the user uses join to add collateral to the urn immediately after the transaction is mined, there is a chance that a reorganization of the chain occurs. This would result in the user losing the ownership of that cdpId/urn pair, therefore losing their collateral. However, this issue can only arise when avoiding the use of the proxy functions via a profile proxy as the user will open the cdp and join collateral in the same transaction.
Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license.