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

chore: add automation script for injective assets #974

Conversation

shane-moore
Copy link

Intent

  • I made this PR as a skeleton to display what we are trying to achieve, as discussed in the Cosmostation <> Injective Protocol TG chat
  • Essentially, DefiLlama uses https://github.com/cosmostation/chainlist/blob/main/chain/injective/assets.json in order to calculate tvl for the dex, Helix. They use assets.json to transform token amounts that exist on helix's orderbook from chain formatted numbers to human readable (using assets.json decimals property) and also use the coingeckoId to get usd price for the assets. The problem is that https://github.com/cosmostation/chainlist/blob/main/chain/injective/assets.json is missing many tokens that are tradable on the dex, which uses bank module under the hood, so they're not being counted towards tvl. Specifically, these assets, and you can imagine additional missing metadata overtime.
┌─────────┬──────┬────────┬────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────┬───────────┐
│ (index) │ name │ symbol │          balance           │                                                   label                                                   │ decimals  │
├─────────┼──────┼────────┼────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────┼───────────┤
│    0    │ '-'  │  '-'   │  '1992531000000000000000'  │                           'ethereum:0x080b12e80c9b45e97c23b6ad10a16b3e2a123949'                           │ undefined │
│    1    │ '-'  │  '-'   │        '391132000'         │                  'ibc:3A6DD3358D9F7ADD18CDE79BA10B400511A5DE4AE2C037D7C9639B52ADAF35C6'                   │ undefined │
│    2    │ '-'  │  '-'   │   '4200000000000000000'    │                           'ethereum:0x3f07a84ecdf494310d397d24c1c78b041d2fa622'                           │ undefined │
│    3    │ '-'  │  '-'   │   '5000000000000000000'    │                           'ethereum:0x4986fd36b6b16f49b43282ee2e24c5cf90ed166d'                           │ undefined │
│    4    │ '-'  │  '-'   │  '125310000000000000000'   │                           'ethereum:0x6b7f87279982d919bbf85182ddeab179b366d8f2'                           │ undefined │
│    5    │ '-'  │  '-'   │       '24585000000'        │                  'ibc:34346A60A95EB030D62D6F5BDD4B745BE18E8A693372A8A347D5D53DBBB1328B'                   │ undefined │
│    6    │ '-'  │  '-'   │       '23093000000'        │ 'injective:factory:inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk:inj1sthrn5ep8ls5vzz8f9gp89khhmedahhdkqa8z3' │ undefined │
│    7    │ '-'  │  '-'   │        '8000000000'        │ 'injective:factory:inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk:inj1q6kpxy6ar5lkxqudjvryarrrttmakwsvzkvcyh' │ undefined │
│    8    │ '-'  │  '-'   │  '270000000000000000000'   │                  'ibc:D91A2C4EE7CD86BBAFCE0FA44A60DDD9AFBB7EEB5B2D46C0984DEBCC6FEDFAE8'                   │ undefined │
│    9    │ '-'  │  '-'   │        '4020000000'        │ 'injective:factory:inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk:inj1d5vz0uzwlpfvgwrwulxg6syy82axa58y4fuszd' │ undefined │
│   10    │ '-'  │  '-'   │      '10757760000000'      │ 'injective:factory:inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk:inj1dxv423h8ygzgxmxnvrf33ws3k94aedfdevxd8h' │ undefined │
│   11    │ '-'  │  '-'   │ '64368146000000000000000'  │                  'ibc:AC87717EA002B0123B10A05063E69BCA274BA2C44D842AEEB41558D2856DCE93'                   │ undefined │
│   12    │ '-'  │  '-'   │        '2135100000'        │                  'ibc:C20C0A822BD22B2CEF0D067400FCCFB6FAEEE9E91D360B4E0725BD522302D565'                   │ undefined │
│   13    │ '-'  │  '-'   │ '131125300000000000000000' │                  'ibc:F6CC233E5C0EA36B1F74AB1AF98471A2D6A80E2542856639703E908B4D93E7C4'                   │ undefined │
└─────────┴──────┴────────┴────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────┴───────────┘
  • In order to resolve this, assets.json needs to be able to map a denom to it's proper decimals + coingeckoId for all the assets on our bank module. In the open source injective-ts repo, there is a canonical map of all tokens used by injective related products. then, there are some helper functions in the @injectivelabs/sdk-ts and @injectivelabs/sdk-ui-ts packages that help narrow down which assets on the canonical token map exist in the bank module and also transform the tokens to a consistent format. I use these helpers in this PR as to showcase what I mean.
  • I also generated an automated-assets.json to display how the injective canonical tokens map can be transformed into a format that is similar to https://github.com/cosmostation/chainlist/blob/main/chain/injective/assets.json. I say similar because there are certain fields such as origin_chain that we do not track in the canonical map, so I couldn't generate this field. I need some feedback from you folks on whether the token metadata in automated-assets.json is sufficient and accurate enough to be added to the tokens already included in https://github.com/cosmostation/chainlist/blob/main/chain/injective/assets.json.

Approaches

I could use your help on a path forward. Here are some ideas:

  1. Tweak script.ts to where it generates sufficient token metadata to append to the existing injective/assets.json. Then, during your CI/CD, script.ts could run and update injective/assets.json on the fly.
  2. Alternatively, we could have a step in the injective-ts CI/CD that makes a PR to this repo to update injective/assets.json using script.ts whenever new denoms are added to our canonical map.

Pertinent

