Vault#

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

The methods of this module create vault transactions

  1. createvault: transaction for creating a vault

  2. deposittovault: transaction for depositing collateral token to a vault

  3. withdrawfromvault: transaction for withdraw of collateral from a vault

createvault(ownerAddress: str, schemeId: str, inputs=[]) Transaction#

Creates a transaction for creating a vault.

The creation of a vault will cost you 1 UTXO as a fee by the blockchain.

SchemeIDs mainnet: MIN1000, MIN500, MIN350, MIN200, MIN175, MIN150 SchemeIDs testnet: C1000, C500, C350, C200, C175, C150

>>> builder.vault.createvault("df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e", "MIN150") # creates a new vault
Parameters:
  • ownerAddress (str) – (required) the address where vault will be created

  • schemeId (str) – (required) the scheme id for the vault

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

Returns:

Transaction

deposittovault(vaultId: str, addressFrom: str, amount: str, inputs=[]) Transaction#

Creates a transaction for depositing collateral token to a vault

>>> builder.vault.deposittovault("5cbe99407674a689fa9b8a522462b7a4b3e7893f61453ce3fa77f1307f7d0600", "df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e", "100@DFI") # deposits collateral to a vault
Parameters:
  • vaultId (str) – (required) vault id

  • addressFrom (str) – (required) address containing collateral

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

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

Returns:

Transaction

withdrawfromvault(vaultId: str, addressTo: str, amount: str, inputs=[]) Transaction#

Creates a transaction for withdraw of collateral from a vault

>>> builder.vault.withdrawfromvault("5cbe99407674a689fa9b8a522462b7a4b3e7893f61453ce3fa77f1307f7d0600", "df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e", "100@DFI") # withdraws collateral from a vault
Parameters:
  • vaultId (str) – (required) vault id

  • addressTo (str) – (required) destination address for withdrawn collateral

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

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

Returns:

Transaction