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

Display the assets of DAOs #34

Closed
19 tasks done
daviddavo opened this issue Oct 11, 2021 · 17 comments
Closed
19 tasks done

Display the assets of DAOs #34

daviddavo opened this issue Oct 11, 2021 · 17 comments
Labels
new metric Adding a new metric to the page
Milestone

Comments

@daviddavo
Copy link
Member

daviddavo commented Oct 11, 2021

For example, Aragon provides the Finance app, which lets you see the token balances of a given DAO. I still don't know if this is possible using The Graph, but first we have to fix #18

E.g: Aragon budget

With other DAOs, we can get the info from Etherscan if The Graph API doesn't provide it, just given the eth address

E.g: dxDao

This is also possible with Aragon using the address of the Vault/Agent app

E.g: Aragon Budget (Ethscan)

The generated graphs can break down the tokens and display it in a graph bar using different colors, like "Proposals by type"

  • Estimate number of queries
  • Create a list of APIs
  • Choose an API
  • Investigate:
    • Investigate about Aragon
    • Investigate about Daohaus
    • Investigate about Daostack
  • Implement Collectors (just tokens):
    • Create blockscout collector
    • Create Aragon TokenBalances Collector
    • Create Daohaus TokenBalances Collector
    • Create Daostack TokenBalances Collector
  • Get holdings in pure eth (not ERC-20 tokens)
  • Get tokens values
  • Decide a visualization method -> Treeview
  • Implement visualization
    • Aragon Visualization
    • Daohaus Visualization
    • Daostack Visualization
@daviddavo daviddavo added the new metric Adding a new metric to the page label Oct 11, 2021
@daviddavo daviddavo added this to the v0.7 milestone Oct 30, 2021
@daviddavo daviddavo modified the milestones: v0.7, v0.7.1 Dec 1, 2021
@daviddavo
Copy link
Member Author

daviddavo commented Dec 7, 2021

This post is WIP

Keep in mind that some tokens are only used in a specific DAO and thus have no fiat conversion.

To convert the assets price to fiat, we can use one of the following APIs:

API Free limit Free commercial Notes
Coinmarketcap 10k calls/mo Has a scholars plan
Etherscan 100k calls/day 5 calls/second ?
Messari ? ? To be able to use it, needs contact by e-mail
Nomics No free version
Blockscout Unlimited? ? Can be self-hosted. Has xdai.

More info on https://github.com/public-apis/public-apis#cryptocurrency

@daviddavo
Copy link
Member Author

Before choosing an API, we need to estimate the number of requests we will be doing. I'll try making a notebook to get how many tokens we have, (and which of them have a public price)

@daviddavo daviddavo modified the milestones: v0.7.1, v0.7.2 Feb 10, 2022
@daviddavo
Copy link
Member Author

We can use a combination of Coinmarketcap and Etherscan when needed

@daviddavo
Copy link
Member Author

daviddavo commented Feb 10, 2022

Aragon

The OrganizationsCollector seems to get a field called recoveryVault. This isn't used anywhere in our code, but if we go in etherscan to that Vault Address we can see that we can have the same information as in the Finance tab on Aragon Client.

For example, let's see lexDAO

It's address is 0xa365a8429fcefdbe1e684dddda3531b6e8d96e75, and the recovery vault is 0x97103fda00a2b47eac669568063c00e65866a633.

In Etherscan, it says 1.7 ETH plus various Tokens. Exactly the same information as in the Aragon client.

Also with blockscout

Why not Using The Graph

I don't know why, but it seems to have tokens with a negative balance... Maybe there are two ways of inserting tokens to a DAO, and the aragon-finance subgraph only takes into account some of them.

@daviddavo
Copy link
Member Author

One problem I think we may have is that we don't have any historical data about the prices, but it might be important for temporal series...

@daviddavo
Copy link
Member Author

daviddavo commented Feb 10, 2022

I found an API with free daily historical data. It's the one used on aragon client

https://min-api.cryptocompare.com/pricing

We can get the tokens that each vault has using the ethscan API or TheGraph, and then the historical data with cryptocompare.

We can use the Aragon Finance subgraph, but It doesn't return the name of the token, and it's just harder to implement than etherscan

@daviddavo
Copy link
Member Author

Hm... Now that I think of it, etherscan has an api just for mainnet, but what about other sidechains?

@daviddavo
Copy link
Member Author

Etherscan has to be discarded because it doesn't work with sidechains...

Nevertheless, I found blockscout, here is Metacartel xDAI tokens and balance

https://blockscout.com/xdai/mainnet/address/0xb152B115c94275b54a3F0b08c1Aa1D21f32a659a/tokens

Sample API query:
https://blockscout.com/xdai/mainnet/api\?module\=account\&action\=tokenlist\&address\=0xb152B115c94275b54a3F0b08c1Aa1D21f32a659a

Response:

