class DexTransferMoneyTransaction extends DEX {

    @Override
    public void applyAttachment(Transaction tx, Account sender, Account recipient) {
        DexControlOfFrozenMoneyAttachment attachment = (DexControlOfFrozenMoneyAttachment) tx.getAttachment();
        lookupAccountService().addToBalanceATM(sender, getLedgerEvent(), tx.getId(), -attachment.getOfferAmount()); // reduce only balanceATM, assume that unconfirmed balance was reduced earlier and was not recovered yet
        lookupAccountService().addToBalanceAndUnconfirmedBalanceATM(recipient, getLedgerEvent(), tx.getId(), attachment.getOfferAmount());

        DexService dexService = lookupDexService();
        ExchangeContract dexContract = dexService.getDexContractById(attachment.getContractId());

        long orderToClose = dexContract.getSender() == sender.getId() ? dexContract.getCounterOrderId() : dexContract.getOrderId(); // close order which was approved
        dexService.closeOrder(orderToClose);
    }

}