Loans#

class defichain.transactions.builder.modules.Loans(builder)#

The methods of this module create loan transactions

  1. takeloan: transaction to take a loan in the desired amount out of the specified vault

  2. paybackloan: transaction to pay back the loan token to the specified vault

takeloan(vaultId: str, addressTo: str, amounts: str | [str], inputs=[]) Transaction#

Creates a transaction to take a loan in the desired amount out of the specified vault

>>> builder.loans.takeloan("8040fe5eaa75f942dabf57bcdace3a5b71e3eb4fab53467e064e870396913800", "df1qrvrnk0zyaen8x3pfrza3yznwrrrv5y08rkgrk2", ["1@DUSD", "2@COIN"]) # takes loan from a vault
Parameters:
  • vaultId (str) – (required) vault id

  • addressTo (str) – (required) address to transfer tokens to

  • amounts (Amounts) – (required) string with amount and token separated by an @

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction

paybackloan(vaultId: str, addressFrom: str, amounts: str | [str], inputs=[]) Transaction#

Creates a transaction to pay back the loan token to the specified vault

>>> builder.loans.paybackloan("8040fe5eaa75f942dabf57bcdace3a5b71e3eb4fab53467e064e870396913800", "df1qrvrnk0zyaen8x3pfrza3yznwrrrv5y08rkgrk2", ["1@DUSD", "2@COIN"]) # pay backs loan to a vault
Parameters:
  • vaultId (str) – (required) vault id

  • addressFrom (str) – (required) address containing repayment tokens

  • amounts (Amounts) – (required) string with amount and token separated by an @

  • inputs ([TxInput]) – (optional) additional inputs to spend

Returns:

Transaction