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
XStakeController
viaxcall
. -
Records stake. Only callable by a known
XStaker
contract on a supported chain. -
Entrypoint for unstaking. This function authorizes withdrawals, and directs a payout to the corresponding
XStaker
viaxcall
. -
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 test
To try out the contracts, you can deploy them to a local Omni devnet.
make devnet-start
make devnet-deploy
This 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.