# Portfolio Margin Systems

Back to Blogs

Published On

January 11, 2023

### Introduction

You may have seen the 2011 film “Margin Call” about the hours before the 2008 crisis, or even “The Big Short” that showcases the greatest swaps purchased in recent financial history. Both movies delve deep into the world of derivatives for careful viewers, and into a story of cascading liquidations and margins for the more meticulous moviegoers. In 2022, 14 years after 2008, we find ourselves in a similar situation of liquidations and portfolio management, but only in the next era of the financial sector.

The liquidations we’ve seen are primarily a fault of margin trading – trading with borrowed capital from entities that are many multiples above the capital that you can provide yourself. Margin trading solves the problem of limited capital: purchasing $100 of ETH versus purchasing$1000 of ETH will obviously result in largely different profits – what if you were to purchase $100 of ETH using your own money, and purchase the remaining$900 of ETH with borrowed capital from an exchange? This way, even though you only put up $100 of your own money, you’re trading with$1000; this is margin trading. Financial institutions, typically brokerages, often charge interest on the margin loans, or deduct a percentage of the overall trade as a fee (larger the trade, higher the fee!) which makes margin loans extremely enticing for the firm as well. Through the blockchain, as we aim to create a truly open and decentralized financial system, we must look at how we can approach solving limited capital for investors within this system as well.

This article looks to explore portfolio margin systems – systems that manage the requirements for liquidation – in greater detail. We specifically delve into on-chain portfolio margin systems, and uncover the problems of creating such systems. We will understand the problems of computation on the blockchain (going all the way down to the architecture of decentralized ledger technology), oracle latency, and even how decentralization might be unwelcome in certain aspects of the financial system. But, before we get any further, let’s first understand the concept of margin

To understand what margin is, you’re required to know about leverage. Most exchanges offer their traders a leverage, i.e. a loan that traders can use to trade in assets. The idea is simple: you could either trade $1000 of your own capital and earn a return on investment (ROI) of x%, or you could deposit the$1000 as collateral and use $10,000 of borrowed capital to earn a ROI of 10x% . Margin is the collateral that a trader has to deposit with their broker or exchange in order to borrow leverage. It covers the credit risk posed by a trader when they borrow cash from the broker; it is very integral in case the trade goes south. However, it is tricky to trade with margins owing to the risk of a margin call (callback to the movie). A margin call occurs when your collateral does not meet the requirements to back your “loan”, i.e. the entity that lent you capital is exposed to uncomfortable credit risk. This margin call is a (rather forceful) plea from the exchange to increase the amount of margin in your account; else, your position is liquidated. Let’s look at an example to better understand. ### What About A Margin Call? Let’s say you’ve deposited$3000 as margin to cover a $10,000 leveraged trade. You’ve put this$10,000 into $ETH post-merge, and are eagerly awaiting for the economic conditions to improve. This$10,000 is essentially split into $3,000 of your capital, and$7,000 of the exchange’s capital. However, a few weeks later, FTX unexpectedly declared bankruptcy and the entire market crashed. Your $10,000 position fell down to$7,200.

An important thing to remember, an exchange will never take on credit risk on its own (in this case, a risk of $7,000). At this point, your position is split into:$7,000 of the exchange’s capital and $200 of your capital. The exchange will send you a margin call – ”deposit$2800 and top up your position to the full $10,000”. If you don’t top up at$7,000, you’ll log back into your account and find that your position (and your collateral) is gone! At $7,000, the exchange was exposed to losing some of its capital. It sells off the$7,000 of ETH from your account, retains its cash, and you’ve lost all your margin.

This is an example of liquidation.

### Overview of Portfolio Margin Systems

Exchanges don’t like seeing their investors lose money – it’s not great for brand reputation. They aim to be as efficient as possible with the margin, so the margin call can occur as low as possible. This efficiency is possible through a well-functioning portfolio margin system.

