-
Notifications
You must be signed in to change notification settings - Fork 129
Loan and Decentralized Tokenization
Prasanna Loganathar edited this page Oct 15, 2021
·
20 revisions
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.
-
ownerAddress: Any DFI address with 2 DFI in UTXO. (1 DFI fee for vault creation, 1 converted to collateral transparently, which is reclaimed onclosevault).
./defi-cli createvault <ownerAddress> <vaultId> <loanSchemeId>
./defi-cli listcollateraltokens
./defi-cli utxostoaccount '{"<address>":"<amount(`value@token`)>"}'
- Any DFI address with collaterals
./defi-cli deposittovault <vaultId> <address> <amount(`value@token`)>
List all available tokens to take a loan from.
./defi-cli listloantokens
- Enought collaterals in vault to respect collateralization ratio
- A valid loan token
./defi-cli takeloan '{"vaultId":"<vaultId>", "amounts":"<amount(`value@token`)>"}'
- Any DFI address with enough loan tokens to payback loan
./src/defi-cli loanpayback '{"vaultId":"<vaultId>", "from":"<DFI Address>","amounts":"<amount(`value@token`)>"}'
- 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`)>
./src/defi-cli getloaninfo
./src/defi-cli listcollateraltokens
./src/defi-cli listloantokens
./src/defi-cli listloanschemes
./src/defi-cli getloanscheme <loanSchemeId>
./src/defi-cli getinterest <loanSchemeId>
./defi-cli getvault <vaultId>
./defi-cli updatevault <vaultId> '{"ownerAddress":"<address>", "loanSchemeId":"<loanSchemeId>"}'
Use listvaults to get all vaults owned by an address
./defi-cli listvaults '{"ownerAddress":"<address>"}'
- Any DFI address to receive collaterals (if any) and half of creation fee back (other half is burnt).
./defi-cli closevault <vaultId> <address>