Processing gain/loss on stock payments

Hello,

We received some stock which sold for higher than what it was when we got it. How do I go about processing  the amount to pay off a pledge and also place the gain on the stocks into the right place financially (since we don't want to record the extra as a gift or a contribution made by a person)

Thanks!