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", "0x10E4597fF93cbee194F4879f8f1d54a370DB6969", "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.9';
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        '0x10E4597fF93cbee194F4879f8f1d54a370DB6969',
26        '0x4971DD016127F390a3EF6b956Ff944d0E2e1e462',
27        '0x0DA0C3e52C977Ed3cBc641fF02DD271c3ED55aFe',
28        '0xfa5dcf356a2d80cf0c89d64a18a742edaf8d30e8',
29        '0x849D52316331967b6fF1198e5E32A0eB168D039d',
30        '0xbc79855178842fdba0c353494895deef509e26bb',
31      ],
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://zerion-api.vercel.app/api/portfolio/${key}`)
76        .then(result => {
77          if (result.success) {
78            return result.value
79          }
80          throw new Error(`Request to 'https://zerion-api.vercel.app/api/portfolio/${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    return portfolio.totalValue
89  }
90
91  const createPortfolioLoader = (addresses: string[], vestingAddresses?: string[]) => async () => {
92    const [{ portfolio }, { portfolio: vestingPortfolio }] = await Promise.all([
93      getPortfolio(addresses),
94      vestingAddresses ? getPortfolio(vestingAddresses) : { portfolio: [] },
95    ]);
96
97    return [
98      ...portfolio,
99      ...vestingPortfolio.map((portfolioItem: any) => ({ ...portfolioItem, vesting: true }))
100    ];
101  };
102
103  for (const org of orgs) {
104    let recentProposals = async () => []
105    if (org.getProposals) {
106      recentProposals = () => org.getProposals!(sdk)
107    } else if (org.snapshotId) {
108      recentProposals = () => getSnapshotProposals(org.snapshotId!)
109    }
110
111    sdk.register({
112      id: org.id,
113      queries: {
114        currentTreasuryUSD: createTreasuryLoader([...org.addresses, ...(org.vestingAddresses || [])]),
115        currentLiquidTreasuryUSD: createTreasuryLoader(org.addresses),
116        currentTreasuryPortfolio: createPortfolioLoader(org.addresses, org.vestingAddresses),
117        recentProposals,
118      },
119      metadata: {
120        ...org.metadata,
121        governanceSite: org.snapshotId
122          ? `https://snapshot.org/#/${org.snapshotId}`
123          : org.governanceSite || null,
124        icon: org.icon ? sdk.ipfs.getDataURILoader(org.icon, org.iconType || 'image/svg+xml') : 0,
125        category: '',
126        treasuries: [...org.addresses, ...(org.vestingAddresses || [])],
127      },
128    });
129  }
130}
131

It's something off?

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

Adapter Info

Version

0.1.9

License

MIT

IPFS CID

QmRGwvKEsWTwMYVjM3sfM8fqrChqwgYBeRubTT22z5Cjw3

CID (source)

QmYCpwLtLFhhxjV8EY1FgayJZCALNiE46jJBRyZumQWzix

Author

0xd25fcBb7b6021Cf83122fcD65BE88a045D5f961c