Skip to content

Commit

Permalink
vm tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
pierremarsotlyon1 committed Oct 2, 2023
1 parent 73fa47f commit b4f82d3
Show file tree
Hide file tree
Showing 7 changed files with 533 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/vmTokens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: All
run-name: ${{ github.actor }} 🚀
on:
workflow_dispatch:
schedule:
- cron: '*/5 * * * *'

jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- uses: actions/checkout@v3
- run: |
npm run vmTokens
# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
188 changes: 188 additions & 0 deletions data/vmTokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
[
{
"symbol": "ALCX",
"name": "Alchemix",
"decimals": 18,
"address": "0xdbdb4d16eda451d0503b854cf79d55697f90c8df"
},
{
"symbol": "DAI",
"name": "Dai Stablecoin",
"decimals": 18,
"address": "0x6b175474e89094c44da98b954eedeac495271d0f"
},
{
"symbol": "sdFXS",
"name": "Stake DAO FXS",
"decimals": 18,
"address": "0x402f878bdd1f5c66fdaf0fababcf74741b68ac36"
},
{
"symbol": "VSP",
"name": "VesperToken",
"decimals": 18,
"address": "0x1b40183efb4dd766f11bda7a7c3ad8982e998421"
},
{
"symbol": "IQ",
"name": "Everipedia IQ",
"decimals": 18,
"address": "0x579cea1889991f68acc35ff5c3dd0621ff29b0c9"
},
{
"symbol": "FXS",
"name": "Frax Share",
"decimals": 18,
"address": "0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0"
},
{
"symbol": "USDC",
"name": "USD Coin",
"decimals": 6,
"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
},
{
"symbol": "GNO",
"name": "Gnosis Token",
"decimals": 18,
"address": "0x6810e776880c02933d47db1b9fc05908e5386b96"
},
{
"symbol": "SDT",
"name": "Stake DAO Token",
"decimals": 18,
"address": "0x73968b9a57c6e53d41345fd57a6e6ae27d6cdb2f"
},
{
"symbol": "MET",
"name": "Metronome2",
"decimals": 18,
"address": "0x2ebd53d035150f328bd754d6dc66b99b0edb89aa"
},
{
"symbol": "CRV",
"name": "Curve DAO Token",
"decimals": 18,
"address": "0xd533a949740bb3306d119cc777fa900ba034cd52"
},
{
"symbol": "LDO",
"name": "Lido DAO Token",
"decimals": 18,
"address": "0x5a98fcbea516cf06857215779fd812ca3bef1b32"
},
{
"symbol": "WACME",
"name": "Wrapped ACME",
"decimals": 8,
"address": "0xdf4ef6ee483953fe3b84abd08c6a060445c01170"
},
{
"symbol": "FIS",
"name": "StaFi",
"decimals": 18,
"address": "0xef3a930e1ffffacd2fc13434ac81bd278b0ecc8d"
},
{
"symbol": "eCFX",
"name": "ethereum Conflux",
"decimals": 18,
"address": "0xa1f82e14bc09a1b42710df1a8a999b62f294e592"
},
{
"symbol": "VEUR",
"name": "VNX Euro",
"decimals": 18,
"address": "0x6ba75d640bebfe5da1197bb5a2aff3327789b5d3"
},
{
"symbol": "OGV",
"name": "Origin Dollar Governance",
"decimals": 18,
"address": "0x9c354503c38481a7a7a51629142963f98ecc12d0"
},
{
"symbol": "SPR",
"name": "Spiral",
"decimals": 18,
"address": "0x85b6acaba696b9e4247175274f8263f99b4b9180"
},
{
"symbol": "AXL",
"name": "Axelar",
"decimals": 6,
"address": "0x467719ad09025fcc6cf6f8311755809d45a5e5f3"
},
{
"symbol": "QI",
"name": "QiDao",
"decimals": 18,
"address": "0x559b7bfc48a5274754b08819f75c5f27af53d53b"
},
{
"symbol": "WETH",
"name": "Wrapped Ether",
"decimals": 18,
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
},
{
"symbol": "ZUSD",
"name": "Z.com USD",
"decimals": 6,
"address": "0xc56c2b7e71b54d38aab6d52e94a04cbfa8f604fa"
},
{
"symbol": "PENDLE",
"name": "Pendle",
"decimals": 18,
"address": "0x808507121b80c02388fad14726482e061b8da827"
},
{
"symbol": "Silo",
"name": "Silo Governance Token",
"decimals": 18,
"address": "0x6f80310ca7f2c654691d1383149fa1a57d8ab1f8"
},
{
"symbol": "BAL",
"name": "Balancer",
"decimals": 18,
"address": "0xba100000625a3754423978a60c9317c58a424e3d"
},
{
"symbol": "RBN",
"name": "Ribbon",
"decimals": 18,
"address": "0x6123b0049f904d730db3c36a31167d9d4121fa6b"
},
{
"symbol": "swETH",
"name": "swETH",
"decimals": 18,
"address": "0xf951e335afb289353dc249e82926178eac7ded78"
},
{
"symbol": "ANKR",
"name": "Ankr Network",
"decimals": 18,
"address": "0x8290333cef9e6d528dd5618fb97a76f268f3edd4"
},
{
"symbol": "BSN",
"name": "Blockswap Network",
"decimals": 18,
"address": "0x534d1f5e617e0f72a6b06a04aa599839af776a5e"
},
{
"symbol": "USDT",
"name": "Tether USD",
"decimals": 6,
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7"
},
{
"symbol": "SPELL",
"name": "Spell Token",
"decimals": 18,
"address": "0x090185f2135308bad17527004364ebcc2d37e5f6"
}
]
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "votemarket-management",
"version": "1.0.0",
"main": "index.js",
"repository": "https://github.com/StakeDAO/votemarket-management.git",
"author": "Marsot Pierre <[email protected]>",
"license": "MIT",
"scripts": {
"vmTokens": "npx ts-node src/vmTokens.ts"
},
"dependencies": {
"@types/node": "^20.8.0",
"axios": "^1.5.1",
"dotenv": "^16.3.1",
"ethers": "^6.7.1",
"viem": "^1.14.0"
}
}
20 changes: 20 additions & 0 deletions src/utils/agnosticUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import axios from "axios";

