Crosschain Vault

Cross-chain vault auto-farms Rootstock assets via LayerZero and bridges yield home.

Crosschain Vault

Created At

ETHGlobal New Delhi

Project Description

This is a cross-chain yield vault that lives on Rootstock and Sepolia. You mint an omnichain fungible token (MyOFT), bridge it with LayerZero, farm the bridged liquidity, and then send the principal plus harvest back to your “home” chain—all from Hardhat scripts.

At the core is VaultLifecycleManager.sol, a controller contract that takes a “bridge ID,” pushes the bridged tokens into a farm (YieldFarmOFT or whatever strategy you point it at), tracks whether rewards should auto-compound, and knows how to exit the position. When you call lz:vault:return it harvests, unwinds a percentage of the stake, and hands the balance off to the existing lz:oft:send task so the assets hop back to the origin chain.

CrossChainVault.sol and RewardsDistributor.sol were upgraded to LayerZero’s V2 messaging interface (the new MessagingFee struct) so every cross-chain message is compatible with the current endpoints. YieldFarmOFT now mints rewards into the contract, builds a proper SendParam, and invokes the LayerZero send path under the hood. Everything is wired through Hardhat with ethers v5 and LayerZero devtools: tasks handle bridging, peer configuration, farming, and returning; the README walks through the workflow; LayerZero config keeps endpoint IDs straight.

In short: it’s a scripted, contract-first pipeline that lets you deposit on Rootstock, bridge to Sepolia, farm, and bridge back with minimal manual glue, all using LayerZero’s OFT stack and a tiny lifecycle manager to coordinate the steps.

How it's Made

Built it as a Hardhat mono-repo that stitches Rootstock and Sepolia together via LayerZero’s OFT stack. The core contracts are plain Solidity 0.8.22:

MyOFT (ERC‑20 + OFT) for bridging, VaultLifecycleManager to babysit bridged positions, CrossChainVault/YieldFarmOFT handling vault math and rewards, LayerZero handlers (_lzSend, send/quoteSend) upgraded to the V2 MessagingFee signature so the cross-chain hops actually settle. Hardhat stays on ethers v5 (@nomiclabs/hardhat-ethers) because LayerZero’s dev tooling still leans on it, which meant a little hackery: wrapped return types, BigNumber math, and ethers.utils.* everywhere after briefly trying ethers v6. The CLI workflow lives in TypeScript tasks (task/*), calling LayerZero’s devtools to resolve endpoint IDs, auto-configure trusted peers, and queue bridge/farm/return steps. README docs and two new tasks (lz:vault:farm, lz:vault:return) make the cross-chain loop a three-step flow.

Most of the “clever” bits revolve around abusing Hardhat tasks to drive the lifecycle instead of building a UI, auto-wiring peers before each send, and faking a position “ID” by hashing the LayerZero bridge tx. No front-end—just scripts, LayerZero config, and Solidity.

background image mobile

Join the mailing list

Get the latest news and updates