Skip to content

Commit

Permalink
add fraxtal and metal
Browse files Browse the repository at this point in the history
  • Loading branch information
hskang9 committed Aug 12, 2024
1 parent 502cfac commit 4efe13f
Show file tree
Hide file tree
Showing 8 changed files with 296 additions and 48 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"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": {
"test": "mocha",
"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"
Expand Down
70 changes: 68 additions & 2 deletions src/buildList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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) {
Expand Down
80 changes: 80 additions & 0 deletions src/pairs/fraxtal.json
Original file line number Diff line number Diff line change
@@ -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
}
]
40 changes: 40 additions & 0 deletions src/pairs/metal.json
Original file line number Diff line number Diff line change
@@ -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
}
]
79 changes: 40 additions & 39 deletions src/scripts/addPairs.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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();
Original file line number Diff line number Diff line change
@@ -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 = [];
Expand All @@ -33,7 +34,7 @@ function addETHUSDTPairs() {
"decimals": token.decimals,
"logoURI": token.logoURI
},
"quote": usdt,
"quote": stablecoin,
"listing_price": 0.
})
}
Expand Down
Loading

0 comments on commit 4efe13f

Please sign in to comment.