const AGNOSTIC_ENDPOINT = "https://proxy.eu-02.agnostic.engineering/query";

export const agnosticFetch = async (query: string): Promise<any> => {
try {
const response = await axios.post(AGNOSTIC_ENDPOINT, query, {
headers: {
'Authorization': `${process.env.AGNOSTIC_API_KEY}`,
"Cache-Control": "max-age=300"
}
});

return response.data.rows;
}
catch (e) {
console.error(e);
return [];
}
}
90 changes: 90 additions & 0 deletions src/vmTokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import fs from "fs";
import dotenv from "dotenv";
import { agnosticFetch } from "./utils/agnosticUtils";
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { parseAbi } from 'viem'

dotenv.config();

const client = createPublicClient({
chain: mainnet,
transport: http("https://eth.llamarpc.com"),
batch: {
multicall: true
}
});

const abi = parseAbi([
'function symbol() view returns (string)',
'function name() view returns (string)',
'function decimals() view returns (uint8)',
]);

const CONTRACTS = [
"0x0000000895cB182E6f983eb4D8b4E0Aa0B31Ae4c",
"0x00000004E4FB0C3017b543EF66cC8A89F5dE74Ff",
"0x0000000446b28e4c90dbf08ead10f3904eb27606",
"0x00000008eF298e2B6dc47E88D72eeB1Fc2b1CA7f",
"0x000000060e56DEfD94110C1a9497579AD7F5b254",
"0x000000071a273073c824E2a8B0192963e0eEA68b"
];

const main = async () => {
const rewardTokensResp = (await agnosticFetch(`
with
(
${CONTRACTS.map((contract: string) => "'" + contract + "'")}
) as bribe_contracts
select
distinct(input_3_value_address as rewardToken)
from evm_events_ethereum_mainnet
where
address IN bribe_contracts and
signature = 'BountyCreated(uint256,address,address,address,uint8,uint256,uint256,uint256,bool)'
`))
.flat();

const contracts = rewardTokensResp.map((rewardToken: string) => {
return [
{
address: rewardToken,
abi,
functionName: "symbol"
},
{
address: rewardToken,
abi,
functionName: "name"
},
{
address: rewardToken,
abi,
functionName: "decimals"
}
]
})
.flat();

const results = await client.multicall({contracts});

const data = rewardTokensResp.map((address: string) => {
const symbol = results.shift()?.result as string;
const name = results.shift()?.result as string;
const decimals = results.shift()?.result as number;

return {
symbol,
name,
decimals,
address
}
});

fs.writeFileSync("./data/vmTokens.json", JSON.stringify(data));
};

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Loading

0 comments on commit b4f82d3

Please sign in to comment.