Produced during the Modular Hacker House (EthCC 2023)
With rollups-as-a-service (RaaS) app-chains becoming popular, new networks will want to incentivize TVL and liquidity. To reduce friction, I've set up an experimental v4 hook that can notify destination chains of liquidity provisioning.
These destination chains can offer incentives such as:
- Token emissions
- Game cosmetics & collectibles
- Token-gated access
An alternative to this implementation is using bespoke contracts:
- Users provision liquidity on Uniswap Interface
- Users receive LP tokens
- Users stake their LP tokens in a bespoke contract
- the bespoke contract handles the cross-chain communications
This sequence involves multiple steps and constrains the user to using Uniswap's canonical position manager. In this repo, liquidity provisioning from anywhere will automatically trigger the cross-chain communication
Because v4 exceeds the bytecode limit of Ethereum and its business licensed, we can only deploy & test hooks on anvil.
-
Clone
polaris
to act as our destination chain (Ran locally too) -
Clone
hyperlane-deploy
for the deployment scripts of Hyperlane Mailboxes -
Copy
demo.sh
tohyperlane-deploy/
# start anvil, with a larger code limit
anvil --port 8555 --chain-id 31338 --block-time 2
# -- in polaris/ -- #
# start polaris on localhost:8545
mage start
# -- in hyperlane-deploy/ -- #
# deploy hyperlane contracts & start up infra
./demo.sh
# deploy the Reward token and Staking contract to polaris
forge script script/DeployBenefits.s.sol \
--rpc-url http://localhost:8545 \
--private-key 0xfffdbb37105441e14b0ee6330d855d8504ff39e705c3afa8f859ac9865f99306 \
--broadcast
# edit the script to point to the proper addresses
# deploy v4, the HyperlaneLPHook, and provision liquidity
forge script script/DeployAndProvision.s.sol \
--rpc-url http://localhost:8555 \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--broadcast
# read the benefits contract for issuance
cast call 0x6B1e75149F6a154988Bb36Fa0C0AF35C8000eC60 "earned(address)(uint256)" 0xd85BdcdaE4db1FAEB8eF93331525FE68D7C8B3f0 --rpc-url http://localhost:8545
Additional resources:
v4-periphery contains advanced hook implementations that serve as a great reference
requires foundry
forge install
forge test