Adapter

Issuance - Mintable tokens - Clone

This adapter tracks issuance of tokens by simply querying the historical supply of the token (7 days prior), and comparing it to the current supply.

Sub-Adapters 9

Preview and test each sub adapter.

Alchemix (alchemix)

Balancer (balancer)

Bancor (bancor)

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

It's something off?

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

Adapter Info

Version

0.3.1

License

MIT

IPFS CID

QmaU7mpsZKH1cf7STqhHW9Tddzj5XmGBnLWC2WiFvKWxCc

CID (source)

QmTfk1v2xdcZuPgh3S3hBuZDkxEuig9DYWQfJnmfLZDPUR

Collections

issuance

Author

0x4570637199432b9820578F3E9A2eed2e50739Ce4