But now, after a change from Germany's taxman, Macquarie's key external law firm, Freshfields, had suddenly ceased giving advice on this type of trade. It was also warning the bank that it would face “massive reputational issues” by continuing to be involved in the practice. “Freshfields our main legal advisers have material reservations about these trades, they referred to the legislator using the word 'corrupt' when the Dec 15 rules were introduced,” a member of the bank's tax division in London wrote to his division head. Undeterred and relying on other legal advice, and a change to the deal's structure, bankers pushed on with the plan, to finance known what is as “cum-ex” trading, a Latin reference to "with-without." This is a mind-bogglingly complex share trading technique that had taken off in Germany's market to exploit the timing of dividend payments and a related link to tax refunds.

Fast forward to today, and Australia’s biggest investment bank has found itself embroiled in an investigation into one of the world's biggest tax scandals, with investigators also reportedly looking at transactions involving banks such as Barclays, Goldman Sachs and Bank of America. A tax adviser who helped Macquarie engineer the deals, Hanno Berger, is one of six individuals charged in May over the scandal. Moore, and his successor Shemara Wikramanayake, were both likely to be interviewed as “persons of interest” or “suspects” by the Cologne Prosecutor’s Office, the bank said on Friday, as part of a group of 30 current and former Macquarie staff in this position. How did it come to this? A cache of documents leaked to German newspaper Handelsblatt, and shared with Fairfax Media, detail how Macquarie pushed ahead with the deals, which promised high returns, but also came with significant political and reputational risk.

Like the other banks now facing similar allegations, Macquarie was attracted by the potential for big profits, and assurances from external advisers that it was legal, though not without risk. Now, its most senior executives are likely to face some the fallout. Earlier that year, in May 2010, Macquarie’s Investment Solutions and Distribution division (MSIS), part of the funds management arm led by Wikramanayake, held a European conference. New York-based hedge funds turned up, and an idea that grabbed attention was the opportunity to use the controversial "cum-ex" trading strategy. It was classic financial engineering: a way to make big profits from a complex manouevre that seemed to serve no other useful purpose other than to create profits for the parties involved. The tactic exploited the fact that in Germany, share investors receive a tax credit with their dividend payment, as some tax is withheld.

In a nutshell, cum-ex trades worked by using short-selling to transfer ownership of a stock in a way that meant more than one party had the right to simultaneously claim dividend refund credits attached to a share. A different part of Macquarie had been involved in the strategy before, but it stopped it in 2009. Within a couple of months of the conference, a draft memo setting out the basics was sent out to MSIS division head Stephen Lucas, and the head of Macquarie Funds Group, Wikramanayake. “MFG has identified an opportunity to lend to 1-3 German hedge funds managed by Avana Invest... that trade strategies around German equities paying dividends,” the note said. The same memo said such trading strategies had been “a matter of some controversy in Germany”, and warned the German government could decide not to allow the funds to claim the full tax credits hoped. And there was also a risk of "negative publicity" for Australia’s biggest investment bank. Over July and August of 2010, Macquarie set about further investigating the dividend arbitrage proposal. The head of its Munich office, Axel von Rosen reported being told by its legal adviser, London-headquartered Freshfields, that other investment banks were “comfortable” with the practice.

Word of the new opportunity was soon getting back to the highest levels of the organisation in Sydney. In September 2010, a briefing was prepared by Lucas for chief executive Nicholas Moore titled “dividend arbitrage opportunities." “The benefit derived by investors in the current transaction arises because there is effectively a double crediting of the tax credits attaching to the dividend,” the memo said. In effect, this meant two investors claiming the same tax credit of a single share and its dividend. A more detailed memo to the Macquarie Bank board the next month estimated Macquarie's “base case” was that the deals would generate “net return on economic capital” of some 304.7 per cent. It said the deal complied with current legislation, but there was a risk "German authorities may seek to deny tax reclaims and take some other action against parties involved."

It was signed off by the board in late October, subject to an independent assessment of the political and reputation risks. Meanwhile, questions about the intricacies of German tax law continued to swirl around the deal. A November article by a German tax official argued that claiming the dividend withholding tax twice - the purpose of the "cum/ex" trade - constituted tax fraud. One of the leaked documents says that when Wikramanayake sought comment on this article, von Rosen replied it was "widely known that part of the tax administration have differing views about economic ownership." Later that month, Lucas emailed other bankers saying he had been told "every other bank doing this has decided to pull out and we are last man standing." Lucas, who remains a senior executive at Macquarie, wrote he felt "duty bound to follow this up" after they had told the board other banks financed the controversial trades.

In response, von Rosen wrote he had been advised they were "by no means the only party." Sure enough, dozens of banks are now facing similar investigations to Macquarie. In December, when Macquarie's main law firm Freshfields stopped advising on "cum-ex" trades following a government ruling, one of the bank's tax advisers wrote in an email to a hedge fund adviser, simply: "Big problem. Game Over." Yet there were other tax advisers at Norton Rose and Ernst & Young who were still telling the bank the trades it planned to finance complied with the law. Faced with this differing advice, the Macquarie bankers ultimately pushed ahead with a slightly different deal. They dumped a plan to lend to German funds and instead lent to Irish hedge funds also looking to do "cum-ex" trades. These deals went ahead in April of 2011, though the funds were unable to claim the tax credits as they had planned.

Had the trades being completed as planned, parties involved in the specific plan, including Macquarie, stood to make a combined "€462 million" in "unjustified tax benefits," it has been alleged in separate civil suit. It is these April 2011 deals are now at the centre of the Cologne Posecutor's Office investigation into Macquarie for "assistance for tax fraud." Macquarie on Friday said it was one of more than 100 financial institutions involved in the market, and it believed it was acting lawfully. One of its key advisers, Dr Hanno Berger, told Handelsblatt: "Everything Macquarie did was legal." Von Rosen's lawyer declined to comment. Beyond what happens with the investigation into Macquarie, however, the case has brought to Australian shores an industry-wide scandal that is estimated to have cost German taxpayers about €10 billion ($16.1 billion).

“A shockingly large number of players sought to unscrupulously enrich themselves at the public’s expense,” said Gerhard Schick, from the German opposition party, Bloomberg reported. “It was a glittering party." Although there were differences of opinion about the legality of the practice in 2010, it was banned in 2012. Fairfax Media and Handelsblatt put detailed questions to Macquarie about the affair last Thursday night. The next morning it released a statement to the ASX, which answered some but not all of the questions. It declined the opportunity for an interview. Regardless of where the criminal investigations lead, the episode also illustrates the lengths to which financial engineers will go in the search to make money by exploiting loopholes, or finding "opportunities," as they are described by bankers. The chief executive of the advocacy group the Tax Justice Network, Alex Cobham, says the general case of cum-ex trading is especially "shocking" because "there seems to be no intention whatsoever to add economic value or create profit."