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

feat: add Polkadot Asset Hub adapter #7862

Closed
wants to merge 2 commits into from

Conversation

Imod7
Copy link

@Imod7 Imod7 commented Oct 27, 2023

Name (to be shown on DefiLlama):

Polkadot Asset Hub

Twitter Link:

N/A

List of audit links if any:

N/A

Website Link:

https://parachains.info/details/statemint
https://metadata.parity.io/#/polkadot-statemint

Logo (High resolution, will be shown with rounded borders):

https://drive.google.com/file/d/1Un0J46IXWC1Jr4U8F80BWrHW9dbQbOXl/view?usp=drive_link

Current TVL:

--- polkadot_asset_hub-offers ---
USDC 250.27 M
USDT 18.00 M
DOT 62.38 k
Total: 268.33 M

To Exclude the pre-minted USDC address

Treasury Addresses (if the protocol has treasury)

13UVJyLgBASGhE2ok3TvxUfaQBGUt88JCcdYjHvUhvQkFTTx

Chain:

Polkadot Asset Hub
1000 (substrate/ parachain on polkadot)

Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)

N/A

Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)

N/A

Short Description (to be shown on DefiLlama):

The Asset Hub on both Polkadot and Kusama are the first system parachains.
The Asset Hub is an asset portal for the entire network. It helps asset creators (e.g. reserve backed stablecoin issuers) to track the total issuance of their asset in the Polkadot network, including amounts that have been transferred to other parachains. It is also the point where they can transact, mint and burn, and manage the on-chain asset.

Token address and ticker if any:

DOT (native)

