Sub-Adapters 1
Preview and test each sub adapter.
bZx (bzx)
Metadata
- ID
- bzx
- name
"bZx"
- icon
- website
"https://bzx.network"
- governanceForum
"https://forum.bzx.network"
- governanceSite
"https://snapshot.org/#/bzx.eth"
- treasuries
[ "0xfedC4dD5247B93feb41e899A09C44cFaBec29Cbc" ]
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source.
1export const name = 'bzx Treasury - Clone';
2export const version = '0.2.0';
3export const license = 'MIT';
4
5const TREASURY_ADDRESS = '0xfedC4dD5247B93feb41e899A09C44cFaBec29Cbc'
6
7export async function setup(sdk: Context) {
8 let treasuryPortfolioPromise: Promise<any> | null
9 const getTreasuryPortfolio = (): Promise<any> => {
10 if (!treasuryPortfolioPromise) {
11 treasuryPortfolioPromise = sdk.http.get(`https://cryptostats-api-proxy.vercel.app/api/v1/zapper/${TREASURY_ADDRESS}`)
12 .then(result => {
13 if (result.success) {
14 return result.value
15 }
16 throw new Error(result.error)
17 })
18 }
19 return treasuryPortfolioPromise
20 }
21
22 const getTreasuryInUSD = async () => {
23 const portfolio = await getTreasuryPortfolio()
24
25 let totalValue = 0;
26
27 for (const portItem of portfolio) {
28 totalValue += portItem.balanceUSD;
29 }
30 return totalValue
31 }
32
33 const getPortfolio = async () => {
34 const portfolio = await getTreasuryPortfolio()
35
36 let fullPortfolio = []
37
38 for (const portItem of portfolio) {
39 if (portItem.context.symbol === 'VBZRX') {
40 fullPortfolio.push({
41 address: portItem.address,
42 amount: portItem.context.balance,
43 name: portItem.context.symbol,
44 symbol:portItem.context.symbol,
45 icon:portItem.displayProps.images[0],
46 price:portItem.context.price,
47 value:portItem.balanceUSD,
48 vesting: true
49 })
50 } else {
51 fullPortfolio.push({
52 address: portItem.address,
53 amount: portItem.context.balance,
54 name: portItem.context.symbol,
55 symbol:portItem.context.symbol,
56 icon:portItem.displayProps.images[0],
57 price:portItem.context.price,
58 value:portItem.balanceUSD,
59 })
60 }
61 }
62 return fullPortfolio
63 }
64
65 const getLiquidTreasuryInUSD = async () => {
66 const portfolio = await getTreasuryPortfolio()
67
68 let liquidTreasury = 0
69
70 for (const portItem of portfolio) {
71 if (portItem.context.symbol === 'VBZRX'){
72 } else {
73 liquidTreasury += portItem.balanceUSD
74 }
75 }
76
77 return liquidTreasury
78 }
79
80
81 async function getSnapshotProposals(id: string) {
82 const response = await sdk.http.post('https://hub.snapshot.org/graphql', {
83 query: `query Proposals($space: String!) {
84 proposals (
85 first: 5,
86 skip: 0,
87 where: { space_in: [$space] },
88 orderBy: "created",
89 orderDirection: desc
90 ) {
91 id
92 title
93 start
94 end
95 state
96 link
97 }
98 }`,
99 variables: { space: id },
100 });
101
102 return response.data.proposals;
103 }
104
105 sdk.register({
106 id: 'bzx',
107 queries: {
108 currentTreasuryUSD: getTreasuryInUSD,
109 currentLiquidTreasuryUSD: getLiquidTreasuryInUSD,
110 currentTreasuryPortfolio: getPortfolio,
111 recentProposals: () => getSnapshotProposals('bzx.eth'),
112 },
113 metadata: {
114 name: 'bZx',
115 icon: sdk.ipfs.getDataURILoader('QmYhs7n7pGCPbbLdcQTb2ThX2WgQ7nSTgdhsX4UXzXCxG5', 'image/svg+xml'),
116 website: 'https://bzx.network',
117 governanceForum: 'https://forum.bzx.network',
118 governanceSite: 'https://snapshot.org/#/bzx.eth',
119 treasuries: [TREASURY_ADDRESS],
120 },
121 })
122}
123
It's something off?
Report it to the discussion board on Discord, we will take care of it.