Sub-Adapters 1
Preview and test each sub adapter.
DXdao (dxdao)
Metadata
- ID
- dxdao
- icon
- name
"DXdao"
- description
"DXdao is a decentralized collective that builds and governs decentralized products and services."
- website
"https://dxdao.eth.link"
- governanceSite
"https://alchemy.daostack.io/dao/0x519b70055af55a007110b4ff99b0ea33071c720a"
- governanceForum
"https://daotalk.org/c/dx-dao"
- governanceModel
""
- treasuries
[ "0x519b70055af55a007110b4ff99b0ea33071c720a", "0xa1d65e8fb6e87b60feccbc582f7f97804b725521" ]
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
1export const name = 'dxDAO Treasury';
2export const version = '0.1.0';
3export const license = 'MIT';
4
5const TREASURY_ADDRESS = '0x519b70055af55a007110b4ff99b0ea33071c720a'
6const DXD_TOKEN = '0xa1d65e8fb6e87b60feccbc582f7f97804b725521'
7const USDC_TOKEN = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
8
9export async function setup(sdk: Context) {
10 let treasuryPortfolioPromise: Promise<any> | null
11 const getTresuryPortfolio = (): Promise<any> => {
12 if (!treasuryPortfolioPromise) {
13 treasuryPortfolioPromise = sdk.http.get(`https://zerion-api.vercel.app/api/portfolio/${TREASURY_ADDRESS}`)
14 .then(result => {
15 if (result.success) {
16 return result.value
17 }
18 throw new Error(result.error)
19 })
20 }
21 return treasuryPortfolioPromise
22 }
23
24 const getBondingCurve = async () => {
25 const [dxdPrice, dxdBalance, usdcBalance] = await Promise.all([
26 sdk.coinGecko.getCurrentPrice('dxdao'),
27 sdk.ethers.getERC20Contract(DXD_TOKEN).balanceOf(DXD_TOKEN),
28 sdk.ethers.getERC20Contract(USDC_TOKEN).balanceOf(DXD_TOKEN),
29 ])
30
31 const totalValue = (usdcBalance.toString() / 1e6) + (dxdPrice * dxdBalance.toString() / 1e18)
32 const portfolio = [
33 {
34 address: USDC_TOKEN,
35 amount: usdcBalance.toString() / 1e6,
36 value: usdcBalance.toString() / 1e6,
37 price: 1,
38 name: 'USDC',
39 symbol: 'USDC',
40 icon: `https://s3.amazonaws.com/token-icons/${USDC_TOKEN}.png`,
41 },
42 {
43 address: DXD_TOKEN,
44 amount: dxdBalance.toString() / 1e18,
45 value: dxdPrice * dxdBalance.toString() / 1e18,
46 price: dxdPrice,
47 name: 'DXdao',
48 symbol: 'DXD',
49 icon: `https://s3.amazonaws.com/token-icons/${DXD_TOKEN}.png`,
50 },
51 ]
52
53 return { totalValue, portfolio }
54 }
55
56 const getTreasuryInUSD = async () => {
57 const [treasury, { totalValue: bondingCurveVal }] = await Promise.all([
58 getTresuryPortfolio(),
59 getBondingCurve(),
60 ])
61
62 return treasury.totalValue + bondingCurveVal
63 }
64
65 const getPortfolio = async () => {
66 const [{ portfolio: reservePortfolio }, { portfolio: bondingCurvePortfolio }] = await Promise.all([
67 getTresuryPortfolio(),
68 getBondingCurve(),
69 ])
70
71 return [...reservePortfolio, ...bondingCurvePortfolio]
72 }
73
74 sdk.register({
75 id: 'dxdao',
76 queries: {
77 currentTreasuryUSD: getTreasuryInUSD,
78 currentLiquidTreasuryUSD: getTreasuryInUSD,
79 currentTreasuryPortfolio: getPortfolio,
80 recentProposals: async () => [],
81 },
82 metadata: {
83 icon: sdk.ipfs.getDataURILoader('QmVvZF3qMp8fx9dpYvkCMV849U6oLaKJJA5BxxUCmabvb4', 'image/svg+xml'),
84 name: 'DXdao',
85 description: 'DXdao is a decentralized collective that builds and governs decentralized products and services.',
86 website: 'https://dxdao.eth.link',
87 governanceSite: 'https://alchemy.daostack.io/dao/0x519b70055af55a007110b4ff99b0ea33071c720a',
88 governanceForum: 'https://daotalk.org/c/dx-dao',
89 governanceModel: '',
90 treasuries: [TREASURY_ADDRESS, DXD_TOKEN],
91 },
92 })
93}
94
It's something off?
Report it to the discussion board on Discord, we will take care of it.