Sub-Adapters 1
Preview and test each sub adapter.
GnosisDAO (gnosisdao)
Metadata
- ID
- gnosisdao
- name
"GnosisDAO"
- icon
- description
"GnosisDAO is a collective that uses Gnosis products to transparently guide decisions on development, support, and governance of its token ecosystem."
- website
"https://gnosis.io/gnosisdao/"
- governanceSite
"https://snapshot.org/#/gnosis.eth"
- governanceForum
"https://forum.gnosis.io/"
- governanceModel
""
- category
""
- treasuries
[ "0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f", "0x10E4597fF93cbee194F4879f8f1d54a370DB6969", "0x4971DD016127F390a3EF6b956Ff944d0E2e1e462", "0x0DA0C3e52C977Ed3cBc641fF02DD271c3ED55aFe", "0xfa5dcf356a2d80cf0c89d64a18a742edaf8d30e8", "0x849D52316331967b6fF1198e5E32A0eB168D039d", "0xbc79855178842fdba0c353494895deef509e26bb", "0xec83f750adfe0e52a8b0dba6eeb6be5ba0bee535" ]
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
1export const name = 'GnosisDAO Treasury';
2export const version = '0.2.0';
3export const license = 'MIT';
4
5interface Org {
6 id: string
7 icon?: string
8 addresses: string[]
9 vestingAddresses?: string[]
10 nativeTokens?: string[]
11 iconType?: string
12 snapshotId?: string
13 governanceSite?: string
14 metadata: any
15 getProposals?: (sdk: Context) => Promise<any>
16}
17
18export async function setup(sdk: Context) {
19 const orgs: Org[] = [
20 {
21 id: 'gnosisdao',
22 addresses: [
23 '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f',
24 '0x10E4597fF93cbee194F4879f8f1d54a370DB6969',
25 '0x4971DD016127F390a3EF6b956Ff944d0E2e1e462',
26 '0x0DA0C3e52C977Ed3cBc641fF02DD271c3ED55aFe',
27 '0xfa5dcf356a2d80cf0c89d64a18a742edaf8d30e8',
28 '0x849D52316331967b6fF1198e5E32A0eB168D039d',
29 '0xbc79855178842fdba0c353494895deef509e26bb',
30 ],
31 vestingAddresses: ['0xec83f750adfe0e52a8b0dba6eeb6be5ba0bee535'],
32 icon: 'QmUMW8f5uqE5M9SBvxssz7f4LgUDq1tjue4hJdYo67WGJG',
33 iconType: 'image/jpeg',
34 snapshotId: 'gnosis.eth',
35 metadata: {
36 name: 'GnosisDAO',
37 icon: sdk.ipfs.getDataURILoader('QmUMW8f5uqE5M9SBvxssz7f4LgUDq1tjue4hJdYo67WGJG', 'image/png'),
38 description: 'GnosisDAO is a collective that uses Gnosis products to transparently guide decisions on development, support, and governance of its token ecosystem.',
39 website: 'https://gnosis.io/gnosisdao/',
40 governanceSite: 'https://snapshot.org/#/gnosis.eth',
41 governanceForum: 'https://forum.gnosis.io/',
42 governanceModel: '',
43 },
44 },
45 ];
46
47 async function getSnapshotProposals(id: string) {
48 const response = await sdk.http.post('https://hub.snapshot.org/graphql', {
49 query: `query Proposals($space: String!) {
50 proposals (
51 first: 5,
52 skip: 0,
53 where: { space_in: [$space] },
54 orderBy: "created",
55 orderDirection: desc
56 ) {
57 id
58 title
59 start
60 end
61 state
62 link
63 }
64 }`,
65 variables: { space: id },
66 });
67
68 return response.data.proposals;
69 }
70
71 const portfolioCache: { [addresses: string]: Promise<any> } = {}
72 const getPortfolio = (addresses: string[]): Promise<any> => {
73 const key = addresses.join(',')
74 if (!portfolioCache[key]) {
75 portfolioCache[key] = sdk.http.get(`https://cryptostats-api-proxy.vercel.app/api/v1/zapper/${key}`)
76 .then(result => {
77 if (result.success) {
78 return result.value
79 }
80 throw new Error(`Request to https://cryptostats-api-proxy.vercel.app/api/v1/zapper/${key}' failed: ${result.message}`)
81 });
82 }
83 return portfolioCache[key];
84 }
85
86 const createTreasuryLoader = (addresses: string[]) => async () => {
87 const portfolio = await getPortfolio(addresses)
88 let totalValue = 0;
89
90 for (const portItem of portfolio) {
91 totalValue += portItem.balanceUSD;
92 }
93
94 return totalValue
95 }
96
97 const createPortfolioLoader = (addresses: string[], vestingAddresses?: string[]) => async () => {
98 const [portfolio , vestingPortfolio] = await Promise.all([
99 getPortfolio(addresses),
100 vestingAddresses ? getPortfolio(vestingAddresses) : [] ,
101 ]);
102
103 let fullPortfolio = []
104
105 for (const portItem of portfolio) {
106 fullPortfolio.push({
107 address: portItem.address,
108 amount: portItem.context.balance,
109 name: portItem.context.symbol,
110 symbol:portItem.context.symbol,
111 icon:portItem.displayProps.images[0],
112 price:portItem.context.price,
113 value:portItem.balanceUSD,
114 })
115 }
116
117 for (const portItem of vestingPortfolio) {
118 fullPortfolio.push({
119 address: portItem.address,
120 amount: portItem.context.balance,
121 name: portItem.context.symbol,
122 symbol:portItem.context.symbol,
123 icon:portItem.displayProps.images[0],
124 price:portItem.context.price,
125 value:portItem.balanceUSD,
126 vesting: true
127 })
128 }
129 return fullPortfolio
130 };
131
132 for (const org of orgs) {
133 let recentProposals = async () => []
134 if (org.getProposals) {
135 recentProposals = () => org.getProposals!(sdk)
136 } else if (org.snapshotId) {
137 recentProposals = () => getSnapshotProposals(org.snapshotId!)
138 }
139
140 sdk.register({
141 id: org.id,
142 queries: {
143 currentTreasuryUSD: createTreasuryLoader([...org.addresses, ...(org.vestingAddresses || [])]),
144 currentLiquidTreasuryUSD: createTreasuryLoader(org.addresses),
145 currentTreasuryPortfolio: createPortfolioLoader(org.addresses, org.vestingAddresses),
146 recentProposals,
147 },
148 metadata: {
149 ...org.metadata,
150 governanceSite: org.snapshotId
151 ? `https://snapshot.org/#/${org.snapshotId}`
152 : org.governanceSite || null,
153 icon: org.icon ? sdk.ipfs.getDataURILoader(org.icon, org.iconType || 'image/svg+xml') : 0,
154 category: '',
155 treasuries: [...org.addresses, ...(org.vestingAddresses || [])],
156 },
157 });
158 }
159}
160
It's something off?
Report it to the discussion board on Discord, we will take care of it.