This repository contains a token swap contract for the "Arbitrum deprecated GRT". It allows users to exchange 1:1 their "Arbitrum deprecated GRT" tokens for the canonical GRT without bridging back and forth between L1 and L2.
Arbitrum allows users to bridge tokens to L2 using a standard ERC20 gateway. This is the default behavior unless the token implements a custom gateway. Bridged tokens on L2 are handled by a copy of the L1 token contract deployed on L2. This is the "Arbitrum deprecated GRT" token, which has seen activity since shortly after the launch of Arbitrum in June 2021.
Later on, in November 2022, The Graph Team deployed a custom gateway for the GRT token and a custom L2 token contract. This is the canonical GRT token and the one that supports the protocol going forward.
In order to participate in the protocol, holders of the "Arbitrum deprecated GRT" need to swap their tokens for the canonical GRT. There are two alternatives for this:
- Bridge "Arbitrum deprecated GRT" to L1 using the standard ERC20 gateway, then bridge the GRT back to L2 using the custom GRT gateway. This is a cumbersome and costly process involving multiple transactions, wait times and fees.
- Swap the "Arbitrum deprecated GRT" for the canonical GRT on L2 using this contract. This only requires two transactions on L2 (approve and swap) and no bridging, so it's much cheaper and faster.
Read more about Arbitrum token bridging here: https://developer.arbitrum.io/asset-bridging#bridging-erc20-tokens
- Setup > clone this repository, install dependencies and build it:
git clone http://github.com/edgeandnode/token-swap.git
cd token-swap
yarn install
yarn build
- Run the swap command:
Note: Please handle your private keys/mnemonic with care!
If you want to use a private key: PRIVATE_KEY=<PRIVATE_KEY> hh swap --network <NETWORK_NAME>
If you want to use mnemonic: MNEMONIC="<MNEMONIC>" hh swap --network <NETWORK_NAME>
NETWORK_NAME
can be one ofarbitrum-one
orarbitrum-goerli
PRIVATE_KEY
is the private key of the account that will have it's deprecated GRT swappedMNEMONIC
is the mnemonic of the account that will have it's deprecated GRT swapped
The script will swap ALL of your deprecated GRT tokens for the canonical ones.
Deploy with:
hh deploy --network <NETWORK_NAME> --canonical-token <TOKEN_ADDRESS> --deprecated-token <DEPRECATED_TOKEN_ADDRESS>
NETWORK_NAME
can be one ofarbitrum-one
,arbitrum-goerli
orlocalhost
.TOKEN_ADDRESS
is the address of the canonical GRT token.DEPRECATED_TOKEN_ADDRESS
is the address of the "Arbitrum deprecated GRT" token.
When deploying to localhost
the token addresses are not required as the script will deploy them from scratch.
Run the test suite with:
yarn test