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