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.1.0';
3export const license = 'MIT';
4
5const TREASURY_ADDRESS = '0x42cd8312D2BCe04277dD5161832460e95b24262E'
6const VESTING_ADDRESS = '0x21950E281bDE1714ffd1062ed17c56D4D8de2359'
7const SCUSDC_TOKEN = '0x391a437196c81eea7bbbbd5ed4df6b49de4f5c96'
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://zerion-api.vercel.app/api/portfolio/${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 getSCUSDC = async () => {
25 const balance = await sdk.ethers.getERC20Contract(SCUSDC_TOKEN).balanceOf(TREASURY_ADDRESS)
26 return balance.toString() / 1e6
27 }
28
29 const getTreasuryInUSD = async () => {
30 const [treasury, vesting, scusdc] = await Promise.all([
31 getPortfolio(TREASURY_ADDRESS),
32 getPortfolio(VESTING_ADDRESS),
33 getSCUSDC(),
34 ])
35
36 return treasury.totalValue + vesting.totalValue + scusdc
37 }
38
39 const getLiquidTreasuryInUSD = async () => {
40 const [treasury, scusdc] = await Promise.all([
41 getPortfolio(TREASURY_ADDRESS),
42 getSCUSDC(),
43 ])
44
45 return treasury.totalValue + scusdc
46 }
47
48 const getTreasuryPortfolio = async () => {
49 const [treasury, vesting, scusdc] = await Promise.all([
50 getPortfolio(TREASURY_ADDRESS),
51 getPortfolio(VESTING_ADDRESS),
52 getSCUSDC(),
53 ])
54
55 return [
56 ...treasury.portfolio,
57 ...vesting.portfolio.map((portfolioItem: any) => ({ ...portfolioItem, vesting: true })),
58 {
59 address: SCUSDC_TOKEN,
60 amount: scusdc,
61 value: scusdc,
62 price: 1,
63 name: 'PoolTogether USDC Sponsorship',
64 symbol: 'ScUSDC',
65 icon: null,
66 },
67 ]
68 }
69
70 sdk.register({
71 id: 'pooltogether',
72 queries: {
73 currentTreasuryUSD: getTreasuryInUSD,
74 currentLiquidTreasuryUSD: getLiquidTreasuryInUSD,
75 currentTreasuryPortfolio: getTreasuryPortfolio,
76 recentProposals: async () => [],
77 },
78 metadata: {
79 icon: sdk.ipfs.getDataURILoader('QmUCxUzEuxbnGT31rXnCGfefr4a768YCkV6yfBWeSdSTPX', 'image/svg+xml'),
80 name: 'PoolTogether',
81 website: 'https://pooltogether.com',
82 governanceSite: 'https://vote.pooltogether.com/',
83 treasuries: [TREASURY_ADDRESS, VESTING_ADDRESS],
84 },
85 })
86}
87
It's something off?
Report it to the discussion board on Discord, we will take care of it.