Sub-Adapters 8
Preview and test each sub adapter.
Alchemix (alchemix)
Balancer (balancer)
Convex (convex)
Curve (curve)
Lido (lido)
Liquity (liquity)
SushiSwap (sushi)
Synthetix (synthetix)
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source.
1export const name = 'Issuance - Mintable tokens';
2export const version = '0.3.3';
3export const license = 'MIT';
4export const description =
5 'This adapter tracks issuance of tokens by simply querying the historical supply of ' +
6 'the token (7 days prior), and comparing it to the current supply.'
7export const changeLog = 'Remove bancor'
8
9interface Token {
10 id: string
11 name: string
12 token: string
13 excludeAddresses?: string[]
14 coinGeckoId: string
15 icon?: string
16 iconType?: string
17 issuanceDescription?: string
18 website?: string
19}
20
21const tokens: Token[] = [
22 {
23 id: 'alchemix',
24 name: 'Alchemix',
25 token: '0xdbdb4d16eda451d0503b854cf79d55697f90c8df',
26 coinGeckoId: 'alchemix',
27 icon: 'QmSuSUcAvGkxkJ7n5RxnDyqXUchAjXMwTmNioz2xzXVfxo',
28 iconType: 'image/jpeg',
29 website: 'https://alchemix.fi',
30 },
31 {
32 id: 'balancer',
33 name: 'Balancer',
34 token: '0xba100000625a3754423978a60c9317c58a424e3d',
35 coinGeckoId: 'balancer',
36 icon: 'Qmb3u8knknnGYyLBVrw5ZTqYUue2LC1zCkDWsfctBHJBHN',
37 issuanceDescription: 'BAL tokens are issued to liquidity providers on select pools.',
38 website: 'https://balancer.fi',
39 },
40 {
41 id: 'convex',
42 name: 'Convex',
43 token: '0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b',
44 coinGeckoId: 'convex-finance',
45 icon: 'QmWCuYT5Be2feMEi6MM2PifFrvMncF17VoLHJ9FE1gNAV5',
46 },
47 {
48 id: 'curve',
49 name: 'Curve',
50 token: '0xd533a949740bb3306d119cc777fa900ba034cd52',
51 coinGeckoId: 'curve-dao-token',
52 icon: 'QmeGCLQAfUANUB79AJ6hMnY7DeBdX3WssantuZDBXNbAF8',
53 iconType: 'image/png',
54 issuanceDescription: 'CRV tokens are issued to liquidity providers, with boosted rewards for veCRV stakers.',
55 website: 'https://curve.fi',
56 },
57 {
58 id: 'lido',
59 name: 'Lido',
60 token: '0x5a98fcbea516cf06857215779fd812ca3bef1b32',
61 excludeAddresses: [
62 '0x3e40d73eb977dc6a537af587d48316fee66e9c8c', // Treasury
63 '0x1dd909cddf3dbe61ac08112dc0fdf2ab949f79d8', // Balancer manager
64 '0x75ff3dd673ef9fc459a52e1054db5df2a1101212', // Sushi rewards
65 '0x884226c9f7b7205f607922E0431419276a64CF8f', // Merkle distributor
66 '0x753d5167c31fbeb5b49624314d74a957eb271709', // Curve manager
67 '0x99ac10631f69c753ddb595d074422a0922d9056b', // Curve farming
68 '0x182B723a58739a9c974cFDB385ceaDb237453c28', // Curve gague
69 ],
70 coinGeckoId: 'lido-dao',
71 icon: 'QmcsGcopqrVyzTLXETtecJuhqxqxbzUvuFMqBd27yFKCMt',
72 issuanceDescription: 'LDO tokens are issued to liquidity providers on stETH/ETH pools on Curve, Balancer and SushiSwap.',
73 website: 'https://sushi.com',
74 },
75 {
76 id: 'liquity',
77 name: 'Liquity',
78 token: '0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d',
79 excludeAddresses: [
80 '0xD8c9D9071123a059C6E0A945cF0e0c82b508d816', // Issuance contract
81 ],
82 coinGeckoId: 'liquity',
83 icon: 'QmbQkK78NB9czUbcMTEduhpquDkRVj9bMkNY9APBBA391c',
84 issuanceDescription: 'LQTY rewards are paid to users who deposit LUSD to the Stability Pool and liquidity providers of the LUSD:ETH Uniswap pool.',
85 website: 'https://liquity.fi/',
86 },
87 {
88 id: 'sushi',
89 name: 'SushiSwap',
90 token: '0x6b3595068778dd592e39a122f4f5a5cf09c90fe2',
91 coinGeckoId: 'sushi',
92 icon: 'QmVAko4auvE2NDr8kfnovVqTqujrJ69YrUZQFPZeREMWk5',
93 issuanceDescription: 'SUSHI tokens are issued to liquidity providers on select pools.',
94 website: 'https://sushi.com',
95 },
96 {
97 id: 'synthetix',
98 name: 'Synthetix',
99 token: '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
100 coinGeckoId: 'havven',
101 icon: 'QmYPqFXTqYcynD5hT9sZbsoPZXbvjSfL7WWQPL7EwYAyE5',
102 issuanceDescription: 'SNX tokens are issued to users who stake SNX to mint sUSD, with a 12-month vesting period.',
103 website: 'https://synthetix.io',
104 },
105]
106
107export async function setup(sdk: Context) {
108 const getSupply = async (token: string, date: string, excludeAddresses: string[] = []) => {
109 const tokenContract = sdk.ethers.getERC20Contract(token)
110
111 const [supply, excludeBalances] = await Promise.all([
112 tokenContract.totalSupply({ blockTag: date }),
113 Promise.all(excludeAddresses.map((address: string) => tokenContract.balanceOf(address, { blockTag: date }))),
114 ])
115
116 const decimalUnit = 1e18 // TODO: query decimals
117
118 const excludeTotal = excludeBalances.reduce((total: number, balance: any) => total + (balance.toString() / decimalUnit), 0)
119
120 return (supply.toString() / decimalUnit) - excludeTotal
121 }
122
123 const getIssuanceData = (address: string, coinGeckoId: string, excludeAddresses?: string[]) => async () => {
124 const today = sdk.date.formatDate(new Date())
125 const weekAgo = sdk.date.offsetDaysFormatted(today, -7)
126
127 const [price, todaySupply, weekAgoSupply] = await Promise.all([
128 sdk.coinGecko.getCurrentPrice(coinGeckoId),
129 getSupply(address, today, excludeAddresses),
130 getSupply(address, weekAgo, excludeAddresses),
131 ])
132 sdk.log.log(`${todaySupply}, ${weekAgoSupply}`)
133
134 const oneWeekIssuance = todaySupply - weekAgoSupply
135
136 const sevenDayAvg = oneWeekIssuance / 7 * price
137 return sevenDayAvg
138 }
139
140 const getInflationRate = (address: string, excludeAddresses?: string[]) => async () => {
141 const today = sdk.date.formatDate(new Date())
142 const weekAgo = sdk.date.offsetDaysFormatted(today, -7)
143
144 const [todaySupply, weekAgoSupply] = await Promise.all([
145 getSupply(address, today, excludeAddresses),
146 getSupply(address, weekAgo, excludeAddresses),
147 ])
148
149 return ((todaySupply / weekAgoSupply) - 1) * 52
150 }
151
152 for (const token of tokens) {
153 sdk.register({
154 id: token.id,
155 queries: {
156 issuance7DayAvgUSD: getIssuanceData(token.token, token.coinGeckoId, token.excludeAddresses),
157 issuanceRateCurrent: getInflationRate(token.token, token.excludeAddresses),
158 },
159 metadata: {
160 icon: token.icon && sdk.ipfs.getDataURILoader(token.icon, token.iconType || 'image/svg+xml'),
161 category: 'app',
162 name: token.name,
163 issuanceDescription: token.issuanceDescription || null,
164 website: token.website || null,
165 },
166 })
167 }
168}
It's something off?
Report it to the discussion board on Discord, we will take care of it.