Closed daviddavo closed 2 years ago
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
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)
We can use a combination of Coinmarketcap and Etherscan when needed
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
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.
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...
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
Hm... Now that I think of it, etherscan has an api just for mainnet, but what about other sidechains?
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"
}
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)
Comparing with the Treasury
on daohaus.club, I think we should be using The Graph, filtering by guildBank.
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.
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
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.
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.
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
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
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:
This is how it's going. Displaying info for daohaus. I'll implement it for the other platforms and then merge with develop.
It's finally done on all three platforms. I'll merge it with develop and the visual changes on Monday.
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
With other DAOs, we can get the info from Etherscan if The Graph API doesn't provide it, just given the eth address
This is also possible with Aragon using the address of the Vault/Agent app
The generated graphs can break down the tokens and display it in a graph bar using different colors, like "Proposals by type"
Treeview