Skip to content

Commit

Permalink
Rename usdt occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Mar 6, 2024
1 parent b1d460d commit c481a67
Show file tree
Hide file tree
Showing 27 changed files with 158 additions and 162 deletions.
12 changes: 5 additions & 7 deletions cmd/zetae2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ contracts:
zevm:
system_contract: "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B"
eth_zrc20: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4"
usdt_zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a"
zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a"
btc_zrc20: "0x65a45c57636f9BcCeD4fe193A602008578BcA90b"
uniswap_factory: "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c"
uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe"
evm:
zeta_eth: "0x0000c304d2934c00db1d51995b9f6996affd17c0"
connector_eth: "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea"
custody: "0x000047f11c6e42293f433c82473532e869ce4ec5"
usdt: "0x07865c6e87b9f70255377e024ace6630c1eaa37f"
erc20: "0x07865c6e87b9f70255377e024ace6630c1eaa37f"
```

### Bitcoin setup
Expand Down Expand Up @@ -126,9 +126,7 @@ contracts:
One of the tests can be commented out in case only a deposit or a withdrawal is to be tested.
Testing an ERC20 ZRC20 from an EVM chain

Testing ZRC20 requires the same config as for the gas tokens, but must include the `usdt` field that contains the address of the ERC20 on the evm chain and `usdt_zrc20` on ZetaChain.

It is currently named USDT because it was the defacto ERC20 tested in local tests, this field will be renamed into a more generic name in the future
Testing ZRC20 requires the same config as for the gas tokens, but must include the `erc20` field that contains the address of the ERC20 on the evm chain and `zrc20` on ZetaChain.

```go
zeta_chain_id
Expand All @@ -142,9 +140,9 @@ rpcs:
zetacore_rpc
contracts:
zevm:
usdt_zrc20
zrc20
evm:
usdt
erc20
```

### Testing a ZRC20 from a Bitcoin chain
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
conf.Contracts.EVM.ZetaEthAddress = r.ZetaEthAddr.Hex()
conf.Contracts.EVM.ConnectorEthAddr = r.ConnectorEthAddr.Hex()
conf.Contracts.EVM.CustodyAddr = r.ERC20CustodyAddr.Hex()
conf.Contracts.EVM.USDT = r.USDTERC20Addr.Hex()
conf.Contracts.EVM.ERC20 = r.ERC20Addr.Hex()

conf.Contracts.ZEVM.SystemContractAddr = r.SystemContractAddr.Hex()
conf.Contracts.ZEVM.ETHZRC20Addr = r.ETHZRC20Addr.Hex()
conf.Contracts.ZEVM.USDTZRC20Addr = r.USDTZRC20Addr.Hex()
conf.Contracts.ZEVM.ZRC20Addr = r.ZRC20Addr.Hex()
conf.Contracts.ZEVM.BTCZRC20Addr = r.BTCZRC20Addr.Hex()
conf.Contracts.ZEVM.UniswapFactoryAddr = r.UniswapV2FactoryAddr.Hex()
conf.Contracts.ZEVM.UniswapRouterAddr = r.UniswapV2RouterAddr.Hex()
Expand Down
24 changes: 12 additions & 12 deletions cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return err
}
}
if c := conf.Contracts.EVM.USDT; c != "" {
if c := conf.Contracts.EVM.ERC20; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid USDT: %s", c)
return fmt.Errorf("invalid ERC20: %s", c)
}
r.USDTERC20Addr = ethcommon.HexToAddress(c)
r.USDTERC20, err = erc20.NewERC20(r.USDTERC20Addr, r.GoerliClient)
r.ERC20Addr = ethcommon.HexToAddress(c)
r.ERC20, err = erc20.NewERC20(r.ERC20Addr, r.GoerliClient)
if err != nil {
return err
}
Expand All @@ -87,12 +87,12 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return err
}
}
if c := conf.Contracts.ZEVM.USDTZRC20Addr; c != "" {
if c := conf.Contracts.ZEVM.ZRC20Addr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid USDTZRC20Addr: %s", c)
return fmt.Errorf("invalid ZRC20Addr: %s", c)
}
r.USDTZRC20Addr = ethcommon.HexToAddress(c)
r.USDTZRC20, err = zrc20.NewZRC20(r.USDTZRC20Addr, r.ZevmClient)
r.ZRC20Addr = ethcommon.HexToAddress(c)
r.ZRC20, err = zrc20.NewZRC20(r.ZRC20Addr, r.ZevmClient)
if err != nil {
return err
}
Expand All @@ -107,12 +107,12 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
return err
}
}
if c := conf.Contracts.ZEVM.USDTZRC20Addr; c != "" {
if c := conf.Contracts.ZEVM.ZRC20Addr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid USDTZRC20Addr: %s", c)
return fmt.Errorf("invalid ZRC20Addr: %s", c)
}
r.USDTZRC20Addr = ethcommon.HexToAddress(c)
r.USDTZRC20, err = zrc20.NewZRC20(r.USDTZRC20Addr, r.ZevmClient)
r.ZRC20Addr = ethcommon.HexToAddress(c)
r.ZRC20, err = zrc20.NewZRC20(r.ZRC20Addr, r.ZevmClient)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/config/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ contracts:
zevm:
system_contract: "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B"
eth_zrc20: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4"
usdt_zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a"
zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a"
btc_zrc20: "0x65a45c57636f9BcCeD4fe193A602008578BcA90b"
uniswap_factory: "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c"
uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe"
evm:
zeta_eth: "0x0000c304d2934c00db1d51995b9f6996affd17c0"
connector_eth: "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea"
custody: "0x000047f11c6e42293f433c82473532e869ce4ec5"
usdt: "0x07865c6e87b9f70255377e024ace6630c1eaa37f"
erc20: "0x07865c6e87b9f70255377e024ace6630c1eaa37f"

4 changes: 2 additions & 2 deletions cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contracts:
zevm:
system_contract: "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921"
eth_zrc20: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4"
usdt_zrc20: "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb"
zrc20: "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb"
btc_zrc20: "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891"
uniswap_factory: "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c"
uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe"
Expand All @@ -28,4 +28,4 @@ contracts:
zeta_eth: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9"
connector_eth: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca"
custody: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a"
usdt: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564"
erc20: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564"
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func adminTestRoutine(

// funding the account
txZetaSend := deployerRunner.SendZetaOnEvm(UserAdminAddress, 1000)
txUSDTSend := deployerRunner.SendUSDTOnEvm(UserAdminAddress, 1000)
txERC20Send := deployerRunner.SendERC20OnEvm(UserAdminAddress, 1000)
adminRunner.WaitForTxReceiptOnEvm(txZetaSend)
adminRunner.WaitForTxReceiptOnEvm(txUSDTSend)
adminRunner.WaitForTxReceiptOnEvm(txERC20Send)

// depositing the necessary tokens on ZetaChain
txZetaDeposit := adminRunner.DepositZeta()
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func bitcoinTestRoutine(
startTime := time.Now()

// funding the account
txUSDTSend := deployerRunner.SendUSDTOnEvm(UserBitcoinAddress, 1000)
bitcoinRunner.WaitForTxReceiptOnEvm(txUSDTSend)
txERC20Send := deployerRunner.SendERC20OnEvm(UserBitcoinAddress, 1000)
bitcoinRunner.WaitForTxReceiptOnEvm(txERC20Send)

// depositing the necessary tokens on ZetaChain
txEtherDeposit := bitcoinRunner.DepositEther(false)
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func erc20TestRoutine(
startTime := time.Now()

// funding the account
txUSDTSend := deployerRunner.SendUSDTOnEvm(UserERC20Address, 10)
erc20Runner.WaitForTxReceiptOnEvm(txUSDTSend)
txERC20Send := deployerRunner.SendERC20OnEvm(UserERC20Address, 10)
erc20Runner.WaitForTxReceiptOnEvm(txERC20Send)

// depositing the necessary tokens on ZetaChain
txEtherDeposit := erc20Runner.DepositEther(false)
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
startTime := time.Now()
deployerRunner.SetupEVM(contractsDeployed)
deployerRunner.SetZEVMContracts()
deployerRunner.MintUSDTOnEvm(10000)
deployerRunner.MintERC20OnEvm(10000)
logger.Print("✅ setup completed in %s", time.Since(startTime))
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ func StressTest(cmd *cobra.Command, _ []string) {
fmt.Println(" 2. Display Network metrics to monitor performance [Num Pending outbound tx], [Num Trackers]")

e2eTest.WG.Add(2)
go WithdrawCCtx(e2eTest) // Withdraw USDT from ZEVM to EVM - goerli
go WithdrawCCtx(e2eTest) // Withdraw from ZEVM to EVM - goerli
go EchoNetworkMetrics(e2eTest) // Display Network metrics periodically to monitor performance

e2eTest.WG.Wait()
}

// WithdrawCCtx withdraw USDT from ZEVM to EVM
// WithdrawCCtx withdraw ETHZRC20 from ZEVM to EVM
func WithdrawCCtx(runner *runner.E2ERunner) {
ticker := time.NewTicker(time.Millisecond * time.Duration(stressTestArgs.txnInterval))
for {
Expand Down
4 changes: 2 additions & 2 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A config YAML file can be provided to the E2E test tool via the `--config` flag.
**EVM Contracts**
- `ZetaEthAddress`: Address of Zeta token contract on EVM chain.
- `ConnectorEthAddr`: Address of a connector contract on EVM chain.
- `USDT`: Address of the USDT token contract on EVM chain.
- `ERC20`: Address of the ERC20 token contract on EVM chain.

### Config Example

Expand All @@ -51,7 +51,7 @@ contracts:
evm:
zeta_eth: "0x..."
connector_eth: "0x..."
usdt: "0x..."
erc20: "0x..."
zeta_chain_id: "zetachain-1"
```
Expand Down
6 changes: 3 additions & 3 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ type EVM struct {
ZetaEthAddress string `yaml:"zeta_eth"`
ConnectorEthAddr string `yaml:"connector_eth"`
CustodyAddr string `yaml:"custody"`
USDT string `yaml:"usdt"`
ERC20 string `yaml:"erc20"`
}

