Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update permit utils #347

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/permitInfo/fetchPermitInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { getUnsupportedTokensFromPermitInfo } from './utils/getUnsupportedTokens

// TODO: maybe make the args nicer?
// Get args from cli: chainId, optional token lists path, optional rpcUrl, optional recheckUnsupported flag
const [, scriptPath, chainId, tokenListPath, rpcUrl, recheckUnsupported] = argv
const [, scriptPath, chainId, tokenListPath, rpcUrl, recheckUnsupported, forceRecheck] = argv

if (!chainId) {
console.error('ChainId is missing. Invoke the script with the chainId as the first parameter.')
Expand All @@ -58,12 +58,12 @@ if (!chainId) {
// Change to script dir so relative paths work properly
chdir(path.dirname(scriptPath))


async function fetchPermitInfo(
chainId: number,
tokenListPath: string | undefined,
rpcUrl: string | undefined,
recheckUnsupported: boolean = false,
forceRecheck: boolean = false,
): Promise<void> {
// Load existing permitInfo.json file for given chainId
const permitInfoPath = path.join(BASE_PATH, `PermitInfo.${chainId}.json`)
Expand All @@ -75,7 +75,7 @@ async function fetchPermitInfo(
allPermitInfo = JSON.parse(readFileSync(permitInfoPath, 'utf8')) as Record<string, PermitInfo>
} catch (_) {
// File doesn't exist. It'll be created later on.
if (recheckUnsupported) {
if (recheckUnsupported || forceRecheck) {
console.error('recheck option set without existing permitInfo. There is nothing to recheck')
exit(1)
}
Expand All @@ -93,9 +93,12 @@ async function fetchPermitInfo(
const fetchAllPermits = tokens.map((token) => {
const existingInfo = allPermitInfo[token.address.toLowerCase()]

return pRetry(async () => _fetchPermitInfo(chainId, provider, token, existingInfo, recheckUnsupported), {
retries: 3,
})
return pRetry(
async () => _fetchPermitInfo(chainId, provider, token, existingInfo, recheckUnsupported, forceRecheck),
{
retries: 3,
},
)
})

// Await for all of them to complete
Expand Down Expand Up @@ -134,12 +137,13 @@ async function _fetchPermitInfo(
token: Token,
existing: PermitInfo | undefined,
recheckUnsupported: boolean,
forceRecheck: boolean,
): Promise<undefined | [string, PermitInfo]> {
const tokenId = token.symbol || token.name || token.address

if (token.chainId !== chainId) {
console.info(`Token ${tokenId}: belongs to a different network (${token.chainId}), skipping`)
} else if (isSupportedPermitInfo(existing) || (existing && !recheckUnsupported)) {
} else if (!forceRecheck && (isSupportedPermitInfo(existing) || (existing && !recheckUnsupported))) {
console.info(`Token ${tokenId}: already known, skipping`, existing)
} else {
const response: GetTokenPermitIntoResult = await throttledGetTokenPermitInfo({
Expand All @@ -165,4 +169,6 @@ async function _fetchPermitInfo(
}

// Execute the script
fetchPermitInfo(+chainId, tokenListPath, rpcUrl, !!recheckUnsupported).then(() => console.info(`Done 🏁`))
fetchPermitInfo(+chainId, tokenListPath, rpcUrl, !!recheckUnsupported, !!forceRecheck).then(() =>
console.info(`Done 🏁`),
)
63 changes: 57 additions & 6 deletions src/public/PermitInfo.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
"version": "1",
"name": "agEUR"
},
"0x1abaea1f7c830bd89acc67ec4af516284b1bc33c": {
"type": "eip-2612",
"version": "2",
"name": "Euro Coin"
},
"0x1b40183efb4dd766f11bda7a7c3ad8982e998421": {
"type": "eip-2612",
"version": "1",
Expand Down Expand Up @@ -239,6 +244,11 @@
"version": "1",
"name": "StakeWise"
},
"0x4da27a545c0c5b758a6ba100e3a049001de870f5": {
"type": "eip-2612",
"version": "2",
"name": "Staked Aave"
},
"0x5165d24277cd063f5ac44efd447b27025e888f37": {
"type": "eip-2612",
"version": "1",
Expand Down Expand Up @@ -353,15 +363,20 @@
"version": "1",
"name": "ConstitutionDAO"
},
"0x7dd9c5cba05e151c895fde1cf355c9a1d5da6429": {
"type": "dai-like",
"version": "1",
"name": "Golem Network Token"
},
"0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0": {
"type": "eip-2612",
"version": "1",
"name": "Wrapped liquid staked Ether 2.0"
},
"0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9": {
"type": "eip-2612",
"version": "1",
"name": "Aave Token"
"version": "2",
"name": "Aave token V3"
Comment on lines 376 to +379
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated AAVE token

},
"0x8254e26e453eb5abd29b3c37ac9e8da32e5d3299": {
"type": "eip-2612",
Expand Down Expand Up @@ -776,6 +791,10 @@
"type": "unsupported",
"name": "SparkPoint"
},
"0x048930eec73c91b44b0844aeacdebadc2f2b6efb": {
"type": "unsupported",
"name": "Aave Interest bearing UniDAI"
},
"0x04a5198063e45d84b1999516d3228167146417a6": {
"type": "unsupported",
"name": "ShiraINU"
Expand Down Expand Up @@ -1176,10 +1195,6 @@
"type": "unsupported",
"name": "OWL Token"
},
"0x1abaea1f7c830bd89acc67ec4af516284b1bc33c": {
"type": "unsupported",
"name": "Euro Coin"
},
"0x1bed97cbc3c24a4fb5c069c6e311a967386131f7": {
"type": "unsupported",
"name": "Yearn Ether"
Expand Down Expand Up @@ -1216,6 +1231,10 @@
"type": "unsupported",
"name": "Cream AlphaToken"
},
"0x1d0e53a0e524e3cc92c1f0f33ae268fff8d7e7a5": {
"type": "unsupported",
"name": "Aave Interest bearing UniUSDCETH"
},
"0x1d37986f252d0e349522ea6c3b98cb935495e63e": {
"type": "unsupported",
"name": "ChartEx"
Expand Down Expand Up @@ -2308,6 +2327,10 @@
"type": "unsupported",
"name": "Kounotori"
},
"0x6179078872605396ee62960917128f9477a5ddbb": {
"type": "unsupported",
"name": "Aave Interest bearing UniETH"
},
"0x618679df9efcd19694bb1daa8d00718eacfa2883": {
"type": "unsupported",
"name": "XYZ Governance Token"
Expand Down Expand Up @@ -2900,6 +2923,10 @@
"type": "unsupported",
"name": "ArtVerse Token"
},
"0x84bbcab430717ff832c3904fa6515f97fc63c76f": {
"type": "unsupported",
"name": "Aave Interest bearing UniSETHETH"
},
"0x84ca8bc7997272c7cfb4d0cd3d55cd942b3c9419": {
"type": "unsupported",
"name": "DIAToken"
Expand Down Expand Up @@ -3056,6 +3083,10 @@
"type": "unsupported",
"name": "VLX"
},
"0x8c69f7a4c9b38f1b48005d216c398efb2f1ce3e4": {
"type": "unsupported",
"name": "Aave Interest bearing UniMKRETH"
},
"0x8cb924583681cbfe487a62140a994a49f833c244": {
"type": "unsupported",
"name": "Swapp Token"
Expand Down Expand Up @@ -3168,6 +3199,10 @@
"type": "unsupported",
"name": "Meridian Network"
},
"0x9548db8b1ca9b6c757485e7861918b640390169c": {
"type": "unsupported",
"name": "Aave Interest bearing UniLINKETH"
},
"0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593": {
"type": "unsupported",
"name": "StaFi"
Expand Down Expand Up @@ -3756,6 +3791,10 @@
"type": "unsupported",
"name": "BNB"
},
"0xb977ee318010a5252774171494a1bcb98e7fab65": {
"type": "unsupported",
"name": "Aave Interest bearing UniUSDT"
},
"0xb987d48ed8f2c468d52d6405624eadba5e76d723": {
"type": "unsupported",
"name": "Stabilize Token"
Expand Down Expand Up @@ -3812,6 +3851,10 @@
"type": "unsupported",
"name": "Pangea Arbitration Token"
},
"0xbbbb7f2ac04484f7f04a2c2c16f20479791bbb44": {
"type": "unsupported",
"name": "Aave Interest bearing UniDAIETH"
},
"0xbbbbca6a901c926f240b89eacb641d8aec7aeafd": {
"type": "unsupported",
"name": "LoopringCoin V2"
Expand Down Expand Up @@ -4024,6 +4067,10 @@
"type": "unsupported",
"name": "Convergence"
},
"0xc88ebbf7c523f38ef3eb8a151273c0f0da421e63": {
"type": "unsupported",
"name": "Aave Interest bearing UniLENDETH"
},
"0xc944e90c64b2c07662a292be6244bdf05cda44a7": {
"type": "unsupported",
"name": "Graph Token"
Expand Down Expand Up @@ -4364,6 +4411,10 @@
"type": "unsupported",
"name": "Karma"
},
"0xe02b2ad63eff3ac1d5827cbd7ab9dd3dac4f4ad0": {
"type": "unsupported",
"name": "Aave Interest bearing UniUSDC"
},
"0xe047705117eb07e712c3d684f5b18e74577e83ac": {
"type": "unsupported",
"name": "BitcashPay"
Expand Down
Loading