Vault manager
The vault manager works with vaults that are owned by the CdpManager contract, which is also used by Oasis Borrow. This intermediary contract allows the use of incrementing integer IDs for vaults, familiar to users of Single-Collateral Sai, as well as other conveniences.
In the code, this is called CdpManager.
Instance methods
The methods below are all asynchronous.
getCdpIds()
Return an array describing the vaults owned by the specified address. Note that if the vaults were created in Oasis Borrow, the address of the proxy contract should be used.
getCdp()
Get an existing vault by its numerical ID. Returns a Vault instance.
open()
Open a new vault with the specified collateral type. Will create a proxy if one does not already exist. Returns a Vault instance. Works with the transaction manager.
openLockAndDraw()
Open a new vault, then lock and/or draw in a single transaction. Will create a proxy if one does not already exist. Returns a Vault instance.
Vault instances
In the code, these are called ManagedCdp.
Properties
A note on caching: When a vault instance is created, its data is pre-fetched from the blockchain, allowing the properties below to be read synchronously. This data is cached in the instance. To refresh this data, do the following:
collateralAmount
The amount of collateral tokens locked, as a currency unit.
collateralValue
The USD value of collateral locked, given the current price according to the price feed, as a currency unit.
debtValue
The amount of Dai drawn, as a currency unit.
liquidationPrice
The USD price of collateral at which the Vault becomes unsafe.
isSafe
Whether the Vault is currently safe or not.
Instance methods
All of the methods below are asynchronous and work with the transaction manager. Amount arguments should be currency units, e.g.:
lockCollateral(amount)
Deposit the specified amount of collateral.
drawDai(amount)
Generate the specified amount of Dai.
lockAndDraw(lockAmount, drawAmount)
Deposit some collateral and generate some Dai in a single transaction.
wipeDai(amount)
Pay back the specified amount of Dai.
wipeAll()
Pay back all debt. This method ensures that dust amounts do not remain.
freeCollateral(amount)
Withdraw the specified amount of collateral.
wipeAndFree(wipeAmount, freeAmount)
Pay back some debt and withdraw some collateral in a single transaction.
wipeAllAndFree(freeAmount)
Pay back all debt, ensuring dust amounts do not remain, and withdraw a specified amount of collateral in a single transaction.
give(address)
Transfer ownership of this vault to address
. Note that if the new owner plans to use this vault with Oasis Borrow, it should be transferred to their proxy with giveToProxy instead.
giveToProxy(address)
Look up the proxy contract owned by address
and transfer ownership of this vault to that proxy.
Last updated