contract RentAuction is ClockAuction {
    function RentAuction(address _deedContractAddress, uint256 _fee) ClockAuction(_deedContractAddress, _fee) public {}
    
    /// @dev Allows other contracts to check whether this is the expected contract.
    bool public isRentAuction = true;
    
    mapping (uint256 => uint256) public identifierToRentPeriod;
    
    /// @notice Create an auction for a given deed. Be careful when calling
    /// createAuction for a RentAuction, that this overloaded function (including
    /// the _rentPeriod parameter) is used. Otherwise the rent period defaults to
    /// a week.
    /// Must previously have been given approval to take ownership of the deed.
    /// @param _deedId The identifier of the deed to create an auction for.
    /// @param _startPrice The starting price of the auction.
    /// @param _endPrice The ending price of the auction.
    /// @param _duration The duration in seconds of the dynamic pricing part of the auction.
    /// @param _rentPeriod The rent period in seconds being auctioned.
    function createAuction(
        uint256 _deedId,
        uint256 _startPrice,
        uint256 _endPrice,
        uint256 _duration,
        uint256 _rentPeriod
    )
        external
    {
        // Require the rent period to be at least one hour.
        require(_rentPeriod >= 3600);
        
        // Require there to be no active renter.
        DWorldRenting dWorldRentingContract = DWorldRenting(deedContract);
        var (renter,) = dWorldRentingContract.renterOf(_deedId);
        require(renter == address(0));
    
        // Set the rent period.
        identifierToRentPeriod[_deedId] = _rentPeriod;
    
        // Throws (reverts) if creating the auction fails.
        createAuction(_deedId, _startPrice, _endPrice, _duration);
    }
    
    /// @dev Perform the bid win logic (in this case: give renter status to the winner).
    /// @param _seller The address of the seller.
    /// @param _winner The address of the winner.
    /// @param _deedId The identifier of the deed.
    /// @param _price The price the auction was bought at.
    function _winBid(address _seller, address _winner, uint256 _deedId, uint256 _price) internal {
        DWorldRenting dWorldRentingContract = DWorldRenting(deedContract);
    
        uint256 rentPeriod = identifierToRentPeriod[_deedId];
        if (rentPeriod == 0) {
            rentPeriod = 604800; // 1 week by default
        }
    
        // Rent the deed out to the winner.
        dWorldRentingContract.rentOut(_winner, identifierToRentPeriod[_deedId], _deedId);
        
        // Transfer the deed back to the seller.
        _transfer(_seller, _deedId);
    }
    
    /// @dev Remove an auction.
    /// @param _deedId The identifier of the deed for which the auction should be removed.
    function _removeAuction(uint256 _deedId) internal {
        delete identifierToAuction[_deedId];
        delete identifierToRentPeriod[_deedId];
    }
}
function createAuction(
    uint256 _deedId,
    uint256 _startPrice,
    uint256 _endPrice,
    uint256 _duration,
    uint256 _rentPeriod
)
    external
{
    // Require the rent period to be at least one hour.
    require(_rentPeriod >= 3600);
        
    // Require there to be no active renter.
    DWorldRenting dWorldRentingContract = DWorldRenting(deedContract);
    var (renter,) = dWorldRentingContract.renterOf(_deedId);
    require(renter == address(0));
    
    // Set the rent period.
    identifierToRentPeriod[_deedId] = _rentPeriod;
    
    // Throws (reverts) if creating the auction fails.
    createAuction(_deedId, _startPrice, _endPrice, _duration);
}

/// @notice Create an auction for a given deed. Be careful when calling
/// createAuction for a RentAuction, that this overloaded function (including
/// the _rentPeriod parameter) is used. Otherwise the rent period defaults to
/// a week.
/// Must previously have been given approval to take ownership of the deed.
/// @param _deedId The identifier of the deed to create an auction for.
/// @param _startPrice The starting price of the auction.
/// @param _endPrice The ending price of the auction.
/// @param _duration The duration in seconds of the dynamic pricing part of the auction.
/// @param _rentPeriod The rent period in seconds being auctioned.