Skip to content

DeluxeRaph/longETH

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LongETH LP Vault

Built for the UHI8 Hookathon.

LongETH is a Uniswap v4 hook vault for a USDC/USDT pool.

It accepts stablecoin deposits, mints transferable receipt shares, routes idle assets through YieldHub adapters, and captures protocol fees from:

  • swaps (stable-only) via Uniswap v4 afterSwap return deltas
  • realized stable yield on withdrawals/claims

Captured stable fees are routed to ETHEngine, which buys ETH in batches, wraps to WETH, and deposits through the configured WETH yield source.

Protocol goals

  • Keep LP capital productive between AMM activity and lending yield.
  • Maintain share-based accounting for USDC/USDT deposits and withdrawals.
  • Convert part of stablecoin yield into protocol-owned ETH.
  • Distribute ETH yield (not ETH principal) to LPs over time.

How it works

flowchart LR
    User([User]) --> LongETH[LongETH Vault]
    LongETH --> ActiveOrIdle{Active or Idle}
    ActiveOrIdle -->|Active| AMM[Active liquidity funds AMM]
    ActiveOrIdle -->|Idle| YieldHub((YieldHub))

    YieldHub --> Morpho[Morpho Adapter]
    YieldHub --> Aave[Aave Adapter]
    YieldHub --> Restaking[ETH Restaking Adapter]

    AMM -->|Protocol swap fee captured| BuyETH[Stable fees used to buy ETH]
    BuyETH -->|Buy WETH / route ETH side| YieldHub

    YieldHub -->|Stables/ETH yield| User
Loading
  1. LP deposits USDC and USDT and receives receipt shares.
  2. Stablecoins are deposited into configured YieldHub sources.
  3. On swaps, hook liquidity is added/removed just-in-time in the Uniswap v4 pool.
  4. On swap, a 0.005% protocol fee is captured only when unspecified output currency is USDC/USDT.
  5. On stable-yield realization (withdraw/claim), a 0.005% fee on the yield portion is captured.
  6. Captured stable fees are forwarded to ETHEngine (pendingStableYield) and allocated by dynamic split policy.
  7. ETH buy flow is handled by ETHEngine, then wrapped to WETH and deposited via YieldHub.
  8. ETH yield is checkpointed and distributed per share via an accumulator (paid out in WETH).

Proper usage

1) Deployment and initialization

  • Deploy LongETH with:
    • Uniswap v4 PoolManager
    • owner address
    • USDC and USDT token addresses
  • Initialize exactly one pool key through PoolManager.initialize(...).
    The hook stores that pool key and reverts on re-initialize.

2) Owner configuration (required before production use)

The owner must set external integrations with:

  • setYieldHub(yieldHub)
  • setEthEngine(engine) (optional, for ETH fee/yield routing)

Expected wiring:

  • yieldHub: hub that manages active sources for USDC/USDT0/WETH routing
  • engine: deployed ETHEngine controller if ETH fee conversion/distribution is enabled

3) Liquidity providers

Deposit flow:

  1. Call previewDeposit(amountUSDC, amountUSDT) to estimate shares.
  2. Approve USDC/USDT to the hook.
  3. Call addLiquidity(shares).
  4. Hook internally uses previewMint(shares) and pulls only required token amounts.

Withdraw flow:

  1. Call previewRedeem(shares) to estimate returned stablecoin amounts.
  2. Call removeLiquidity(shares).
  3. Hook withdraws from yield sources and transfers net stablecoin amounts after stable-yield fee (fee applies only to yield portion).
  4. If ETH yield is accrued, claim is tracked in ETHEngine and paid in WETH.

4) Share and reward behavior

  • Receipt shares are transferable.
  • ETH reward debt is updated on mint/transfer/burn paths so transferred shares carry the correct reward state.
  • pendingEthYield(user) reports claimable ETH yield derived from the global accumulator.

Share math

  • If totalSupply == 0: shares/amounts are derived from Uniswap price and the configured tick range.
  • Otherwise:
    • deposit shares are proportional to current per-asset vault balances
    • minted shares are constrained by the limiting asset (min(shares0, shares1))
    • rounding favors existing LPs (previewMint rounds up costs; previewRedeem rounds down outputs)

Risk and trust assumptions

  • Owner can reconfigure the yield hub via setYieldHub.
    In production, owner controls should be secured (multisig + timelock recommended).
  • Swap-fee extraction is economically observable and potentially MEV-targeted, but ETH buy execution is bounded by ETHEngine controls.
  • Integration risk remains for external protocols (YieldHub adapter config, Morpho/Uniswap dependencies, and controller permissions).

Development

Build

forge build

Test

forge test

Format

forge fmt

Deploy

Use the numbered scripts in script/unichain/steps. Each script does one thing so delegated-account rate limits do not break a multi-step deployment.

Unichain Deployment

Current deployed addresses on Unichain:

  • USDC: 0x078D782b760474a361dDA0AF3839290b0EF57AD6
  • USDT0: 0x9151434b16b9763660705744891fA906F660EcC5
  • WETH: 0x4200000000000000000000000000000000000006
  • SwapRouter02: 0x73855d06DE49d0fe4A9c42636Ba96c62da12FF9C

Deployment contracts:

  • LongETH: 0x1112f5873547f6BA9cc8D287159742B54f3D28C4
  • ETHEngine: 0xA7Ea1243d067685b35B7dCb979504C9022842BEa

Ordered deployment flow:

  1. 01_DeployLongETH.s.sol
  2. 02_InitializeLongETHPool.s.sol
  3. 03_DeployOnlyEthEngine.s.sol
  4. 04_WireOnlyEthEngine.s.sol
  5. 05_DeployYieldHub.s.sol
  6. 06_DeployMorphoAdapter.s.sol three times for USDC, USDT0, and WETH
  7. 07_SetYieldHubAssetController.s.sol three times
  8. 08_AddYieldHubSource.s.sol three times
  9. 09_SetYieldHubMigrationTolerance.s.sol three times
  10. 10_QueueYieldHubActivation.s.sol three times with a safe future timestamp
  11. 11_SetLongETHYieldHub.s.sol
  12. 12_SetEthEngineYieldHub.s.sol
  13. 13_SetEthEngineSwapRouter.s.sol
  14. 14_SetEthEngineSwapFeeTier.s.sol twice for USDC and USDT0

Example commands:

forge script script/unichain/steps/05_DeployYieldHub.s.sol:DeployYieldHub --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/06_DeployMorphoAdapter.s.sol:DeployMorphoAdapter --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/07_SetYieldHubAssetController.s.sol:SetYieldHubAssetController --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/08_AddYieldHubSource.s.sol:AddYieldHubSource --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/09_SetYieldHubMigrationTolerance.s.sol:SetYieldHubMigrationTolerance --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/10_QueueYieldHubActivation.s.sol:QueueYieldHubActivation --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/11_SetLongETHYieldHub.s.sol:SetLongETHYieldHub --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/12_SetEthEngineYieldHub.s.sol:SetEthEngineYieldHub --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/13_SetEthEngineSwapRouter.s.sol:SetEthEngineSwapRouter --rpc-url "$RPC_URL" --broadcast -vvvv
forge script script/unichain/steps/14_SetEthEngineSwapFeeTier.s.sol:SetEthEngineSwapFeeTier --rpc-url "$RPC_URL" --broadcast -vvvv

Documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors