From 26120e9d3e67094598839a569bf3b15237938f39 Mon Sep 17 00:00:00 2001 From: Patrick McKelvy Date: Mon, 4 Dec 2023 21:21:20 -0500 Subject: [PATCH] add toc for docs website. --- docs/deployed-addresses/1-assets-3.0.1.md | 3 +- docs/deployed-addresses/8453-assets-3.0.1.md | 2 +- docs/deployed-addresses/index.json | 36 ++++++++++++ tasks/deployment/get-addresses.ts | 58 ++++++++++++++------ 4 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 docs/deployed-addresses/index.json diff --git a/docs/deployed-addresses/1-assets-3.0.1.md b/docs/deployed-addresses/1-assets-3.0.1.md index 2b586a2b80..9205b1b537 100644 --- a/docs/deployed-addresses/1-assets-3.0.1.md +++ b/docs/deployed-addresses/1-assets-3.0.1.md @@ -36,7 +36,7 @@ | fUSDT | [0xbe6Fb2b2908D85179e34ee0D996e32fa2BF4410A](https://etherscan.io/address/0xbe6Fb2b2908D85179e34ee0D996e32fa2BF4410A) | | fDAI | [0x33C1665Eb1b3673213Daa5f068ae1026fC8D5875](https://etherscan.io/address/0x33C1665Eb1b3673213Daa5f068ae1026fC8D5875) | | fFRAX | [0xaAeF84f6FfDE4D0390E14DA9c527d1a1ABf28B92](https://etherscan.io/address/0xaAeF84f6FfDE4D0390E14DA9c527d1a1ABf28B92) | -| cUSDCv3 | [0x85b256e9051B781A0BC0A987857AD6166C94040a](https://etherscan.io/address/0x85b256e9051B781A0BC0A987857AD6166C94040a) | +| cUSDCv3 | [0x7Dee4DbeF75f93cCA06823Ac915Df990be3F1538](https://etherscan.io/address/0x7Dee4DbeF75f93cCA06823Ac915Df990be3F1538) | | cvx3Pool | [0x62C394620f674e85768a7618a6C202baE7fB8Dd1](https://etherscan.io/address/0x62C394620f674e85768a7618a6C202baE7fB8Dd1) | | cvxeUSDFRAXBP | [0x890FAa00C16EAD6AA76F18A1A7fe9C40838F9122](https://etherscan.io/address/0x890FAa00C16EAD6AA76F18A1A7fe9C40838F9122) | | cvxMIM3Pool | [0xCBE084C44e7A2223F76362Dcc4EbDacA5Fb1cbA7](https://etherscan.io/address/0xCBE084C44e7A2223F76362Dcc4EbDacA5Fb1cbA7) | @@ -52,4 +52,5 @@ | maWETH | [0x878b995bDD2D9900BEE896Bd78ADd877672e1637](https://etherscan.io/address/0x878b995bDD2D9900BEE896Bd78ADd877672e1637) | | maStETH | [0x33E840e5711549358f6d4D11F9Ab2896B36E9822](https://etherscan.io/address/0x33E840e5711549358f6d4D11F9Ab2896B36E9822) | | aEthUSDC | [0x12c3BB1B0da85fDaE0137aE8fDe901F7D0e106ba](https://etherscan.io/address/0x12c3BB1B0da85fDaE0137aE8fDe901F7D0e106ba) | +| sFRAX | [0x7E4650af145f6a9146b91E8b363DF49ee32b0A58](https://etherscan.io/address/0x7E4650af145f6a9146b91E8b363DF49ee32b0A58) | \ No newline at end of file diff --git a/docs/deployed-addresses/8453-assets-3.0.1.md b/docs/deployed-addresses/8453-assets-3.0.1.md index b53352b1a7..0c26f6845b 100644 --- a/docs/deployed-addresses/8453-assets-3.0.1.md +++ b/docs/deployed-addresses/8453-assets-3.0.1.md @@ -12,7 +12,7 @@ | WETH | [0x42D0fA25d6d5bff01aC050c0F5aB0B2C9D01b4a3](https://basescan.org/address/0x42D0fA25d6d5bff01aC050c0F5aB0B2C9D01b4a3) | | USDbC | [0x6490D66B17A1E9a460Ab54131165C8F921aCcDeB](https://basescan.org/address/0x6490D66B17A1E9a460Ab54131165C8F921aCcDeB) | | cbETH | [0x5fE248625aC2AB0e17A115fef288f17AF1952402](https://basescan.org/address/0x5fE248625aC2AB0e17A115fef288f17AF1952402) | -| cUSDbCv3 | [0xa372EC846131FBf9AE8b589efa3D041D9a94dF41](https://basescan.org/address/0xa372EC846131FBf9AE8b589efa3D041D9a94dF41) | +| cUSDbCv3 | [0xd3025304C6487FC5c39010bEA0B46cc0690ab229](https://basescan.org/address/0xd3025304C6487FC5c39010bEA0B46cc0690ab229) | | aBasUSDbC | [0x1DdB7dfdC5D26FE1f2aD02d9972f12481346Ae9b](https://basescan.org/address/0x1DdB7dfdC5D26FE1f2aD02d9972f12481346Ae9b) | | wsgUSDbC | [0x15395aCCbF8c6b28671fe41624D599624709a2D6](https://basescan.org/address/0x15395aCCbF8c6b28671fe41624D599624709a2D6) | \ No newline at end of file diff --git a/docs/deployed-addresses/index.json b/docs/deployed-addresses/index.json new file mode 100644 index 0000000000..41ee236cd2 --- /dev/null +++ b/docs/deployed-addresses/index.json @@ -0,0 +1,36 @@ +{ + "mainnet": { + "components": [ + "components-2.0.0", + "components-2.1.0", + "components-3.0.0", + "components-3.0.1" + ], + "assets": [ + "assets-2.0.0", + "assets-2.1.0", + "assets-3.0.0", + "assets-3.0.1" + ], + "rtokens": [ + "eUSD", + "ETH+", + "hyUSD", + "USDC+" + ] + }, + "base": { + "components": [ + "components-3.0.0", + "components-3.0.1" + ], + "assets": [ + "assets-3.0.0", + "assets-3.0.1" + ], + "rtokens": [ + "hyUSD", + "Vaya" + ] + } +} \ No newline at end of file diff --git a/tasks/deployment/get-addresses.ts b/tasks/deployment/get-addresses.ts index 3fb2b86a13..f8433460d4 100644 --- a/tasks/deployment/get-addresses.ts +++ b/tasks/deployment/get-addresses.ts @@ -10,6 +10,10 @@ import { import { ITokens } from '#/common/configuration' import { MainP1 } from '@typechain/MainP1' import { Contract } from 'ethers' +const tocFilename = 'docs/deployed-addresses/index.json' +import toc from '#/docs/deployed-addresses/index.json' + +type Network = 'mainnet' | 'base' task('get-addys', 'Compile the deployed addresses of an RToken deployment') .addOptionalParam('rtoken', 'The address of the RToken', undefined, types.string) @@ -17,17 +21,18 @@ task('get-addys', 'Compile the deployed addresses of an RToken deployment') .addOptionalParam('ver', 'The target version', undefined, types.string) .setAction(async (params, hre) => { /* - Helper functions + Helper functions */ - - // hacky api throttler, basescan has rate limits 5req/sec - const delay = async (ms: number) => { - return new Promise( resolve => setTimeout(resolve, ms) ); + + // hacky api throttler, basescan has rate limits 5req/sec + const delay = async (ms: number) => { + return new Promise( resolve => setTimeout(resolve, ms) ); } - + const capitalize = (s: string) => s && s[0].toUpperCase() + s.slice(1) - - const network = hre.network.name + + const chainId = await getChainId(hre) + const network: Network = hre.network.name as Network let scannerUrl: string; let scannerApiUrl: string; switch(network) { @@ -147,20 +152,25 @@ ${collaterals} } const getRTokenFileName = async (rtoken: string) => { - const chainId = await getChainId(hre) const rToken = await hre.ethers.getContractAt('IRToken', rtoken) const rTokenSymbol = await rToken.symbol() return `${outputDir}${chainId}-${rTokenSymbol}.md` } - const getAssetFileName = async (version: string) => { - const chainId = await getChainId(hre) - return `${outputDir}${chainId}-assets-${version}.md` + const getAssetFileId = (version: string) => { + return `assets-${version}` } - const getComponentFileName = async (version: string) => { - const chainId = await getChainId(hre) - return `${outputDir}${chainId}-components-${version}.md` + const getComponentFileId = (version: string) => { + return `components-${version}` + } + + const getAssetFileName = (assetFileId: string) => { + return `${outputDir}${chainId}-${assetFileId}.md` + } + + const getComponentFileName = (componentFileId: string) => { + return `${outputDir}${chainId}-${componentFileId}.md` } /* @@ -229,6 +239,11 @@ ${collaterals} const rTokenFileName = await getRTokenFileName(params.rtoken) fs.writeFileSync(rTokenFileName, markdown) console.log(`Wrote ${rTokenFileName}`) + + toc[network]['rtokens'].indexOf(rTokenSymbol) === -1 && toc[network]['rtokens'].push(rTokenSymbol) + fs.writeFileSync(tocFilename, JSON.stringify(toc, null, 2)) + console.log(`Updated table of contents`) + } else if (params.ver) { console.log(`Collecting addresses for Version: ${params.ver} (${hre.network.name})`) // if version is provided, print implementation addresses @@ -254,7 +269,9 @@ ${collaterals} assetRows, collateralRows ) - const assetFileName = await getAssetFileName(params.ver) + const assetFileId = getAssetFileId(params.ver) + const assetFileName = getAssetFileName(assetFileId) + fs.writeFileSync(assetFileName, assetMarkdown) console.log(`Wrote ${assetFileName}`) @@ -283,9 +300,16 @@ ${collaterals} `Component Implementations (${capitalize(hre.network.name)} ${params.ver})`, await createTableRows(components, false, true) ) - const componentFileName = await getComponentFileName(params.ver) + + const componentFileId = getComponentFileId(params.ver) + const componentFileName = getComponentFileName(componentFileId) fs.writeFileSync(componentFileName, componentMarkdown) console.log(`Wrote ${componentFileName}`) + + toc[network]['components'].indexOf(componentFileId) === -1 && toc[network]['components'].push(componentFileId) + toc[network]['assets'].indexOf(assetFileId) === -1 && toc[network]['assets'].push(assetFileId) + fs.writeFileSync(tocFilename, JSON.stringify(toc, null, 2)) + console.log(`Updated table of contents`) } else { // if neither rtoken address nor version number is provided, throw error throw new Error(