Cross-chain staking, built with Omni.
This repository is meant as an example. It demonstrates how to accept ERC20 deposits chains on multiple chains, and maintain global accounting on Omni.
These contracts are unaudited, and should not be used in production.
The protocol has two contracts
The first accepts deposits, and pays out withdrawals. The second maintains global accounting, and authorizes withdrawals. To learn how each contract works, read the source code. It's not long, and is commented generously. Read in the following order:
-
Entrypoint for staking. This function accepts deposits, and records them with the
XStakeControllerviaxcall. -
Records stake. Only callable by a known
XStakercontract on a supported chain. -
Entrypoint for unstaking. This function authorizes withdrawals, and directs a payout to the corresponding
XStakerviaxcall. -
Withdraws stake back to the user. Only callable by the
XStakeController.
This example includes example solidity tests . They make use of Omni's MockPortal utility to test cross chain interactions.
Run tests with
make testTo try out the contracts, you can deploy them to a local Omni devnet.
make devnet-start
make devnet-deployThis deploys an XStakeController to Omni's devnet EVM. Along with an
XStaker to each mock rollup - mock arb and mock op. It also deploys an ERC20
staking token to each rollup. This token has a public mint() method, so you
can mint tokens to test with.