diff --git a/.github/PULL_REQUEST_TEMPLATE/new-listing.md b/.github/PULL_REQUEST_TEMPLATE/new-listing.md new file mode 100644 index 0000000..ed2c3e7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/new-listing.md @@ -0,0 +1,87 @@ +# Adding a New Token + +To add a new token to the repository, please follow these steps: + +## Step 1: Fill in the Token Information + +You need to add the relevant information for the new token in the `src/new-token.json` file. The format for the JSON object is as follows: + +```json + { + "name": "Token Name", + "address": "", + "symbol": "TokenSymbol", + "decimals": 18, + "chainId": 122, + "logoURI": "https://raw.githubusercontent.com/voltfinance/swap-default-token-list/master/logos//logo.png", + "oneLiner": "A brief description or tagline for the token.", + "bullishSentence": "A sentence highlighting any bullish aspects of the token, such as utility, burn mechanisms, or airdrops.", + "socials": { + "website": "https://tokenwebsite.com", + "twitter": "https://twitter.com/tokenhandle", + "discord": "https://discord.com/invite/tokeninvite", + "telegram": "https://t.me/tokenhandle" + } + } +``` + +- **name**: The full name of the token. +- **address**: The token contract address in checksum format. +- **symbol**: The ticker symbol of the token. +- **decimals**: Typically, ERC-20 tokens have 18 decimals. If your token is different, specify the correct number of decimals. +- **chainId**: This should be `122` (for Fuse). +- **logoURI**: Replace `` with your token's contract address in checksum format. +- **oneLiner**: A brief description or tagline for the token. +- **bullishSentence**: A sentence highlighting any bullish aspects of the token, such as utility, burn mechanisms, or airdrops. +- **socials**: Provide the relevant social media links (optional but recommended). + +## Step 2: Add Token Logo + +You need to add a logo for your token: + +1. Navigate to the `logos/` directory in the repository. +2. Create a new folder named after your token’s address in checksum format. +3. Add a PNG file named `logo.png` with the dimensions 250x250 pixels inside the folder. + +Example: + +``` +logos//logo.png +``` + +## Step 3: Submit a Pair with WFUSE + +For a new token to be accepted, a trading pair with `10,000 WFUSE` as the initial liquidity must exist: + +- Ensure that the pair is live and that liquidity provision is enabled. + +## Example JSON Submission + +```json + { + "name": "Example Token", + "address": "0x1234567890ABCDEF1234567890ABCDEF12345678", + "symbol": "EXT", + "decimals": 18, + "chainId": 122, + "logoURI": "https://raw.githubusercontent.com/voltfinance/swap-default-token-list/master/logos/0x1234567890ABCDEF1234567890ABCDEF12345678/logo.png", + "oneLiner": "Example Token is revolutionizing decentralized finance.", + "bullishSentence": "With a built-in burn mechanism and upcoming airdrop, Example Token is poised for growth.", + "socials": { + "website": "https://exampletoken.com", + "twitter": "https://twitter.com/exampletoken", + "discord": "https://discord.com/invite/exampletoken", + "telegram": "https://t.me/exampletoken" + } + } +``` + +## Step 4: Submit a Pull Request + +After you've filled out the `src/new-token.json` file and added the logo: + +1. Commit your changes. +2. Push your branch to your forked repository. +3. Open a pull request to the main repository. + +Please ensure that all information is accurate and that the pull request follows the repository's guidelines. The maintainers will review your submission and provide feedback if necessary. diff --git a/.github/workflows/analyze.yaml b/.github/workflows/analyze.yaml index b85f6da..3f4e6dd 100644 --- a/.github/workflows/analyze.yaml +++ b/.github/workflows/analyze.yaml @@ -1,23 +1,60 @@ -name: Analyze -on: [pull_request] +name: Analyze Token + +on: + pull_request: + branches: + # - master + - feat/telegram-bot + jobs: analyze: runs-on: ubuntu-latest name: Analyze Token + steps: - - uses: actions/checkout@v2 - - name: Setup node - uses: actions/setup-node@v1 + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 # Use the latest v2 for setup-node with: node-version: 14 - - run: npm install + + - name: Install dependencies + run: npm install + - id: analyze - name: Analyze PR + name: Run Analysis run: | npm run analyze - [ -f summary.txt ] && echo "{SKIP}={false}" >> "$GITHUB_ENV" || echo "{SKIP}={true}" >> "$GITHUB_ENV" - - uses: mshick/add-pr-comment@v2 - if: ${{env.SKIP == true}} - name: Comment on PR + if [ -f summary.txt ]; then + echo "SKIP=false" >> "$GITHUB_ENV" + else + echo "SKIP=true" >> "$GITHUB_ENV" + fi + + - name: Comment on PR + if: env.SKIP == 'false' + uses: mshick/add-pr-comment@v2 with: - message-path: ./summary.txt \ No newline at end of file + message-path: ./summary.txt + + - name: Update build + if: env.SKIP == 'false' + run: | + npm run build + + - name: Configure git + if: env.SKIP == 'false' + run: | + git config user.name "GitHub Action" + git config user.email "action@github.com" + + - name: Commit changes + if: env.SKIP == 'false' + run: | + git add . + git commit -m "Automated build update" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/telegram-notify.yml b/.github/workflows/telegram-notify.yml index 2e32664..51b2213 100644 --- a/.github/workflows/telegram-notify.yml +++ b/.github/workflows/telegram-notify.yml @@ -2,6 +2,9 @@ name: Notify Telegram on JSON Update on: push: + branches: + # - master + - feat/telegram-bot paths: - './build/voltage-swap-default.tokenlist.json' @@ -26,3 +29,13 @@ jobs: env: TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} + + - name: Commit changes + if: env.SKIP == 'false' + run: | + git add . + git commit -m "Clean new-token.json" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/scripts/analyze.js b/scripts/analyze.js index e652311..0ef8be4 100644 --- a/scripts/analyze.js +++ b/scripts/analyze.js @@ -1,43 +1,54 @@ +const path = require('path') const fs = require('fs/promises') const Mustache = require('mustache') -const isLiquidityValid = require('./helpers/isLiquidityValid') +const newToken = require('../src/new-token.json') + const isNameValid = require('./helpers/isNameValid') const isSymbolValid = require('./helpers/isSymbolValid') -const getNewTokenList = require('./helpers/getNewTokenList') -const getCurrentTokenList = require('./helpers/getCurrentTokenList') -const getNewToken = require('./helpers/getNewToken') const getContributors = require('./helpers/getContributors') +const isLiquidityValid = require('./helpers/isLiquidityValid') +const getCurrentTokenList = require('./helpers/getCurrentTokenList') + +// Deprecated +// const getNewToken = require('./helpers/getNewToken') +// const getNewTokenList = require('./helpers/getNewTokenList') + +const getLogoURI = (tokenAddress) => + `https://raw.githubusercontent.com/voltfinance/swap-default-token-list/master/logos/${tokenAddress}/logo.png` async function analyze() { const errors = [] const contributors = await getContributors() - const newTokenList = await getNewTokenList() const currentTokenList = await getCurrentTokenList() - const newToken = await getNewToken(newTokenList, currentTokenList) if (!newToken) { - return } const nameError = await isNameValid(newToken, currentTokenList) - if (nameError) errors.push(nameError) + if (nameError) { + errors.push(nameError) + } const symbolError = await isSymbolValid(newToken, currentTokenList) - if (symbolError) errors.push(symbolError) + if (symbolError) { + errors.push(symbolError) + } const liquidityError = await isLiquidityValid(newToken) - if (liquidityError) errors.push(liquidityError) + if (liquidityError) { + errors.push(liquidityError) + } const view = { address: newToken.address, name: newToken.name, symbol: newToken.symbol, decimals: newToken.decimals, - logoURI: newToken.logoURI, - contributors: contributors.map(c => `@${c}`).join(" "), + logoURI: getLogoURI(newToken.address), + contributors: contributors.map((c) => `@${c}`).join(' '), errors, } @@ -61,10 +72,32 @@ async function analyze() { ![{{name}} logo]({{{logoURI}}}) {{contributors}} `, - view, + view ) await fs.writeFile('summary.txt', summary.trim()) + + try { + const fuseFilePath = path.join(__dirname, '../src/tokens/fuse.json') + const fuseTokens = JSON.parse(await fs.readFile(fuseFilePath, 'utf8')) + + const newTokenObject = { + name: newToken.name, + address: newToken.address, + symbol: newToken.symbol, + decimals: newToken.decimals, + chainId: newToken.chainId, + logoURI: getLogoURI(newToken.address), + } + + // Add the new token to the list + fuseTokens.push(view) + + // Write the updated list back to the file + await fs.writeFile(fuseFilePath, JSON.stringify(fuseTokens, null, 2)) + } catch (err) { + console.error(err) + } } analyze() diff --git a/scripts/notify-telegram.js b/scripts/notify-telegram.js index 204fe24..e42bd94 100644 --- a/scripts/notify-telegram.js +++ b/scripts/notify-telegram.js @@ -1,9 +1,11 @@ +const path = require('path') const axios = require('axios') +const fs = require('fs/promises') -// const token = process.env.TELEGRAM_BOT_TOKEN -// const chatId = process.env.TELEGRAM_CHAT_ID -const TELEGRAM_BOT_TOKEN = '' -const TELEGRAM_CHAT_ID = '' +const newToken = require('../src/new-token.json') + +const TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN +const TELEGRAM_CHAT_ID = process.env.TELEGRAM_CHAT_ID if (!TELEGRAM_BOT_TOKEN || !TELEGRAM_CHAT_ID) { throw new Error('TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID is not set') @@ -12,38 +14,30 @@ if (!TELEGRAM_BOT_TOKEN || !TELEGRAM_CHAT_ID) { async function sendMessage(chatId) { const url = `https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage` - // const currentTokenList = await getCurrentTokenList() - // const newToken = await getNewToken(newTokenList, currentTokenList) - - // if (!newToken) { - // console.log('No new token has been added') - // return - // } - - // mock - const newToken = { - name: 'Dai Stablecoin V2', - address: '0x2502F488D481Df4F5054330C71b95d93D41625C2', - symbol: 'DAI V2', - decimals: 18, - chainId: 122, - logoURI: - 'https://raw.githubusercontent.com/voltfinance/swap-default-token-list/master/logos/0x440B63C0e7b21a57A3784D8AB8E819B9dA383FDf/logo.png', - } - const text = ` - There has been a new listing! - - Token address: ${newToken.address} - - Name: ${newToken.name} - - Symbol: ${newToken.symbol} - - Decimals: ${newToken.decimals} - ` +⚑ [#VoltageDEX]: + +Voltage Finance DEX just listed a new token: ${newToken.symbol} + +${newToken.oneLiner} + +${newToken.bullishSentence} + +πŸ’Ž ${newToken.name} - ${newToken.address} + +πŸ’§ Trade & provide liquidity now: https://voltage.finance/swap + +🌐 [Website](${newToken.socials.website}) +🐦 [Twitter](${newToken.socials.twitter}) +πŸ’¬ [Telegram](${newToken.socials.telegram}) +` try { console.log(text) const response = await axios.post(url, { chat_id: chatId, text: text, + parse_mode: 'Markdown', }) console.log('Message sent:', response.data) } catch (error) { @@ -58,6 +52,31 @@ async function sendMessage(chatId) { console.error('Unexpected error:', error) } } + + try { + const newTokensPath = path.join(__dirname, '../src/new-token.json') + + const newTokenObject = { + name: '', + address: '', + symbol: '', + decimals: 18, + chainId: 122, + logoURI: '', + oneLiner: '', + bullishSentence: '', + socials: { + website: '', + twitter: '', + telegram: '', + }, + } + + // Write the updated list back to the file + await fs.writeFile(newTokensPath, JSON.stringify(newTokenObject, null, 2)) + } catch (err) { + console.log(err) + } } sendMessage(TELEGRAM_CHAT_ID) diff --git a/src/new-token.json b/src/new-token.json new file mode 100644 index 0000000..e654f36 --- /dev/null +++ b/src/new-token.json @@ -0,0 +1,15 @@ +{ + "name": "", + "address": "", + "symbol": "", + "decimals": 18, + "chainId": 122, + "logoURI": "", + "oneLiner": "", + "bullishSentence": "", + "socials": { + "website": "", + "twitter": "", + "telegram": "" + } +} \ No newline at end of file