Open lajarre opened 2 years ago
Yes, that could be quite a big omission
I tend to use Etherscan's /tokenholdings page for cross-checking treasury allocations: https://etherscan.io/tokenholdings?a=0x8da8f82d2bbdd896822de723f55d6edf416130ba
It seems to be an orphan to both search and navigation, i.e. you have to go directly to the page
For example, Deepdao displays these tokens value: https://deepdao.io/organization/4c31770a-e3ca-4cc8-9292-508d632ff66a/organization_data/finance
I'm sure I'm just not looking well enough because I can't find this data on that DeepDao page 😅.
Still, I think this can be achieved with Uni's v2 subgraph with a query similar to this:
# request
{
user(id: "0x8da8f82d2bbdd896822de723f55d6edf416130ba"){
id,
liquidityPositions{
pair{
id,
token0{
id,
symbol
},
token1{
id,
symbol
}
},
liquidityTokenBalance
}
}
}
# response
{
"data": {
"user": {
"id": "0x8da8f82d2bbdd896822de723f55d6edf416130ba",
"liquidityPositions": [
{
"pair": {
"id": "0x8c1c499b1796d7f3c2521ac37186b52de024e58c",
"token0": {
"id": "0x31c8eacbffdd875c74b94b077895bd78cf1e64a3",
"symbol": "RAD"
},
"token1": {
"id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"symbol": "USDC"
}
},
"liquidityTokenBalance": "1.198749348279279609"
}
]
}
}
}```
@acemasterjb third token down is the Uniswap-V2 LP position
The query above gives us the token balance but I assume we retrieve all ERC20 tokens from cg/covalent.
If we just want to get an idea of the value of the treasury's claim on the pool, we can get the pool's totalSupply
and reserveUSD
:
# request
{
pair(id: "0x8c1c499b1796d7f3c2521ac37186b52de024e58c"){
totalSupply,
reserveUSD,
}
}
# response
{
"data": {
"pair": {
"totalSupply": "1.198797283990609674",
"reserveUSD": "3854828.384767350338857343251090302"
}
}
}
In this case:
(1.198749348279279609/1.198797283990609674)*3854828.384767350338857343251090302
= $3,854,674.24
Which is fairly close to what DeepDao are showing for Radicle.
side note: Etherscan omit price/value for LP positions and separate them from the main holdings in the /tokenholdings page. I assume this is to do with quality control around accuracy, but we can cross that bridge when we get to it.
Lastly, this is a solution for Uniswap-V2 LP positions but doesn't cover V1 pools (UNI still maintains a V1 position), V3 (held as NFTs), or other AMMs like Sushi & Balancer (Radicle have a Balancer pool token in their treasury).
I'll add this to the product backlog for us to discuss later.
Covalent have a pool by address endpoint: https://www.covalenthq.com/docs/api/#/0/Get%20XY=K%20pools%20by%20address/USD/1
Note that:
Actually, we can get away with using the pricing/historical_by_addresses_v2
covalent endpoint once we have the contract address of the LP token:
This takes care of the historical prices of the LP tokens, for the balances we can also utilize covalent for Uni v2 (and Uni v1, and derivatives of both too I think). The portfolio_v2
endpoint also shows the Uni-v2 LP token for Rad-USDC, for example.
Which means that we can most likely close this ticket once we find a way to incorporate Uni LP tokens to the whitelist, which we can most likely do with Covalent's xy=k/uniswap_v2/pools
endpoint.
Radicle DAO has LP tokens in a RAD/USDC pool: https://etherscan.io/token/0x8c1c499b1796d7f3c2521ac37186b52de024e58c?a=0x8da8f82d2bbdd896822de723f55d6edf416130ba
For example, Deepdao displays these tokens value: https://deepdao.io/organization/4c31770a-e3ca-4cc8-9292-508d632ff66a/organization_data/finance