Sub-Adapters 1
Preview and test each sub adapter.
MakerDAO (makerdao)
Metadata
- ID
- makerdao
- icon
- category
"app"
- name
"MakerDAO"
- website
"https://makerdao.com"
- governanceSite
"https://vote.makerdao.com"
- governanceForum
"https://forum.makerdao.com"
- governanceModel
""
- treasuries
[ "0xbe8e3e3618f7474f8cb1d074a26affef007e98fb" ]
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source.
1export const name = 'MakerDAO Treasury';
2export const version = '0.1.0';
3export const license = 'MIT';
4
5const VAT_ADDRESS = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b'
6const PAUSE_ADDRESS = '0xbe8e3e3618f7474f8cb1d074a26affef007e98fb'
7
8const vatABI = [
9 'function dai(address holder) external view returns (uint256)',
10 'function sin(address holder) external view returns (uint256)',
11]
12
13export async function setup(sdk: Context) {
14 let pausePortfolioPromise: Promise<any> | null
15 const getPausePortfolio = (): Promise<any> => {
16 if (!pausePortfolioPromise) {
17 pausePortfolioPromise = sdk.http.get(`https://zerion-api.vercel.app/api/portfolio/${PAUSE_ADDRESS}`)
18 .then(result => {
19 if (result.success) {
20 return result.value
21 }
22 throw new Error(result.error)
23 })
24 }
25 return pausePortfolioPromise
26 }
27
28 const getDaiSurplus = async () => {
29 const vat = sdk.ethers.getContract(VAT_ADDRESS, vatABI)
30 const [dai, sin] = await Promise.all([
31 vat.dai('0xA950524441892A31ebddF91d3cEEFa04Bf454466'),
32 vat.sin('0xA950524441892A31ebddF91d3cEEFa04Bf454466'),
33 ])
34
35 const daiSurplus = dai.sub(sin).toString() / 1e45
36 return daiSurplus
37 }
38
39 const getTreasuryInUSD = async () => {
40 const [daiSurplus, pauseValue] = await Promise.all([
41 getDaiSurplus(),
42 getPausePortfolio(),
43 ])
44
45 return daiSurplus + pauseValue.totalValue
46 }
47
48 const getPortfolio = async () => {
49 const [pausePortfolio, daiSurplus] = await Promise.all([
50 getPausePortfolio(),
51 getDaiSurplus(),
52 ])
53
54 return [
55 ...pausePortfolio.portfolio,
56 {
57 address: '0x6b175474e89094c44da98b954eedeac495271d0f',
58 amount: daiSurplus,
59 name: 'Dai Stablecoin',
60 symbol: 'DAI',
61 icon: 'https://s3.amazonaws.com/token-icons/0x6b175474e89094c44da98b954eedeac495271d0f.png',
62 price: 1,
63 value: daiSurplus
64 },
65 ]
66 }
67
68 sdk.register({
69 id: 'makerdao',
70 queries: {
71 currentTreasuryUSD: getTreasuryInUSD,
72 currentLiquidTreasuryUSD: getTreasuryInUSD,
73 currentTreasuryPortfolio: getPortfolio,
74 recentProposals: async () => [], // TODO: Fetch actual proposals
75 },
76 metadata: {
77 icon: sdk.ipfs.getDataURILoader('QmNuxELX7oWXJtJKveaCFDC7niZ4APtkWgPn1NZm2FLSJV', 'image/svg+xml'),
78 category: 'app',
79 name: 'MakerDAO',
80 website: 'https://makerdao.com',
81 governanceSite: 'https://vote.makerdao.com',
82 governanceForum: 'https://forum.makerdao.com',
83 governanceModel: '',
84 treasuries: [PAUSE_ADDRESS],
85 },
86 })
87}
88
It's something off?
Report it to the discussion board on Discord, we will take care of it.