Athens has clinched a critical bond-swap deal with private creditors allowing Greece to narrowly escape default, opening the door for a bailout injection.