// ZEVM contains the addresses of predeployed contracts on the zEVM chain
type ZEVM struct {
SystemContractAddr string `yaml:"system_contract"`
ETHZRC20Addr string `yaml:"eth_zrc20"`
USDTZRC20Addr string `yaml:"usdt_zrc20"`
ZRC20Addr string `yaml:"zrc20"`
BTCZRC20Addr string `yaml:"btc_zrc20"`
UniswapFactoryAddr string `yaml:"uniswap_factory"`
UniswapRouterAddr string `yaml:"uniswap_router"`
Expand Down Expand Up @@ -92,7 +92,7 @@ func DefaultConfig() Config {
ZetaChainID: "athens_101-1",
Contracts: Contracts{
EVM: EVM{
USDT: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a",
ERC20: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a",
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var AllE2ETests = []runner.E2ETest{
),
runner.NewE2ETest(
TestMultipleERC20DepositName,
"deposit USDT ERC20 into ZEVM in multiple deposits",
"deposit ERC20 into ZEVM in multiple deposits",
[]runner.ArgDefinition{
runner.ArgDefinition{Description: "amount", DefaultValue: "1000000000"},
runner.ArgDefinition{Description: "count", DefaultValue: "3"},
Expand Down Expand Up @@ -125,7 +125,7 @@ var AllE2ETests = []runner.E2ETest{
),
runner.NewE2ETest(
TestZRC20SwapName,
"swap ZRC20 USDT for ZRC20 ETH",
"swap ZRC20 token for ZRC20 ETH",
[]runner.ArgDefinition{},
TestZRC20Swap,
),
Expand Down
22 changes: 11 additions & 11 deletions e2e/e2etests/test_crosschain_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
// https://github.com/zeta-chain/node-private/issues/88
// it is kept as is for now to be consistent with the old implementation
// if the tx fails due to already initialized, it will be ignored
_, err := r.UniswapV2Factory.CreatePair(r.ZevmAuth, r.USDTZRC20Addr, r.BTCZRC20Addr)
_, err := r.UniswapV2Factory.CreatePair(r.ZevmAuth, r.ZRC20Addr, r.BTCZRC20Addr)
if err != nil {
r.Logger.Print("ℹ️create pair error")
}
txUSDTApprove, err := r.USDTZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e18))
txApprove, err := r.ZRC20.Approve(r.ZevmAuth, r.UniswapV2RouterAddr, big.NewInt(1e18))
if err != nil {
panic(err)
}
Expand All @@ -42,8 +42,8 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
panic(err)
}

if receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, txUSDTApprove, r.Logger, r.ReceiptTimeout); receipt.Status != 1 {
panic("usdt approve failed")
if receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, txApprove, r.Logger, r.ReceiptTimeout); receipt.Status != 1 {
panic("zrc20 approve failed")
}
if receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZevmClient, txBTCApprove, r.Logger, r.ReceiptTimeout); receipt.Status != 1 {
panic("btc approve failed")
Expand All @@ -55,10 +55,10 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
panic("BTC ZRC20 transfer failed")
}

// Add 100 USDT liq and 0.001 BTC
// Add 100 zrc20 token liq and 0.001 BTC
txAddLiquidity, err := r.UniswapV2Router.AddLiquidity(
r.ZevmAuth,
r.USDTZRC20Addr,
r.ZRC20Addr,
r.BTCZRC20Addr,
big.NewInt(1e8),
big.NewInt(1e8),
Expand Down Expand Up @@ -87,8 +87,8 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
r.Logger.Info("memobytes(%d) %x", len(memobytes), memobytes)
msg = append(msg, memobytes...)

r.Logger.Info("***** First test: USDT -> BTC")
// Should deposit USDT for swap, swap for BTC and withdraw BTC
r.Logger.Info("***** First test: ERC20 -> BTC")
// Should deposit ERC20 for swap, swap for BTC and withdraw BTC
txHash := r.DepositERC20WithAmountAndMessage(r.DeployerAddress, big.NewInt(8e7), msg)
cctx1 := utils.WaitCctxMinedByInTxHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout)

Expand Down Expand Up @@ -118,14 +118,14 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {

r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutTxParam().OutboundTxHash)

r.Logger.Info("******* Second test: BTC -> USDT")
r.Logger.Info("******* Second test: BTC -> ZRC20")
utxos, err := r.BtcRPCClient.ListUnspent()
if err != nil {
panic(err)
}
r.Logger.Info("#utxos %d", len(utxos))
r.Logger.Info("memo address %s", r.USDTZRC20Addr)
memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.USDTZRC20Addr, r.DeployerAddress.Bytes())
r.Logger.Info("memo address %s", r.ZRC20Addr)
memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.ZRC20Addr, r.DeployerAddress.Bytes())
if err != nil {
panic(err)
}
Expand Down
10 changes: 5 additions & 5 deletions e2e/e2etests/test_erc20_multiple_deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestMultipleERC20Deposit(r *runner.E2ERunner, args []string) {
panic("Invalid number of deposits specified for TestMultipleERC20Deposit.")
}

