# Thinking Around Margin Trades and Shorts
## TLDR
The question that set us off was where the liabilities go: whether they stay in one pool or travel with the borrowed tokens. Tracing a rough ledger of a traditional equity short sale, we concluded that the liabilities have to stay with the originating pool(s) and agent, and that no liabilities go to whomever purchases the borrowed asset.
## Definitions
There are two ways to take a position in an asset: long and short. Since every hedge is some combination of these two primitives, they should be clearly defined. They are defined here in terms of the underlying belief of the trader, as well as the orders they make.
A **long position** believes the value of the asset will rise, and hopes to profit from that rise. A trader opens a long position by purchasing some quantity of an asset. They close their long position by selling that same quantity of that asset.
A **short position** believes the value of the asset will fall, and hopes to profit from that fall. Being short in an asset means investing in it in such a way as to profit when it falls in value. A trader effectively purchases an obligation that will increase in value as the underlying asset falls.
## Equity Shorts
There are two asset classes that are relevant here, each with different implementations of a short that could be useful: equities and currencies (forex).
In an equity short, a short seller borrows a quantity of stock from a broker. The broker lends the stock from their own inventory or from another margin account. On behalf of the short seller, the broker sells the borrowed stock, providing the proceeds (net fees) to the seller. As time passes, the broker collects interest on the loaned stock from the short seller. If the price of the stock falls sufficiently, the short seller orders the broker to buy the same quantity of stock back and pockets the difference (sale price less buy price, fees, and interest). If the price of the stock rises, the difference between the sell price and the current price will eat into the short seller’s margin account. Eventually, they will have to buy the quantity of stock back at a loss. The broker, meanwhile, collects fees and interest regardless of the direction of the stock’s move.
### A Rough Journal
Using this equities interpretation and applying it to token trading, an agent believes that the price of bitcoin will fall and they wish to profit from it. Leaving aside the question of the swap into Rowan, we can go stepwise:
The agent borrows a quantity of bitcoin from the liquidity pool
+ agent assets (agent borrows bitcoin)
+ agent principal liabilities (agent owes bitcoin to lp)
+ agent interest liabilities (agent pays lp for the loan)
- liquidity pool assets (lp has lent out bitcoin)
+ lp liabilities (lp has to get that btc back)
+ lp assets (lp gets fees for loaning btc)
The agent sells the bitcoin into another liquidity pool
- agent assets (agent has no bitcoin)
+ agent assets (agent has whatever currency they used to complete the sale)
+ lp interest assets (lp gets interest for the loan)
Agent purchases bitcoin from somewhere
+ agent assets (agent has bitcoin)
- agent assets (agent pays for bitcoin)
Agent returns btc to original lp
- agent assets (agent gives up bitcoin)
- agent principal liabilities (agent returns bitcoin)
+ lp assets (lp regains bitcoin)
0 lp liabilities (lp returns bitcoin to pool)
0 lp interest assets (lp no longer receiving interest payments)
The point of this is to demonstrate that in this equity-style short, the person who purchases the borrowed asset does not incur any liabilities. That pool/agent is under no obligation to ‘sell back’ the token that they purchased. In a strict ledger, they would be decreasing their cash and increasing their btc. Any liabilities in this transaction are still on the side of the short seller and the pool they borrowed the shorted asset from.
## Currency (FOREX) Shorts
Unlike equities, currencies trade in pairs. That is, a trader uses one currency to buy another. The major pairs include the dollar/euro, the yen/dollar, and the dollar/pound. By using dollars to buy pounds, a trader is taking a de facto short position in the dollar and a long position in the pound. Their expectation is that the dollar will be worth less in the future against the pound. A currency or forex (foreign exchange) broker collects fees on the transaction.
## Relevance to Sifchain Margin Trading
Under the swap mechanism that is implemented with the margin trading model, we might say that an agent that has bitcoin shorts that bitcoin when they swap for rowan. At the same time, they go long in rowan. If they make a second swap, they will have shorted rowan in favor of the second token. Of course, by taking any long position in a token using dollars, a trader is effectively shorting the dollar, and vice versa.
The single swap example is really a margin purchase to open a currency-type short. Once the mtp is established with some token (X), it swaps those tokens for rowan (Y), then borrows additional rowan (hence, the margin) for which interest is earned by the pool (and incurred by the borrower). The original swap is a short insofar as the trader has exchanged X for Y.
If the trader wishes to be short in Rowan, they must use Rowan to purchase some other token (Z), with the intention (obligation?) to use Z to purchase Rowan at a later point in time. If a trader holds some token X, but actually wishes to hold a short position in Z they should use Z to purchase X…
### Undeveloped Notes Hereafter
X -> Y // Short X, long Y
Y -> X // unwinds the short position in X by going long in X using Y….so long as the quantity of the Y tokens is the same; not the value. The hope, obviously, is that the value of X has fallen relative to Y (that rowan has gotten more expensive, so that the same quantity of rowan purchases more X)
So why is the double swap necessary?
If I only hold X but I want to hold a short position in Z, obviously. But how do you get there? The swap from X -> Y creates a short position in X. The swap Y -> Z makes it long in Z short in Y. So you have to collateralize some quantity of X in order to acquire the Z that you swap with Y. Even then, though, you’re still shorting in a Z:Y pair, not an X:Z pair. Is Rowan really supposed to fluctuate that much?
But I don’t want to ‘own’ an asset that I think is going to fall in value, period. That’s just not a rational-investor thing to do. So to open a short position in Z, I instead borrow a quantity of Z, using a proportional value of X as collateral, and sell that. BUT Y has to be in there somewhere, somehow. That’s how the system has to work.
So, again, if I want to short X, I have to swap for an amount of Y that will get me the amount of Z that I want to short
Let’s say that I somehow figure out how to open a short position in Z, when all I hold is X. What happens when I close that position?
There’s no way to sell Z for X. We have to sell Z for Y and then sell Y for X.
Two main groups of users: traders who are coming in to swap, and liquidity provider who have provided some of those two stacks.
2021.Aug.19 Mtg w/ Barlin - Things to capture
Custody, Collateral, Margin
A trader opens a margin account with their broker by putting a sum of money up as collateral. That sum allows a purchase of about 50% of its value for some stock(s). This is the loan, and the broker collects interest on it.
Custody in the sifchain specification is effectively both margin and collateral because of how it's now being treated - since it’s what’s being used to pay margin fees. It is a doubling of the collateral used to purchase the assets in question. In essence, a trader has to put up collateral twice: first to borrow the initial token, and then to make the swap from Y to Z. It might behoove us to clarify this particular position and the role of custody in all of this.
Simplifying Assumptions: There’s Always a Buyer
What does the margin trading system as specified assume about transactions?
Does the pool make decisions or is it individual traders and LPs inside the pool?
There may be an implicit assumption that there is always a buyer for a sale. This particular assumption may hold in most cases, contingent on the depth and breadth of the pool, but in the event of an explosion or implosion - the times when a short is most useful for hedging - there may not be a buyer for the sale.
A transaction cannot happen in any system without two parties: a buyer and a seller. A person who wants to sell but cannot find a buyer, either at their desired ask or at any price, is not a seller. They’re just a person with something to sell.
As a short seller, I don’t have to buy the tokens back from any particular individual/pool/market. I have to buy them from somewhere, though.
Who lends?
-- health intended to be a high-frequency sensor. Such that if health is poor (down/more liabilities than assets) the interest rate on margin has to go up.
Multiple pools for each rowan/token pair?
Is the pool the buyer? Is it an individual LP the buyer?
Hold some time in the meeting to discuss:
-- Collateral vs custody vs margin
-- Accounting of a liquidity position?
-- Assumptions around buying and selling broadly
-- -- Automated market maker are implicit counterparties
-- -- -- They are continuously making offers/purchases/sales on the pool’s behalf?
-- -- -- Is there a reason to make the counterparty more explicit?
-- -- -- -- If you short, you borrow some asset and then trade in such a way to have debt in the asset you borrowed that you are shorting. The AMM
-- -- -- -- The borrowing from the counterparty is novel in this system.
-- -- Merging Barlin’s version of the short in our specs.
-- Add to the narrative here
-- Multiple pair pools?
-- Can we subset user stories? (LP vs margin trader vs swap)
---- Users coming in to make swaps vs users opening margin positions