Skip to content

Commit

Permalink
Merge pull request #59 from superfluid-finance/2024-09-18-add-fetch-f…
Browse files Browse the repository at this point in the history
…unctions-and-update-tokens

2024-09-18 add fetch functions and update tokens
  • Loading branch information
kasparkallas authored Sep 18, 2024
2 parents 4be4bf9 + 4c2b822 commit 23414f8
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@superfluid-finance/tokenlist-repo",
"private": true,
"version": "5.6.0",
"version": "5.7.0",
"license": "MIT",
"scripts": {
"tsc": "tsc --noEmit",
Expand Down
55 changes: 55 additions & 0 deletions packages/tokenlist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,59 @@ export const extendedSuperTokenList = extendedTokenListJSON as SuperTokenList;

const superTokenList = tokenListJSON as SuperTokenList;

export const fetchLatestSuperTokenList = async (): Promise<SuperTokenList> => {
const data = await fetchTokenList("https://raw.githubusercontent.com/superfluid-finance/tokenlist/main/superfluid.tokenlist.json", {
fallbackTokenList: superTokenList
});
return data;
};

export const fetchLatestExtendedSuperTokenList = async (): Promise<SuperTokenList> => {
const data = await fetchTokenList("https://raw.githubusercontent.com/superfluid-finance/tokenlist/main/superfluid.extended.tokenlist.json", {
fallbackTokenList: extendedSuperTokenList
});
return data;
};

export default superTokenList;

const inMemoryCache = new Map();

async function fetchTokenList(url: string, options: {
timeout?: number;
cacheTTL?: number;
fallbackTokenList: SuperTokenList;
}): Promise<SuperTokenList> {
const {
timeout = 3000,
fallbackTokenList
} = options;

// Check cache
if (inMemoryCache.has(url)) {
return inMemoryCache.get(url).data;
}

const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeout);

try {
const response = await fetch(url, { signal: controller.signal });
clearTimeout(timeoutId);

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

const data = await response.json();

// Cache the successful response
inMemoryCache.set(url, { data, timestamp: Date.now() });

return data as SuperTokenList;
} catch (error: unknown) {
console.error('Error fetching tokenlist:', error);
console.warn('Using fallback token list.');
return fallbackTokenList;
}
}
2 changes: 1 addition & 1 deletion packages/tokenlist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superfluid-finance/tokenlist",
"version": "5.6.1",
"version": "5.7.0",
"license": "MIT",
"type": "module",
"main": "dist/index.cjs",
Expand Down
114 changes: 111 additions & 3 deletions superfluid.extended.tokenlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "Superfluid Token List",
"version": {
"major": 5,
"minor": 6,
"patch": 1
"minor": 7,
"patch": 0
},
"timestamp": "2024-09-04T11:18:54.267Z",
"timestamp": "2024-09-18T08:59:01.051Z",
"tokens": [
{
"address": "0x00d05eed85bad962ba5237dd4afff12004455a8a",
Expand Down Expand Up @@ -2705,6 +2705,32 @@
"supertoken"
]
},
{
"address": "0xc3fa1e27a2a58ee476f04d4f4867f06b6e906cc5",
"name": "Super Zurf",
"symbol": "ZURFx",
"decimals": 18,
"chainId": 137,
"extensions": {
"superTokenInfo": {
"type": "Wrapper",
"underlyingTokenAddress": "0x8906365c65589e87870040d681e51a69e9c6f91e"
}
},
"tags": [
"supertoken"
]
},
{
"address": "0x8906365c65589e87870040d681e51a69e9c6f91e",
"name": "ZURF",
"symbol": "ZURF",
"decimals": 18,
"chainId": 137,
"tags": [
"underlying"
]
},
{
"address": "0xc49c15350f001efee91e154f03bddf38cfd0d96e",
"name": "Super Adept Camp Doge Coin",
Expand Down Expand Up @@ -3510,6 +3536,32 @@
"underlying"
]
},
{
"address": "0x9f41d0aa24e599fd8d0c180ee3c0f609dc41c622",
"name": "Super Glo Dollar",
"symbol": "USDGLOx",
"decimals": 18,
"chainId": 10,
"extensions": {
"superTokenInfo": {
"type": "Wrapper",
"underlyingTokenAddress": "0x4f604735c1cf31399c6e711d5962b2b3e0225ad3"
}
},
"tags": [
"supertoken"
]
},
{
"address": "0x4f604735c1cf31399c6e711d5962b2b3e0225ad3",
"name": "Glo Dollar",
"symbol": "USDGLO",
"decimals": 18,
"chainId": 10,
"tags": [
"underlying"
]
},
{
"address": "0xbd80cfa9d93a87d1bb895f810ea348e496611cd4",
"name": "Own a fraction",
Expand Down Expand Up @@ -3985,6 +4037,34 @@
"underlying"
]
},
{
"address": "0x0419e1fa3671754f77ec7d5416219a5f9a08b530",
"name": "Super Binance-Peg USD coin",
"symbol": "USDCx",
"decimals": 18,
"chainId": 56,
"extensions": {
"superTokenInfo": {
"type": "Wrapper",
"underlyingTokenAddress": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d"
}
},
"logoURI": "https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/usdc/icon.svg",
"tags": [
"supertoken"
]
},
{
"address": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
"name": "USD Coin",
"symbol": "USDC",
"decimals": 18,
"chainId": 56,
"logoURI": "https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/usdc/icon.svg",
"tags": [
"underlying"
]
},
{
"address": "0x529a4116f160c833c61311569d6b33dff41fd657",
"name": "Super BNB",
Expand Down Expand Up @@ -4835,6 +4915,34 @@
"underlying"
]
},
{
"address": "0xedf89f2612a5b07fef051e1a0444342b5410c405",
"name": "Super Xocolatl MXN Stablecoin",
"symbol": "XOCx",
"decimals": 18,
"chainId": 8453,
"extensions": {
"superTokenInfo": {
"type": "Wrapper",
"underlyingTokenAddress": "0xa411c9aa00e020e4f88bc19996d29c5b7adb4acf"
}
},
"logoURI": "https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/xoc/icon.png",
"tags": [
"supertoken"
]
},
{
"address": "0xa411c9aa00e020e4f88bc19996d29c5b7adb4acf",
"name": "Xocolatl MXN Stablecoin",
"symbol": "XOC",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/xoc/icon.png",
"tags": [
"underlying"
]
},
{
"address": "0xefbe11336b0008dce3797c515e6457cc4841645c",
"name": "Super TN100X",
Expand Down
114 changes: 111 additions & 3 deletions superfluid.tokenlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "Superfluid Token List",
"version": {
"major": 5,
"minor": 6,
"patch": 1
"minor": 7,
"patch": 0
},
"timestamp": "2024-09-04T11:18:54.267Z",
"timestamp": "2024-09-18T08:59:01.051Z",
"tokens": [
{
"address": "0x1234756ccf0660e866305289267211823ae86eec",
Expand Down Expand Up @@ -2123,6 +2123,32 @@
"supertoken"
]
},
{
"address": "0xc3fa1e27a2a58ee476f04d4f4867f06b6e906cc5",
"name": "Super Zurf",
"symbol": "ZURFx",
"decimals": 18,
"chainId": 137,
"extensions": {
"superTokenInfo": {
"type": "Wrapper",
"underlyingTokenAddress": "0x8906365c65589e87870040d681e51a69e9c6f91e"
}
},
"tags": [
"supertoken"
]
},
{
"address": "0x8906365c65589e87870040d681e51a69e9c6f91e",
"name": "ZURF",
"symbol": "ZURF",
"decimals": 18,
"chainId": 137,
"tags": [
"underlying"
]
},
{
"address": "0xc49c15350f001efee91e154f03bddf38cfd0d96e",
"name": "Super Adept Camp Doge Coin",
Expand Down Expand Up @@ -2928,6 +2954,32 @@
"underlying"
]
},
{
"address": "0x9f41d0aa24e599fd8d0c180ee3c0f609dc41c622",
"name": "Super Glo Dollar",
"symbol": "USDGLOx",
"decimals": 18,
"chainId": 10,
"extensions": {
"superTokenInfo": {
"type": "Wrapper",
"underlyingTokenAddress": "0x4f604735c1cf31399c6e711d5962b2b3e0225ad3"
}
},
"tags": [
"supertoken"
]
},
{
"address": "0x4f604735c1cf31399c6e711d5962b2b3e0225ad3",
"name": "Glo Dollar",
"symbol": "USDGLO",
"decimals": 18,
"chainId": 10,
"tags": [
"underlying"
]
},
{
"address": "0xbd80cfa9d93a87d1bb895f810ea348e496611cd4",
"name": "Own a fraction",
Expand Down Expand Up @@ -3403,6 +3455,34 @@
"underlying"
]
},
{
"address": "0x0419e1fa3671754f77ec7d5416219a5f9a08b530",
"name": "Super Binance-Peg USD coin",
"symbol": "USDCx",
"decimals": 18,
"chainId": 56,
"extensions": {
"superTokenInfo": {
"type": "Wrapper",
"underlyingTokenAddress": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d"
}
},
"logoURI": "https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/usdc/icon.svg",
"tags": [
"supertoken"
]
},
{
"address": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
"name": "USD Coin",
"symbol": "USDC",
"decimals": 18,
"chainId": 56,
"logoURI": "https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/usdc/icon.svg",
"tags": [
"underlying"
]
},
{
"address": "0x529a4116f160c833c61311569d6b33dff41fd657",
"name": "Super BNB",
Expand Down Expand Up @@ -4253,6 +4333,34 @@
"underlying"
]
},
{
"address": "0xedf89f2612a5b07fef051e1a0444342b5410c405",
"name": "Super Xocolatl MXN Stablecoin",
"symbol": "XOCx",
"decimals": 18,
"chainId": 8453,
"extensions": {
"superTokenInfo": {
"type": "Wrapper",
"underlyingTokenAddress": "0xa411c9aa00e020e4f88bc19996d29c5b7adb4acf"
}
},
"logoURI": "https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/xoc/icon.png",
"tags": [
"supertoken"
]
},
{
"address": "0xa411c9aa00e020e4f88bc19996d29c5b7adb4acf",
"name": "Xocolatl MXN Stablecoin",
"symbol": "XOC",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/xoc/icon.png",
"tags": [
"underlying"
]
},
{
"address": "0xefbe11336b0008dce3797c515e6457cc4841645c",
"name": "Super TN100X",
Expand Down

0 comments on commit 23414f8

Please sign in to comment.