* TSX ends up 138.49 points, or 1.1 percent, at 13,104.98
* All 10 of the main groups are higher (Adds details, comments)
By Claire Sibonney
TORONTO, June 28 (Reuters) - Toronto's main stock index ended sharply higher on Tuesday as heightened optimism that the Greek debt crisis would be resolved boosted commodity prices and investor confidence.
Hopes that the Greek government can push an unpopular austerity program through parliament on Wednesday and avoid becoming the first sovereign default in the euro zone prompted investors to flock to riskier assets, despite violent street protests in Athens against spending cutbacks. [MKTS/GLOB]
The index's energy group led advances, jumping 1.8 percent as oil prices rallied. The index's top three most influential gainers were in the group: Canadian Natural Resources (CNQ.TO) surged almost 3 percent to C$39.44, Suncor Energy (SU.TO) advanced 1.5 percent to C$37.52, while Cenovus Energy (CVE.TO) rose 3.6 percent to C$34.61.
"I think it all hinges on Greece now," said Elvis Picardo, strategist and vice president of research at Global Securities in Vancouver.
"This is a problem that has transfixed the markets for quite a few weeks and just based on the latest action it does seem like investors are optimistic that the package will pass and that we will be able to avert a wider potential catastrophe."
The Toronto Stock Exchange's S&P/TSX composite index .GSPTSE ended up 138.49 points, or 1.07 percent, at 13,104.98.
Picardo said that if the Greek program does get through parliament, the reaction should be quite muted. "If it doesn't then, of course, you have the flip side of the coin where you could see a steep selloff."
Near-term support on the TSX has drifted higher to around 12,800-13,000, he said.
All 10 of the index's main groups ended higher on Tuesday, including the weighty materials sector, up 1.4 percent, and financials, up 0.6 percent.
Royal Bank of Canada (RY.TO) rose 1.1 percent to C$54.49, while Teck Resources TCKb.TO gained 3.1 percent to C$47.38.
In individual company news, SNC-Lavalin Group (SNC.TO) rose 1.6 percent to C$56.64 after a Globe and Mail report said the Canadian government was set to announce the sale of Atomic Energy of Canada to SNC, Canada's biggest engineering firm. [ID:nN1E75R0OG]
Shares of Westport Innovations WPT.TO, which announced it was developing a new natural-gas engine technology with General Motors, jumped more than 10 percent to C$23.55. [ID:nL3E7HS27R]
On the downside, Yellow Media YLO.TO was one of the index's biggest decliners, extending Monday's dramatic losses and falling another 4.6 percent to C$2.28 on worries over the telephone directory publisher's struggle to transform from print to digital. [ID:nL3E7HS2DZ]
Irwin Michael, portfolio manager at ABC Funds, said the next couple days will be interesting as Thursday marks was both the month- and quarter-end. Friday is a holiday in Canada and Monday is a holiday in the United States.
"It doesn't take very much to move the market up either way," he said, noting lighter-than-usual volumes.
Michael also pointed out that the weakness in the market over the last two months probably means it's a little oversold and that it may be due for a recovery.
($1=$0.98 Canadian) (Reporting by Claire Sibonney; editing by Peter Galloway)