Looping In Crypto
Looping (also known as leveraging or recursive borrowing) is a strategy that enables investors to amplify their exposure to digital assets by using lending protocols. It works by depositing collateral, borrowing against it, and reinvesting the borrowed funds to increase the position size.
For example, if you have $1,000 worth of ETH and want 3x exposure, you would:
- Deposit $1,000 ETH as collateral
- Borrow ~$800 worth of stablecoins (at 80% LTV)
- Swap stablecoins back to ETH
- Deposit the new ETH as additional collateral
- Repeat until reaching 3x exposure (~$3,000 ETH collateral, ~$2,000 debt)
The key metric to monitor is the health factor - a measure of how close your position is to liquidation. When the health factor drops below 1, the position becomes eligible for liquidation.
Looping In DeFi (The Manual Way)
Opening a leveraged position manually in DeFi is a tedious, multi-step process. Here's what it takes to open a 4x leveraged ETH position starting with $1,000:
Manual Looping Process (22+ Transactions)
==========================================
Round 1:
├── Approve ETH spending
├── Supply $1,000 ETH to Aave
├── Borrow $800 USDC
├── Approve USDC for swap
├── Swap $800 USDC → ETH (~$800 ETH)
└── Supply $800 ETH to Aave
Round 2:
├── Borrow $640 USDC
├── Approve USDC for swap
├── Swap $640 USDC → ETH (~$640 ETH)
└── Supply $640 ETH to Aave
Round 3:
├── Borrow $512 USDC
├── Approve USDC for swap
├── Swap $512 USDC → ETH (~$512 ETH)
└── Supply $512 ETH to Aave
... continue until target leverage reached ...
Final Position:
├── Total Collateral: ~$4,000 ETH
├── Total Debt: ~$3,000 USDC
└── Leverage: 4x
Problems with manual looping:
- 22+ transactions required for a single position
- High gas costs - each transaction costs gas
- Price movement risk - ETH price can change between transactions
- Time consuming - takes 30+ minutes to execute
- Error prone - easy to make mistakes in the process
How 1delta Automates The Flow
1delta reduces the entire looping process to a single atomic transaction by leveraging flash loans. Here's how it works:
1delta Looping Process (1 Transaction)
======================================
┌─────────────────────────────────────────────────────────────┐
│ SINGLE TRANSACTION │
├─────────────────────────────────────────────────────────────┤
│ │
│ 1. Flash Loan $3,000 USDC │
│ │ │
│ ▼ │
│ 2. Swap $3,000 USDC → ~$3,000 ETH │
│ │ │
│ ▼ │
│ 3. Deposit $1,000 user ETH + $3,000 swapped ETH │
│ = $4,000 total collateral │
│ │ │
│ ▼ │
│ 4. Borrow $3,000 USDC from lending protocol │
│ │ │
│ ▼ │
│ 5. Repay flash loan with borrowed USDC │
│ │
└─────────────────────────────────────────────────────────────┘
Final Position (achieved atomically):
├── Total Collateral: $4,000 ETH
├── Total Debt: $3,000 USDC
└── Leverage: 4x
The Flash Loan Advantage
Flash loans allow borrowing any amount without collateral, as long as the loan is repaid within the same transaction. 1delta uses this to:
- Borrow the full leverage amount upfront via flash loan
- Execute all swaps and deposits in one transaction
- Borrow from the lending protocol to repay the flash loan
- Complete atomically - if any step fails, everything reverts
Architecture Flow
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ User │ │ 1delta │ │ Flash Loan │
│ Wallet │────▶│ Composer │────▶│ Provider │
└──────────────┘ └──────────────┘ └──────────────┘
│ │
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ DEX │ │ Lending │
│ (Swap) │ │ Protocol │
└──────────────┘ └──────────────┘
Comparison: Manual vs 1delta
| Aspect | Manual Looping | 1delta Looping |
|---|---|---|
| Transactions | 22+ | 1 |
| Gas Cost | ~$200+ | ~$40 |
| Execution Time | 30+ minutes | Single block |
| Price Risk | High (price moves between txs) | None (atomic) |
| Partial Execution | Possible | Impossible |
| Complexity | High | Low |
Supported Operations
1delta supports various looping-related operations:
Opening Positions (Leverage)
Create leveraged long or short positions in a single transaction. → See Leverage Example
Closing Positions
Unwind your leveraged position atomically by repaying debt and withdrawing collateral. → See Close Example
Collateral Swaps
Change your collateral type without closing the position (e.g., ETH → WBTC). → See Collateral Swap Example
Debt Swaps
Change your debt type without affecting collateral (e.g., USDC → USDT). → See Debt Swap Example
Protocol Migration
Move your entire position from one protocol to another in a single transaction. → See Migration Example
Risk Considerations
When using looping strategies, be aware of:
- Liquidation Risk - If collateral value drops or debt value rises, your position may be liquidated
- Smart Contract Risk - Lending protocols and DEXs carry smart contract risk
- Oracle Risk - Price oracle failures can trigger unexpected liquidations
- Interest Rate Risk - Variable borrow rates can increase over time
Always monitor your health factor and maintain adequate buffer above 1.0.