initialBal, err := r.USDTZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress)
initialBal, err := r.ZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress)
if err != nil {
panic(err)
}
Expand All @@ -37,7 +37,7 @@ func TestMultipleERC20Deposit(r *runner.E2ERunner, args []string) {
}

// check new balance is increased by amount * count
bal, err := r.USDTZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress)
bal, err := r.ZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress)
if err != nil {
panic(err)
}
Expand All @@ -58,18 +58,18 @@ func MultipleDeposits(r *runner.E2ERunner, amount, count *big.Int) ethcommon.Has
fullAmount := big.NewInt(0).Mul(amount, count)

// approve
tx, err := r.USDTERC20.Approve(r.GoerliAuth, depositorAddr, fullAmount)
tx, err := r.ERC20.Approve(r.GoerliAuth, depositorAddr, fullAmount)
if err != nil {
panic(err)
}
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.GoerliClient, tx, r.Logger, r.ReceiptTimeout)
if receipt.Status == 0 {
panic("approve failed")
}
r.Logger.Info("USDT Approve receipt tx hash: %s", tx.Hash().Hex())
r.Logger.Info("ERC20 Approve receipt tx hash: %s", tx.Hash().Hex())

// deposit
tx, err = depositor.RunDeposits(r.GoerliAuth, r.DeployerAddress.Bytes(), r.USDTERC20Addr, amount, []byte{}, count)
tx, err = depositor.RunDeposits(r.GoerliAuth, r.DeployerAddress.Bytes(), r.ERC20Addr, amount, []byte{}, count)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit c481a67

Please sign in to comment.