diff --git a/.env.dev b/.env.dev index 51611970..0c807eb9 100644 --- a/.env.dev +++ b/.env.dev @@ -18,7 +18,7 @@ CRONOS_NODE_URL=https://cronos.blockpi.network/v1/rpc/public ARBITRUM_NODE_URL=https://arb-mainnet-public.unifra.io ZKSYNC-ERA_NODE_URL=https://mainnet.era.zksync.io ELYSIUM_NODE_URL=https://rpc.elysiumchain.tech -CORE_NODE_URL=https://rpc-core.icecreamswap.com +CORE_NODE_URL=https://core.public.infstones.com BASE_NODE_URL=https://base.llamarpc.com LINEA_NODE_URL=https://rpc.linea.build ##======================== LOGSTASH ======================== diff --git a/package-lock.json b/package-lock.json index 0e28ab56..0ae92448 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@solana/web3.js": "^1.30.2", "@supercharge/promise-pool": "^2.4.0", "@taquito/taquito": "^14.1.0", + "aptos": "^1.21.0", "bignumber.js": "^9.1.0", "dotenv": "^16.0.3", "ethers": "^5.7.2", @@ -232,6 +233,89 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, + "node_modules/@aptos-labs/aptos-client": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@aptos-labs/aptos-client/-/aptos-client-0.1.0.tgz", + "integrity": "sha512-q3s6pPq8H2buGp+tPuIRInWsYOuhSEwuNJPwd2YnsiID3YSLihn2ug39ktDJAcSOprUcp7Nid8WK7hKqnUmSdA==", + "dependencies": { + "axios": "1.6.2", + "got": "^11.8.6" + }, + "engines": { + "node": ">=15.10.0" + } + }, + "node_modules/@aptos-labs/aptos-client/node_modules/@szmarczak/http-timer": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", + "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", + "dependencies": { + "defer-to-connect": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@aptos-labs/aptos-client/node_modules/cacheable-lookup": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", + "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", + "engines": { + "node": ">=10.6.0" + } + }, + "node_modules/@aptos-labs/aptos-client/node_modules/got": { + "version": "11.8.6", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", + "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", + "dependencies": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.2", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=10.19.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/got?sponsor=1" + } + }, + "node_modules/@aptos-labs/aptos-client/node_modules/http2-wrapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", + "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", + "dependencies": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" + }, + "engines": { + "node": ">=10.19.0" + } + }, + "node_modules/@aptos-labs/aptos-client/node_modules/lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@aptos-labs/aptos-client/node_modules/p-cancelable": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", + "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", + "engines": { + "node": ">=8" + } + }, "node_modules/@babel/code-frame": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", @@ -1773,29 +1857,6 @@ } } }, - "node_modules/@hashgraph/sdk/node_modules/axios": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", - "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/@hashgraph/sdk/node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/@hethers/abstract-provider": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@hethers/abstract-provider/-/abstract-provider-1.2.1.tgz", @@ -4113,15 +4174,15 @@ ] }, "node_modules/@noble/hashes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.2.0.tgz", - "integrity": "sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ] + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", + "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } }, "node_modules/@noble/secp256k1": { "version": "1.7.1", @@ -4352,6 +4413,26 @@ "@redis/client": "^1.0.0" } }, + "node_modules/@scure/base": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", + "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", + "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", + "dependencies": { + "@noble/hashes": "~1.3.0", + "@scure/base": "~1.1.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@sindresorhus/is": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", @@ -5569,6 +5650,40 @@ "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" }, + "node_modules/aptos": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/aptos/-/aptos-1.21.0.tgz", + "integrity": "sha512-PRKjoFgL8tVEc9+oS7eJUv8GNxx8n3+0byH2+m7CP3raYOD6yFKOecuwjVMIJmgfpjp6xH0P0HDMGZAXmSyU0Q==", + "dependencies": { + "@aptos-labs/aptos-client": "^0.1.0", + "@noble/hashes": "1.3.3", + "@scure/bip39": "1.2.1", + "eventemitter3": "^5.0.1", + "form-data": "4.0.0", + "tweetnacl": "1.0.3" + }, + "engines": { + "node": ">=11.0.0" + } + }, + "node_modules/aptos/node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, + "node_modules/aptos/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -5667,9 +5782,9 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==" }, "node_modules/axios": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.1.tgz", - "integrity": "sha512-I88cFiGu9ryt/tfVEi4kX2SITsvDddTajXTOFmt2uK1ZVA8LytjtdeyefdQWEf5PU8w+4SSJDoYnggflB5tW4A==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "dependencies": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -6936,6 +7051,20 @@ "node": ">=0.10" } }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -8569,31 +8698,6 @@ "url": "https://github.com/sindresorhus/got?sponsor=1" } }, - "node_modules/got/node_modules/decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/got/node_modules/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/graceful-fs": { "version": "4.2.10", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", @@ -10954,6 +11058,17 @@ "node": ">=6" } }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/min-document": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", @@ -13332,20 +13447,6 @@ "node": ">=10.6.0" } }, - "node_modules/swarm-js/node_modules/decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/swarm-js/node_modules/fs-extra": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", @@ -13408,17 +13509,6 @@ "node": ">=8" } }, - "node_modules/swarm-js/node_modules/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/swarm-js/node_modules/p-cancelable": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", @@ -15177,6 +15267,67 @@ } } }, + "@aptos-labs/aptos-client": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@aptos-labs/aptos-client/-/aptos-client-0.1.0.tgz", + "integrity": "sha512-q3s6pPq8H2buGp+tPuIRInWsYOuhSEwuNJPwd2YnsiID3YSLihn2ug39ktDJAcSOprUcp7Nid8WK7hKqnUmSdA==", + "requires": { + "axios": "1.6.2", + "got": "^11.8.6" + }, + "dependencies": { + "@szmarczak/http-timer": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", + "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", + "requires": { + "defer-to-connect": "^2.0.0" + } + }, + "cacheable-lookup": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", + "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==" + }, + "got": { + "version": "11.8.6", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", + "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", + "requires": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.2", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + } + }, + "http2-wrapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", + "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", + "requires": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" + } + }, + "lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" + }, + "p-cancelable": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", + "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==" + } + } + }, "@babel/code-frame": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", @@ -16209,28 +16360,6 @@ "long": "^4.0.0", "protobufjs": "^7.1.2", "utf8": "^3.0.0" - }, - "dependencies": { - "axios": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", - "requires": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - } } }, "@hethers/abstract-provider": { @@ -17738,9 +17867,9 @@ "integrity": "sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==" }, "@noble/hashes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.2.0.tgz", - "integrity": "sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ==" + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", + "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==" }, "@noble/secp256k1": { "version": "1.7.1", @@ -17925,6 +18054,20 @@ "integrity": "sha512-ThUIgo2U/g7cCuZavucQTQzA9g9JbDDY2f64u3AbAoz/8vE2lt2U37LamDUVChhaDA3IRT9R6VvJwqnUfTJzng==", "requires": {} }, + "@scure/base": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", + "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==" + }, + "@scure/bip39": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", + "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", + "requires": { + "@noble/hashes": "~1.3.0", + "@scure/base": "~1.1.0" + } + }, "@sindresorhus/is": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", @@ -18934,6 +19077,36 @@ "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" }, + "aptos": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/aptos/-/aptos-1.21.0.tgz", + "integrity": "sha512-PRKjoFgL8tVEc9+oS7eJUv8GNxx8n3+0byH2+m7CP3raYOD6yFKOecuwjVMIJmgfpjp6xH0P0HDMGZAXmSyU0Q==", + "requires": { + "@aptos-labs/aptos-client": "^0.1.0", + "@noble/hashes": "1.3.3", + "@scure/bip39": "1.2.1", + "eventemitter3": "^5.0.1", + "form-data": "4.0.0", + "tweetnacl": "1.0.3" + }, + "dependencies": { + "eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -19019,9 +19192,9 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==" }, "axios": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.1.tgz", - "integrity": "sha512-I88cFiGu9ryt/tfVEi4kX2SITsvDddTajXTOFmt2uK1ZVA8LytjtdeyefdQWEf5PU8w+4SSJDoYnggflB5tW4A==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "requires": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -20006,6 +20179,14 @@ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==" }, + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + } + }, "dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -21291,21 +21472,6 @@ "lowercase-keys": "^3.0.0", "p-cancelable": "^3.0.0", "responselike": "^2.0.0" - }, - "dependencies": { - "decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "requires": { - "mimic-response": "^3.1.0" - } - }, - "mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" - } } }, "graceful-fs": { @@ -23074,6 +23240,11 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + }, "min-document": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", @@ -24854,14 +25025,6 @@ "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==" }, - "decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "requires": { - "mimic-response": "^3.1.0" - } - }, "fs-extra": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", @@ -24912,11 +25075,6 @@ "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" }, - "mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" - }, "p-cancelable": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", diff --git a/package.json b/package.json index 88d8572a..2cf7f924 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@solana/web3.js": "^1.30.2", "@supercharge/promise-pool": "^2.4.0", "@taquito/taquito": "^14.1.0", + "aptos": "^1.21.0", "bignumber.js": "^9.1.0", "dotenv": "^16.0.3", "ethers": "^5.7.2", diff --git a/src/app.config.ts b/src/app.config.ts index bd360fc2..11cc305f 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -58,5 +58,6 @@ nodeUrls['BASE_NODE_URL'] = process.env['BASE_NODE_URL']; nodeUrls['CORE_NODE_URL'] = process.env['CORE_NODE_URL']; nodeUrls['LINEA_NODE_URL'] = process.env['LINEA_NODE_URL']; nodeUrls['WAX_NODE_URL'] = process.env['WAX_NODE_URL']; +nodeUrls['APTOS_NODE_URL'] = process.env['APTOS_NODE_URL']; export { config, nodeUrls }; diff --git a/src/constants/tokens/aptos/core.json b/src/constants/tokens/aptos/core.json new file mode 100644 index 00000000..11605e31 --- /dev/null +++ b/src/constants/tokens/aptos/core.json @@ -0,0 +1,23 @@ +{ + "APT": "0x1::aptos_coin::AptosCoin", + "USDC": "0x5e156f1207d0ebfa19a9eeff00d62a282278fb8719f4fab3a586a0a2c0fffbea::coin::T", + "USDT": "0xa2eda21a58856fda86451436513b867c97eecb4ba099da5775520e0f7492e852::coin::T", + "WBTC": "0xae478ff7d83ed072dbc5e264250e67ef58f57c99d89b447efd8a0a2e8b2be76e::coin::T", + "ETH": "0xcc8a89c8dce9693d354449f1f73e60e14e347417854f029db5bc8e7454008abb::coin::T", + "USDC_1": "0xc91d826e29a3183eb3b6f6aa3a722089fdffb8e9642b94c5fcd4c48d035c0080::coin::T", + "USDA": "0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc::usda::USDA", + "USDC_2": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC", + "USDT_2": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT", + "WETH": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::WETH", + "SOL": "0xdd89c0e695df0692205912fb69fc290418bed0dbe6e4573d744a6d5e6bab6c13::coin::T", + "ST_APT": "0x84d7aeef42d38a5ffc3ccef853e1b82e4958659d16a7de736a29c55fbbeb0114::staked_aptos_coin::StakedAptosCoin", + "ST_APT2": "0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::staked_coin::StakedAptos", + "CELER_BNB": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::BnbCoin", + "CELER_BUSD": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::BusdCoin", + "CELER_USDC": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::UsdcCoin", + "CELER_USDT": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::UsdtCoin", + "CELER_DAI": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::DaiCoin", + "CELER_ETH": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::WethCoin", + "CELER_WBTC": "0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::WbtcCoin", + "amAPT": "0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::amapt_token::AmnisApt" +} \ No newline at end of file diff --git a/src/factory/providers/aptos/amnis/index.ts b/src/factory/providers/aptos/amnis/index.ts new file mode 100644 index 00000000..3a2d2b94 --- /dev/null +++ b/src/factory/providers/aptos/amnis/index.ts @@ -0,0 +1,19 @@ +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; + +async function tvl(params: ITvlParams): Promise> { + const { block, chain, provider, web3 } = params; + const { + data: { supply }, + } = ( + await web3.eth.query( + '/accounts/0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a/resource/0x1::coin::CoinInfo%3C0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::amapt_token::AmnisApt%3E', + ) + ).data; + + return { + balances: { + '0x1::aptos_coin::aptoscoin': supply.vec[0].integer.vec[0].value, + }, + }; +} +export { tvl }; diff --git a/src/factory/providers/aptos/aries/index.ts b/src/factory/providers/aptos/aries/index.ts new file mode 100644 index 00000000..3952e409 --- /dev/null +++ b/src/factory/providers/aptos/aries/index.ts @@ -0,0 +1,29 @@ +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; + +async function tvl(params: ITvlParams): Promise> { + const { block, chain, provider, web3 } = params; + const balances = {}; + const resourcesCache = await web3.eth.getResources( + '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3', + ); + const coinContainers = resourcesCache + .filter((token) => + token.type.includes( + '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::reserve::ReserveCoinContainer', + ), + ) + .map((i) => ({ + lamports: i.data.underlying_coin.value, + tokenAddress: i.type.slice( + i.type.indexOf('<') + 1, + i.type.lastIndexOf('>'), + ), + })); + coinContainers.forEach((token) => { + balances[token.tokenAddress.toLowerCase()] = token.lamports; + }); + return { + balances, + }; +} +export { tvl }; diff --git a/src/factory/providers/aptos/liquidswap/index.ts b/src/factory/providers/aptos/liquidswap/index.ts new file mode 100644 index 00000000..181d9386 --- /dev/null +++ b/src/factory/providers/aptos/liquidswap/index.ts @@ -0,0 +1,25 @@ +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; + +async function tvl(params: ITvlParams): Promise> { + const { block, chain, provider, web3 } = params; + const balances = await web3.eth.dexExport({ + account: + '0x05a97986a9d031c4567e15b797be516910cfcb4156312482efc6a19c0a30c948', + poolStr: 'liquidity_pool::LiquidityPool', + }); + const liqPool = await web3.eth.dexExport({ + account: + '0x61d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8', + poolStr: 'liquidity_pool::LiquidityPool', + }); + Object.entries(liqPool).forEach(([address, balance]) => { + if (!balances[address]) { + balances[address] = balance; + } else balances[address] = balances[address].plus(balance); + }); + return { + balances, + }; +} + +export { tvl }; diff --git a/src/factory/providers/aptos/pancakeswap/index.ts b/src/factory/providers/aptos/pancakeswap/index.ts new file mode 100644 index 00000000..0e12ea8d --- /dev/null +++ b/src/factory/providers/aptos/pancakeswap/index.ts @@ -0,0 +1,19 @@ +import formatter from '../../../../util/formatter'; +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; + +async function tvl(params: ITvlParams): Promise> { + const { block, chain, provider, web3 } = params; + const balances = await web3.eth.dexExport({ + account: + '0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa', + poolStr: 'swap::TokenPairReserve', + token0Reserve: (i) => i.data.reserve_x, + token1Reserve: (i) => i.data.reserve_y, + }); + formatter.convertBalancesToFixed(balances); + return { + balances, + }; +} + +export { tvl }; diff --git a/src/factory/providers/aptos/sushiswap/index.ts b/src/factory/providers/aptos/sushiswap/index.ts new file mode 100644 index 00000000..36f21218 --- /dev/null +++ b/src/factory/providers/aptos/sushiswap/index.ts @@ -0,0 +1,19 @@ +import formatter from '../../../../util/formatter'; +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; + +async function tvl(params: ITvlParams): Promise> { + const { block, chain, provider, web3 } = params; + const balances = await web3.eth.dexExport({ + account: + '0x31a6675cbe84365bf2b0cbce617ece6c47023ef70826533bde5203d32171dc3c', + poolStr: 'swap::TokenPairReserve', + token0Reserve: (i) => i.data.reserve_x, + token1Reserve: (i) => i.data.reserve_y, + }); + formatter.convertBalancesToFixed(balances); + return { + balances, + }; +} + +export { tvl }; diff --git a/src/factory/providers/aptos/thala/index.ts b/src/factory/providers/aptos/thala/index.ts new file mode 100644 index 00000000..933fb629 --- /dev/null +++ b/src/factory/providers/aptos/thala/index.ts @@ -0,0 +1,115 @@ +import formatter from '../../../../util/formatter'; +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; +import BigNumber from 'bignumber.js'; +const TAHA_SWAP = + '0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af'; +const MOVE_DOLLAR = + '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01'; +const LSD_ACCOUNT = + '0xfaf4e633ae9eb31366c9ca24214231760926576c7b625313b3688b5e900731f6'; + +function sum(balances, result) { + Object.entries(result).forEach(([address, balance]) => { + if (!balances[address]) { + balances[address] = balance; + } else balances[address] = balances[address].plus(balance); + }); +} +async function tvl(params: ITvlParams): Promise> { + const balances = {}; + const swap = await thalaSwap(params); + const cdp = await thalaCDP(params); + const lsd = await thalaLSD(params); + + sum(balances, swap.balances); + sum(balances, cdp.balances); + sum(balances, lsd.balances); + formatter.convertBalancesToFixed(balances); + return { balances }; +} + +async function thalaSwap(params: ITvlParams): Promise> { + const { web3 } = params; + + const balances = {}; + const resources = await web3.eth.getResources(TAHA_SWAP); + + const pools = resources + .filter( + (resource) => + resource.type.includes(`${TAHA_SWAP}::stable_pool::StablePool<`) || + resource.type.includes(`${TAHA_SWAP}::weighted_pool::WeightedPool<`), + ) + .map((pool) => ({ + assets: [ + pool.data.asset_0, + pool.data.asset_1, + pool.data.asset_2, + pool.data.asset_3, + ], + asset_types: pool.type.split('<')[1].replace('>', '').split(', '), + })); + + pools.forEach(({ assets, asset_types }) => { + assets.forEach((asset, index) => { + if (!asset_types[index]?.includes('base_pool::Null')) + formatter.merge(balances, asset_types[index], asset.value); + }); + }); + + return { balances }; +} + +async function thalaCDP(params: ITvlParams): Promise> { + const { web3 } = params; + + const balances = {}; + const resources = await web3.eth.getResources(MOVE_DOLLAR); + const vaults = resources + .filter((resource) => + resource.type.includes(`${MOVE_DOLLAR}::vault::Vaults<`), + ) + .map((vault) => ({ + total_collateral: vault.data.total_collateral, + asset_type: vault.type.split('<')[1].replace('>', '').split(', '), + })); + + const psms = resources + .filter((resource) => resource.type.includes(`${MOVE_DOLLAR}::psm::PSM<`)) + .map((psm) => ({ + total_collateral: psm.data.coin.value, + asset_type: psm.type.split('<')[1].replace('>', '').split(', '), + })); + + vaults.forEach(({ asset_type, total_collateral }) => { + formatter.merge(balances, asset_type[0], total_collateral); + }); + psms.forEach(({ asset_type, total_collateral }) => { + formatter.merge(balances, asset_type[0], total_collateral); + }); + + return { balances }; +} + +async function thalaLSD( + params: ITvlParams, +): Promise<{ balances: { '0x1::aptos_coin::aptoscoin': BigNumber } }> { + const { web3 } = params; + + const { + data: { supply }, + } = ( + await web3.eth.query( + `/accounts/${LSD_ACCOUNT}/resource/0x1::coin::CoinInfo%3C${LSD_ACCOUNT}::staking::ThalaAPT%3E`, + ) + ).data; + + return { + balances: { + '0x1::aptos_coin::aptoscoin': new BigNumber( + supply.vec[0].integer.vec[0].value / 1e8, + ), + }, + }; +} +export { tvl }; diff --git a/src/factory/providers/aptos/tortuga/index.ts b/src/factory/providers/aptos/tortuga/index.ts new file mode 100644 index 00000000..d39c7f99 --- /dev/null +++ b/src/factory/providers/aptos/tortuga/index.ts @@ -0,0 +1,19 @@ +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; + +async function tvl(params: ITvlParams): Promise> { + const { block, chain, provider, web3 } = params; + const { + data: { supply }, + } = ( + await web3.eth.query( + '/accounts/0x84d7aeef42d38a5ffc3ccef853e1b82e4958659d16a7de736a29c55fbbeb0114/resource/0x1::coin::CoinInfo%3C0x84d7aeef42d38a5ffc3ccef853e1b82e4958659d16a7de736a29c55fbbeb0114::staked_aptos_coin::StakedAptosCoin%3E', + ) + ).data; + + return { + balances: { + '0x1::aptos_coin::aptoscoin': supply.vec[0].integer.vec[0].value, + }, + }; +} +export { tvl }; diff --git a/src/factory/providers/cronos/ferro/index.ts b/src/factory/providers/cronos/ferro/index.ts index 3ef02d83..bd0f839f 100644 --- a/src/factory/providers/cronos/ferro/index.ts +++ b/src/factory/providers/cronos/ferro/index.ts @@ -8,8 +8,8 @@ const START_BLOCK = 2539442; const SWAP_DEPLOYER = '0xc4106bba1a8752e54940be71f7bd02c38e64f9e3'; const TOPIC = '0x0838512b7934222cec571cf3fde1cf3e9e864bbc431bd5d1ef4d9ed3079093d9'; -const LOGS_BATCH_SIZE = 10000; -const CHUNK_SIZE = 2; +const LOGS_BATCH_SIZE = 1000; +const CHUNK_SIZE = 5; async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; @@ -34,33 +34,35 @@ async function tvl(params: ITvlParams): Promise> { { type: 'address[]', name: 'pooledTokens' }, ]; - try { - const decodedLogsParameters = await util.getDecodedLogsParameters( - cache.start, - block, - TOPIC, - SWAP_DEPLOYER, - undefined, - typesArray, - web3, - LOGS_BATCH_SIZE, - CHUNK_SIZE, - ); - decodedLogsParameters.forEach((decodedLogParameters) => { - cache.pools.push({ - swapAddress: decodedLogParameters.swapAddress, - pooledTokens: decodedLogParameters.pooledTokens, + if (cache.start < block) { + try { + const decodedLogsParameters = await util.getDecodedLogsParameters( + cache.start, + block, + TOPIC, + SWAP_DEPLOYER, + undefined, + typesArray, + web3, + LOGS_BATCH_SIZE, + CHUNK_SIZE, + ); + decodedLogsParameters.forEach((decodedLogParameters) => { + cache.pools.push({ + swapAddress: decodedLogParameters.swapAddress, + pooledTokens: decodedLogParameters.pooledTokens, + }); + }); + cache.start = block + 1; + await basicUtil.saveIntoCache(cache, 'cache/cache.json', chain, provider); + } catch (e) { + log.error({ + message: e?.message || '', + stack: e?.stack || '', + detail: `Error: tvl of cronos/ferro. New logs are not scanned`, + endpoint: 'tvl', }); - }); - cache.start = block + 1; - await basicUtil.saveIntoCache(cache, 'cache/cache.json', chain, provider); - } catch (e) { - log.error({ - message: e?.message || '', - stack: e?.stack || '', - detail: `Error: tvl of cronos/ferro. New logs are not scanned`, - endpoint: 'tvl', - }); + } } for (const pool of cache.pools) { diff --git a/src/factory/providers/zksync-era/velocore/index.ts b/src/factory/providers/zksync-era/velocore/index.ts index 4bbbce48..29bfcb9c 100644 --- a/src/factory/providers/zksync-era/velocore/index.ts +++ b/src/factory/providers/zksync-era/velocore/index.ts @@ -12,6 +12,31 @@ const FACTORY_ADDRESS_V2 = '0xf55150000aac457eCC88b34dA9291e3F6E7DB165'; const VAULT_ADDRESS_V2 = '0xf5E67261CB357eDb6C7719fEFAFaaB280cB5E2A6'; const E_ADDRESS = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'; +async function getAllCanonicalPools(contract, block) { + const MAX_POOLS_PER_CALL = 20; + let allPools = []; + let startPosition = 0; + let hasMorePools = true; + + while (hasMorePools) { + const pools = await contract.methods['canonicalPools']( + FACTORY_ADDRESS_V2, + startPosition, + MAX_POOLS_PER_CALL, + ).call(null, block); + + allPools = allPools.concat(pools); + + if (pools.length < MAX_POOLS_PER_CALL) { + hasMorePools = false; + } else { + startPosition += MAX_POOLS_PER_CALL; + } + } + + return allPools; +} + async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; if (block < START_BLOCK) { @@ -36,11 +61,7 @@ async function tvl(params: ITvlParams): Promise> { const contract = new web3.eth.Contract(factoryAbi, FACTORY_ADDRESS_V2); - const canonicalPools = await contract.methods['canonicalPools']( - FACTORY_ADDRESS_V2, - 0, - 1000, - ).call(null, block); + const canonicalPools = await getAllCanonicalPools(contract, block); const wombatGauges = await contract.methods['wombatGauges']( FACTORY_ADDRESS_V2, diff --git a/src/util/data.ts b/src/util/data.ts index 33c04b43..d7a1acf1 100644 --- a/src/util/data.ts +++ b/src/util/data.ts @@ -93,7 +93,11 @@ const data = { }, core: { prefix: 'core_', - delay: 400, + delay: 0, + }, + aptos: { + prefix: 'apt_', + delay: 4600, }, }, FILTERS: { diff --git a/src/util/formatter.ts b/src/util/formatter.ts index f77022f5..d6ac611d 100644 --- a/src/util/formatter.ts +++ b/src/util/formatter.ts @@ -69,6 +69,13 @@ function sum(balanceArray) { return balances; } +function merge(balances, token, reserve) { + if (!balances[token.toLowerCase()]) { + balances[token.toLowerCase()] = new BigNumber(reserve); + } else + balances[token.toLowerCase()] = balances[token.toLowerCase()].plus(reserve); +} + function sumMultiBalanceOf(balances, results, chain = '', provider = '') { try { if (results.output) { @@ -145,6 +152,7 @@ export default { decodeResult, convertBalancesToFixed, convertBalancesToBigNumber, + merge, sum, sumMultiBalanceOf, swapTokenAddresses, diff --git a/src/web3Provider/aptos.ts b/src/web3Provider/aptos.ts new file mode 100644 index 00000000..01c4e3cb --- /dev/null +++ b/src/web3Provider/aptos.ts @@ -0,0 +1,113 @@ +import { nodeUrls } from '../app.config'; +import { Injectable } from '@nestjs/common'; +import axios from 'axios'; +import aptosToken from '../constants/tokens/aptos/core.json'; +import { AptosClient } from 'aptos'; +import formatter from '../util/formatter'; + +const nodeUrl = nodeUrls.APTOS_NODE_URL; + +@Injectable() +export class Aptos { + async query(api) { + return axios.get(`${nodeUrl}${api}`); + } + + async getResources(account) { + const data = []; + let lastData; + let cursor; + do { + let url = `${nodeUrl}/accounts/${account}/resources?limit=9999`; + if (cursor) url += '&start=' + cursor; + const res = await axios.get(url); + lastData = res.data; + data.push(...lastData); + console.log('fetched resource length', lastData.length); + cursor = res.headers['x-aptos-cursor']; + } while (lastData.length === 9999); + return data; + } + + async getResource(account, key) { + const url = `${nodeUrl}/accounts/${account}/resource/${key}`; + const { data } = (await axios.get(url)).data; + return data; + } + + async getCoinInfo(address) { + if (address === '0x1') return { data: { decimals: 8, name: 'Aptos' } }; + const data = ( + await axios.get( + `${nodeUrl}/accounts/${address}/resource/0x1::coin::CoinInfo%3C${address}::coin::T%3E`, + ) + ).data; + return data; + } + + async getTableData({ table, data }) { + const response = (await axios.post(`${nodeUrl}/tables/${table}/item`, data)) + .data; + return response; + } + + async function_view({ functionStr, type_arguments = [], args = [] }) { + const response = ( + await axios.post(`${nodeUrl}/view`, { + function: functionStr, + type_arguments: type_arguments, + arguments: args, + }) + ).data; + return response; + } + + async dexExport({ + account, + poolStr, + token0Reserve = (i) => i.data.coin_x_reserve.value, + token1Reserve = (i) => i.data.coin_y_reserve.value, + getTokens = (i) => i.type.split('<')[1].replace('>', '').split(', '), + }) { + const aptosTokenValue = Object.values(aptosToken); + const balances = {}; + let pools = await this.getResources(account); + pools = pools.filter((i) => i.type.includes(poolStr)); + console.log(`Number of pools: ${pools.length}`); + pools.forEach((i) => { + const reserve0 = token0Reserve(i); + const reserve1 = token1Reserve(i); + const [token0, token1] = getTokens(i); + const isCoreAsset0 = aptosTokenValue.includes(token0); + const isCoreAsset1 = aptosTokenValue.includes(token1); + const nonNeglibleReserves = reserve0 !== '0' && reserve1 !== '0'; + if (isCoreAsset0 && isCoreAsset1) { + formatter.merge(balances, token0, reserve0); + formatter.merge(balances, token1, reserve1); + } else if (isCoreAsset0) { + formatter.merge(balances, token0, reserve0); + if (nonNeglibleReserves) formatter.merge(balances, token0, reserve0); + } else if (isCoreAsset1) { + formatter.merge(balances, token1, reserve1); + if (nonNeglibleReserves) formatter.merge(balances, token1, reserve1); + } + }); + + return balances; + } + + async getBlockNumber() { + const client = new AptosClient(nodeUrl); + const ledgerInfo = await client.getLedgerInfo(); + return ledgerInfo.block_height; + } + + async getBlock(blockNumber) { + const client = new AptosClient(nodeUrl); + const ledgerInfo = await client.getBlockByHeight(blockNumber); + return { + timestamp: ledgerInfo.block_timestamp, + number: ledgerInfo.block_height, + }; + } +} diff --git a/src/web3Provider/web3Provider.module.ts b/src/web3Provider/web3Provider.module.ts index 853b01b1..fbd8bfff 100644 --- a/src/web3Provider/web3Provider.module.ts +++ b/src/web3Provider/web3Provider.module.ts @@ -7,6 +7,7 @@ import { Stacks } from './stacks'; import { Near } from './near'; import { Tezos } from './tezos'; import { Wax } from './wax'; +import { Aptos } from './aptos'; @Module({ exports: [Web3ProviderService], @@ -19,6 +20,7 @@ import { Wax } from './wax'; Stacks, Tezos, Wax, + Aptos, ], }) export class Web3ProviderModule {} diff --git a/src/web3Provider/web3Provider.service.ts b/src/web3Provider/web3Provider.service.ts index cb251788..cf05ed1b 100644 --- a/src/web3Provider/web3Provider.service.ts +++ b/src/web3Provider/web3Provider.service.ts @@ -8,6 +8,7 @@ import { Stacks } from './stacks'; import { Tezos } from './tezos'; import Web3 from 'web3'; import { Wax } from './wax'; +import { Aptos } from './aptos'; const webSocketConfig = { timeout: 60000, @@ -36,6 +37,7 @@ export class Web3ProviderService { private readonly stacks: Stacks, private readonly tezos: Tezos, private readonly wax: Wax, + private readonly aptos: Aptos, ) {} async getWeb3(chain = 'ethereum') { @@ -54,6 +56,7 @@ export class Web3ProviderService { nodeUrls[`ETHEREUM_NODE_URL`]); let web3; + console.log(nodeUrls[`${chain.toUpperCase()}_NODE_URL`]); switch (chain) { case 'everscale': { web3 = { eth: this.everscale }; @@ -80,6 +83,10 @@ export class Web3ProviderService { web3 = { eth: this.stacks }; break; } + case 'aptos': { + web3 = { eth: this.aptos }; + break; + } case 'tezos': { web3 = { eth: this.tezos }; await web3.eth.onModuleInit();