{
  "message": "OK",
  "result": [
    {
      "balance": "295692983666393282927",
      "contractAddress": "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1",
      "decimals": "18",
      "name": "Wrapped Ether on xDai",
      "symbol": "WETH",
      "type": "ERC-20"
    },
    {
      "balance": "31010000000000000000",
      "contractAddress": "0xb0c5f3100a4d9d9532a4cfd68c55f1ae8da987eb",
      "decimals": "18",
      "name": "DAOhaus Token on xDai",
      "symbol": "HAUS",
      "type": "ERC-20"
    },
    {
      "balance": "1000000000000000",
      "contractAddress": "0xb7d311e2eb55f2f68a9440da38e7989210b9a05e",
      "decimals": "18",
      "name": "STAKE on xDai",
      "symbol": "STAKE",
      "type": "ERC-20"
    },
    {
      "balance": "100000000000000000000",
      "contractAddress": "0xd3226b12e6188133b19ac0419f34b0ed5b10f069",
      "decimals": "18",
      "name": "EsportsRef",
      "symbol": "ESR",
      "type": "ERC-20"
    },
    {
      "balance": "19079758648560662397693",
      "contractAddress": "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d",
      "decimals": "18",
      "name": "Wrapped XDAI",
      "symbol": "WXDAI",
      "type": "ERC-20"
    }
  ],
  "status": "1"
}

@daviddavo
Copy link
Member Author

daviddavo commented Feb 14, 2022

Daohaus

We can use either The Graph or blockscout. Blockscout also shows non-whitelisted tokens, but The Graph shows the proprietary of the tokens.

Example for LexDAO (0x58234d4bf7a83693dc0815d97189ed7d188f6981 xdai)

image

Comparing with the Treasury on daohaus.club, I think we should be using The Graph, filtering by guildBank.

image

To get the price history and build a time series, we can query the subgraph with a certain block number (easier), or we can just get all transactions and process them.

@daviddavo
Copy link
Member Author

Daostack

We can obtain the reputation supply from the subgraph. (Btw, it has 18 decimals), but Alchemy (DAOstack's web platform) seems to use etherscan to get the DAL holdings.

For example, with dxDAO, we can get exactly the same data as in Alchemy just using this blockscout link:

https://blockscout.com/eth/mainnet/address/0x519b70055af55A007110B4Ff99b0eA33071c720a/tokens#tokens

image

@daviddavo
Copy link
Member Author

daviddavo commented Feb 16, 2022

Unknown tokens

On MetaCartel ventures treasury we can see a lot of strange tokens called MCV01, MCV02... and so forth. Maybe these kinds of tokens without USD value are not even worth saving on our database. On the other hand, we can't keep a manual list of "worthwhile" tokens, because of the rapid-changing world of crypto. We need an endpoint to get a list of the 1000 most used tokens or something like that so we can filter before saving the datawarehouse.

@javiag
Copy link
Contributor

javiag commented Feb 16, 2022

Tokens without USD value ARE WORTH saving on our database. However, we will give them a different treatment (no value in USD will be shown). Thus, we need (at least) two lists: one for tokens with fiat value and one for tokens without it.

@daviddavo
Copy link
Member Author

According to Blockscout's documentation, Ethereum mainnet hosted instance is discontinued

But we can use etherscan for mainnet if we just change our method of obtaining the ballances to a method of processing transactions

https://docs.etherscan.io/api-endpoints/accounts#get-a-list-of-erc20-token-transfer-events-by-address

@daviddavo
Copy link
Member Author

I can't seem to do anything weird with the treemap, because it expects the non-leaf value to be the sum of all its children.

Here you have the notebook I've been using to develop this, @javiag

https://gist.github.com/daviddavo/b543aad74cd063ff391ca254c8115294

The second to last code frame is the one with the loop we can modify. We should edit the line df_tree['value'] = ... in such a way that it maintains the restriction

@javiag
Copy link
Contributor

javiag commented Mar 3, 2022

Hi,

a quick answer, without looking at your notebook. If you transform the USD value at the leaf level, it should work.

That is, if you transform the value of the USD equivalence of crypto X hold by DAO Y deployed in network Z, then you can always go up the tree, that is, aggregate the transformed value and the problem of the non-leaf being the sum of all its children should work.

Am I missing something?

Regarding the transformation, I think root square could be more interesting than logarithm because:

  1. It's less aggressive, i.e. it compresses less the range than the logarithm.
  2. It produces positive values when the original value is less than 1 (and bigger than zero), while the logarithm produces negative values.

@daviddavo
Copy link
Member Author

This is how it's going. Displaying info for daohaus. I'll implement it for the other platforms and then merge with develop.

image

@daviddavo
Copy link
Member Author

It's finally done on all three platforms. I'll merge it with develop and the visual changes on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new metric Adding a new metric to the page
Projects
Development

No branches or pull requests

2 participants