The objective of a good portfolio margin system is to offset the risks to the lender through consolidating, or netting, positions to account for a portfolio’s overall risk. It typically results in lower margin requirements for hedged positions compared to traditional policy rules. The system must allow investors to trade a portfolio of securities with less capital than would be required if each position were traded separately.

Portfolio margin accounting requires a margin position that is equal to the remaining liability that exists after all offsetting positions have been netted against each other. For example, if a position in the portfolio is netting a positive return, it could offset the liability of a losing position in the same portfolio. This would reduce the overall margin requirement that is necessary for holding a losing derivatives position. Similarly, if an investor has a portfolio of stocks and bonds, the portfolio margining system will take into account the fact that the stocks and bonds offset each other and can lower the margin requirements for the portfolio as a whole. This can allow the investor to trade the portfolio with less capital than would be required if each position were traded separately.

### Portfolio Margin

- Initial and maintenance margin is the same

- Traders can use margin on long options and they can use long options as collateral for other marginable trades

- Trader's overall portfolio is evaluated by offsetting positions against one another

- Buying power (maintenance excess) = net liquidation value - margin requirements

- Broad based indices allow for more leverage

- Stock volatility and hypothetical future scenarios are part of portfolio margin calculation

### Portfolio Margin Systems in Crypto

Crypto and web3 are rapidly evolving the financial markets in more ways than one. As such, it needs to mature and adapt – adding on what has made traditional financial markets so successful. Derivative markets, prediction markets, margin – these are the transformations within TradFi that have occurred over the last hundred years, but must be a part of DeFi and crypto going forward.

DeFi is quickly accelerating to become a powerful financial system as evidenced by $300bn in TVL at its peak pre-May (grown by 1400% in less than 2 years) to Jerome Powell speaking of DeFi’s future impact on global economies. Some in DeFi have begun to transition to an era of KYC-less borrowing and lending, and even automated options-underwriting systems; DeFi simply needs to maintain its current rate of innovation and incorporate more aspects of TradFi – portfolio margin systems being one of them. But, it’s not easy to buidl in web3 just yet. There are multiple considerations to make instead of only server architectures and sprint schedules – builders need to plan for decentralized vs. centralized architecture, gas fees, trade-offs between chains, choice of oracle architecture, and much more. There are significant bottlenecks in web3 development, and as the complexity increases these bottlenecks narrow. Portfolio margin systems are computationally heavy and there are significant difficulties with hosting these systems on-chain; let’s take a look at some of the bottlenecks to developing on-chain portfolio margin systems. ### Bottlenecks of On-Chain Portfolio Margin Development #### Computation Ethereum might be one of the most novel technologies of the modern era, and some consider it to be “the world’s computer”. With the benefits of immutability and security of blockchain infrastructure, and the power of computation, Ethereum has evolved to be the home of thousands of decentralized applications and smart contracts. Smart contracts are programs stored on the blockchain that execute certain actions – for example, the act of trading one token for another can be executed through a smart contract. However, storage on blockchains cost a certain amount of money called gas fees. Similar to how one may pay fees for computing credits to use AWS databases, people have to pay gas fees to operate on the blockchain. These gas fees are used to compensate miners/validators who validate transactions on-chain. Purchasing an NFT, or conducting a trade on Uniswap, costs around$80 on a good day (on Ethereum), but the cost of storing data on the blockchain is far more expensive than the cost of a simple transaction. Storing a 256-bit word on the blockchain costs 0.001 ETH, a kilobyte of data costs about 0.032 ETH or $38.4 USD by current prices, 1 MB of data costs about$38,800 USD, and 1 GB of data…$38,800,000! Note, this is the cost of storing data on the Ethereum blockchain, but alternatives aren’t much cheaper; the cost of storing 200 kb of data for a year on Solana is about$1000 per month (as per SOL prices in February), for example.

