Skip to content

Commit

Permalink
feat: add new zkevm token list (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chef-Yogi authored Jul 26, 2023
1 parent 81d9f99 commit 53d7dc2
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions lists/pancakeswap-polygon-zkevm-default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "PancakeSwap Zkevm Default",
"timestamp": "2023-07-25T11:30:46.083Z",
"version": {
"major": 0,
"minor": 0,
"patch": 1
},
"logoURI": "https://pancakeswap.finance/logo.png",
"keywords": [
"pancakeswap",
"default",
"polygon",
"zkevm"
],
"tokens": [
{
"name": "Wrapped Ether",
"symbol": "WETH",
"address": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
"chainId": 1101,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9.png"
},
{
"name": "USD Coin",
"symbol": "USDC",
"address": "0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035",
"chainId": 1101,
"decimals": 6,
"logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035.png"
},
{
"name": "Tether USD",
"symbol": "USDT",
"address": "0x1E4a5963aBFD975d8c9021ce480b42188849D41d",
"chainId": 1101,
"decimals": 6,
"logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0x1E4a5963aBFD975d8c9021ce480b42188849D41d.png"
},
{
"name": "Matic Token",
"symbol": "MATIC",
"address": "0xa2036f0538221a77A3937F1379699f44945018d0",
"chainId": 1101,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0xa2036f0538221a77A3937F1379699f44945018d0.png"
}
]
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"checksum:pcs-eth-default": "yarn build && node ./dist checksum pancakeswap-eth-default",
"generate:pcs-eth-default": "yarn test --list=pancakeswap-eth-default && yarn build && node ./dist generate pancakeswap-eth-default",
"makelist:pcs-eth-default": "yarn checksum:pcs-eth-default && yarn generate:pcs-eth-default",
"checksum:pcs-polygon-zkevm-default": "yarn build && node ./dist checksum pancakeswap-polygon-zkevm-default",
"generate:pcs-polygon-zkevm-default": "yarn test --list=pancakeswap-polygon-zkevm-default && yarn build && node ./dist generate pancakeswap-polygon-zkevm-default",
"makelist:pcs-polygon-zkevm-default": "yarn checksum:pcs-polygon-zkevm-default && yarn generate:pcs-polygon-zkevm-default",
"checksum:pcs-eth-mm": "yarn build && node ./dist checksum pancakeswap-eth-mm",
"generate:pcs-eth-mm": "yarn test --list=pancakeswap-eth-mm && yarn build && node ./dist generate pancakeswap-eth-mm",
"makelist:pcs-eth-mm": "yarn checksum:pcs-eth-mm && yarn generate:pcs-eth-mm",
Expand Down
10 changes: 10 additions & 0 deletions src/buildList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from "path";
import { TokenList } from "@pancakeswap/token-lists";
import { version as pancakeswapDefaultVersion } from "../lists/pancakeswap-default.json";
import { version as pancakeswapEthDefaultVersion } from "../lists/pancakeswap-eth-default.json";
import { version as pancakeswapPolygonZkevmDefaultVersion } from "../lists/pancakeswap-polygon-zkevm-default.json";
import { version as pancakeswapEthMMVersion } from "../lists/pancakeswap-eth-mm.json";
import { version as pancakeswapBnbMMVersion } from "../lists/pancakeswap-bnb-mm.json";
import { version as pancakeswapExtendedVersion } from "../lists/pancakeswap-extended.json";
Expand All @@ -15,6 +16,7 @@ import { version as pancakeswapMiniVersion } from "../lists/pancakeswap-mini.jso
import { version as pancakeswapMiniExtendedVersion } from "../lists/pancakeswap-mini-extended.json";
import pancakeswapAptos from "./tokens/pancakeswap-aptos.json";
import pancakeswapDefault from "./tokens/pancakeswap-default.json";
import pancakeswapPolygonZkevmDefault from "./tokens/pancakeswap-polygon-zkevm-default.json";
import pancakeswapEthDefault from "./tokens/pancakeswap-eth-default.json";
import pancakeswapEthMM from "./tokens/pancakeswap-eth-mm.json";
import pancakeswapExtended from "./tokens/pancakeswap-extended.json";
Expand Down Expand Up @@ -48,6 +50,14 @@ const lists = {
currentVersion: pancakeswapAptosVersion,
schema: "aptos",
},
"pancakeswap-polygon-zkevm-default": {
list: pancakeswapPolygonZkevmDefault,
name: "PancakeSwap Zkevm Default",
keywords: ["pancakeswap", "default", "polygon", "zkevm"],
logoURI: "https://pancakeswap.finance/logo.png",
sort: false,
currentVersion: pancakeswapPolygonZkevmDefaultVersion,
},
"pancakeswap-eth-default": {
list: pancakeswapEthDefault,
name: "PancakeSwap Ethereum Default",
Expand Down
2 changes: 2 additions & 0 deletions src/checksum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from "path";
import { getAddress } from "@ethersproject/address";
import pancakeswapDefault from "./tokens/pancakeswap-default.json";
import pancakeswapEthDefault from "./tokens/pancakeswap-eth-default.json";
import pancakeswapPolygonZkevmDefault from "./tokens/pancakeswap-polygon-zkevm-default.json";
import pancakeswapEthMM from "./tokens/pancakeswap-eth-mm.json";
import pancakeswapBnbMM from "./tokens/pancakeswap-bnb-mm.json";
import pancakeswapExtended from "./tokens/pancakeswap-extended.json";
Expand All @@ -16,6 +17,7 @@ import pancakeswapMiniExtended from "./tokens/pancakeswap-mini-extended.json";
const lists = {
"pancakeswap-default": pancakeswapDefault,
"pancakeswap-eth-default": pancakeswapEthDefault,
"pancakeswap-polygon-zkevm-default": pancakeswapPolygonZkevmDefault,
"pancakeswap-eth-mm": pancakeswapEthMM,
"pancakeswap-bnb-mm": pancakeswapBnbMM,
"pancakeswap-extended": pancakeswapExtended,
Expand Down
7 changes: 7 additions & 0 deletions src/ci-check.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import srcDefault from "./tokens/pancakeswap-default.json";
import srcEthDefault from "./tokens/pancakeswap-eth-default.json";
import srcPolygonZkevmDefault from "./tokens/pancakeswap-polygon-zkevm-default.json";
import srcExtended from "./tokens/pancakeswap-extended.json";
import srcTop100 from "./tokens/pancakeswap-top-100.json";
import srcTop15 from "./tokens/pancakeswap-top-15.json";
Expand All @@ -9,6 +10,7 @@ import srcMini from "./tokens/pancakeswap-mini.json";
import srcMiniExtended from "./tokens/pancakeswap-mini-extended.json";
import defaultList from "../lists/pancakeswap-default.json";
import defaultEthList from "../lists/pancakeswap-eth-default.json";
import defaultPolygonZkevmList from "../lists/pancakeswap-polygon-zkevm-default.json";
import extendedtList from "../lists/pancakeswap-extended.json";
import top15List from "../lists/pancakeswap-top-15.json";
import top100tList from "../lists/pancakeswap-top-100.json";
Expand All @@ -28,6 +30,11 @@ const lists = [
src: srcEthDefault,
actual: defaultEthList,
},
{
name: "pancakeswap-polygon-zkevm-default",
src: srcPolygonZkevmDefault,
actual: defaultPolygonZkevmList,
},
{
name: "pancakeswap-extended",
src: srcExtended,
Expand Down
35 changes: 35 additions & 0 deletions src/tokens/pancakeswap-polygon-zkevm-default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"name": "Wrapped Ether",
"symbol": "WETH",
"address": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
"chainId": 1101,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9.png"
},
{
"name": "USD Coin",
"symbol": "USDC",
"address": "0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035",
"chainId": 1101,
"decimals": 6,
"logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035.png"
},
{
"name": "Tether USD",
"symbol": "USDT",
"address": "0x1E4a5963aBFD975d8c9021ce480b42188849D41d",
"chainId": 1101,
"decimals": 6,
"logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0x1E4a5963aBFD975d8c9021ce480b42188849D41d.png"
},

{
"name": "Matic Token",
"symbol": "MATIC",
"address": "0xa2036f0538221a77A3937F1379699f44945018d0",
"chainId": 1101,
"decimals": 18,
"logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0xa2036f0538221a77A3937F1379699f44945018d0.png"
}
]
1 change: 1 addition & 0 deletions src/utils/multicall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import simpleRpcProvider from "./simpleRpcProvider";
const multicall = {
[1]: "0xcA11bde05977b3631167028862bE2a173976CA11",
[56]: "0xcA11bde05977b3631167028862bE2a173976CA11",
[1101]: "0xcA11bde05977b3631167028862bE2a173976CA11",
};

interface MultiCall {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/simpleRpcProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import { ethers } from "ethers";

const RPC_URL = "https://nodes.pancakeswap.info";
const ETH_RPC_URL = "https://cloudflare-eth.com";
const POLYGON_ZKEVM_RPC_URL = "https://f2562de09abc5efbd21eefa083ff5326.zkevm-rpc.com/";

const bscRpcProvider = new ethers.providers.StaticJsonRpcProvider(RPC_URL, 56);
const ethRpcProvider = new ethers.providers.StaticJsonRpcProvider(ETH_RPC_URL, 1);
const polygonZkevmRpcProvider = new ethers.providers.StaticJsonRpcProvider(POLYGON_ZKEVM_RPC_URL, 1101);

const simpleRpcProvider = {
[1]: ethRpcProvider,
[56]: bscRpcProvider,
[1101]: polygonZkevmRpcProvider,
};

export default simpleRpcProvider;
28 changes: 24 additions & 4 deletions test/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getAddress } from "@ethersproject/address";
import pancakeswapSchema from "@pancakeswap/token-lists/schema/pancakeswap.json";
import currentPancakeswapDefaultList from "../lists/pancakeswap-default.json";
import currentPancakeswapEthDefaultList from "../lists/pancakeswap-eth-default.json";
import currentPancakeswapPolygonZkevmDefaultList from "../lists/pancakeswap-polygon-zkevm-default.json";
import currentPancakeswapEthMMList from "../lists/pancakeswap-eth-mm.json";
import currentPancakeswapBnbMMList from "../lists/pancakeswap-bnb-mm.json";
import currentPancakeswapExtendedtList from "../lists/pancakeswap-extended.json";
Expand All @@ -28,6 +29,7 @@ const listArgs = process.argv
const CASES = [
["pancakeswap-default"],
["pancakeswap-eth-default"],
["pancakeswap-polygon-zkevm-default"],
["pancakeswap-eth-mm"],
["pancakeswap-extended"],
["pancakeswap-top-100"],
Expand All @@ -47,6 +49,7 @@ const currentLists = {
"pancakeswap-eth-mm": currentPancakeswapEthMMList,
"pancakeswap-bnb-mm": currentPancakeswapBnbMMList,
"pancakeswap-eth-default": currentPancakeswapEthDefaultList,
"pancakeswap-polygon-zkevm-default": currentPancakeswapPolygonZkevmDefaultList,
"pancakeswap-extended": currentPancakeswapExtendedtList,
"pancakeswap-top-100": currentPancakeswapTop100tList,
"pancakeswap-top-15": currentPancakeswapTop15List,
Expand Down Expand Up @@ -80,6 +83,7 @@ const validate = ajv.compile(pancakeswapSchema);

const pathToImages = path.join(path.resolve(), "lists", "images");
const pathToEthImages = path.join(path.resolve(), "lists", "images", "eth");
const pathToPolygonZkevmImages = path.join(path.resolve(), "lists", "images", "polygon-zkevm");

const logoFiles = fs
.readdirSync(pathToImages, { withFileTypes: true })
Expand All @@ -91,6 +95,23 @@ const ethLogoFiles = fs
.filter((f) => f.isFile())
.filter((f) => !/(^|\/)\.[^\/\.]/g.test(f.name));

const polygonZkevmLogoFiles = fs
.readdirSync(pathToPolygonZkevmImages, { withFileTypes: true })
.filter((f) => f.isFile())
.filter((f) => !/(^|\/)\.[^\/\.]/g.test(f.name));

const multiChainLogoPath = {
[56]: "",
[1]: "/eth",
[1101]: "/polygon-zkevm",
};

const multiChainLogoFiles = {
[56]: logoFiles,
[1]: ethLogoFiles,
[1101]: polygonZkevmLogoFiles,
};

// Modified https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
const getByAjvPath = (obj, propertyPath: string, defaultValue = undefined) => {
const travel = (regexp) =>
Expand Down Expand Up @@ -152,13 +173,12 @@ expect.extend({
token.logoURI === `https://assets-cdn.trustwallet.com/blockchains/smartchain/assets/${token.address}/logo.png`;
let hasLocalLogo = false;
const refersToLocalLogo =
token.logoURI === `https://tokens.pancakeswap.finance/images/${token.address}.png` ||
token.logoURI === `https://tokens.pancakeswap.finance/images/eth/${token.address}.png`;
token.logoURI ===
`https://tokens.pancakeswap.finance/images${multiChainLogoPath?.[token.chainId] || ""}/${token.address}.png`;
if (refersToLocalLogo) {
const fileName = token.logoURI.split("/").pop();
// Note: fs.existsSync can't be used here because its not case sensetive
hasLocalLogo =
logoFiles.map((f) => f.name).includes(fileName) || ethLogoFiles.map((f) => f.name).includes(fileName);
hasLocalLogo = multiChainLogoFiles[token.chainId]?.map((f) => f.name).includes(fileName);
}
if (hasTWLogo || hasLocalLogo) {
return {
Expand Down

0 comments on commit 53d7dc2

Please sign in to comment.