PRO: Leverage Bible

Some tips for skilled [degenerate] farmers and traders.

A different understanding of "collateral"

DeFi users are accustomed to think of collateral as "my idle asset, sits there and affects my borrowing power for better or worse, but doesn't change". With Gearbox, it's not exactly like that. That is because the entire composition of your Credit Account, whatever you have on it - be it WBTC or a farm token - acts as collateral to your debt at the same time. Denominated in the debt asset, of course.

Your starting asset(s) are usually not relevant. What is important is your debt asset - and then all of the assets on your Credit Account denominated in that debt asset.

If you go put in ETH and WBTC but then swap all your assets into a stablecoin farm - your collateral now is the ERC20 representation of that stablecoin farm. Your ETH became something else.

In case you want to keep your asset as truly idle, for example you want to keep ETH yet borrow stables and grow your borrowing power, then you need to keep it idle on Credit Account:

  • Open a Credit Account with debt in stablecoin (USDC, for example)

  • Put ETH in there as collateral and NOT sell it or not ape it into a position

  • Borrow more stables due to ETH borrowing power

You lose some capital efficiency since not your entire position is "working", but that might be indeed your strategy. ETH goes up and u can borrow even more stables - that could work!

What is the minimum / maximum borrow and leverage?

The protocol works without any trust or off-chain mechanisms, so the values are derived from onchain. Even if the interface sometimes can show that your maximum leverage is reached - in reality, by interacting with the contracts onchain, you could squeeze to the last bits! But maybe don't...

The dApps have a green sliding bar to help you figure this out.

The reason why minimum borrow limits are in place is to ensure that liquidations work safely, so that no bad debt accrues to the protocol. The higher the minimum borrow limit, the more likely it that ~3% or so of the liquidator fee would make up for the gas fees and slippage they pay during a liquidation process. Check inside the integrations page.

The limits on Credit Accounts are enforced on the contract level by minimum borrow and maximum borrow limits. As per the DAO governance, those can change. The dApps will help you figure this out and show you the max available leverage as well as the minimum amount to borrow.

  • Min leverage is only defined by the minimum borrow amount. If $20K is the min: it can be an x2 position if you do it with $20K initial capital [your capital worth $20K where $20K is the minimum limit x2 leverage = $40K total]; or can be an x6 if your initial capital is $5K [your capital is worth $5K and at x6 it means your position will be $30K total, so $25K borrowed].

  • Now, the maximum leverage is more complex than that...

How to calculate max leverage?

First of all, you need to understand how Health Factor works. In a nutshell, all of the assets on your Credit Account are denominated in the debt asset you took as a borrowable asset. In other words, all the assets on your Credit Account in total act as collateral. Whether you have some ERC20s on your CA or farming positions - all of them have LTVs with respect to the debt asset you have chosen.

In case you want simple liquidation levels, you can isolate positions per different debt assets. Like: stablecoin farm vs stablecoin debt asset. Or ETH Lido farms with WETH as borrowed asset (debt). Then it's much simpler for you to know the liquidation prices. In case you cross-margin a few positions with different assets within a single Credit Account, it becomes harder. But maybe that's your goal after all, like those trying to go delta-neutral or get paying longs Boosted Long/Short or "Free Leverage".

The math for max leverage works as follows:

Let's say you go into Convex GUSD3crv farm [stkcvxgusd3CRV] with debt as USDC. If LTV for that is 90, the max leverage would be: 1/(1-0,90) = 10x. Let's do yvCurve-stETH [Yearn farm for stETH/ETH Curve pool] with WETH as debt. The LTV for either is 90 right now. That means 1/(1-0,90) = 10x as well. If LTVs for some farms become higher, more leverage could be applied.

That's technically the max leverage you can take which will make your HF = 1. If the deviations in assets within a farm [assets on your Credit Account acting as collateral] never occur - then you can remain as is, but that's VERY risky. It's better to count in some fluctuations.

You don't have to assume the worst case scenario right away. You can simply rebalance and reduce leverage [or debt] to avoid liquidations. If you are active in DeFi, you can take changes after sensing a farm could be worsening. No requirement to do it from the start.

How to max out leverage... but kinda "safely"?

These tips are for traders & farmers who are absolutely degenerate. Maximum leverage, maximum risk. Exercise with caution. It's better if you are able to understand Etherscan WRITE functions in case anything goes wrong with the interface. Be careful and read the code!

Keep in mind that in reality you could encounter slippage, fast price changes, and other scenarios - so don't try to squueze every last drop unless you are a MEV guru. It's better to be safe and reduce your desired leverage factor by at least a factor of 0.5 to account for those. It still keeps you maxed out but helps avoid a liquidation.

Let's say you want to go into FRAX3Crv. Out of all the assets inside, you might think that FRAX has some perceived risk. Maybe yes maybe no, doesn't matter for this exercise. Your debt asset is USDC, and you just wanna max out this farm. Let's say LTV is 90. The formula is:

