Adapter

GnosisDAO Treasury

GnosisDAO is a collective that uses Gnosis products to transparently guide decisions on development, support, and governance of its token ecosystem.

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

[ "0xec83f750adfe0e52a8b0dba6eeb6be5ba0bee535", "0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f", "0x4971DD016127F390a3EF6b956Ff944d0E2e1e462", "0x0DA0C3e52C977Ed3cBc641fF02DD271c3ED55aFe", "0xfa5dcf356a2d80cf0c89d64a18a742edaf8d30e8", "0x849D52316331967b6fF1198e5E32A0eB168D039d", "0xbc79855178842fdba0c353494895deef509e26bb" ]

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

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

It's something off?

Report it to the discussion board on Discord, we will take care of it.

Adapter Info

Version

0.1.8

License

MIT

IPFS CID

QmWztHapR1RFUFbHtuMipiQw7YVKGCZx3BsBwNd42JdrRe

CID (source)

QmPRyGgEj1yv3Qrw7MeD9hy8HP4eTvMWoRpXm7eLfMAixE

Author

0xd25fcBb7b6021Cf83122fcD65BE88a045D5f961c