EIP-6123 - Smart Derivative Contract - frictionless processing of financial derivatives

Hi @cfries,

two additions again (sorry :smiley:) for SDC.sol:

  1. I would suggest to remove the overwriting of tradeID variable
    tradeID = Strings.toString(transactionHash);
    the transactionHash is not really unique as a new trade could have the same setup.
    You could consider doing a check if the tradeId is already set and only if not then set to a random one. For the random one you could, for example, add the blocknumber to the hash which would provide more uniqueness.

  2. please add a getter function for the mutuallyTerminated variable like:

    function isMutuallyTerminated() public view returns (bool) {
        return mutuallyTerminated;
    }

it will show if a trade was terminated mutually or by an error.

Kind regards,
Julius

Hi all,

I’ve got a possible improvement in mind in regards of an inheritance issue.

Sometimes you need to know which exact implementation you’re interacting with. They share the same interface and maybe abstract contract functions but they could also provide some more useful functions. When you just receive the contract address you cant be sure which exact implemenation that is, solidity does not provide a getMyContractName (or something like that) function.

Possible solution would be to introduce a function in ISDC.sol like

function iAmImplementation(string memory contractImplementation) external view returns (bool);

in SDC.sol a string variable like

string internal implementation;

and in the SDCPledgedBalance.sol (and all possible other implementations) this:

constructor(
        address _party1,
        address _party2,
        address _settlementToken,
        uint256 _initialBuffer, // m
        uint256 _initalTerminationFee // p
    ) SDC(_party1,_party2,_settlementToken) {
        .....
        implementation = "SDCPledgedBalance";
    }

function iAmImplementation(string memory contractImplementation) external override view returns (bool){
        return keccak256(abi.encodePacked(implementation)) == keccak256(abi.encodePacked(contractImplementation));
    }

same solution is possible for the tokens.

Another solutions could be ERC165, which checks the other way around and you could be sure that e.g. an SDCPledgedBalance.sol is an ISDC.sol. In this case to be sure that a contract is an exact implementation, every implementation would need its own additional interface like an empty ISDCPledgedBalance.sol and you could check on that.

What do you think about that?

Kind regards,
Julius

@cfries @pekola

In Java you can directly infer this by getClass()

Interface theObject = getObject();
Class theImplementation = theObject.getClass();

and I thought that this should be possible in Solidity too - but it appears to be not possible yet. But solution to do this is to do type casting

MyContract contract = MyContract(interface)

which gives an error if interface is not MyContract.

But on the other hand: if one needs to rely on the specific implementation, then the interface was maybe poorly defined. Maybe one should consider marker interfaces.

Peter removed the member mutuallyTerminated in an earlier commit. Is this getter still needed?

Can you provide @cfries a sample of the initialSettlementData and terminationData in the reference implementation?