-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from nickp96/revert_update_volume
update squid volume to previous tracking
- Loading branch information
Showing
2 changed files
with
63 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,56 @@ | ||
import fetch from "node-fetch"; | ||
const retry = require("async-retry"); | ||
|
||
export const getTokenAddress = (symbol: string, chain: string, assets: any[]) => { | ||
symbol = getSymbol(symbol); | ||
chain = getChain(chain); | ||
let tokenAddress = assets.find((asset) => asset.symbol === symbol)?.addresses?.[chain]?.address; | ||
export const getTokenAddress = (symbol: string, chain: string, assets: any[]) => { | ||
symbol = getSymbol(symbol); | ||
chain = getChain(chain); | ||
let tokenAddress = assets.find((asset) => asset.symbol === symbol)?.addresses?.[chain]?.address; | ||
|
||
if (tokenAddress == undefined || symbol === "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE") | ||
tokenAddress = "0x0000000000000000000000000000000000000000"; | ||
if (tokenAddress == undefined) tokenAddress = "0x000000000000000000000000000000000000dEaD" | ||
|
||
return tokenAddress; | ||
}; | ||
return tokenAddress; | ||
} | ||
|
||
const getChain = (chain: string) => { | ||
switch (chain) { | ||
case "avax": | ||
return "avalanche"; | ||
case "bsc": | ||
return "binance"; | ||
case "avax": return "avalanche"; | ||
case "bsc": return "binance"; | ||
// Add any new chain mappings here if needed | ||
default: | ||
return chain; | ||
default: return chain; | ||
} | ||
}; | ||
} | ||
|
||
const getSymbol = (rawSymbol: string) => { | ||
let symbol: string = rawSymbol; | ||
if (symbol.startsWith("axl-")) symbol = symbol.slice(4); | ||
if (symbol.startsWith("axl")) symbol = symbol.slice(3); | ||
|
||
const nativeTokenMap: { [key: string]: string } = { | ||
AVAX: "WAVAX", | ||
FTM: "WFTM", | ||
BNB: "WBNB", | ||
MATIC: "WMATIC", | ||
FIL: "WFIL", | ||
ETH: "WETH", | ||
wAXL: "AXL", | ||
const nativeTokenMap: {[key: string]: string} = { | ||
"AVAX": "WAVAX", | ||
"FTM": "WFTM", | ||
"BNB": "WBNB", | ||
"MATIC": "WMATIC", | ||
"FIL": "WFIL", | ||
"ETH": "WETH", | ||
"wAXL": "AXL", | ||
// Add any new native token mappings here if needed | ||
}; | ||
|
||
symbol = nativeTokenMap[symbol] || symbol; | ||
|
||
return symbol.charAt(0) === symbol.toUpperCase().charAt(0) ? symbol.toUpperCase() : symbol; | ||
}; | ||
} | ||
|
||
export const fetchAssets = () => { | ||
return retry(() => | ||
fetch("https://api.axelarscan.io/", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
method: "getAssets", | ||
}), | ||
}).then((res) => res.json()) | ||
); | ||
}; | ||
return retry(() => | ||
fetch("https://api.axelarscan.io/", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
method: "getAssets", | ||
}), | ||
}).then((res) => res.json()) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters