Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor addresses.json to account for ZRC-20 of ERC-20s #89

Closed
fadeev opened this issue Oct 16, 2023 · 9 comments
Closed

Refactor addresses.json to account for ZRC-20 of ERC-20s #89

fadeev opened this issue Oct 16, 2023 · 9 comments

Comments

@fadeev
Copy link
Member

fadeev commented Oct 16, 2023

Currently we have only 1 ZRC-20 per chain:

"zevm": {
"bsc_testnet": {
"zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891"
},
"goerli_testnet": {
"zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4"
},
"mumbai_testnet": {
"zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb"
},
"zeta_testnet": {
"fungibleModule": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB",
"systemContract": "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B",
"uniswapv2Factory": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c",
"uniswapv2Router02": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe"
}
}

On chain "foreign coins":

{
  "foreignCoins": [
    {
      "zrc20_contract_address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a",
      "asset": "0x07865c6e87b9f70255377e024ace6630c1eaa37f",
      "foreign_chain_id": "5",
      "decimals": 6,
      "name": "USDC-goerli_testnet",
      "symbol": "USDC",
      "coin_type": "ERC20",
      "gas_limit": "100000",
      "paused": false
    },
    {
      "zrc20_contract_address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4",
      "asset": "",
      "foreign_chain_id": "5",
      "decimals": 18,
      "name": "ETH-goerli_testnet",
      "symbol": "gETH",
      "coin_type": "Gas",
      "gas_limit": "21000",
      "paused": false
    },
    {
      "zrc20_contract_address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb",
      "asset": "",
      "foreign_chain_id": "80001",
      "decimals": 18,
      "name": "MATIC-mumbai_testnet",
      "symbol": "tMATIC",
      "coin_type": "Gas",
      "gas_limit": "21000",
      "paused": false
    },
    {
      "zrc20_contract_address": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b",
      "asset": "",
      "foreign_chain_id": "18332",
      "decimals": 8,
      "name": "BTC-btc_testnet-btc_testnet",
      "symbol": "tBTC",
      "coin_type": "Gas",
      "gas_limit": "100",
      "paused": false
    },
    {
      "zrc20_contract_address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7",
      "asset": "0x64544969ed7EBf5f083679233325356EbE738930",
      "foreign_chain_id": "97",
      "decimals": 6,
      "name": "USDC-bsc_testnet",
      "symbol": "USDC",
      "coin_type": "ERC20",
      "gas_limit": "100000",
      "paused": false
    },
    {
      "zrc20_contract_address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F",
      "asset": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97",
      "foreign_chain_id": "80001",
      "decimals": 6,
      "name": "USDC-mumbai_testnet",
      "symbol": "USDC",
      "coin_type": "ERC20",
      "gas_limit": "100000",
      "paused": false
    },
    {
      "zrc20_contract_address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891",
      "asset": "",
      "foreign_chain_id": "97",
      "decimals": 18,
      "name": "BNB-bsc_testnet",
      "symbol": "tBNB",
      "coin_type": "Gas",
      "gas_limit": "21000",
      "paused": false
    }
  ],
  "pagination": {
    "next_key": null,
    "total": "7"
  }
}

Source: https://zetachain-athens.blockpi.network/lcd/v1/public/zeta-chain/zetacore/fungible/foreign_coins

cc @lucas-janon @andresaiello

@fadeev fadeev changed the title Refactor adresses.json to account for ERC-20s Refactor adresses.json to account for ZRC-20 for ERC-20s Oct 16, 2023
@fadeev fadeev changed the title Refactor adresses.json to account for ZRC-20 for ERC-20s Refactor adresses.json to account for ZRC-20 of ERC-20s Oct 16, 2023
@fadeev
Copy link
Member Author

fadeev commented Oct 18, 2023

We also probably need a convention to label tokens from different chains. For example, when using the swap example you want swap USDC for gETH on Goerli:

