From 4efe13f75802b5faedcd7fc2d28e10e4d62a1152 Mon Sep 17 00:00:00 2001 From: Hyungsuk Kang Date: Mon, 12 Aug 2024 15:51:33 +0900 Subject: [PATCH] add fraxtal and metal --- package.json | 4 +- src/buildList.js | 70 +++++++++++++++- src/pairs/fraxtal.json | 80 +++++++++++++++++++ src/pairs/metal.json | 40 ++++++++++ src/scripts/addPairs.js | 79 +++++++++--------- ...THUSDTPairs.js => generateDefaultPairs.js} | 11 +-- src/tokens/fraxtal.json | 34 ++++++++ src/tokens/metal.json | 26 ++++++ 8 files changed, 296 insertions(+), 48 deletions(-) create mode 100644 src/pairs/fraxtal.json create mode 100644 src/pairs/metal.json rename src/scripts/{generateETHUSDTPairs.js => generateDefaultPairs.js} (69%) create mode 100644 src/tokens/fraxtal.json create mode 100644 src/tokens/metal.json diff --git a/package.json b/package.json index 3dd65923..56ba2fa2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@standardweb3/default-token-list", - "version": "0.0.16", + "version": "0.0.17", "description": "Standard default token list", "main": "build/standard-default.tokenlist.json", "scripts": { @@ -8,7 +8,7 @@ "build": "rimraf build && mkdir -p build && node src/write.js > build/standard-default.tokenlist.json", "prepublishOnly": "npm test && npm run build", "addPairs": "node src/scripts/addPairs.js", - "generateETHUSDTPairs": "node src/scripts/generateETHUSDTPairs.js" + "generateDefaultPairs": "node src/scripts/generateDefaultPairs.js" }, "files": [ "build/standard-default.tokenlist.json" diff --git a/src/buildList.js b/src/buildList.js index f2defc88..4134ba92 100644 --- a/src/buildList.js +++ b/src/buildList.js @@ -16,11 +16,15 @@ const base = require("./tokens/base.json"); const blast = require("./tokens/blast.json"); const kroma = require("./tokens/kroma.json"); const morphHolesky = require("./tokens/morph_holesky.json"); +const metal = require("./tokens/metal.json"); +const fraxtal = require("./tokens/fraxtal.json"); // pairs const basePairs = require("./pairs/base.json"); const kromaPairs = require("./pairs/kroma.json"); const morphHoleskyPairs = require("./pairs/morph_holesky.json"); +const metalPairs = require("./pairs/metal.json"); +const fraxtalPairs = require("./pairs/fraxtal.json"); const bridgeUtils = require("@uniswap/token-list-bridge-utils"); @@ -60,6 +64,24 @@ module.exports = function buildList() { logoURI: "https://raw.githubusercontent.com/morph-l2/morph-list/main/tokenIcons/ETH.svg", }, + Fraxtal: { + chainId: 252, + address: "0xFC00000000000000000000000000000000000006", + name: "Frax Ether", + symbol: "FRXETH", + decimals: 18, + logoURI: + "https://assets.coingecko.com/coins/images/28284/standard/frxETH_icon.png?1696527284", + }, + Metal: { + chainId: 1750, + address: "0x4200000000000000000000000000000000000006", + name: "Ether", + symbol: "ETH", + decimals: 18, + logoURI: + "https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880", + }, }, defaultPair: { Base: { @@ -120,11 +142,49 @@ module.exports = function buildList() { "https://raw.githubusercontent.com/morph-l2/morph-list/main/tokenIcons/USDT.svg", }, }, + Fraxtal: { + "base": { + "chainId": 252, + "address": "0xFc00000000000000000000000000000000000001", + "symbol": "FRAX", + "name": "Frax", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/13422/small/frax_logo.png?1608476506" + }, + "quote": { + "chainId": 252, + "address": "0xFC00000000000000000000000000000000000006", + "name": "Frax Ether", + "symbol": "FRXETH", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/28284/standard/frxETH_icon.png?1696527284" + } + }, + Metal: { + "base": { + "chainId": 1750, + "address": "0xBCFc435d8F276585f6431Fc1b9EE9A850B5C00A9", + "symbol": "MTL", + "name": "Metal", + "decimals": 8, + "logoURI": "https://assets.coingecko.com/coins/images/763/standard/Metal.png?1696501916" + }, + "quote": { + "chainId": 1750, + "address": "0x4200000000000000000000000000000000000006", + "name": "Ether", + "symbol": "ETH", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880" + }, + } }, scannerLink: { Base: "https://basescan.org", Kroma: "https://kromascan.com", "Morph Holesky": "https://explorer-holesky.morphl2.io/", + Fraxtal: "https://fraxscan.com/", + Metal: "https://metalscan.io/", }, matchingEngine: { Base: { @@ -157,8 +217,14 @@ module.exports = function buildList() { tags: {}, logoURI: "https://avatars.githubusercontent.com/u/73440097?s=200&v=4", keywords: ["standard", "default"], - pairs: [...basePairs, ...kromaPairs, ...morphHoleskyPairs], - tokens: [...base, ...kroma, ...morphHolesky] + pairs: [ + ...basePairs, + ...kromaPairs, + ...morphHoleskyPairs, + ...fraxtalPairs, + ...metalPairs, + ], + tokens: [...base, ...kroma, ...morphHolesky, ...fraxtal, ...metal] // sort them by symbol for easy readability .sort((t1, t2) => { if (t1.chainId === t2.chainId) { diff --git a/src/pairs/fraxtal.json b/src/pairs/fraxtal.json new file mode 100644 index 00000000..df9351b1 --- /dev/null +++ b/src/pairs/fraxtal.json @@ -0,0 +1,80 @@ +[ + { + "base": { + "chainId": 252, + "address": "0xFc00000000000000000000000000000000000001", + "symbol": "FRAX", + "name": "Frax", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/13422/small/frax_logo.png?1608476506" + }, + "quote": { + "chainId": 252, + "address": "0xFC00000000000000000000000000000000000006", + "name": "Frax Ether", + "symbol": "FRXETH", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/28284/standard/frxETH_icon.png?1696527284" + }, + "listing_price": 0.00039179 + }, + { + "base": { + "chainId": 252, + "address": "0xFc00000000000000000000000000000000000001", + "symbol": "FRAX", + "name": "Frax", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/13422/small/frax_logo.png?1608476506" + }, + "quote": { + "chainId": 252, + "address": "0xDcc0F2D8F90FDe85b10aC1c8Ab57dc0AE946A543", + "name": "USD Coin", + "symbol": "USDC", + "decimals": 6, + "logoURI": "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png?1547042389" + }, + "listing_price": 0.99729973, + "buy_tick": 10, + "sell_tick": 10 + }, + { + "base": { + "chainId": 252, + "address": "0xFc00000000000000000000000000000000000003", + "symbol": "FPI", + "name": "Frax Price Index", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/24945/standard/FPI_icon.png?1696524100" + }, + "quote": { + "chainId": 252, + "address": "0xFC00000000000000000000000000000000000006", + "name": "Frax Ether", + "symbol": "FRXETH", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/28284/standard/frxETH_icon.png?1696527284" + }, + "listing_price": 0.00043611 + }, + { + "base": { + "chainId": 252, + "address": "0xFc00000000000000000000000000000000000003", + "symbol": "FPI", + "name": "Frax Price Index", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/24945/standard/FPI_icon.png?1696524100" + }, + "quote": { + "chainId": 252, + "address": "0xDcc0F2D8F90FDe85b10aC1c8Ab57dc0AE946A543", + "name": "USD Coin", + "symbol": "USDC", + "decimals": 6, + "logoURI": "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png?1547042389" + }, + "listing_price": 1.11 + } + ] \ No newline at end of file diff --git a/src/pairs/metal.json b/src/pairs/metal.json new file mode 100644 index 00000000..339ba953 --- /dev/null +++ b/src/pairs/metal.json @@ -0,0 +1,40 @@ +[ + { + "base": { + "chainId": 1750, + "address": "0xBCFc435d8F276585f6431Fc1b9EE9A850B5C00A9", + "symbol": "MTL", + "name": "Metal", + "decimals": 8, + "logoURI": "https://assets.coingecko.com/coins/images/763/standard/Metal.png?1696501916" + }, + "quote": { + "chainId": 1750, + "address": "0x4200000000000000000000000000000000000006", + "name": "Ether", + "symbol": "ETH", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880" + }, + "listing_price": 0.00037089 + }, + { + "base": { + "chainId": 1750, + "address": "0xBCFc435d8F276585f6431Fc1b9EE9A850B5C00A9", + "symbol": "MTL", + "name": "Metal", + "decimals": 8, + "logoURI": "https://assets.coingecko.com/coins/images/763/standard/Metal.png?1696501916" + }, + "quote": { + "chainId": 1750, + "address": "0xb91CFCcA485C6E40E3bC622f9BFA02a8ACdEeBab", + "name": "USD Coin", + "symbol": "USDC", + "decimals": 6, + "logoURI": "https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png?1547042389" + }, + "listing_price": 0.944 + } + ] \ No newline at end of file diff --git a/src/scripts/addPairs.js b/src/scripts/addPairs.js index 3bf0889b..0e35f1a0 100644 --- a/src/scripts/addPairs.js +++ b/src/scripts/addPairs.js @@ -1,20 +1,22 @@ -const { createWalletClient, http, parseUnits } = require('viem'); -const { privateKeyToAccount } = require('viem/accounts'); -const { base, kroma, morphHolesky } = require('viem/chains'); +const { createWalletClient, http, parseUnits } = require("viem"); +const { privateKeyToAccount } = require("viem/accounts"); +const { base, kroma, morphHolesky } = require("viem/chains"); //const { MatchingEngineABI } = require('./abis/matchingEngineAbi'); -const { ChainIds } = require('../const'); -const { MatchingEngineABI } = require('../abis/matchingEngineAbi'); -const defaultTokenList = require('../../build/standard-default.tokenlist.json'); -require('dotenv').config() +const { ChainIds } = require("../const"); +const { MatchingEngineABI } = require("../abis/matchingEngineAbi"); +const defaultTokenList = require("../../build/standard-default.tokenlist.json"); +require("dotenv").config(); async function getPairs(networkName) { - try { - const chainId = ChainIds[networkName]; - const pairs = defaultTokenList.pairs.filter((pair)=> pair.base.chainId == chainId); - return pairs; - } catch (error) { - console.error("Error getting pairs:", error); - } + try { + const chainId = ChainIds[networkName]; + const pairs = defaultTokenList.pairs.filter( + (pair) => pair.base.chainId == chainId + ); + return pairs; + } catch (error) { + console.error("Error getting pairs:", error); + } } async function addPair(pair, matchingEngine, walletClient, abi) { @@ -41,42 +43,41 @@ async function setSpread(pair, matchingEngine, walletClient, abi) { try { // Set up ticks for listed pair const result2 = await walletClient.writeContract({ - address: matchingEngine, - abi: abi, - functionName: "setSpread", - args: [ - pair.base.address, - pair.quote.address, - pair.buy_tick ?? 200, - pair.sell_tick ?? 200 - ], - }); + address: matchingEngine, + abi: abi, + functionName: "setSpread", + args: [ + pair.base.address, + pair.quote.address, + pair.buy_tick ?? 200, + pair.sell_tick ?? 200, + ], + }); - console.log("Transaction hash for setting ticks:", result2); - } catch (error) { - console.error("Error setting up ticks:", error); - } + console.log("Transaction hash for setting ticks:", result2); + } catch (error) { + console.error("Error setting up ticks:", error); + } } async function main() { + const account = privateKeyToAccount(process.env.ADMIN_PRIVATE_KEY); + const walletClient = createWalletClient({ + account, + chain: morphHolesky, + transport: http(process.env.MORPH_HOLESKY_RPC), + }); + const abi = MatchingEngineABI; -const account = privateKeyToAccount(process.env.ADMIN_PRIVATE_KEY); -const walletClient = createWalletClient({ - account, - chain: morphHolesky, - transport: http(process.env.MORPH_HOLESKY_RPC), -}); - -const abi = MatchingEngineABI; - const pairs = await getPairs("Morph Holesky"); // make contract call on each pair in the list - const matchingEngine = defaultTokenList.matchingEngine["Morph Holesky"].address; + const matchingEngine = + defaultTokenList.matchingEngine["Morph Holesky"].address; for (const pair of pairs) { await addPair(pair, matchingEngine, walletClient, abi); await setSpread(pair, matchingEngine, walletClient, abi); } } -main() +main(); diff --git a/src/scripts/generateETHUSDTPairs.js b/src/scripts/generateDefaultPairs.js similarity index 69% rename from src/scripts/generateETHUSDTPairs.js rename to src/scripts/generateDefaultPairs.js index a0078b9e..0b3a3baa 100644 --- a/src/scripts/generateETHUSDTPairs.js +++ b/src/scripts/generateDefaultPairs.js @@ -1,12 +1,13 @@ -const morphHolesky = require("../tokens/morph_holesky.json") +// replace path with path to desired network tokenlist +const tokenlist = require("../tokens/metal.json") function addETHUSDTPairs() { - const usdt = morphHolesky.find((token) => token.symbol === "USDT"); - const eth = morphHolesky.find((token) => token.symbol === "ETH"); + const stablecoin = tokenlist.find((token) => token.symbol === "USDC"); + const eth = tokenlist.find((token) => token.symbol === "ETH"); - const remainingTokens = morphHolesky.filter((token) => token.address !== usdt.address && token.address !== eth.address); + const remainingTokens = tokenlist.filter((token) => token.address !== stablecoin.address && token.address !== eth.address); const ETHUSDTPairs = []; @@ -33,7 +34,7 @@ function addETHUSDTPairs() { "decimals": token.decimals, "logoURI": token.logoURI }, - "quote": usdt, + "quote": stablecoin, "listing_price": 0. }) } diff --git a/src/tokens/fraxtal.json b/src/tokens/fraxtal.json new file mode 100644 index 00000000..b26b9b1d --- /dev/null +++ b/src/tokens/fraxtal.json @@ -0,0 +1,34 @@ +[ + { + "chainId": 252, + "address": "0xFc00000000000000000000000000000000000001", + "name": "Frax", + "symbol": "FRAX", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/13422/small/frax_logo.png?1608476506" + }, + { + "chainId": 252, + "address": "0xFC00000000000000000000000000000000000006", + "name": "Frax Ether", + "symbol": "FRXETH", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/28284/standard/frxETH_icon.png?1696527284" + }, + { + "chainId": 252, + "address": "0xFc00000000000000000000000000000000000003", + "name": "Frax Price Index", + "symbol": "FPI", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/24945/standard/FPI_icon.png?1696524100" + }, + { + "chainId": 252, + "address": "0xDcc0F2D8F90FDe85b10aC1c8Ab57dc0AE946A543", + "name": "USD Coin", + "symbol": "USDC", + "decimals": 6, + "logoURI": "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png?1547042389" + } +] \ No newline at end of file diff --git a/src/tokens/metal.json b/src/tokens/metal.json new file mode 100644 index 00000000..039956d3 --- /dev/null +++ b/src/tokens/metal.json @@ -0,0 +1,26 @@ +[ + { + "chainId": 1750, + "address": "0xBCFc435d8F276585f6431Fc1b9EE9A850B5C00A9", + "name": "Metal", + "symbol": "MTL", + "decimals": 8, + "logoURI": "https://assets.coingecko.com/coins/images/763/standard/Metal.png?1696501916" + }, + { + "chainId": 1750, + "address": "0x4200000000000000000000000000000000000006", + "name": "Ether", + "symbol": "ETH", + "decimals": 18, + "logoURI": "https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880" + }, + { + "chainId": 1750, + "address": "0xb91CFCcA485C6E40E3bC622f9BFA02a8ACdEeBab", + "name": "USD Coin", + "symbol": "USDC", + "decimals": 6, + "logoURI": "https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png?1547042389" + } +] \ No newline at end of file