How to set up an AEP fee router
Quick start
You can adopt the AEP Fee Router by using the AEP Router deployment scripts provided in the Orbit SDK
Canonical contracts
Network | Contract | Address | Configured for |
---|---|---|---|
Ethereum | Arbitrum Foundation's multisig wallet | 0x1Afa41C006dA1605846271E7bdae942F2787f941 | ETH , ERC-20 |
Arbitrum Nova | Child2ParentRouter | 0xd27cb0fe2a696ebaa80d606ce0edf55aabaeab84 | ETH |
Base | Child2ParentRouter | 0xd9a2e0e5d7509f0bf1b2d33884f8c1b4d4490879 | ETH |
The AEP fee router contract system
This section describes the different fee distribution and router contracts that are available. You can find their source code here.
RewardDistributor
The AEP fee router system relies on configuring an escrow contract as the intended reward address for protocol fee components. This intermediary contract is known as the RewardDistributor.
The RewardDistributor
is configured to separate the AEP portion of the fees from fees intended for the chain owner. The RewardDistributor
can be permissionlessly called to perform a withdrawal which simultaneously transfers 90% of accrued fees to the chain’s fee collector and 10% of accrued fees to a target address on the parent chain. From here, the chain owner has complete control over their earned fees, and the routing contracts can direct AEP fees to a collecting address for the Arbitrum DAO.
ChildToParentRouter
AEP fees from the RewardDistributor
must first be sent to Ethereum before they can be deposited to the DAO-controlled address on Arbitrum One. To facilitate this transfer to Ethereum, AEP fees are sent through a series of contracts known as ChildToParentRouters.
The ChildToParentRouter
is configured to withdraw a single token (immutable and specified at deployment) from the child chain to a specific target address on the parent chain: either another ChildToParentRouter
or an address controlled by the Arbitrum Foundation on Ethereum.
Deploying your AEP fee router contracts
An Orbit chain is responsible for deploying all ChildToParentRouters
necessary for their AEP funds to arrive at the address controlled by the Arbitrum Foundation on Ethereum.
This includes:
- Deploying a
ChildToParentRouter
on their Orbit chain configured for their gas token and configured to send funds to either:- An address controlled by the Arbitrum Foundation on Ethereum (assuming the network is a Layer-2)
- Another
ChildToParentRouter
configured to the same gas token and configured to send funds to a successive parent chain (this is the case for a Layer-3 network or higher)
- Deploying a
RewardDistributor
contract configured to forward 10% of fees to theChildToParentRouter
and 90% to the chain owner’s preferred reward-receiving address.
In the event that a ChildToParentRouter
does not connect to the address controlled by the Arbitrum Foundation on Ethereum, an Orbit chain must deploy successive ChildToParentRouter
contracts until a connection to such address is established. Additional ChildToParentRouter
contracts configured to route ETH have been deployed in certain networks and can be leveraged by chains created on top of these networks. You can see which networks have a router deployed here.
Optionally, an Orbit chain can decide to deduct assertion costs by following the instructions in the Deducting Assertion Costs section:
Deployment scripts
The Orbit SDK provides a configurable script that allows a chain operator to deploy quickly and set up the AEP fee router contracts.
The standard script deploys and sets up the AEP fee router contracts to route funds to the parent chain. L2 chains are expected to route funds to the multisig wallet owned by the Arbitrum Foundation living on Ethereum. L3 chains (or further layers) might need to specify a different target address on the parent chain depending on the gas token of the chain. If the chain uses ETH as the gas token, and a ChildToParentRouter contract is deployed in the parent chain, they can route their funds to that contract. If the chain uses a different gas token, please contact the Arbitrum Foundation to confirm the target address to withdraw the AEP fees to.
The script performs the following operations:
- Obtain the rollup and inbox contract of the chain. These are needed to execute the next steps.
- Obtain the current fee collectors of the chain: Orbit base fee collector, Orbit surplus fee collector, and Parent chain surplus fee collector.
- Deploy the
ChildToParentRouter
contract, configured to send the amounts received to the appropriate target address on the parent chain. - Deploy a
RewardDistributor
contract for each different fee collector account, configured to distribute 90% of the amounts received to the current fee collector, and 10% to the ChildToParentRouter contract deployed in the previous step. - Set each of the fee collectors to the
RewardDistributor
contracts
Note that if the same address collects all three fee types, only one RewardDistributor
contract will be deployed, which will collect all those fees.
To configure the script, you need to specify the following environment variables:
ROLLUP_ADDRESS
: address of the rollup contractCHAIN_OWNER_PRIVATE_KEY
: private key of the account with executor privileges in theUpgradeExecutor
admin contract for the chainORBIT_CHAIN_ID
: chain id of the Orbit chainORBIT_CHAIN_RPC
: RPC of the Orbit chainPARENT_CHAIN_ID
: chain id of the parent chain, which shouldn't be an Arbitrum chainPARENT_CHAIN_TARGET_ADDRESS
: address on the parent chain where 10% of the revenue will be sent to. You can find the potential target addresses in this document's canonical contracts section. If the parent chain is not on that list, or if your chain uses a gas token different than the one the router is configured for, contact the Arbitrum Foundation to obtain a specific target address for your chain.
Finally, follow these steps to execute the script (from the examples/setup-aep-fee-router
folder):
- Install dependencies
yarn install
- Create .env file and add the env vars
cp .env.example .env
- Run the script
yarn dev