Vault and loan with CLI
Based on the information provided in Vaults and Loans, this guide will describe all steps on how to generate a DFI only vault to mint some dUSD to profit from the negative interest rate.
Key learningsβ
- Set up a wallet on the Testnet and ensure that it has enough DFI for the vault creation process
- Use the CLI to create a new vault and deposit DFI into it
- Use the CLI to estimate and take out a dUSD loan from the vault
- Check the status of the vault and loan using the CLI
- Repay the loan and close the vault using the CLI
Preparationsβ
- Ensure that your wallet has at least 2 DFI available for the vault creation.
- 1 DFI is burned during creation, the other one is paid back when the vault is closed.
- Unlock your wallet
- Navigate to the CLI within the Desktop Wallet.
The CLI is very fragile when it comes to spaces within the commands. It is recommended to remove spaces wherever possible.
Let's start with a new wallet on the Testnet filled with 1000 DFI from the Testnet faucet.
listaddressgroupings
Expected output
Vault creationβ
To generate a new vault, the command createvault "ownerAddress" ("loanSchemeId")
is used.
For a list of all available schemes, call listloanschemes
.
In this example we use the default loan scheme MIN150
so we just specify the account address. transaction
createvault tbRQNwSTJ3rqGbFnx17ng4BuGyz3s4fEtH
Expected output
The transaction ID is automatically the vaultid
.
Next, get a list of all vaults within the wallet.
listvaults {"ownerAddress":"tbRQNwSTJ3rqGbFnx17ng4BuGyz3s4fEtH"}
Expected output
Or directly call getvault "{vaultId}"
with the provided transaction ID of the vault creation step
getvault "40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b"
Expected output
After vault generation, the balances might have been transferred to another address within the wallet.
listaddressgroupings
Expected output
Vault DFI depositβ
Next, deposit some DFI into the generated vault.
Only tokens can be deposited into the vault, so transfer UTXO to token if needed using the command utxotoaccount {"address":"amount@token"}
. transaction
utxostoaccount {"tgPJbMNsGzXVBsn57KZGGCZXsF4K88xRGB":"500@DFI"}
Expected output
waitfornewblock
Then deposit the DFI in the vault with the command deposittovault "vaultId" "fromAddress" "amount"
. transaction
deposittovault 40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b tgPJbMNsGzXVBsn57KZGGCZXsF4K88xRGB 500@DFI
Expected output
waitfornewblock
getvault 40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b true
Expected output
Vault dUSD loanβ
Now we are eligible to take a loan out of the vault.
Estimate loanβ
For the case you like to take as much dUSD as possible out of your vault, use the estimateloan "vaultId" {"split":n} targetRatio
command.
Here as an example with a split into 100% dUSD token and a collateral of at least 150% (the minimum of the chosen loan scheme).
estimateloan "40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b" {"DUSD":1.0} 150
Take dUSD loanβ
With the command takeloan {"vaultId":"hex","to":"address","amounts":"str"}
the loan can be taken from the vault. transaction
takeloan {"vaultId":"40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b","to":"tgPJbMNsGzXVBsn57KZGGCZXsF4K88xRGB","amounts":"100@DUSD"}
Expected output
waitfornewblock
getvault 40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b true
Expected output
Loop dUSD loanβ
If you just want to profit from the negative interest rate, the taken loan dUSD tokens can be deposit back into the vault as additional collateral. transaction
deposittovault 40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b tgPJbMNsGzXVBsn57KZGGCZXsF4K88xRGB 100@DUSD
Expected output
waitfornewblock
getvault 40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b true
Expected output
As seen in the result, we get already our first negative interest onto the dUSD loan, so the payback amount is not 100DUSD anymore.
Payback Loanβ
Because we deposit the loan dUSD tokens into the collateral, we should first pay back the dUSD loan with our dUSD collateral.
To do so, use the command paybackwithcollateral "vaultId"
. transaction
paybackwithcollateral "40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b"
Expected output
waitfornewblock
getvault 40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b true
Expected output
Pay the remaining dUSD loan back with dUSD tokens from the wallet using the command paybackloan {"vaultId":"hex","from":"address","amounts":"str"}
Hint: It's save to define an amount which is higher than the collateral transaction
paybackloan {"vaultId":"40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b","from":"tbRQNwSTJ3rqGbFnx17ng4BuGyz3s4fEtH","amounts":"31@DUSD"}
Expected output
waitfornewblock
getvault 40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b true
Expected output
Withdraw Collateralβ
Withdraw the DFI collateral with the command withdrawfromvault "vaultId" "toAddress" "amount"
.
In case the vault gets closed afterward, this step can be skipped because the closevault
command automatically send all remaining collateral to the specified address.
withdrawfromvault "40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b" "tbRQNwSTJ3rqGbFnx17ng4BuGyz3s4fEtH" "500@DFI"
Expected output
waitfornewblock
getvault 40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b true
Expected output
Close the vaultβ
Optionally close the vault with the command closevault "vaultId" "toAddress"
. transaction
closevault "40bfc5ce57fb7203bb89fb22aabeac4a495c364bede02606ed01e60331288b9b" "tbRQNwSTJ3rqGbFnx17ng4BuGyz3s4fEtH"
Expected output
waitfornewblock
listvaults {"ownerAddress":"tbRQNwSTJ3rqGbFnx17ng4BuGyz3s4fEtH"}