While simple smart contracts with a few kilobytes of code can easily be stored on blockchains at a (relatively) low cost, the cost of storing heavy code is extremely high. And, when it comes to code to accurately calculate portfolio margin (with live price feeds, to churn out an executable action in a matter of seconds), you would be demanding a ton of storage on the blockchain. The amount of storage required by intensive portfolio margin systems is simply too costly to afford for most companies, hence an enormous bottleneck in the creation of on-chain margin systems. Furthermore, calling these intensive smart contracts multiple times per minute is costly and creates latency in the protocol – further diminishing the power of on-chain portfolio margin systems.

To account for this, protocols must significantly dial back the power of their system – minimize the number of positions being calculated, restrict the number of assets that can be accounted for by the system, use delayed data instead of live price feeds, and so on. However, these changes drastically undermine the utility of portfolio margin systems. For example, OptiFi (a Solana-based derivatives decentralized exchange) only allows for a limited number of instruments whose positions can be computed by their on-chain portfolio margin system. For options markets that expire December 1st, OptiFi’s on-chain system can only compute up to 8-9 strikes owing to the intense computation required for anything more! As a result of these inefficiencies, MarginFi (a Solana-based portfolio margin system) is working on moving its entire risk-engine off-chain. The benefits of being off-chain far outweigh the costs of centralizing the system; in addition, they intend on using oracle bridges and decentralized infrastructure to maintain transparency but an off-chain margin system is exponentially more powerful and efficient than an on-chain one – on-chain settlement + off-chain computation = maximum speed.

#### Oracle Latency

Oracles are a significant aspect of the web3 ecosystem – important to connect blockchain infrastructure with all real-world data. Decentralized Oracle Networks (DONs) enable the creation of “hybrid smart contracts” where on-chain code and off-chain infrastructure are combined to support advanced decentralized applications (dApps) that react to real-world events and interoperate with traditional systems. The disconnectedness of smart contracts with the real world are essential to valuable properties like strong consensus on the validity of transactions, prevention of double-spending attacks, and more. However, the disconnectedness also prevents smart contracts from acting on real-world data – financial, social, anything! DONs are essential to solving this problem.

However, in their current form, oracles introduce “the oracle problem” – how can we trust the oracles? While different oracle systems have their own solution to this problem, the time required for data validation across most (if not all) oracle systems today is additional time for a computation; this is latency. If validation was rushed, then the integrity of data is compromised and that’s an entire can of worms that should never be opened for decentralized systems.  In the context of portfolio margin systems, the issue of latency is additional time taken to complete a computation and may force systems to work on delayed data; as portfolio margin systems need immediate calculations or else they run the risk of a large market movement affecting liquidations and compromising multiple leveraged positions, any latency is a no-no.

Once again, if a portfolio margin system was to be on-chain, oracle latency proves another bottleneck for margin protocols. While a hybrid system that uses centralized data collection may avoid latency, the need for trustlessness is very much present. Another mechanism of offsetting the risk of oracle latency is by implementing SPAN margin in on-chain options protocols (collateral put up by the user to cover against possible adverse risk movements). Yet another mechanism is to simply improve oracles, as Chainlink has done with its low-latency oracle solution for the DeFi derivatives market. However, more systems simply attempt to completely remove the dependency of oracles (and data collection) to avoid costly seconds in computation. For example, Panoptic is an “oracle-free options protocol” built on Ethereum that handles the minting, trading, and market-making of call and put perpetual options. Panoptic uses a different pricing model for their options (as opposed to Black-Scholes that requires external data like implied volatility and spot prices), that is path-dependent and will grow at each block according to the proximity of the spot price to the option strike price. The premium is not an upfront cost, but is instead deducted from the gain (or added to the loss) at the end of the option’s life after the path-dependent calculation is complete!

#### Front-running

This is a niche problem for EVM chains owing to the way validation/verification of transactions occur – through the mystical mempool. The mempool is a waiting area for transactions that are yet to be validated, and that are publicly accessible. This mempool is the primary reason for MEV, but also for front-running. Front-running is the process by which individuals can scan the mempool and watch for certain transactions (typically high-volume buys or sells of an asset). While such a transaction waits to be validated and verified, the trader can create a high-priority trade based on this information. For example, if there was information that someone was selling 100,000 ETH, this means that the price of ETH may drop; the keen-eyed individual who’s scanning the mempool can short ETH while this transaction waits to be validated and make money!

