It's been called "the devil's machine" and the "biggest bank scandal in history".
But on a spring morning in October 2010, the Macquarie Group board sat down to discuss the tax scheme using a more technical name: "German Short Trading".
The proposal before the board was to provide hundreds of millions of dollars to overseas funds, enabling them to take advantage of a quirk of the German tax system.
It had the potential to deliver up to $30 million to Macquarie for each lending agreement.
Macquarie's legal advice at the time said that the transactions were legal, and that other banks were taking part.
But there were potential landmines.
A memo submitted ahead of the board meeting noted: "The risk of reputational damage remains should the German authorities take action against the funds."
"lt is difficult to quantify the reputational risk associated with this transaction and we suggest [the Executive Committee] weigh this against the anticipated returns," the memo said.
There were also concerns about regulatory and legal risks.
Macquarie's then-CEO, Nicholas Moore, told the board the scheme would be examined by the legal team and auditors, and the plan was given tentative approval on one condition.
"The Board asked that management obtain an independent view of the reputation and political risks for Macquarie of entering into the transactions, from a respected German person/authority."
Less than a month later, it was approved.
A cache of documents
Macquarie's involvement in an overseas tax scandal has been leaking out of Germany over the past few years.
In a joint investigation with German investigative journalism outlet Correctiv, the ABC has obtained documents covering a period of six years revealing new details of key meetings and concerns raised inside the bank.
The documents show how Australia's largest investment bank took part in a controversial German tax scheme despite warnings of reputational damage and legal risk.
Macquarie's involvement has taken on new importance as the bank recently announced it was the subject of a rash of new civil claims involving the trades.
Macquarie's former CEO Mr Moore has also recently taken on a powerful new position overseeing Australia's two primary financial regulators APRA and ASIC, despite remaining a person of interest in investigations by German prosecutors.
The documents reveal current chief executive Shamara Wikramanayake received an email speculating that, in one tax expert's opinion, the controversial transactions, in some circumstances, could amount to tax fraud.
The matter was escalated, and the bank was reassured by its lawyers that there was no risk of the trades being seen as tax fraud.
German prosecutors are now investigating over a hundred banks and financial institutions, including Macquarie, for their involvement in the so-called "cum-ex" scandal, which has cost governments an estimated $80 billion.
"This isn't about a few rogue traders taking advantage of an opportunity in order to make personal gains," Alex Simpson, a criminologist who specialises in financial institutions, told the ABC.
"This is about whole industries taking advantage ... exploiting the German taxpayer."
Earlier this year, Macquarie told the market 100 current and former staffers were persons of interest in the investigation, including Ms Wikramanayake and Mr Moore.
Those investigations remain ongoing and the allegations against Macquarie have not yet been tested in court.
Mr Simpson questioned Mr Moore's appointment to the regulatory position given the unresolved questions hanging over him, and said it showed "the revolving door that exists between finance and regulation".
"That's tantamount to self-regulation, which is a deficit of accountability," Mr Simpson said.
Pass the parcel
At the centre of investigations in Germany is a scheme which was designed to exploit a tax loophole.
Even among the specialised minds of the investment banking community, the so-called "cum-ex" trading scheme was complicated.
It involved the rapid transfer of shares and their ownership rights during a brief window of time each year to reap a double tax refund from a single share.
In Germany at the time, authorities handed out refunds to shareholders who bought and sold shares around the dividend reporting date, as compensation for capital gains tax already paid.
But what Macquarie and other banks realised was that by quickly moving the share to a second party, a second refund could be claimed.
Mr Simpson described the trades as a "complicated kind of pass the parcel".
"It means that the German tax authorities don't know who owns the shares at what time," he said.
Macquarie has always argued it was under the impression the transactions were legal, even if they did involve what internal memos called "double crediting".
But in at least one case involving another bank, the trades have subsequently been found to constitute fraud.
In July this year, Germany's Federal Court upheld the convictions of two British bankers over their involvement in cum-ex trades.
In the circumstances of that case, Justice Rolf Baum held: "There was no loophole here."
"On the contrary, it was a bold grab into the till into which all taxpayers normally pay, which, by the way, is no different to ordinary sales tax fraud," he said.
The leaked documents reveal that, inside Macquarie, the practice was thought to be a legal loophole which was tolerated — although not endorsed — by the German tax authorities.
In one document from March 2008, a lawyer advised that "taking advantage of a loophole deliberately accepted by the legislator is in our view not inappropriate".
Macquarie's external lawyers provided reassuring advice that Germany "does not have a policy/approach in naming and shaming institutions".
In another note, Macquarie was told the transactions met German law and that other banks were up to the same thing, noting there was only a "remote risk" the bank "may be associated with a transaction seen by the German tax authorities as undesirable".
Macquarie had initially participated directly in cum-ex trades but by 2009 the bank was weighing up the risks of lending money to clients to take part in the transactions instead.
Even with the trades at arm's length, the leaked documents reveal lingering disquiet among some senior managers.
"It is a bit strange that we are financing trades that we cannot get comfortable with to do ourselves," wrote one senior executive in October 2010.
"Providing finance may be fine but the actual trades probably have some curly tax issues."
But one of the supporters of lending money to fund the trades, according to the documents, was then-CEO Nicholas Moore.
"Nicholas rang me last night to discuss our capital usage," wrote an executive in an email.
"Of course, when he saw the size of the overall pie, he was interested in whether Macquarie should be doing more on these trades.
"When I said that I understood [there were concerns] that none of us should be participating in this business he said don't worry about that and asked if I could send him a note that explains how the deals work and who plays what role etc and what roles we thought the broader Macquarie could play."
In November 2010, as Mr Moore was seeking an external opinion on the trades to satisfy the board, an email with a worrying prediction threatened to derail the whole enterprise.
"Presume you guys have seen this," the email said.
It was sent to Shemara Wikramanayake — who eight years later would succeed Mr Moore as CEO — and contained a tax alert from the Big Four accounting firm EY warning anyone seeking to engage in dividend trades.
It quoted a German official called Jan-Willem Bruns, a leading member of the German tax authorities in Hamburg, stating that, in his view, in time the transactions may come to be viewed as tax fraud "if the buyer is aware of the fact that German dividend withholding tax is claimed twice".
"The German tax authorities want to tackle double reclaims," the note said.
"It will be only a matter of time until the question of beneficial ownership in case of cum/ex short sales will be presented to the German tax courts."
"Thoughts?" Ms Wikramanayake wrote as she forwarded the email for a second opinion.
A colleague's reply said authorities had varied opinions about the trades.
"Shemara, we know this publication and it is also widely known that part of the tax administration have differing views," the colleague replied.
"There was an article just a couple weeks ago from a law professor who expressed exactly the opposite view."
Legal advice subsequently confirmed that Macquarie's involvement would not amount to fraud.
Around six hours after this email arrived, the Macquarie board met again and the application to provide funding for the transactions was approved.
The German government closed the tax loophole in 2012 and Macquarie has since repaid around $150 million, according to local media reports.
The ABC sought comment from Ms Wikramanayake and Mr Moore, but both declined to be interviewed.
A spokeswoman for Macquarie issued a statement saying the bank continued to "cooperate constructively with German authorities" and was "unable to comment further".
Federal Treasurer Josh Frydenberg told the ABC in a statement that Mr Moore was the right person for the job of overseeing Australia's financial regulators, describing him as "an outstanding business leader with ... an in-depth understanding of Australia's regulatory framework."