Even without the automation, it's important to us to have the bank module denoms that are currently missing in injective/assets.json added, so that we can show TVL properly on DefiLlama. Most important to add are the 14 denoms that are shown as missing above, whether they are added manually using the token metadata from automated-assets.json or otherwise. Please help with this piece first, and we can handle the automation next.

Thanks for helping us get this sorted!

@soaryong-c
Copy link
Contributor

Hello team!
I sincerely appreciate for providing ideas and feedback regarding the issue. Currently, we do have some things that are not clear enough, and it would greatly benefit both of the teams if we could clear them out first.

Firstly, the asset.json is updated based on the chainlist provided by the Injective team. Could you please check if all of the data are included in the json file??

And the things that are not clear are the following:

  • It seems like Astroport Injective (a contract token created using the token factory) is not specifically classified and displays origin_denom as just ‘inj’. Since the origin_denom is not clearly specified, we are unsure if we can just display it as ‘inj’ or not register the denom as a token.
    • “factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj12kq4zh7kckuu0rfpxcr9l6l2x26ajf23uc0w55”,
  • We are unable to display unknown tokens to the mintscan. And it seems like some of the unknown denoms are included in the chainlist. Is there any way the team can filter it out?
    • factory/inj1dwfggufv8vkjcfkuk7fkkucs4rje0krav9ruyr/presale
  • The last part is regarding the process of how we are going to do it. From the previous call, we discussed that the injective team submits a PR to the chainlist of the Cosmostation github by automating the system using the github actions. I would like to confirm the process of how we are going to make the process as smooth as possible.

@shane-moore
Copy link
Author

@soaryong-c, happy to help clarify!

Firstly, the asset.json is updated based on the chainlist provided by the Injective team. Could you please check if all of the data are included in the json file??

  • the script in this PR is able to get all denoms that exist in the bank module and transform them into tokens with metadata. The results are located in chain/injective/automated-assets.json. also, the script will check if your hard-coded list already contains a denom, and if so, it will just use the existing token metadata from your hardcoded list

It seems like Astroport Injective (a contract token created using the token factory) is not specifically classified and displays origin_denom as just ‘inj’. Since the origin_denom is not clearly specified, we are unsure if we can just display it as ‘inj’ or not register the denom as a token.
“factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj12kq4zh7kckuu0rfpxcr9l6l2x26ajf23uc0w55”,

It seems you're referencing this denom from the automated-assets.json list:

 {
    "denom": "factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj12kq4zh7kckuu0rfpxcr9l6l2x26ajf23uc0w55",
    "type": "native",
    "origin_denom": "inj",
    "symbol": "INJ",
    "decimals": 18,
    "coinGeckoId": ""
  },

I see what you're saying that there is not a way to register the Astroport Injective factory denom as a token to display properly on your end based off the mapping in automated-assets.json. The automated-assets.json was an attempt to format our denoms similar to your assets.json but is not 1-to-1 the same due to limitations of what we track.

The most info we can get regarding this token is the following based off our tooling:

 {
   "denom": "factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj12kq4zh7kckuu0rfpxcr9l6l2x26ajf23uc0w55",
   "name": "CW20-wrapped inj",
   "symbol": "INJ",
   "decimals": 18,
   "logo": "unknown.svg",
   "coinGeckoId": "",
   "tokenType": "cw20",
   "tokenVerification": "internal",
   "cw20": {
     "decimals": 18,
     "address": "inj12kq4zh7kckuu0rfpxcr9l6l2x26ajf23uc0w55",
     "symbol": "INJ",
     "tokenType": "cw20"
   }
 },

Since this token doesnt have a coingeckoId and the logo is unknown, we could filter this token out of the result set and any similar ones missing enough metadata that would make them compatible with your schema. Those would just have to be added manually if needed. we wouldnt need these tokens for the defillama tvl calculations since they dont have a coingeckoId and wouldnt be able to be registered by them to count towards tvl

We are unable to display unknown tokens to the mintscan. And it seems like some of the unknown denoms are included in the chainlist. Is there any way the team can filter it out?
factory/inj1dwfggufv8vkjcfkuk7fkkucs4rje0krav9ruyr/presale

yep, we can definitely filter out unknown tokens. we wouldn't need these tokens for the defillama tvl as well since no coingeckoId

The last part is regarding the process of how we are going to do it. From the previous call, we discussed that the injective team submits a PR to the chainlist of the Cosmostation github by automating the system using the github actions. I would like to confirm the process of how we are going to make the process as smooth as possible.

yes, we can add a step to our CI/CD to make a PR to Cosmostation chainlist to update the assets.json. then, your team can validate whether the metadata is sufficient. Note that our more immediate need is listed in the Pertinent section of this PR, and this automation effort can be handled afterwards.

For automation, I just need to know which tokens on the automated-assets.json are sufficiently formatted to be added to your assets.json and if not, they can be filtered out.

@soaryong-c
Copy link
Contributor

@shane-moore
Thank you for reviewing on what we commented on the previous message.
I assume that we are able to implement the data by filtering out the unfiltered/unknown data that you provided.
However, there may be some cases the data format is different, so we may need to review and edit some of the data if necessary

Additionally, when you submit a PR to add the token, could you add on the information where the token is using right now? (Similar to what you mentioned in the previous message that you are going to use the token in the helix) It is because for mintscan, we have a policy to only display the tokens that are actually using right now.

Thank you again and we will close the current issue that is on the github. Let's continue the discussion regarding this topic on Telegram.
Please let us know if you have any questions and we are trying our best to support Injective as much as possible.

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

Successfully merging this pull request may close these issues.

None yet

2 participants