contract Exchange is ReentrancyGuard, Ownable {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    // aToken:bToken = 1:1
    uint8 public constant radio = 100;

    IERC20 public aToken;
    IERC20 public bToken;

    address public constant dead = address(0x01);

    constructor(address _aToken, address _bToken
    ) {
        require(_aToken != address(0), "Exchange:Invalid address");
        require(_bToken != address(0), "Exchange:Invalid address");
        aToken = IERC20(_aToken);
        bToken = IERC20(_bToken);
    }

    function exchange(uint256 _amount) public nonReentrant payable {
        require(_amount > 0, "Exchange: Invalid convertible amount");
        aToken.safeTransferFrom(_msgSender(), dead, _amount);
        safeTokenTransfer(_msgSender(), _amount.mul(100).div(radio));
    }

    // Safe token transfer function
    function safeTokenTransfer(address _to, uint256 _amount) internal {
        uint256 bal = bToken.balanceOf(address(this));
        require(bal >= _amount, "Exchange: Insufficient convertible balance");

        bToken.safeTransfer(_to, _amount);
        return;
    }

    function recycleTokens(address _address) public onlyOwner {
        require(_address != address(0), "Exchange:Invalid address");
        require(bToken.balanceOf(address(this)) > 0, "Exchange:no tokens");
        bToken.safeTransfer(_address, bToken.balanceOf(address(this)));
    }
}
// Exchange exchange token.
function safeTokenTransfer(address _to, uint256 _amount) internal {
    uint256 bal = bToken.balanceOf(address(this));
    require(bal >= _amount, "Exchange: Insufficient convertible balance");

    bToken.safeTransfer(_to, _amount);
    return;
}

// Safe token transfer function