Skip to content

Commit 058581f

Browse files
authored
Merge pull request #29 from axieinfinity/feat/remove-unuse-default-token-list-uniswap
feat: remove unuse default token list uniswap
2 parents 759ccfc + a9c9d2e commit 058581f

File tree

3 files changed

+55
-34
lines changed

3 files changed

+55
-34
lines changed

lib/cron/cache-token-lists.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { S3 } from 'aws-sdk'
33
import axios from 'axios'
44
import { default as bunyan, default as Logger } from 'bunyan'
55

6+
// TEMP no need default token list
67
const TOKEN_LISTS: any = []
78

89
const handler: ScheduledHandler = async (event: EventBridgeEvent<string, void>) => {

lib/handlers/injector-sor.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ import { GraphQLTokenFeeFetcher } from '../graphql/graphql-token-fee-fetcher'
6161
import { UniGraphQLProvider } from '../graphql/graphql-provider'
6262
import { TrafficSwitcherITokenFeeFetcher } from '../util/traffic-switch/traffic-switcher-i-token-fee-fetcher'
6363
import { OnChainTokenFeeFetcher } from '@sky-mavis/smart-order-router/dist/main/providers/token-fee-fetcher'
64-
65-
const DEFAULT_TOKEN_LIST = 'https://gateway.ipfs.io/ipns/tokens.uniswap.org'
66-
6764
export interface RequestInjected<Router> extends BaseRInj {
6865
chainId: ChainId
6966
metric: IMetric
@@ -123,7 +120,7 @@ export abstract class InjectorSOR<Router, QueryParams> extends Injector<
123120
const {
124121
POOL_CACHE_BUCKET_3,
125122
POOL_CACHE_GZIP_KEY,
126-
TOKEN_LIST_CACHE_BUCKET,
123+
// TOKEN_LIST_CACHE_BUCKET,
127124
ROUTES_TABLE_NAME,
128125
ROUTES_CACHING_REQUEST_FLAG_TABLE_NAME,
129126
CACHED_ROUTES_TABLE_NAME,
@@ -233,7 +230,8 @@ export abstract class InjectorSOR<Router, QueryParams> extends Injector<
233230

234231
const [tokenListProvider, blockedTokenListProvider, v3SubgraphProvider, v2SubgraphProvider] =
235232
await Promise.all([
236-
AWSTokenListProvider.fromTokenListS3Bucket(chainId, TOKEN_LIST_CACHE_BUCKET!, DEFAULT_TOKEN_LIST),
233+
// AWSTokenListProvider.fromTokenListS3Bucket(chainId, TOKEN_LIST_CACHE_BUCKET!, DEFAULT_TOKEN_LIST),
234+
AWSTokenListProvider.fromTokenListS3Bucket(chainId),
237235
CachingTokenListProvider.fromTokenList(chainId, UNSUPPORTED_TOKEN_LIST as TokenList, blockedTokenCache),
238236
(async () => {
239237
try {

lib/handlers/router-entities/aws-token-list-provider.ts

+51-29
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,74 @@ import {
33
CachingTokenListProvider,
44
ITokenListProvider,
55
ITokenProvider,
6-
log,
76
NodeJSCache,
87
} from '@sky-mavis/smart-order-router'
9-
import { TokenList } from '@uniswap/token-lists'
10-
import S3 from 'aws-sdk/clients/s3'
118
import NodeCache from 'node-cache'
129

13-
const TOKEN_LIST_CACHE = new NodeCache({ stdTTL: 600, useClones: false })
10+
// const TOKEN_LIST_CACHE = new NodeCache({ stdTTL: 600, useClones: false })
11+
12+
const DEFAULT_TEMPLATE = {
13+
"name": "Uniswap Labs Default",
14+
"timestamp": "2024-11-18T15:56:01.725Z",
15+
"version": {
16+
"major": 12,
17+
"minor": 26,
18+
"patch": 0
19+
},
20+
"tags": {},
21+
"logoURI": "ipfs://QmNa8mQkrNKp1WEEeGjFezDmDeodkWRevGFN8JCV7b4Xir",
22+
"keywords": [
23+
"uniswap",
24+
"default"
25+
],
26+
"tokens": [
27+
{
28+
"chainId": 1,
29+
"address": "0x3E5A19c91266aD8cE2477B91585d1856B84062dF",
30+
"name": "Ancient8",
31+
"symbol": "A8",
32+
"decimals": 18,
33+
"logoURI": "https://assets.coingecko.com/coins/images/39170/standard/A8_Token-04_200x200.png?1720798300"
34+
},
35+
]
36+
}
1437

1538
export class AWSTokenListProvider extends CachingTokenListProvider {
1639
public static async fromTokenListS3Bucket(
1740
chainId: ChainId,
18-
bucket: string,
19-
tokenListURI: string
41+
// bucket: string,
42+
// tokenListURI: string
2043
): Promise<ITokenListProvider & ITokenProvider> {
21-
const s3 = new S3({ correctClockSkew: true, maxRetries: 3 })
22-
23-
const cachedTokenList = TOKEN_LIST_CACHE.get<TokenList>(tokenListURI)
24-
44+
// const s3 = new S3({ correctClockSkew: true, maxRetries: 3 })
45+
// const cachedTokenList = TOKEN_LIST_CACHE.get<TokenList>(tokenListURI)
2546
const tokenCache = new NodeCache({ stdTTL: 360, useClones: false })
47+
return super.fromTokenList(chainId, DEFAULT_TEMPLATE, new NodeJSCache(tokenCache))
2648

27-
if (cachedTokenList) {
28-
log.info(`Found token lists for ${tokenListURI} in local cache`)
29-
return super.fromTokenList(chainId, cachedTokenList, new NodeJSCache(tokenCache))
30-
}
49+
// if (cachedTokenList) {
50+
// log.info(`Found token lists for ${tokenListURI} in local cache`)
51+
// return super.fromTokenList(chainId, DEFAULT_TEMPLATE, new NodeJSCache(tokenCache))
52+
// }
3153

32-
try {
33-
log.info(`Getting tokenLists from s3.`)
34-
const tokenListResult = await s3.getObject({ Key: encodeURIComponent(tokenListURI), Bucket: bucket }).promise()
54+
// try {
55+
// log.info(`Getting tokenLists from s3.`)
56+
// const tokenListResult = await s3.getObject({ Key: encodeURIComponent(tokenListURI), Bucket: bucket }).promise()
3557

36-
const { Body: tokenListBuffer } = tokenListResult
58+
// const { Body: tokenListBuffer } = tokenListResult
3759

38-
if (!tokenListBuffer) {
39-
return super.fromTokenListURI(chainId, tokenListURI, new NodeJSCache(tokenCache))
40-
}
60+
// if (!tokenListBuffer) {
61+
// return super.fromTokenListURI(chainId, tokenListURI, new NodeJSCache(tokenCache))
62+
// }
4163

42-
const tokenList = JSON.parse(tokenListBuffer.toString('utf-8')) as TokenList
64+
// const tokenList = JSON.parse(tokenListBuffer.toString('utf-8')) as TokenList
4365

44-
log.info(`Got both tokenLists from s3. ${tokenList.tokens.length} tokens in main list.`)
66+
// log.info(`Got both tokenLists from s3. ${tokenList.tokens.length} tokens in main list.`)
4567

46-
TOKEN_LIST_CACHE.set<TokenList>(tokenListURI, tokenList)
68+
// TOKEN_LIST_CACHE.set<TokenList>(tokenListURI, tokenList)
4769

48-
return new CachingTokenListProvider(chainId, tokenList, new NodeJSCache(tokenCache))
49-
} catch (err) {
50-
log.info({ err }, `Failed to get tokenLists from s3.`)
51-
return super.fromTokenListURI(chainId, tokenListURI, new NodeJSCache(tokenCache))
52-
}
70+
// return new CachingTokenListProvider(chainId, tokenList, new NodeJSCache(tokenCache))
71+
// } catch (err) {
72+
// log.info({ err }, `Failed to get tokenLists from s3.`)
73+
// return super.fromTokenListURI(chainId, tokenListURI, new NodeJSCache(tokenCache))
74+
// }
5375
}
5476
}

0 commit comments

Comments
 (0)