Category (full list at https://defillama.com/categories) *Please choose only one:

Cross Chain (please check appropriateness here)

Oracle used (Chainlink/Band/API3/TWAP or any other that you are using):

-

forkedFrom (Does your project originate from another project):

-

methodology (what is being counted as tvl, how is tvl being calculated):

TVL is calculated as sum of all assets listed in AssetHub recalculated to their respective token prices. AssetHub by the nature/purpose of this system parachain should count all of its assets toward TVL, meaning, it should be categorized into this type "Offers - funds that are approved for spending on a non-custodial platform, but not actually deposited into the platform contracts" (source - DefiLlama-What to include as TVL?).

The tokens we included in the Offers section are the ones we consider that have "real" value in Polkadot Asset Hub.

The tokens that we identified with real value are the following :

  1. native in Polkadot Asset Hub -> DOT (Polkadot)
  2. Registered Assets
    2.1 USDC (USD Coin)
    2.2 USDt (Tether)
  3. Registered Foreign Assets as of now (27/10/2023) :
    3.1 KSM (Kusama)
    3.2 EQ (Equilibrium)
    3.3. EQD (Equilibrium Dollar)
Github org/user (Optional, if your code is open source, we can track activity):

https://github.com/paritytech/polkadot-sdk

Aditional information

PR to add Offers adapter for Polkadot Asset Hub.

Implementation

Based on the docs of Defi Llama to add a new project I added :

  • a new folder polkadot-asset-hub inside the folder projects
  • a new entry for polkadot-asset-hub in the chains.json file.

Run

To run the Polkadot Asset Hub script and test the results you need to do the following :

  • git clone current repo
  • git checkout in this branch
  • npm install
  • npm install @polkadot/api
  • node test.js projects/polkadot-asset-hub/index.js
  • The object returned is
{
  polkadot: 15141.1970349293,
  tether: 17998747.607192,
  'usd-coin': 250019990.612722
}

Output

The output is :

-------------------
Warning:
Token coingecko:usd-coin has more than 100M in value (250.019991 M) , price data:  {
  price: 1,
  symbol: 'USDC',
  timestamp: 1698410399,
  confidence: 0.99,
  mcap: 25102765089.485973
}
-------------------
--- polkadot_asset_hub ---
Total: 0

--- polkadot_asset_hub-offers ---
USDC                      250.02 M
USDT                      18.02 M
DOT                       62.38 k
Total: 268.10 M

--- tvl ---
Total: 0

--- offers ---
USDC                      250.02 M
USDT                      18.02 M
DOT                       62.38 k
Total: 268.10 M

------ TVL ------
polkadot_asset_hub        0
polkadot_asset_hub-offers 268.10 M
offers                    268.10 M

total                    0

Additional Requests from DefiLlama team

1. Exclude Address

From the above results, we think it is best to exclude this specific pre-minted USDC address:

15QjVp1rx6tjbBjmaWhhwUV7ESHMG6KjdDdhRuw5dQKWkqzB

so that the results are more accurate. Kindly asking the DefiLlama team if you can advice on how can we do this in the current implementation ?

2. Change in Label

In https://defillama.com/chains/Parachain --> Preferably this “Parachain” label should be renamed to “Polkadot” in the light of upcoming agile Polkadot changes.

@llamatester
Copy link

Error while running adapter at projects/polkadot-asset-hub:

Error: Protocol doesn't have total tvl, make sure to export a tvl key either on the main object or in one of the chains
Truncated error stack:

    at /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:205:11

@llamatester
Copy link

The adapter at projects/polkadot-asset-hub exports TVL:

polkadot_asset_hub        0
polkadot_asset_hub-offers 268.39 M
offers                    268.39 M

total                    0 

@Imod7
Copy link
Author

Imod7 commented Oct 27, 2023

Error while running adapter at projects/polkadot-asset-hub:

Error: Protocol doesn't have total tvl, make sure to export a tvl key either on the main object or in one of the chains
Truncated error stack:

    at /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:205:11

I pushed the polkadot/api dependency in package.json and now there is no error.

@Imod7
Copy link
Author

Imod7 commented Oct 27, 2023

The adapter at projects/polkadot-asset-hub exports TVL:

polkadot_asset_hub        0
polkadot_asset_hub-offers 268.39 M
offers                    268.39 M

total                    0 

Yes, now with the update in package.json it exports correctly the tvl key even if it is zero. All the amounts are under Offers.

@g1nt0ki
Copy link
Member

g1nt0ki commented Oct 30, 2023

Hi @Imod7, the code has no issues, but I am afraid this is not a defi project/has no tvl. I checked with the team as well and they felt the same. Sorry, we cant list this.

@Imod7
Copy link
Author

Imod7 commented Oct 30, 2023

Hi @Imod7, the code has no issues, but I am afraid this is not a defi project/has no tvl. I checked with the team as well and they felt the same. Sorry, we cant list this.

Thank you very much for your prompt feedback! Based on this guide you provide, my goal was to add all the corresponding amounts with tvl filter equals Offers. So, the tvl under Offers is non zero.

❗From the current result, it is pending to exclude the funds from this pre-minted address so to subtract approximately 248M USDC. I mentioned it in the description of this PR in case you could suggest the best way to implement this.

If this amount is substracted then the final tvl under Offers should be approximately :

--- offers ---
USDC                     ~ 2 M
USDT                      18.02 M
DOT                       62.38 k
Total: ~ 20 M
...
...
------ TVL ------
polkadot_asset_hub-offers ~ 20 MM

@g1nt0ki g1nt0ki self-assigned this Oct 30, 2023
@g1nt0ki
Copy link
Member

g1nt0ki commented Oct 31, 2023

hi @Imod7 correct me if I am wrong, what you are tracking here is asset issuance/circulating supply, but that is not we track in tvl dashboard

@Imod7
Copy link
Author

Imod7 commented Nov 1, 2023

hi @Imod7 correct me if I am wrong, what you are tracking here is asset issuance/circulating supply, but that is not we track in tvl dashboard

Hello @g1nt0ki
Yes exactly, that is what we are tracking in Asset Hub and since this is not what you track in the tvl dashboard then I understand that it cannot be included. My only remaining doubts are from the guide you have here where the TVL Filter of Offers is mentioned with the following definition :

Offers - funds that are approved for spending on a non-custodial platform, but not actually deposited into the platform contracts

This is very close to the definition of Asset Hub as you mentioned it in your last reply :

you are tracking here is asset issuance/circulating supply

  1. So, if you agree that these definitions are very close/similar, why it cannot be added as tvl Offers ? Could you share what type of projects you include with the filter Offers?

Also, from your first comment

I am afraid this is not a defi project

kindly challenging this statement by mentioning that Polkadot Asset Hub is a liquidity portal for the entire Polkadot network and holds and manages assets in a decentralized manner similar to DeFi platforms by utilising Multisig, Proxy and Utility Substrate pallets (link).

  1. So, Asset Hub couldn't be considered as a DeFi project in that sense and be added in the Offers section ?

Thank you so much in advance for your patience, clarifications and answers that you provided until now in this PR 🙏 If you could answer these two last points so I can also share with my team, that would be awesome and I would greatly appreciate it! Soon after of course, I will also close this PR. Just to also point out that the goal of my arguments are just to get a better understanding and nothing more than that. Thank you again for your time! 🙏

@g1nt0ki
Copy link
Member

g1nt0ki commented Nov 2, 2023

hi @Imod7

The Offers category is (unofficially) deprecated. It was created for https://swap.cat as this is dex that allowed users to create offers but the tokens are not locked in smart contract (like usual dex) and matched with other users p2p. Another example is opensea, but atm, we are not counting offers on opensea and delisted swapcat (stale data). IMO, we should remove offers from documentation.

The only protocol listed now that has offers field: https://defillama.com/protocol/owna where we track loan offers. Just noticed that it is not visible in the UI anyway.

Just to be clear, I do think Asset Hub is important piece of infra but we dont track value locked in things like multisigs.

@Imod7
Copy link
Author

Imod7 commented Nov 2, 2023

@g1nt0ki Thank you so much for all the feedback! Very much appreciated! I will inform the team and closing this PR!

@Imod7 Imod7 closed this Nov 2, 2023
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

3 participants