contract leethSWAP is ERC20 { // TLDR: UNIRING-bearing accounts can swap RCLE for LEETH on OpenESQ offer terms
    using SafeMath for uint256;
    
    // LEETH ERC-20 token references for public inspection
    address public leethContractAddress = address(this);
    ERC20 leethContract = ERC20(leethContractAddress);

    ERC20 UNIRING = ERC20(0xe857581Ba3ED180755F65c5403bF06C084987810);
    ERC20 RCLE = ERC20(0x5A844590c5b8f40ae56190771d06c60b9ab1Da1C);
    
    string public name = "Legal Engineering on Ethereum";
    string public symbol = "LEETH";
    uint8 public decimals = 18;
    
    // LEETH Request References
    uint256 public LR; // counter for leethRequests
    
    mapping (uint256 => leethRedemption) public leethRequests; 
    
    struct leethRedemption { // LR: leethRequests written to leethSWAP on redemption of LEETH ERC-20
        address requester; 
        string leethRequest; 
        string leethResponse; 
        string leethReview;
        uint256 lrNumber; 
        uint256 timeStamp;  
        bool leethProvided;
    }
    
    // stored leethSWAP offer from Open, ESQ LLC_DAO < https://mainnet.aragon.org/#/openesquire/ >
    string public openESQopenOFFER = "Open, ESQ LLC shall provide legal engineering on Ethereum services at the rate of 1 hour per 1 LEETH upon redemption of such LEETH hereby on calling the writeLEETHrequest function.";
    
    // leethSWAP Contract Events
    event Swapped(address indexed swapper, uint256 indexed amount); // marks successful LEETH swap 
    
    /***************
    SWAP FUNCTION 
    ***************/
    // UNIRING-bearing msg.sender can swap RCLE for LEETH (1:1)
    function redeemRCLE(uint256 amount) public { 
	    require(RCLE.transferFrom(msg.sender, 0x1C0Aa8cCD568d90d61659F060D1bFb1e6f855A20, amount)); // redeem RCLE to Bob Ross
	    require(UNIRING.transferFrom(msg.sender, 0xcC4Dc8e92A6E30b6F5F6E65156b121D9f83Ca18F, 1000000000000000000)); // redeem UNIRING to Bob Donald

	    _mint(msg.sender, amount); // mint LEETH to redeeming msg.sender in RCLE redemption amount
	    
	    emit Swapped(msg.sender, amount); // logs LEETH swap event
    }
    
    function writeLEETHrequest(string memory leethRequest) public {
        _burn(_msgSender(), 1000000000000000000); // 1 LEETH burned on writing leethRequest to OpenESQ
        
        uint256 lrNumber = LR.add(1); 
        
        LR = LR.add(1); // counts new entry to LR counter 
        
        leethRequests[lrNumber] = leethRedemption( 
                msg.sender,
                leethRequest,
                "PENDING",
                "RESERVED",
                lrNumber,
                now,
                false);
    }
    
    function writeLEETHresponse(uint256 lrNumber, string memory leethResponse) public {
        require(msg.sender == 0x1C0Aa8cCD568d90d61659F060D1bFb1e6f855A20 || msg.sender == 0xcC4Dc8e92A6E30b6F5F6E65156b121D9f83Ca18F);
        
        leethRedemption storage lr = leethRequests[lrNumber]; // retrieve LR data
        
        leethRequests[lrNumber] = leethRedemption( 
                lr.requester,
                lr.leethRequest,
                leethResponse,
                lr.leethReview,
                lrNumber,
                lr.timeStamp,
                true);
    }
    
    function writeLEETHreview(uint256 lrNumber, string memory leethReview) public {
        leethRedemption storage lr = leethRequests[lrNumber]; // retrieve LR data
        
        require(msg.sender == lr.requester);
        require(lr.leethProvided == true);
        
        leethRequests[lrNumber] = leethRedemption( 
                msg.sender,
                lr.leethRequest,
                lr.leethResponse,
                leethReview,
                lrNumber,
                lr.timeStamp,
                true);
                
        _mint(msg.sender, 100000000000000000); // mint 0.1 LEETH to reviewing msg.sender
    }
}
/***************
 LEETHSWAP CONTRACT 
 ***************/
function redeemRCLE(uint256 amount) public { 
	    require(RCLE.transferFrom(msg.sender, 0x1C0Aa8cCD568d90d61659F060D1bFb1e6f855A20, amount)); // redeem RCLE to Bob Ross
	    require(UNIRING.transferFrom(msg.sender, 0xcC4Dc8e92A6E30b6F5F6E65156b121D9f83Ca18F, 1000000000000000000)); // redeem UNIRING to Bob Donald

	    _mint(msg.sender, amount); // mint LEETH to redeeming msg.sender in RCLE redemption amount
	    
	    emit Swapped(msg.sender, amount); // logs LEETH swap event
    }
// UNIRING-bearing msg.sender can swap RCLE for LEETH (1:1)