Where N is the max leverage factor that you are trying to find, and p is the price you think that FRAX price could drop to. Let's say you think that the lowest it could go to is $0.95. So then it is:

That means with leverage of x6.8 you are still fine even if FRAX price drops to $0.95.

Here is the link to the sheet above. Copy and play with the values, check scenarios, etc.

Let's try this exercise with Convex steCRV [Curve stETH/ETH pool]. That would be:

That is max leverage factor you can apply if you are afraid of stETH ever revisiting its lows compared to the debt asset (ETH). In case you think the lows could be 0.90 relative to ETH, then the max leverage would be: 1/(1-0,90*0,90) = 5.26. Still, pretty damn capital efficient to farm with such leverage! FYI, Gearbox Protocol currently uses USD Chainlink or Redstone price feeds, so the ETH debt calculations are using an extra hoop when it comes to conversions.

Check this article about Yearn, Curve, & other oracles. And read code!

What oracles are used?

As a simple reply: currently, only from oracle providers like Chainlink and Redstone. So this is where you should look for the source of truth, it's onchain.

With farming positions it's a bit more tricky. For the implementation of Curve pool oracles [as such, Yearn & Convex positions for these assets respectively too], custom PriceFeeds look at virtualprice * price of the cheapest asset inside the pool. That is because in an event that any one asset inside a Curve pool goes down in price, the pool automatically trades into that asset. So while not a 100% will be traded into it immediately, for the safety of Gearbox Protocol, the worst case scenario is assumed when calculating the position value. -> Contracts deployed are available here.

For the avoidance* of Cream-like flash loan attacks, there is a min-max range applied to LP token price shares, which can be observed in the code/audits + mentioned in here.

*That is, unless a new attack vector is found. Security is important, please verify.

Slippage & price impact. Beware of MEV!

When swapping large amounts at once, you can encounter slippage. That is totally normal to have, like 0.05% on $1M is not unusual = $500 loss. But you have to keep in mind that you can't socialize losses with the borrowed capital, so that loss is applied to your assets within the Credit Account. Otherwise it would be an attack vector that would let an attacker "lose" all lender money.

What it means is that if you went x10 leverage on $100K of your capital, you will technically get a 1% loss on your capital, meaning -1% instantly. Sounds scary? Hold on!

That is not really an issue if you are leverage farming, because your larger position also makes back larger APY (per each leverage factor). On a medium to long-term timeline (or even short-term) this is practically negligible. It's the same as if you did not use leverage!

You might want to use MEV protection, something like MEV blocker.

You keep all the profits to yourself. Just don't... trade poorly, ok?!

Doomer interface numbers

The above happens because the dApps [both the and] use Chainlink or Redstone oracles to calculate prices in the UI instead of spot prices, and those quite often deviate. So, the interface presents a pessimistic scenario. You can check Nansen instead for the prices and value of your Credit Account closer to reality. Just input your Credit Account address into Nansen, and you can see all the positions there.

An even better way is to check on-chain virtual price of the positions you are in. So, the loss you are seeing in the dApps is just an honest max-pessimism scenario. Reality is always better!

The same goes for slippage numbers in the interface when you try to trade & swap assets. In those cases, the interface shows the maximum drop in case your slippage, let's say if it is selected as 0.1%. Try making it lower, and the number will improve.

Claim farming rewards before closing CA

The interface logic doesn't always perfectly claim your unclaimed rewards efficiently, from Curve or Convex, so make sure to claim them before closing your Credit Account. These rewards would not be lost conceptually, but the next user of this particular CA might wake up with a nice present. Unless you are playing a "take 100 bucks, or I double it and pass onto the next" - not recommended.

  • Claim your rewards from Curve / Convex / etc.;

  • Sell them manually if you really want to be sure inside the "Swap" tab;

  • Or just skip the step above and simple close your Credit Account at once.

PURE liquidation price being "bad"

Since PURE uses real assets, the slippage and liquidity requirement isn’t just limited to your collateral but the entirety of your position. This leads to the calculation of liquidation price being slightly different than what you are used to on perps, and hence needs more attention while opening a position. It's all visible in the dApp, we are just pointing this out so you are super aware of the differences.

With this being the alpha version, we have been conservative with the LTVs, as the risk framework evolves, the UX on this too should improve. It’s not a protocol “issue”, just a precautionary risk management that should improve as we grow. Trade safe!

Now, go, degen ->

When exercising max leverage - you should keep in mind that even a few-minutes of interface not responding properly [Infura/Alchemy downtime, bugs, whatever it is] can lead to liquidations. Everyone remembers the "oops maintaince mode" of BitMex? Well, in DeFi you can control these cases, because the contracts are onchain / verified - as such, you can interact with them directly without any interface. See the contracts.

Last updated