With order-book protocols (like OptiFi), EVM chains with mempools pose front-running risk which could be very costly for the protocol (slippage for traders, lack of users, MEV opportunities for traders, and so on). This is yet another bottleneck for any order-book mechanism, let alone a portfolio margin system!

#### Unwelcome Decentralization

Blockchain infrastructure is meant to eliminate the intermediary – if Person A wishes to interact with Person B, there should not be a Person C to facilitate the interaction as A and B should interact directly! But sometimes, the presence of an intermediary is beneficial, especially when it comes to derivatives and portfolio margin systems and leverage. To avoid a single user absorbing the credit risk of another, intermediates were set up to absorb all risk (from clearing houses, to banks, to even e-trading platforms to an extent). However, as blockchains eliminate the intermediary, the credit risk is eliminated with much more mathematics – if the system calculates an impending opportunity for credit or counterparty risk, it auto-liquidates a position and fulfills the transaction! For example, if someone had a margin call at $1000, the margin call will immediately be done. While this is fine with smaller margins, when it comes to larger margin top-ups, individuals/firms may need some time to fulfill this transaction. If a firm had a margin call at$100M and needed \$400M more to top up their margin, this isn’t something that can be done in a few hours, let alone a matter of seconds.

Intermediaries and off-chain portfolio margin systems allow for a certain level of flexibility. For example, when an investor gets a margin call, they are given around 3 to 5 days to top up their margin and prevent liquidations, even if their position’s value decreases further. However, in DeFi where “code is law”, this flexibility is unwelcomed. Investors may not get the 3 to 5 day buffer, because as soon as their margin meets the minimum threshold, it will be liquidated. On-chain portfolio margin systems pose an enormous risk to highly leveraged traders owing to their strictness with liquidations. While on-chain portfolio margin systems may be more flexible the question is how, to which we simply don’t have an answer yet.

### The Need for Portfolio Margin Systems in DeFi

The blockchain offers speed; efficiency, and trustlessness, to create an open financial and transparent system. As we aim to integrate more aspects of the TradFi industry with DeFi and blockchain infrastructure, we face important bottlenecks owing to the foundation of decentralized ledger technology. With the problems of expensive computation, oracle latency, and perhaps too much transparency that risks front-running, we must find novel solutions as we develop the DeFi industry.

However, portfolio margin in DeFi will be especially important owing to the multiple streams of risk offsets that can be taken into account – staking yield, emissions rewards, DOV passive income, for example. In TradFi, multiple securities are calculated to offset one another but DeFi completely disrupts these models; it isn’t just cryptoasset prices that must be offset but the multiple streams of passive income and rewards for a DeFi investor. If this was taken into account, DeFi could truly push the boundaries of leverage and margin trading with investors being able to borrow many times what’s possible in TradFi markets. It will be important to work towards creating better margin system models and not copy TradFi counterparts. The current TradFi margin system model is the Theoretical Intermarket Margin System (TIMS); this must be transformed to allow for investors to take leverage on their positions and not just their assets.

Further, it’s important to note that DeFi allows for interoperability between protocols. A margin you hold on your TD Ameritrade cannot be used as margin for another broker, but DeFi would be able to allow for this interoperability!

### Conclusion

To conclude, portfolio margin systems will be pivotal to the success of high-frequency trading and attracting many investors. With on-chain versus centralized margin systems, there are significant trade-offs, but on-chain systems have the potential to push the boundaries of leveraged trading as never before. While it can be debated that the process of liquidation should be made less harsh, the benefits of on-chain margin systems are truly aplenty. We are entering a new era of finance – decentralized options vaults, minute liquidity provision, KYC-less finance – and margin trading is an important piece of the puzzle.

Article by
We've recently updated our privacy policy. The updated policy can be found here. Continued use of our services constitutes acceptance of our updated policy.