1) You pay them! Gain is measured the same way it is with any other asset (including any non-USD currency): sale price less acquisition cost (aka "cost basis" in tax parlance) and certain maintenance expenses. There are other adjustments which probably aren't applicable to digital currency. In this case, it doesn't appear that w was entirely y or z coins, and probably includes coins from both groups. Since the z have a different acquisition cost, generally the calculation is split into smaller sub-calculations to the extent the data is available (gain on sale of the y coins sold, and gain on sale of the z coins sold). The cost basis of goods acquired as compensation is generally the amount treated as income for other tax purposes, usually the fair market value.
If a = y coins sold and b = z coins sold, then gain should be...
=[sales price allocable to a coins - purchase purchase allocable to a coins] + [sales price allocable to b coins - purchase purchase allocable to b coins]
=[[a/w * w sales price - [a/y* y purchase price]] + [b/w * w sales price - [b/z* z purchase price]
2) It should be possible to add the cost of the cracker into the "cost basis" of the xxx-w coins, which should affect the amount of taxable gain on a later sale of some or all of those coins. However, there should not be any immediate or current year tax implications.
3) There are some write-offs for lost or stolen goods. Don't know how applicable they would be to digital goods like Bitcoin since nobody has actually gotten to that point yet! It's not really been established whether digital goods can be "lost" for tax purposes. If analogizing the tangible property, its likely that a court would eventually say they can be lost and thus written-off, but no courts actually gone out and said it...yet. (There have been cases dealing with this on non-tax grounds.) However, in this situation, the tax from #1 is still there, at best there could be a deduction for the losses incurred in #3.