How it works
A normal on-chain margin trade
Having grasped the basic concept of Margin Trading and Flash Swap, let’s dive into how Flæx utilizes these features to power its own trading platform.
For margin trades, it is common that a trader has access to a pool of assets available for borrowing.
Roll back to the example in Basic understanding about margin trade, supposed John would like to go for a long position on ETH/USDC.
Since John is going on long on ETH, which is the base token, John has to already own some ETH and needs to borrow some USDC in order to buy more ETH.
John can go to any existing Lending Protocols such as AAVE, Compound… and deposit his ETH as collateral, he then is eligible to borrow any other allowed assets against his collateral. In this case, he can borrow some USDC, which is the quote token, to buy more ETH.
However, Lending Protocols limit his borrowing power due to their “over-collateralized” model, which means he cannot borrow more than what he has put in as collateral. In fact, he can only borrow at a maximum cap of around 80-85% depending on which kind of assets being supplied.
Let’s say John put in 0.5 ETH aka $1500 (at a value of $3000 per ETH), he decides to go for an 80% maximum cap of borrowable, which is equal to 1200 USDC and buys another 0.4 ETH.
At this point, John’s position would be:
Collateral: 0.5 ETH
A loan with Aave: 1200 USDC
Available asset: 0.4 ETH
This would mean that John has entered a Long position in ETH/USDC at 1.8x Leverage.
What John can do now is re-supply his 0.4 ETH to the Lending Protocol to “rinse and repeat”, effectively keeps increasing his leverage.

However, one can clearly see that this approach poses a great deal of risks and requires many repetitive transactions. John can be instantly liquidated right after he hits his first borrow at 80% as the interest is accrued to his debt.
Leverage conflict
Assume ETH/USDC is $3,000. John wants to long 1 ETH but only has $1,500 USDC, aiming for 2x leverage. Following the previous examples, the goal is to borrow an additional 1500 USDC so that, combined with the 1500 USDC (or 0.5 ETH) he already has, he can purchase 1 ETH
Let’s check out the flows:
Step 1: John somehow could borrow 1,500 USDC from Aave
Step 2: John uses 1,500 USDC he borrowed, plus the 1,500 USDC he has, to buys 1 ETH on Uniswap
-> This is simply impossible from step 1 because John could not borrow $1,500 USDC from Aave if he haven't deposit 1 ETH as collateral yet!
This is where Flæx comes into play and provide an extremely clever solution.
Flaex's solution
In order to increase leverage, the most crucial task is to be able to keep on borrowing, buying assets and re-supplying those assets back as collateral.
After the first borrow, John is left with 0.5 ETH which he would definitely continue to re-supply into the Lending Protocol as collateral. What if John has access this 0.5 ETH even before he has to supply the first 0.5 ETH? If John can achieve this, he can actually supply 1 ETH and thus has effectively increased his borrowable amount.
It turns out that this is entirely possible thanks to the power of Flash Swap. After first Flash Swap 01 ETH, he can now supply 01 ETH into the Aave as collateral and proceed to borrow the same $1,500 USDC as previously explained plus his initial $1,500 USDC to repay the Flash Swap amount.

In this case, John only has to borrow a much less amount of USDC which is reflected in terms of loan-to-value because:
Collateral: 1 ETH
Borrow: 1,500 USDC
Loan to Value: {1500 / (3000 USDC per ETH)} / 1 = 50%
John can easily increase his leverage by increasing the Flash Swap amount, as long as his loan-to-value doesn’t exceed the maximum cap, he will not be liquidated.
At 80% maximum cap, John can effectively go as high as 4x!
This model attracts investors who are willing to become "collateral providers" to earn real yield generated from both interest rate from AAVE and sharable profit from other trader’s commission fees.
To see how a transparent liquidation works, see
Last updated

