function createLiability(
        bytes calldata _demand,
        bytes calldata _offer
    )
        external
        onlyLighthouse
        returns (ILiability liability)
    {
        
        liability = ILiability(liabilityCode.proxy());
        require(Liability(address(liability)).setup(xrt));

        emit NewLiability(address(liability));

        
        (bool success, bytes memory returnData)
            = address(liability).call(abi.encodePacked(bytes4(0x48a984e4), _demand)); 
        require(success);
        singletonHash(liability.demandHash());
        nonceOf[liability.promisee()] += 1;

        (success, returnData)
            = address(liability).call(abi.encodePacked(bytes4(0x413781d2), _offer)); 
        require(success);
        singletonHash(liability.offerHash());
        nonceOf[liability.promisor()] += 1;

        
        require(isLighthouse[liability.lighthouse()]);

        
        if (liability.lighthouseFee() > 0)
            xrt.safeTransferFrom(liability.promisor(),
                                 tx.origin,
                                 liability.lighthouseFee());

        
        ERC20 token = ERC20(liability.token());
        if (liability.cost() > 0)
            token.safeTransferFrom(liability.promisee(),
                                   address(liability),
                                   liability.cost());

        
        if (liability.validator() != address(0) && liability.validatorFee() > 0)
            xrt.safeTransferFrom(liability.promisee(),
                                 address(liability),
                                 liability.validatorFee());
     }