Skip to content

A smart contract enabling seamless Synthetix v3 collateral conversions ("zapping") and unwinding, utilizing Aave flash loans and Uniswap v3 swaps for efficient, atomic transactions.

License

Notifications You must be signed in to change notification settings

JaredBorders/zap

Repository files navigation

Zap Flashloan Utility

Github Actions Foundry License: GPL-3.0

Overview

Zap is a smart contract that facilitates stablecoin "zapping" and Synthetix native collateral unwinding by integrating flash loans from Aave and Odos swaps.

What is a Zap?

ONLY USDC is supported

USDC <--(spot market)--> sUSDC <--(spot market)--> USDx

What is Collateral Unwinding?

Flashloan Utility Flow

  1. Request Flash Loans (Aave): Borrow USDC to access liquidity without posting collateral.
  2. Zap into USDx (Synthetix Spot Market): Use the borrowed funds to zap into USDx.
  3. Burn USDx & Repay Debt (Synthetix Core): Repay Synthetix debt by burning USDx.
  4. Withdraw and Unwrap Collateral (Synthetix Spot Market): Withdraw margin (e.g., sETH) and convert it back to underlying assets (e.g., WETH).
  5. Swap (Odos): Exchange collateral assets (like WETH) for USDC to repay the flash loan.
  6. Flash Loan Repayment (Aave): The USDC loan, including the premium, is repaid to Aave.
  7. Send Remaining Collateral (Synthetix): Any surplus collateral is returned to the user.

Key Features

  • Zap via Synthetix
  • Wrap & Unwrap Collateral via Synthetix
  • Buy & Sell via Synthetix
  • Unwind Collateral via Synthetix, Aave, and Odos
  • Burn Debt via Synthetix
  • Withdraw Perp Collateral via Synthetix
  • Swap via Odos

Development

Build, Test, Report

  1. Build the project

    forge build
    
  2. Run tests

    forge test
    
  3. Report Test Coverage

    make coverage
    
  4. Report Gas Snapshot

    make snapshot
    

How to Deploy

  • See the deployments/ folder for Arbitrum and Base deployments.

How to Deploy:

  1. Create a .env file using .env-example as a reference

  2. Deploy to Base

    make deploy_base
    
  3. Deploy to Arbitrum

    make deploy_arbitrum
    

Audits

  • See the audits/ folder for Audit reports.

About

A smart contract enabling seamless Synthetix v3 collateral conversions ("zapping") and unwinding, utilizing Aave flash loans and Uniswap v3 swaps for efficient, atomic transactions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages