enzymefinance / enzip

Enzyme Improvement Proposal
https://github.com/enzymefinance/ENZIP
8 stars 11 forks source link

MIP1 - Auditing #1

Open benzumbrunn opened 6 years ago

benzumbrunn commented 6 years ago
MIP: 1
Title: Auditing
Authors: Benjamin Zumbrunn, benzumbrunn@gmail.com; Simon Emanuel Schmid, simon@schmid.io
Status: Final
Type: MIP
Created: 2018-04-24
Reference implementation: https://github.com/melonproject/reporting/blob/master/src/contracts/src/Auditing.sol

Abstract

This MIP describes standard functions an auditing contract must implement in order to be compatible as a Melon Auditing module.

Background

The auditing process goes like this:

Motivation

Different fund setups have different auditing requirements:

In order to follow the modularisation approach of the Melon smart-contract system we hereby define a standard so that minimal requirements can be met. This leads to an open system where module developers can implement their auditing functionality according to their needs outside of our imagination.

Contract details

Transactions

add

function add(address _fundAddress, bytes32 _dataHash, uint256 _timespanStart, uint256 _timespanEnd, uint256 _opinion, string _comment) returns (bool)

Add a new audit of a melon fund to the blockchain. msg.sender == auditor.

Calls

exists

exists(address _fundAddress, address _auditor, bytes32 _dataHash) returns (bool)

Validates that the provided data is mapped to an existing audit.

getLength

function getLength(address _fundAddress) constant returns (uint256 index)

Get the length of the audit array for a specific melon fund. This is needed to iterate through audits with getByIndex().

getByIndex

function getByIndex(address _fundAddress, uint256 _index) constant returns (address auditor, bytes32 dataHash, uint256 timespanStart, uint256 timespanEnd, uint256 opinion, string _comment)

Get the stored information of an audit.

Requires that _index is smaller than the size of the audit array.

isApprovedAuditor

isApprovedAuditor(address _auditor) returns (bool)

Checks if the provided address can use the add function on the contract.

If there are no restrictions on who can audit, this funtion shall always return true.

isComplete

isComplete(address _fundAddress, uint256 _timespanStart, uint256 _timespanEnd) returns (bool)

Checks if a fund is completely audited for a given timespan.

Risk management might prevent trades if a fund is not completely audited. For example:

A fund that is audited every month could have the following lookup in risk management: isComplete(0xfundaddress, fund.inception, now - 30*24*60*60)

Events

Added

event Added(address _fundAddress, uint256 _index)

Triggered when a new audit is stored successfully.

Auditing Interface

AuditingInterface.sol

Reference Implementation

Auditing.sol

In the reference implementation, we require that only approved auditors can use the method add(...). The approved auditors are supplied on contract creation via the constructor.

It is possible to validate if an address is an approved (i.e. stored) auditor:

isApprovedAuditor(address _auditor) returns (bool)

Contract developers are free to use their own enumeration of opinions. In the reference implementation, we use the following values:

enum Opinion {
    UnqualifiedOpinion, 
    QualifiedOpinion, 
    AdverseOpinion, 
    DisclaimerOfOpinion 
}