Loan#

class defichain.node.Loan(node)#
createloanscheme(mincolratio: int, interestrate: float, id: str, inputs: [{}] = None) str#

Creates a loan scheme transaction.

Parameters:
  • mincolratio (int) – (required) Minimum collateralization ratio (integer)

  • interestrate (float) – (required) Interest rate (integer or float)

  • id (str) – (required) Unique identifier of the loan scheme (8 chars max)

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.createloanscheme(150, 5, "MyScheme")
destroyloanscheme(id: str, ACTIVATE_AFTER_BLOCK: int = None, inputs: [{}] = None) str#

Destroys a loan scheme.

Parameters:
  • id (str) – (required) Unique identifier of the loan scheme (8 chars max)

  • ACTIVATE_AFTER_BLOCK (int) – (optional) Block height at which new changes take effect

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.destroyloanscheme("MyScheme")
getcollateraltoken(token: str) {}#

Return collateral token information.

Parameters:

token (str) – (required) Symbol or id of collateral token

Returns:

{…} (json) – Json object with collateral token information

Example:
>>> node.loan.getcollateraltoken("DFI")
getinterest(id: str, token: str = '') {}#

Returns the global and per block interest by loan scheme.

Parameters:
  • id (str) – (required) Unique identifier of the loan scheme (8 chars max)

  • token (str) – (optional) The token’s symbol, id or creation tx

Returns:

{…} (json) – Json object with interest information

interestPerBlock: Interest per block is always ceiled
to the min. unit of fi (8 decimals), however interest
less than this will continue to accrue until actual utilization
(eg. - payback of the loan), or until sub-fi maturity.

realizedInterestPerBlock: The actual realized interest
per block. This is continues to accumulate until
the min. unit of the blockchain (fi) can be realized.

Example:
>>> node.loan.getinterest("MyScheme", "DUSD")
getloaninfo() {}#

Returns the loan stats.

Returns:

{…} (json) – Json object with loan information

Example:
>>> node.loan.getloaninfo()
getloanscheme(id: str) {}#

Returns information about loan scheme.

Parameters:

id (str) – (required) Unique identifier of the loan scheme (8 chars max)

Returns:

{…} (json) – returns loanscheme from id

{
    "id" : n                   (string)
    "mincolratio" : n          (numeric)
    "interestrate" : n         (numeric)
}

Example:
>>> node.loan.getloanscheme("MyScheme")
getloantoken(token: str) {}#

Return loan token information.

Parameters:

token (str) – (required) Symbol or id of loan token

Returns:

{…} (json) – Json object with loan token information

Example:
>>> node.loan.getloantoken("DUSD")
listcollateraltokens() {}#

Return list of all created collateral tokens. If no parameters passed it will return all current valid setcollateraltoken transactions

Returns:

{…} (json) – Json object with collateral token information

Example:
>>> node.loan.listcollateraltokens()
listloanschemes() [{}]#

List all available loan schemes.

Returns:

[{…}] (json array) – returns list of loan schemes

[                              (json array of objects)
    {
    "id" : n                   (string)
    "mincolratio" : n          (numeric)
    "interestrate" : n         (numeric)
    },
    ...
]

Example:
>>> node.loan.listloanschemes()
listloantokens() {}#

Return list of all created loan tokens.

Returns:

{…} (json) – Json object with loan token information

Example:
>>> node.loan.listloantokens()
paybackloan(vaultId: str, _from: str, amounts: str = None, loans: [{}] = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a tx to return the loan in desired amount.

Parameters:
  • vaultId (str) – (required) Id of vault used for loan

  • _from (str) – (required) Address containing repayment tokens. If “from” value is: “*” (star), it’s means auto-selection accounts from wallet.

  • amounts (str) – (optional) Address Amount

  • loans (json array) –

    (optional) A json array of json objects

    [
        {                      (json object)
        "dToken": "str",     (string, required) The dTokens's symbol, id or creation tx
        "amounts": "str",    (string, required) Amount in amount@token format.
        },
        ...
    ]
    

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.paybackloan("84b22eee1964768304e624c416f29a91d78a01dc5e8e12db26bdac0670c67bb2", "mxxA2sQMETJFbXcNbNbUzEsBCTn1JSHXST", "10@TSLA")
setcollateraltoken(token: str, factor: float, fixedIntervalPriceId: str, activateAfterBlock: int = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a set colleteral token transaction.

Parameters:
  • token (str) – (required) Symbol or id of collateral token

  • factor (float) – (required) Collateralization factor

  • fixedIntervalPriceId (str) – (required) token/currency pair to use for price of token

  • activateAfterBlock (int) – (optional) changes will be active after the block height

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.setcollateraltoken("TSLA", 150, "TSLA/USD")
setdefaultloanscheme(id: str, inputs: [{}] = None) str#

Sets the default loan scheme.

Parameters:
  • id (str) – (required) Unique identifier of the loan scheme (8 chars max).

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.setdefaultloanscheme("MyScheme")
setloantoken(symbol: str, fixedIntervalPriceId: str, name: str = None, mintable: bool = True, interest: float = 0, inputs: [{}] = None) str#

Creates (and submits to local node and network) a token for a price feed set in collateral token.

Parameters:
  • symbol (str) – (required) Token’s symbol (unique), not longer than 8

  • fixedIntervalPriceId (str) – (required) token/currency pair to use for price of token

  • name (str) – (optional) Token’s name, not longer than 128

  • mintable (bool) – (optional) Token’s ‘Mintable’ property, default is ‘True’

  • interest (float) – (optional) Interest rate (default: 0)

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.setloantoken("TSLA", "TSLA/USD", "TSLA Stock", True, 5)
takeloan(vaultId: str, amounts: str, to: str = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a tx to mint loan token in desired amount based on defined loan.

Parameters:
  • vaultId (str) – (required) Id of vault used for loan

  • amounts (str) – (required) Address Amount

  • to (str) – (optional) Address to transfer tokens

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.takeloan("84b22eee1964768304e624c416f29a91d78a01dc5e8e12db26bdac0670c67bb2", "10@SPY")
updateloanscheme(mincolratio: int, interestrate: float, id: str, ACTIVATE_AFTER_BLOCK: int = None, inputs: [{}] = None) str#

Updates an existing loan scheme.

Parameters:
  • mincolratio (int) – (required) Minimum collateralization ratio

  • interestrate (float) – (required) Interest rate

  • id (str) – (required) Unique identifier of the loan scheme

  • ACTIVATE_AFTER_BLOCK (int) – (optional) Block height at which new changes take effect

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.updateloanscheme(150, 5, "MyScheme")
updateloantoken(token: str, symbol: str = None, name: str = None, fixedIntervalPriceId: str = None, mintable: bool = True, interest: float = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a transaction to update loan token metadata.

Parameters:
  • token (str) – (required) The tokens’s symbol, id or creation tx

  • symbol (str) – (optional) New token’s symbol (unique), not longer than 8

  • name (str) – (optional) New token’s name, not longer than 128

  • fixedIntervalPriceId (str) – (optional) token/currency pair to use for price of token

  • mintable (bool) – (optional) Token’s ‘Mintable’ property, default is ‘True’

  • interest (float) – (optional) Interest rate

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.loan.updateloantoken("TSLA", "TSLAA", "TSLA Stock", "TSLA/USD", True, 5)