Sub-Adapters 1

Preview and test each sub adapter.

PoolTogether (pooltogether)

Metadata

ID
pooltogether
icon
name

"PoolTogether"

website

"https://pooltogether.com"

governanceSite

"https://vote.pooltogether.com/"

treasuries

[ "0x42cd8312D2BCe04277dD5161832460e95b24262E", "0x21950E281bDE1714ffd1062ed17c56D4D8de2359" ]

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'PoolTogether Treasury';
2export const version = '0.2.0';
3export const license = 'MIT';
4
5const TREASURY_ADDRESS = '0x42cd8312D2BCe04277dD5161832460e95b24262E'
6const VESTING_ADDRESS = '0x21950E281bDE1714ffd1062ed17c56D4D8de2359'
7const PTAUSDC_TOKEN = '0xdd4d117723c257cee402285d3acf218e9a8236e1'
8
9export async function setup(sdk: Context) {
10  let portfolioCache: { [address: string]: Promise<any> } = {}
11  const getPortfolio = (key: string): Promise<any> => {
12    if (!portfolioCache[key]) {
13      portfolioCache[key] = sdk.http.get(`https://cryptostats-api-proxy.vercel.app/api/v1/zapper/${key}`)
14        .then(result => {
15          if (result.success) {
16            return result.value
17          }
18          throw new Error(result.error)
19        })
20    }
21    return portfolioCache[key]
22  }
23
24  const getPTAUSDC = async () => {
25    const balance = await sdk.ethers.getERC20Contract(PTAUSDC_TOKEN).balanceOf(TREASURY_ADDRESS)
26    sdk.log(balance)
27    return balance.toString() / 1e6
28  }
29
30  const getTreasuryInUSD = async () => {
31    const [treasury, vesting, ptausdc] = await Promise.all([
32      getPortfolio(TREASURY_ADDRESS),
33      getPortfolio(VESTING_ADDRESS),
34      getPTAUSDC(),
35    ])
36
37    let totalValue = 0;
38
39    for (const portItem of treasury) {
40        totalValue += portItem.balanceUSD;
41      }
42      
43    for (const portItem of vesting) {
44        totalValue += portItem.balanceUSD;
45      }
46
47    return totalValue += ptausdc
48  }
49
50  const getLiquidTreasuryInUSD = async () => {
51    const [treasury, ptausdc] = await Promise.all([
52      getPortfolio(TREASURY_ADDRESS),
53      getPTAUSDC(),
54    ])
55    let totalValue = 0;
56
57    for (const portItem of treasury) {
58        totalValue += portItem.balanceUSD;
59      }
60    return totalValue += ptausdc
61  }
62
63  const getTreasuryPortfolio = async () => {
64    const [treasury, vesting, ptausdc] = await Promise.all([
65      getPortfolio(TREASURY_ADDRESS),
66      getPortfolio(VESTING_ADDRESS),
67      getPTAUSDC(),
68    ])
69
70    const fullPortfolio = [];
71
72    for (const portItem of treasury) {
73        fullPortfolio.push({
74          address: portItem.address, 
75          amount: portItem.context.balance,
76          name: portItem.context.symbol, 
77          symbol:portItem.context.symbol, 
78          icon:portItem.displayProps.images[0],
79          price:portItem.context.price, 
80          value:portItem.balanceUSD,
81        })
82    }
83
84    fullPortfolio.push({
85      address: PTAUSDC_TOKEN, 
86      amount: ptausdc,
87      name: 'PoolTogether aUSDC Ticket', 
88      symbol:'PTAUSDC', 
89      icon: null,
90      price:1, 
91      value:ptausdc
92    })
93
94    for (const portItem of vesting) {
95        fullPortfolio.push({
96          address: portItem.address,
97          amount: portItem.context.balance,
98          name: portItem.context.symbol,
99          symbol:portItem.context.symbol, 
100          icon:portItem.displayProps.images[0], 
101          price:portItem.context.price,
102          value:portItem.balanceUSD,
103          vesting: true
104        })
105    } 
106
107    return fullPortfolio
108  }
109
110  sdk.register({
111    id: 'pooltogether',
112    queries: {
113      currentTreasuryUSD: getTreasuryInUSD,
114      currentLiquidTreasuryUSD: getLiquidTreasuryInUSD,
115      currentTreasuryPortfolio: getTreasuryPortfolio,
116      recentProposals: async () => [],
117    },
118    metadata: {
119      icon: sdk.ipfs.getDataURILoader('QmUCxUzEuxbnGT31rXnCGfefr4a768YCkV6yfBWeSdSTPX', 'image/svg+xml'),
120      name: 'PoolTogether',
121      website: 'https://pooltogether.com',
122      governanceSite: 'https://vote.pooltogether.com/',
123      treasuries: [TREASURY_ADDRESS, VESTING_ADDRESS],
124    },
125  })
126}
127

It's something off?

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

Adapter Info

Version

0.2.0

License

MIT

IPFS CID

QmaRcYGSdM1dijf7aLBuJWUirgK63ECh4aKV5K5teRii8p

CID (source)

QmVYtpvtz1yH1QaBxJtwKpTTw7JRt5QZF64MrDjxSSNn29

Collections

Author

0x70c0EE6bd4a42e9Dc5487e30a765370b65e670A5