Ion Protocol
HomeDiscordTwitter
  • Overview
    • 💧Welcome to Ion Protocol
    • 📚Understanding the Staking and Restaking Ecosystem
    • 🔗Official Links
    • ❔FAQ
  • Ion Protocol
    • ⚙️How Ion Works
    • 👥Referrals
    • 💦Ion Points
  • Lending
    • 💰How To Lend On Ion
    • 🌐ETH-on-ETH Yield
    • 🧪Lending Mechanisms
      • Composable Markets
      • ZKML-Supported Risk Underwriting
  • Borrowing
    • 💸How To Borrow On Ion
    • 📈Multiplying Rewards
    • 🛠️Borrowing Mechanisms
      • Flash Leverage
      • Interest Rates
      • ZK Proof-of-Reserve
  • Liquidations
    • 📉Liquidation Mechanism
    • 🧑‍💻Keepers
  • Supported Collateral
    • LSTs
    • LRTs
    • Exotic ETH-Backed Assets
  • Devs
    • 💻Smart Contract Architecture
      • Home
      • Admin
        • ProxyAdmin
        • TransparentUpgradeableProxy
        • ITransparentUpgradeableProxy
      • Flash
        • LRT
          • RsEthHandler
          • EzEthHandler
          • RswEthHandler
          • WeEthHandler
        • LST
          • SwEthHandler
          • EthXHandler
          • WstEthHandler
        • BalancerFlashloanDirectMintHandler constants
        • BalancerFlashloanDirectMintHandler
        • PtHandler
        • IonHandlerBase
        • UniswapFlashloanBalancerSwapHandler
        • UniswapFlashswapDirectMintHandler
        • UniswapFlashswapDirectMintHandlerWithDust
        • UniswapFlashswapHandler
      • Join
        • GemJoin
      • Libraries
        • LRT
          • KelpDaoLibrary
          • EtherFiLibrary
          • RestakedSwellLibrary
          • RenzoLibrary
        • LST
          • StaderLibrary
          • LidoLibrary
          • SwellLibrary
        • math
          • WadRayMath constants
          • WadRayMath
        • uniswap
          • UniswapOracleLibrary
          • TickMath
      • Oracles
        • Reserve
          • LRT
            • EzEthWstEthReserveOracle
            • RsEthWstEthReserveOracle
            • RswEthWstEthReserveOracle
            • WeEthWstEthReserveOracle
          • LST
            • SwEthReserveOracle
            • EthXReserveOracle
            • WstEthReserveOracle
          • Pendle
            • EzEthPtReserveOracle
            • RsEthPtReserveOracle
            • RswEthPtReserveOracle
            • WeEthPtReserveOracle
          • ReserveOracle
          • ReserveFeed
          • ReserveOracle constants
        • Spot
          • LRT
            • EzEthWstEthSpotOracle
            • RsEthWstEthSpotOracle
            • RswEthWstEthSpotOracle
            • WeEthWstEthSpotOracle
          • LST
            • EthXSpotOracle constants
            • EthXSpotOracle
            • IRedstonePriceFeed
            • SwEthSpotOracle
            • WstEthSpotOracle
          • SpotOracle
          • PtSpotOracle
      • Periphery
        • IonInvariants
        • IonLens
        • IlkSlot0
        • IonRegistry
      • Token
        • IERC20Errors
        • RewardToken
      • Vault
        • VaultFactory
        • Vault
      • Whitelist
      • YieldOracle constants
      • YieldOracle
      • YieldOracleNull
      • YieldOraclePendle
      • Errors
      • Constants
      • Seaport Leverage and Deleverage
    • 📄Deployed Contracts
  • Security
    • 🔐Security Reviews
  • Legal
    • Terms of Use
    • Privacy Policy
  • Import
    • ProxyAdmin
Powered by GitBook
On this page
  • Overview
  • Context
  • Why Seaport?
  • Transaction Flow
  1. Devs
  2. Smart Contract Architecture

Seaport Leverage and Deleverage

Overview


Context

This contract outlines a leverage and deleverage strategy with the following assumptions:

  1. The "base asset" can be sold for the "collateral asset" on Seaport.

  2. The "collateral asset" can be sold for the "base asset" on Seaport.

Why Seaport?


  • As LRTs are having a hard time bootstrapping resilient liquidity on AMMs—especially on Uniswap—we are incorporating a RFQ system that connects the user looking to sell the collateral in a deleverage scenario to a marketmaker willing to buy the collateral at a discount.

  • Because RFQ’s are traditionally non-atomic, they are not compatible with a delverage strategy that relies on atomic flashloans.

  • To make these RFQ’s “atomic”, we incorporate Seaport where a market maker first quotes the price offchain and signs an approval to transfer its payment asset to the deleverage contract.

  • This allows the user and the market maker to agree on an exchange of assets at a specific price prior to sending a transaction. The “swap” is executed atomically when the deleverage contract is called.called.

  • The goal is to facilitate an atomic sale of collateral during a liquidation or a deleverage to an RFQ system that is willing to buy the collateral. We expect this path to be more resilient than the shallow liquidity on on-chain AMMs.

NOTE: Most of the complexity in the RFQ will be the responsibility of the frontend offchain system to match the users to a counterparty. The new on-chain integration that is being built out is the ability to fulfill an offer on seaport.

Transaction Flow


The key idea here is incorporating an ‘atomic’ RFQ-swap through Seaport. The following is the flow for the user looking to deleverage:

  1. The user requests an amount of weETH to sell to the RFQ. [offchain, websocket connection—no contract interaction has been made yet]

  2. The market maker quotes the amount of wstETH they are willing to pay for the given amount of weETH. [offchain, websocket connection]

  3. The market maker generates a signature and approves the wstETH amount via Seaport. The market maker creates an offer on seaport. [the offer is created on-chain on seaport].

  4. Next, the signature is sent from the market maker to the user [offchain, sent to the user interacting on the frontend]

  5. The user on the frontend now calls the deleverage contract and passes this signature along in calldata.

  6. The deleverage contract will now payoff Ion loan, withdraw weETH, then sell this weETH on seaport using the outstanding offer.

  7. The deleverage contract will fulfill the offer on seaport, transferring the wstETH from the market maker’s EOA and transferring the user’s weETH to the market maker.

It should also be noted that if the pricing is too unfavorable for the user, the deleverage may fail as it violates the max LTV requirement.

  • For example, the user and the RFQ counterparty agree on the amount of weETH and wstETH to exchange.

  • The deleverage sources the exact wstETH amount to pay off debt, but if after paying off this debt, the resulting LTV is above the maxLTV, then the contract will revert.

  • The frontend will be responsible for making sure that the pricing is reasonable for the transaction to succeed before initiating any on-chain actions.

  • The transaction should revert when:

wstETHDebtinitial−wstETHamtReceived(weETHAmtinitial−weETHamtSold)∗weETHExchangeRate>maxLTV\frac{wstETHDebt_{initial}-wstETH_{amtReceived}}{(weETHAmt_{initial}-weETH_{amtSold})*weETHExchangeRate} > maxLTV(weETHAmtinitial​−weETHamtSold​)∗weETHExchangeRatewstETHDebtinitial​−wstETHamtReceived​​>maxLTV

the weETHExchangeRate converts `weETH` value to the `wstETH` value.

PreviousConstantsNextDeployed Contracts

Last updated 1 year ago

💻