Skip to content

Loan and Decentralized Tokenization

Prasanna Loganathar edited this page Oct 15, 2021 · 20 revisions

Warning: Loans are in testing phase and is an experimental feature.

Interacting with Defichain loans requires multiple steps. Please refer to the pinkpaper to understand the different concepts such as :

  • Collateral requirements
  • Liquidation
  • Auctions

This tutorial will teach you how to create a vault, take and payback a loan, and bid on an auction through the command line interface.

Create a vault

Prerequisites

  • ownerAddress: Any DFI address with 2 DFI utxo (1 DFI fee for vault creation, 1 converted to collateral transparently, which is reclaimed on closevault).
./defi-cli createvault <ownerAddress> <vaultId> <loanSchemeId>

List collaterals

./defi-cli listcollateraltokens

Send collaterals to address

./defi-cli utxostoaccount '{"<address>":"<amount(`value@token`)>"}'

Deposit to vault

Prerequisites

  • Any DFI address with collaterals
./defi-cli deposittovault <vaultId> <address> <amount(`value@token`)>

List loan tokens

List all available tokens to take a loan from.

./defi-cli listloantokens 

Take a loan

Prerequisites

./defi-cli takeloan '{"vaultId":"<vaultId>", "amounts":"<amount(`value@token`)>"}'

Payback loan

Prerequisite

  • Any DFI address with enough loan tokens to payback loan
./src/defi-cli loanpayback '{"vaultId":"<vaultId>", "from":"<DFI Address>","amounts":"<amount(`value@token`)>"}'

Withdraw collaterals from vault

Prerequisite

  • Enought collaterals to keep collateralization ratio above the one defined by the chosen loan scheme after withdrawal
  • To withdraw all collaterals, there should not be any active loans in vault
./src/defi-cli withdrawfromvault <vaultId> <address> <amount(`value@token`)>

Loan utility functions

Get general loan informations

./src/defi-cli getloaninfo

List collateral tokens

./src/defi-cli listcollateraltokens     

List loan tokens

./src/defi-cli listloantokens

List all available loan schemes

./src/defi-cli listloanschemes

Get loan scheme

./src/defi-cli getloanscheme <loanSchemeId>

Get interest info

./src/defi-cli getinterest <loanSchemeId>

Vault utility functions

Get a vault

./defi-cli getvault <vaultId>

Update a vault

./defi-cli updatevault <vaultId> '{"ownerAddress":"<address>", "loanSchemeId":"<loanSchemeId>"}'

List vaults

Use listvaults to get all vaults owned by an address

./defi-cli listvaults '{"ownerAddress":"<address>"}'

Close vault

Prerequisites

  • Any DFI address to receive collaterals (if any) and half of creation fee back (other half is burnt).
./defi-cli closevault <vaultId> <address>

Clone this wiki locally