예제 #1
0
    def handle(self):
        commit = Commit()

        commit.opcode = "created_debt_engine"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        debt = debt_engine_interface.get_debt_by_id(self._id)

        error = False
        balance = 0

        model = debt.get("model")
        creator = debt.get("creator")
        oracle = debt.get("oracle")

        created = str(self._block_timestamp())

        data = {
            "error": error,
            "balance": str(balance),
            "model": model,
            "creator": creator,
            "oracle": oracle,
            "created": created,
            "id": self._args.get("_id")
        }

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #2
0
    def handle(self):
        commit = Commit()

        commit.opcode = "requested_loan_manager"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        oracle = self._args.get("_oracle")
        try:
            if oracle != "0x0000000000000000000000000000000000000000":
                oracle_contract = OracleInterface(oracle)
                currency = oracle_contract.currency()
            else:
                currency = loan_manager_interface.get_currency(
                    self._args.get('_id'))
                if currency:
                    currency = utils.add_0x_prefix(currency)
        except BadFunctionCallOutput:
            currency = "0x"

        print("currency: {}".format(currency))

        data = {
            "id": self._args.get("_id"),
            "open": True,
            "approved":
            self._args.get("_creator") == self._args.get("_borrower"),
            "position": "0",
            "expiration": str(self._args.get("_expiration")),
            "amount": str(self._args.get("_amount")),
            "cosigner": "0x0000000000000000000000000000000000000000",
            "model": self._args.get("_model"),
            "creator": self._args.get("_creator"),
            "oracle": self._args.get("_oracle"),
            "borrower": self._args.get("_borrower"),
            "callback": self._args.get("_callback"),
            "salt": str(self._args.get("_salt")),
            "loanData": self._args.get("_loanData"),
            "created": str(self._block_timestamp()),
            "currency": currency,
            "status": "0"
        }

        descriptor = loan_manager_interface.get_descriptor(data)

        data["descriptor"] = descriptor

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #3
0
    def handle(self):
        commit = Commit()

        config_data = installments_model_interface.get_config_by_id(self._args.get("_id"))

        commit.opcode = "created_installments"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")
        commit.data = config_data
        commit.id_loan = self._args.get("_id")

        return [commit]
예제 #4
0
    def handle(self):
        commits = []

        commit = Commit()

        commit.opcode = "changed_status_installments"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        data = {
            "id": self._args.get("_id"),
            "timestamp": str(self._args.get("_timestamp")),
            "status": str(self._args.get("_status"))
        }

        commit.id_loan = self._args.get("_id")
        commit.data = data
        commits.append(commit)

        # commit full payment loan manager
        commit_full_payment = Commit()
        commit_full_payment.opcode = "full_payment_loan_manager"
        commit_full_payment.timestamp = commit.timestamp
        commit_full_payment.proof = self._transaction
        commit_full_payment.proof = self._tx.get("from")

        data = {
            "id": self._args.get("_id"),
            "status": str(self._args.get("_status"))
        }

        commit_full_payment.id_loan = self._args.get("_id")
        commit_full_payment.data = data

        commits.append(commit_full_payment)

        return commits
예제 #5
0
    def handle(self):
        commit = Commit()

        commit.opcode = "approved_loan_manager"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        data = {"id": self._args.get("_id"), "approved": True}

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #6
0
    def handle(self):
        commit = Commit()

        commit.opcode = "error_recover_debt_engine"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        data = {"id": self._args.get("_id"), "error": False}

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #7
0
    def handle(self):
        commit = Commit()

        commit.opcode = "pay_batch_error_debt_engine"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        data = {
            "id": self._args.get("_id"),
            "oracle": self._args.get("_oracle")
        }

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #8
0
    def handle(self):
        commit = Commit()

        commit.opcode = "set_paid_base_installments"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        data = {
            "id": self._args.get("_id"),
            "paid_base": str(self._args.get("_paidBase"))
        }

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #9
0
    def handle(self):
        commit = Commit()

        commit.opcode = "settled_lend_loan_manager"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        data = {
            "id": self._args.get("_id"),
            "lender": self._args.get("_lender"),
            "tokens": self._args.get("_tokens")
        }

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #10
0
    def handle(self):
        commit = Commit()

        commit.opcode = "withdrawn_debt_engine"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        data = {
            "id": self._args.get("_id"),
            "sender": self._args.get("_sender"),
            "to": self._args.get("_to"),
            "amount": str(self._args.get("_amount"))
        }

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #11
0
    def handle(self):
        commit = Commit()

        commit.opcode = "added_paid_installments"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        state = State.objects.get(id=self._args.get("_id"))

        data = {
            "id": self._args.get("_id"),
            "real": str(self._args.get("_paid")),
            "paid": str(int(state.paid) + self._args.get("_paid")),
            "state_last_payment": state.clock,
        }

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #12
0
    def handle(self):
        if self._args.get("_from") != "0x0000000000000000000000000000000000000000":

            commit = Commit()

            commit.opcode = "transfer_debt_engine"
            commit.timestamp = self._block_timestamp()
            commit.proof = self._transaction
            commit.address = self._tx.get("from")

            data = {
                "id": self._args.get("_tokenId"),
                "from": self._args.get("_from"),
                "to": self._args.get("_to")
            }

            commit.id_loan = self._args.get("_tokenId")
            commit.data = data

            return [commit]
        else:
            return []
예제 #13
0
    def handle(self):
        commit = Commit()

        commit.opcode = "paid_debt_engine"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._tx.get("from")

        data = {
            "id": self._args.get("_id"),
            "sender": self._args.get("_sender"),
            "origin": self._args.get("_origin"),
            "requested": str(self._args.get("_requested")),
            "requested_tokens": str(self._args.get("_requestedTokens")),
            "paid": str(self._args.get("_paid")),
            "tokens": str(self._args.get("_tokens"))
        }

        commit.id_loan = self._args.get("_id")
        commit.data = data

        return [commit]
예제 #14
0
    def handle(self):
        commit = Commit()

        commit.opcode = "created_collateral"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.id_loan = self._args.get("_debtId")
        commit.address = self._tx.get("from")

        data = {
            "id": str(self._args.get("_entryId")),
            "debt_id": self._args.get("_debtId"),
            "oracle": self._args.get("_oracle"),
            "token": self._args.get("_token"),
            "liquidation_ratio": str(self._args.get("_liquidationRatio")),
            "balance_ratio": str(self._args.get("_balanceRatio")),
            "amount": str(self._args.get("_amount")),
            "status": str(CollateralState.CREATED.value)
        }

        commit.data = data

        return [commit]