Exemplo n.º 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]
Exemplo n.º 2
0
    def handle(self):
        commit = Commit()

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

        collateral_id = str(self._args.get("_entryId"))
        collateral = Collateral.objects.get(id=collateral_id)
        print(collateral.debt_id)
        loan = Loan.objects.get(id=collateral.debt_id)
        if loan.status == "2":
            status = str(CollateralState.TO_WITHDRAW.value)
        else:
            status = str(CollateralState.STARTED.value)

        data = {
            "id": collateral_id,
            "received": str(self._args.get("_received")),
            "leftover": str(self._args.get("_leftover")),
            "status": status
        }

        commit.data = data

        return [commit]
Exemplo n.º 3
0
    def handle(self):
        commit = Commit()

        commit.opcode = "pool_started_loanDAO"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction

        data = {"poolId": self._args.get("_poolId")}

        commit.data = data

        return [commit]
Exemplo n.º 4
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]
Exemplo n.º 5
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]
Exemplo n.º 6
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
Exemplo n.º 7
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]
Exemplo n.º 8
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]
Exemplo n.º 9
0
    def handle(self):
        commit = Commit()

        commit.opcode = "set_URIProvider_collateral"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction

        data = {
            "uriProvider": self._args.get("_uriProvider"),
        }

        commit.data = data

        return [commit]
Exemplo n.º 10
0
    def handle(self):
        commit = Commit()

        commit.opcode = "ownership_transferred_collateral"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction

        data = {
            "previousOwner": self._args.get("_previousOwner"),
            "newOwner": self._args.get("_newOwner"),
        }

        commit.data = data

        return [commit]
Exemplo n.º 11
0
    def handle(self):
        commit = Commit()

        commit.opcode = "pay_back_loanDAO"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction

        data = {
            "poolId": self._args.get("_poolId"),
            "lender": self._args.get("_lender"),
            "rest": str(self._args.get("_rest"))
        }

        commit.data = data

        return [commit]
Exemplo n.º 12
0
    def handle(self):
        commit = Commit()

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

        data = {
            "id": str(self._args.get("_entryId")),
            "status": str(CollateralState.STARTED.value)
        }

        commit.data = data

        return [commit]
Exemplo n.º 13
0
    def handle(self):
        commit = Commit()

        commit.opcode = "approval_for_all_collateral"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction

        data = {
            "owner": self._args.get("_owner"),
            "operator": self._args.get("_operator"),
            "approved": self._args.get("_approved")
        }

        commit.data = data

        return []
Exemplo n.º 14
0
    def handle(self):
        commit = Commit()

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

        data = {
            "id": str(self._args.get("_entryId")),
            "to": str(self._args.get("_to")),
        }

        commit.data = data

        return [commit]
Exemplo n.º 15
0
    def handle(self):
        commit = Commit()

        commit.opcode = "paid_ERC20D"
        commit.timestamp = self._block_timestamp()
        commit.proof = self._transaction
        commit.address = self._address

        data = {
            "from": self._args.get("_from"),
            "value": self._args.get("_value"),
            "contractAddress": self._address
        }

        commit.data = data

        return [commit]
Exemplo n.º 16
0
    def handle(self):
        commit = Commit()

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

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

        commit.data = data

        return [commit]
Exemplo n.º 17
0
    def handle(self):
        commit = Commit()

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

        data = {
            "previous_owner": self._args.get("_previousOwner"),
            "new_owner": self._args.get("_newOwner"),
        }

        commit.data = data

        # return [commit]
        return []
Exemplo n.º 18
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]
Exemplo n.º 19
0
    def handle(self):
        commit = Commit()

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

        data = {
            "oracle": self._args.get("_oracle"),
            "signer": self._args.get("_signer"),
            "rate": str(self._args.get("_rate"))
        }

        commit.data = data

        return [commit]
Exemplo n.º 20
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]
Exemplo n.º 21
0
    def handle(self):
        commit = Commit()

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

        data = {
            "id": str(self._args.get("_entryId")),
            "handler": self._args.get("_handler"),
            "newAmount": str(self._args.get("_newAmount")),
            "status": str(CollateralState.TO_WITHDRAW.value)
        }

        commit.data = data

        return [commit]
Exemplo n.º 22
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]
Exemplo n.º 23
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]
Exemplo n.º 24
0
    def handle(self):
        commit = Commit()

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

        data = {
            "id": str(self._args.get("_entryId")),
            "auctionId": str(self._args.get("_auctionId")),
            "obligation": str(self._args.get("_obligation")),
            "obligationToken": str(self._args.get("_obligationToken")),
            "status": str(CollateralState.IN_AUCTION.value)
        }

        commit.data = data

        return [commit]
Exemplo n.º 25
0
    def handle(self):
        commit = Commit()

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

        data = {
            "id": str(self._args.get("_entryId")),
            "auctionId": str(self._args.get("_auctionId")),
            "debt": str(self._args.get("_debt")),
            "required": str(self._args.get("_required")),
            "marketValue": str(self._args.get("_marketValue")),
            "status": str(CollateralState.IN_AUCTION.value)
        }

        commit.data = data

        return [commit]
Exemplo n.º 26
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]
Exemplo n.º 27
0
    def handle(self):
        commit = Commit()

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

        id = str(self._args.get("_entryId"))
        amount = str(self._args.get("_amount"))
        collateral = Collateral.objects.get(id=id)
        if collateral.status == CollateralState.FINISH.value and amount != '0':
            status = str(CollateralState.TO_WITHDRAW.value)
        else:
            status = str(collateral.status)

        data = {"id": id, "amount": amount, "status": status}

        commit.data = data

        return [commit]
Exemplo n.º 28
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]
Exemplo n.º 29
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 []
Exemplo n.º 30
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]