<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def adjust_debt( self, delta, new_collateral_ratio=None, account=None, target_collateral_ratio=None, ):
 """ Adjust the amount of debt for an asset :param Amount delta: Delta amount of the debt (-10 means reduce debt by 10, +10 means borrow another 10) :param float new_collateral_ratio: collateral ratio to maintain (optional, by default tries to maintain old ratio) :param float target_collateral_ratio: Tag the call order so that in case of margin call, only enough debt is covered to get back to this ratio :raises ValueError: if symbol is not a bitasset :raises ValueError: if collateral ratio is smaller than maintenance collateral ratio :raises ValueError: if required amounts of collateral are not available """

        if not account:
            if "default_account" in self.blockchain.config:
                account = self.blockchain.config["default_account"]
        if not account:
            raise ValueError("You need to provide an account")
        account = Account(account, full=True, blockchain_instance=self.blockchain)

        # We sell quote and pay with base
        symbol = delta["symbol"]
        asset = Asset(symbol, full=True, blockchain_instance=self.blockchain)
        if not asset.is_bitasset:
            raise ValueError("%s is not a bitasset!" % symbol)
        bitasset = asset["bitasset_data"]

        # Check minimum collateral ratio
        backing_asset_id = bitasset["options"]["short_backing_asset"]
        current_debts = self.list_debt_positions(account)
        if not new_collateral_ratio and symbol not in current_debts:
            new_collateral_ratio = (
                bitasset["current_feed"]["maintenance_collateral_ratio"] / 1000
            )
        elif not new_collateral_ratio and symbol in current_debts:
            new_collateral_ratio = current_debts[symbol]["ratio"]

        # Derive Amount of Collateral
        collateral_asset = Asset(backing_asset_id, blockchain_instance=self.blockchain)
        settlement_price = Price(
            bitasset["current_feed"]["settlement_price"],
            blockchain_instance=self.blockchain,
        )

        if symbol in current_debts:
            amount_of_collateral = (
                (float(current_debts[symbol]["debt"]) + float(delta["amount"]))
                * new_collateral_ratio
                / float(settlement_price)
            )
            amount_of_collateral -= float(current_debts[symbol]["collateral"])
        else:
            amount_of_collateral = (
                float(delta["amount"]) * new_collateral_ratio / float(settlement_price)
            )

        # Verify that enough funds are available
        fundsNeeded = amount_of_collateral + float(
            self.returnFees()["call_order_update"]["fee"]
        )
        fundsHave = account.balance(collateral_asset["symbol"]) or 0
        if fundsHave <= fundsNeeded:
            raise ValueError(
                "Not enough funds available. Need %f %s, but only %f %s are available"
                % (
                    fundsNeeded,
                    collateral_asset["symbol"],
                    fundsHave,
                    collateral_asset["symbol"],
                )
            )

        payload = {
            "fee": {"amount": 0, "asset_id": "1.3.0"},
            "delta_debt": {
                "amount": int(float(delta) * 10 ** asset["precision"]),
                "asset_id": asset["id"],
            },
            "delta_collateral": {
                "amount": int(
                    float(amount_of_collateral) * 10 ** collateral_asset["precision"]
                ),
                "asset_id": collateral_asset["id"],
            },
            "funding_account": account["id"],
            "extensions": {},
        }
        # Extension
        if target_collateral_ratio:
            payload["extensions"].update(
                dict(target_collateral_ratio=int(target_collateral_ratio * 100))
            )

        op = operations.Call_order_update(**payload)
        return self.blockchain.finalizeOp(op, account["name"], "active")