Skip to content

orangesantra/hook-cross-chain-rebalancing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

This Uniswap V4 hook is about cross-chain liquidity rebalancing and arbitrage benifits. Though the token cross-chain rebasing part is learned and applied from this repo

It automatically detects arbitrage opportunities and pool imbalances, then triggers cross-chain rebalancing operations to maintain optimal liquidity efficiency.

Hook permissions

  • beforeSwap
  • afterSwap
  • beforeAddLiquidity
  • beforeRemoveLiquidity

Hook Flow

sequenceDiagram
    participant User
    participant PoolManager
    participant RebaseTokenHook
    participant CCIP
    participant RemoteChain

    User->>PoolManager: Initiate Swap
    PoolManager->>RebaseTokenHook: beforeSwap()
    
    RebaseTokenHook->>RebaseTokenHook: Check arbitrage opportunities
    RebaseTokenHook->>RebaseTokenHook: Detect price differences
    
    alt Price difference > 1%
        RebaseTokenHook->>RebaseTokenHook: Calculate imbalance
        RebaseTokenHook->>CCIP: Send cross-chain message
        CCIP->>RemoteChain: Trigger rebalancing
        RemoteChain-->>CCIP: Confirm rebalancing
        CCIP-->>RebaseTokenHook: Rebalancing complete
    end
    
    RebaseTokenHook-->>PoolManager: Continue swap
    PoolManager->>RebaseTokenHook: afterSwap()
    RebaseTokenHook->>RebaseTokenHook: Update counters
    PoolManager-->>User: Swap complete
Loading

Some Thresholds (RANDOMLY CHOOSEN)

Parameter Value Description
Arbitrage Threshold 1% (100 bp) Minimum price difference to trigger arbitrage
Rebalance Cooldown 1 hour Minimum time between rebalancing operations
Default Imbalance Threshold 5% Default pool imbalance trigger level
Max Imbalance Threshold 10% Maximum allowed imbalance threshold
Price Precision 18 decimals Price data precision factor

Test

forge test --match-path test/hook-rebase-fixed.t.sol

About

Uni V4 hook for cross-chain rebalancing and arbitrage benefits.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors