Skip to content

Commit e7fe857

Browse files
optout21Catenocrypt
authored andcommitted
[Internal] Tokenlist pairs update: Only manual update; use exclude/include config; no tokenlist_base (trustwallet#5451)
* Force include and exclude implementation. * Rename update to updateAuto * UpdateManual hooks * UpdateManual hook fix * Update existing tokenlist.json file, use exclude/include config. * Force include only pairs against the main currency. * PS config adjustment * Remove tokenlist_base files * Lint fix * Remove all pairs first. Co-authored-by: Catenocrypt <[email protected]>
1 parent c2885f4 commit e7fe857

File tree

16 files changed

+189
-962
lines changed

16 files changed

+189
-962
lines changed

.github/workflows/periodic-update.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- cron: '0 7,19 * * *'
66
workflow_dispatch:
77
jobs:
8-
periodic-update:
8+
periodic-auto-update:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install Dependencies
1919
run: npm ci
2020
- name: Run scripts
21-
run: npm run update
21+
run: npm run updateAuto
2222
- name: Show update result (diff)
2323
if: success()
2424
run: |

blockchains/ethereum/tokenlist_base.json

Lines changed: 0 additions & 655 deletions
This file was deleted.

blockchains/smartchain/tokenlist_base.json

Lines changed: 0 additions & 259 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"check-sanity": "ts-node ./script/entrypoint/check-sanity",
1010
"fix": "ts-node ./script/entrypoint/fix",
1111
"fix-sanity": "ts-node ./script/entrypoint/fix-sanity",
12-
"update": "ts-node ./script/entrypoint/update",
12+
"updateAuto": "ts-node ./script/entrypoint/updateAuto",
13+
"update": "ts-node ./script/entrypoint/updateManual",
1314
"lint": "npx eslint . --ext .js,.jsx,.ts,.tsx",
1415
"lint:fix": "npx eslint . --ext .js,.jsx,.ts,.tsx --fix"
1516
},

script/blockchain/binance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class BinanceAction implements ActionInterface {
125125
];
126126
}
127127

128-
async update(): Promise<void> {
128+
async updateAuto(): Promise<void> {
129129
// retrieve missing token images; BEP2 (bep8 not supported)
130130
const bep2InfoList = await retrieveBep2AssetList();
131131
const denylist: string[] = readJsonFile(getChainDenylistPath(binanceChain)) as string[];

script/blockchain/ethereum.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from "../generic/subgraph";
99
import { Ethereum } from "../generic/blockchains";
1010
import {
11+
parseForceList,
1112
rebuildTokenlist,
1213
TokenItem
1314
} from "../generic/tokenlists";
@@ -21,14 +22,17 @@ const PrimaryTokens: string[] = ["WETH", "ETH"];
2122
async function retrieveUniswapPairs(): Promise<PairInfo[]> {
2223
console.log(`Retrieving pairs from Uniswap, limit liquidity USD ${config.Uniswap_MinLiquidity} volume ${config.Uniswap_MinVol24} txcount ${config.Uniswap_MinTxCount24}`);
2324

25+
console.log(` forceIncludeList: ${config.Uniswap_ForceInclude}`);
26+
const includeList = parseForceList(config.Uniswap_ForceInclude);
27+
2428
const pairs = await getTradingPairs(config.Uniswap_TradingPairsUrl, config.Uniswap_TradingPairsQuery);
2529
const filtered: PairInfo[] = [];
2630
pairs.forEach(x => {
2731
try {
2832
if (typeof(x) === "object") {
2933
const pairInfo = x as PairInfo;
3034
if (pairInfo) {
31-
if (checkTradingPair(pairInfo, config.Uniswap_MinLiquidity, config.Uniswap_MinVol24, config.Uniswap_MinTxCount24, PrimaryTokens)) {
35+
if (checkTradingPair(pairInfo, config.Uniswap_MinLiquidity, config.Uniswap_MinVol24, config.Uniswap_MinTxCount24, PrimaryTokens, includeList)) {
3236
filtered.push(pairInfo);
3337
}
3438
}
@@ -71,15 +75,15 @@ async function generateTokenlist(): Promise<void> {
7175
}
7276
pairs2.push([tokenItem0, tokenItem1]);
7377
});
74-
await rebuildTokenlist(Ethereum, pairs2, "Ethereum");
78+
await rebuildTokenlist(Ethereum, pairs2, "Ethereum", config.Uniswap_ForceExclude);
7579
}
7680

7781
export class EthereumAction implements ActionInterface {
7882
getName(): string { return "Ethereum"; }
7983

8084
getSanityChecks(): CheckStepInterface[] { return []; }
8185

82-
async update(): Promise<void> {
83-
//await generateTokenlist();
86+
async updateManual(): Promise<void> {
87+
await generateTokenlist();
8488
}
8589
}

script/blockchain/smartchain.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from "../generic/subgraph";
99
import { SmartChain } from "../generic/blockchains";
1010
import {
11+
parseForceList,
1112
rebuildTokenlist,
1213
TokenItem
1314
} from "../generic/tokenlists";
@@ -20,14 +21,17 @@ const PrimaryTokens: string[] = ["WBNB", "BNB"];
2021
async function retrievePancakeSwapPairs(): Promise<PairInfo[]> {
2122
console.log(`Retrieving pairs from PancakeSwap, limit liquidity USD ${config.PancakeSwap_MinLiquidity} volume ${config.PancakeSwap_MinVol24} txcount ${config.PancakeSwap_MinTxCount24}`);
2223

24+
console.log(` forceIncludeList: ${config.PancakeSwap_ForceInclude}`);
25+
const includeList = parseForceList(config.PancakeSwap_ForceInclude);
26+
2327
const pairs = await getTradingPairs(config.PancakeSwap_TradingPairsUrl, config.PancakeSwap_TradingPairsQuery);
2428
const filtered: PairInfo[] = [];
2529
pairs.forEach(x => {
2630
try {
2731
if (typeof(x) === "object") {
2832
const pairInfo = x as PairInfo;
2933
if (pairInfo) {
30-
if (checkTradingPair(pairInfo, config.PancakeSwap_MinLiquidity, config.PancakeSwap_MinVol24, config.PancakeSwap_MinTxCount24, PrimaryTokens)) {
34+
if (checkTradingPair(pairInfo, config.PancakeSwap_MinLiquidity, config.PancakeSwap_MinVol24, config.PancakeSwap_MinTxCount24, PrimaryTokens, includeList)) {
3135
filtered.push(pairInfo);
3236
}
3337
}
@@ -70,15 +74,15 @@ async function generateTokenlist(): Promise<void> {
7074
}
7175
pairs2.push([tokenItem0, tokenItem1]);
7276
});
73-
await rebuildTokenlist(SmartChain, pairs2, "Smart Chain");
77+
await rebuildTokenlist(SmartChain, pairs2, "Smart Chain", config.PancakeSwap_ForceExclude);
7478
}
7579

7680
export class SmartchainAction implements ActionInterface {
7781
getName(): string { return "Binance Smartchain"; }
7882

7983
getSanityChecks(): CheckStepInterface[] { return []; }
8084

81-
async update(): Promise<void> {
82-
//await generateTokenlist();
85+
async updateManual(): Promise<void> {
86+
await generateTokenlist();
8387
}
8488
}

script/blockchain/tezos.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class TezosAction implements ActionInterface {
9696
];
9797
}
9898

99-
async update(): Promise<void> {
99+
async updateAuto(): Promise<void> {
100100
await gen_validators_tezos();
101101
}
102102
}

0 commit comments

Comments
 (0)