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
[ "0x0DA0C3e52C977Ed3cBc641fF02DD271c3ED55aFe", "0xfa5dcf356a2d80cf0c89d64a18a742edaf8d30e8", "0x849D52316331967b6fF1198e5E32A0eB168D039d", "0xbc79855178842fdba0c353494895deef509e26bb" ]
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
1export const name = 'GnosisDAO Treasury';
2export const version = '0.1.7';
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 '0x0DA0C3e52C977Ed3cBc641fF02DD271c3ED55aFe',
24 '0xfa5dcf356a2d80cf0c89d64a18a742edaf8d30e8',
25 '0x849D52316331967b6fF1198e5E32A0eB168D039d',
26 '0xbc79855178842fdba0c353494895deef509e26bb',
27 ],
28 icon: 'QmUMW8f5uqE5M9SBvxssz7f4LgUDq1tjue4hJdYo67WGJG',
29 iconType: 'image/jpeg',
30 snapshotId: 'gnosis.eth',
31 metadata: {
32 name: 'GnosisDAO',
33 icon: sdk.ipfs.getDataURILoader('QmUMW8f5uqE5M9SBvxssz7f4LgUDq1tjue4hJdYo67WGJG', 'image/png'),
34 description: 'GnosisDAO is a collective that uses Gnosis products to transparently guide decisions on development, support, and governance of its token ecosystem.',
35 website: 'https://gnosis.io/gnosisdao/',
36 governanceSite: 'https://snapshot.org/#/gnosis.eth',
37 governanceForum: 'https://forum.gnosis.io/',
38 governanceModel: '',
39 },
40 },
41 ];
42
43 async function getSnapshotProposals(id: string) {
44 const response = await sdk.http.post('https://hub.snapshot.org/graphql', {
45 query: `query Proposals($space: String!) {
46 proposals (
47 first: 5,
48 skip: 0,
49 where: { space_in: [$space] },
50 orderBy: "created",
51 orderDirection: desc
52 ) {
53 id
54 title
55 start
56 end
57 state
58 link
59 }
60 }`,
61 variables: { space: id },
62 });
63
64 return response.data.proposals;
65 }
66
67 const portfolioCache: { [addresses: string]: Promise<any> } = {}
68 const getPortfolio = (addresses: string[]): Promise<any> => {
69 const key = addresses.join(',')
70 if (!portfolioCache[key]) {
71 portfolioCache[key] = sdk.http.get(`https://zerion-api.vercel.app/api/portfolio/${key}`)
72 .then(result => {
73 if (result.success) {
74 return result.value
75 }
76 throw new Error(`Request to 'https://zerion-api.vercel.app/api/portfolio/${key}' failed: ${result.message}`)
77 });
78 }
79 return portfolioCache[key];
80 }
81
82 const createTreasuryLoader = (addresses: string[]) => async () => {
83 const portfolio = await getPortfolio(addresses)
84 return portfolio.totalValue
85 }
86
87 const createPortfolioLoader = (addresses: string[], vestingAddresses?: string[]) => async () => {
88 const [{ portfolio }, { portfolio: vestingPortfolio }] = await Promise.all([
89 getPortfolio(addresses),
90 vestingAddresses ? getPortfolio(vestingAddresses) : { portfolio: [] },
91 ]);
92
93 return [
94 ...portfolio,
95 ...vestingPortfolio.map((portfolioItem: any) => ({ ...portfolioItem, vesting: true }))
96 ];
97 };
98
99 for (const org of orgs) {
100 let recentProposals = async () => []
101 if (org.getProposals) {
102 recentProposals = () => org.getProposals!(sdk)
103 } else if (org.snapshotId) {
104 recentProposals = () => getSnapshotProposals(org.snapshotId!)
105 }
106
107 sdk.register({
108 id: org.id,
109 queries: {
110 currentTreasuryUSD: createTreasuryLoader([...org.addresses, ...(org.vestingAddresses || [])]),
111 currentLiquidTreasuryUSD: createTreasuryLoader(org.addresses),
112 currentTreasuryPortfolio: createPortfolioLoader(org.addresses, org.vestingAddresses),
113 recentProposals,
114 },
115 metadata: {
116 ...org.metadata,
117 governanceSite: org.snapshotId
118 ? `https://snapshot.org/#/${org.snapshotId}`
119 : org.governanceSite || null,
120 icon: org.icon ? sdk.ipfs.getDataURILoader(org.icon, org.iconType || 'image/svg+xml') : 0,
121 category: '',
122 treasuries: [...org.addresses, ...(org.vestingAddresses || [])],
123 },
124 });
125 }
126}
127
It's something off?
Report it to the discussion board on Discord, we will take care of it.