px hardhat interact --contract ADDRESS --amount 0.05 --denom usdc --target-token eth --network goerli_testnet --recipient ADDRESS --destination mumbai_testnet

If there is no denom (usdc) we can default to native gas token.

@fadeev
Copy link
Member Author

fadeev commented Oct 18, 2023

If we ever need to specify both a chain and a token, we can do something like goerli_testnet:usdc.

@fadeev
Copy link
Member Author

fadeev commented Oct 18, 2023

Should we do something like:

"zevm": {
  "goerli_testnet": {
    "zrc20": [
      {
        "symbol": "gETH",
        "zrc20_contract_address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4"
      },
      {
        "symbol": "USDC",
        "zrc20_contract_address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a"
      }
    ]
  },
}

Using the structure from the foreign coins API for consistency.

@fadeev
Copy link
Member Author

fadeev commented Dec 22, 2023

@andresaiello @lucas-janon I really think we should start thinking about a new structure for addresses.json. USDC addresses are currently missing from the JSON and this forces people to get addresses directly from chain's API.

@fadeev
Copy link
Member Author

fadeev commented Dec 22, 2023

How about simplifying the structure:

[
  {
    "chain": "goerli_testnet",
    "type": "zetaToken",
    "address": "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24",
    "category": "messaging"
  },
  {
    "chain": "goerli_testnet",
    "type": "tss",
    "address": "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24",
    "category": "omnichain"
  },
  {
    "chain": "zeta_testnet",
    "type": "zrc20",
    "symbol": "USDC",
    "address": "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24",
    "category": "omnichain"
  },
  {
    "chain": "zeta_testnet",
    "type": "zrc20",
    "symbol": "gETH",
    "address": "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24",
    "category": "omnichain"
  }
]

A flat array structure will let us add more metadata to addresses if needed.

getAddress(chain, type, symbol = null)

Symbol is optional, this way the function is backwards compatible.

getAddress("mumbai_tesnet", "tss")
getAddress("zeta_tesnet", "zrc20", "usdc")

The following will throw an error and we can make the error very discriptive by listing all valid options calculated automatically from the JSON:

getAddress("zeta_tesnet", "zrc20")
Error: please, specify symbol (for example, "usdc", "geth", "tmatic", "tbnb", "tbsc")

We can also run a script to validate the JSON and generate the types from it as well.

@fadeev
Copy link
Member Author

fadeev commented Jan 2, 2024

@lucas-janon @andresaiello please, provide feedback on this! We still don't have USDC in our JSON ‼️

@andresaiello
Copy link
Collaborator

I think we can have two models, tokens and non tokens. For tokens I like

{
      "zrc20_contract_address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F",
      "asset": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97",
      "foreign_chain_id": "80001",
      "decimals": 6,
      "name": "USDC-mumbai_testnet",
      "symbol": "USDC",
      "coin_type": "ERC20",
      "gas_limit": "100000",
      "paused": false
    },
    ```
but for non tokens has a lot of extra info that will be always empty (like for tss etc) and for those we can use the simplify model

@fadeev
Copy link
Member Author

fadeev commented Jan 3, 2024

@andresaiello but they will still be in a single array like so, right?

  {
    "chain": "goerli_testnet",
    "type": "tss",
    "address": "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24",
    "category": "omnichain"
  },
  {
    "zrc20_contract_address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F",
    "asset": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97",
    "foreign_chain_id": "80001",
    "decimals": 6,
    "name": "USDC-mumbai_testnet",
    "symbol": "USDC",
    "coin_type": "ERC20",
    "gas_limit": "100000",
    "paused": false
  },

@fadeev fadeev changed the title Refactor adresses.json to account for ZRC-20 of ERC-20s Refactor addresses.json to account for ZRC-20 of ERC-20s Jan 10, 2024
@fadeev
Copy link
Member Author

fadeev commented Jan 10, 2024

I've updated the script and now it generates addresses in the updated format:

#10 (comment)

@fadeev fadeev closed this as completed Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants