diff --git a/constants/CacheSettings.js b/constants/CacheSettings.js new file mode 100644 index 00000000..612cb2d7 --- /dev/null +++ b/constants/CacheSettings.js @@ -0,0 +1,22 @@ +/** + * Global cache settings: + * - `minTimeToStale` is the number of milliseconds until a cache entry is considered + * stale, and is then refreshed + * - `maxTimeToLive` is the number of milliseconds until a cache entry is considered + * expired (by opposition to *stale*): if considered expired, it will not be returned, + * it will be refreshed instead and will only return after this fresh invocation + * + * Our node-side swr utility bases its behavior on both those props. They can both be + * overridden in individual swr calls (in practice, `minTimeToStale` is most overridden + * the most often). + * Redis only uses `maxTimeToLive` as its `expiry` prop. + */ + +const CACHE_SETTINGS = { + minTimeToStale: 30 * 1000, // 30s + maxTimeToLive: 24 * 60 * 60 * 1000, // 1d + serialize: JSON.stringify, // serialize product object to string + deserialize: JSON.parse, // deserialize cached product string to object +}; + +export default CACHE_SETTINGS; diff --git a/package-lock.json b/package-lock.json index cf18fa04..c0ca6107 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "form-urlencoded": "^6.0.4", "graphql": "^15.5.1", "graphql-request": "^6.1.0", + "ioredis": "^5.3.2", "lodash.groupby": "^4.6.0", "lodash.partition": "^4.6.0", "lodash.uniq": "^4.5.0", @@ -24,6 +25,7 @@ "next": "12.1.0", "react": "^17.0.2", "react-dom": "^17.0.2", + "stale-while-revalidate-cache": "^3.2.1", "web3": "^1.3.4" }, "devDependencies": { @@ -1357,6 +1359,11 @@ "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, + "node_modules/@ioredis/commands": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", + "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==" + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -2337,6 +2344,14 @@ "mimic-response": "^1.0.0" } }, + "node_modules/cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -2667,6 +2682,14 @@ "node": ">=0.4.0" } }, + "node_modules/denque": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", + "engines": { + "node": ">=0.10" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -2769,6 +2792,17 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, + "node_modules/emittery": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.9.2.tgz", + "integrity": "sha512-sweWHu3j4dQm+NjLPu17pv+m5lCeK7g4Ov0NgfbRUEyzLc59DYDeRYXqlxEvuolaToI0VR3ThjFAghzl7Acjfw==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -4407,6 +4441,50 @@ "node": ">= 0.4" } }, + "node_modules/ioredis": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.3.2.tgz", + "integrity": "sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA==", + "dependencies": { + "@ioredis/commands": "^1.1.1", + "cluster-key-slot": "^1.1.0", + "debug": "^4.3.4", + "denque": "^2.1.0", + "lodash.defaults": "^4.2.0", + "lodash.isarguments": "^3.1.0", + "redis-errors": "^1.2.0", + "redis-parser": "^3.0.0", + "standard-as-callback": "^2.1.0" + }, + "engines": { + "node": ">=12.22.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/ioredis" + } + }, + "node_modules/ioredis/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/ioredis/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -4880,11 +4958,21 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "node_modules/lodash.defaults": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==" + }, "node_modules/lodash.groupby": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.groupby/-/lodash.groupby-4.6.0.tgz", "integrity": "sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E=" }, + "node_modules/lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==" + }, "node_modules/lodash.partition": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.partition/-/lodash.partition-4.6.0.tgz", @@ -5934,6 +6022,25 @@ "node": ">= 6" } }, + "node_modules/redis-errors": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", + "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", + "engines": { + "node": ">=4" + } + }, + "node_modules/redis-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", + "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", + "dependencies": { + "redis-errors": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/regenerator-runtime": { "version": "0.13.7", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", @@ -6409,6 +6516,22 @@ "node": ">=0.10.0" } }, + "node_modules/stale-while-revalidate-cache": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/stale-while-revalidate-cache/-/stale-while-revalidate-cache-3.2.1.tgz", + "integrity": "sha512-8wP7p55klckP1GrInakugfsHPBqJOhMGo26rJUwDYMyomfKbZoHWIuJKs63ikYAchHJnjG/BuVeBjPqgMmjklA==", + "dependencies": { + "emittery": "^0.9.2" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/standard-as-callback": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", + "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -8447,6 +8570,11 @@ "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==", "requires": {} }, + "@ioredis/commands": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", + "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==" + }, "@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -9175,6 +9303,11 @@ "mimic-response": "^1.0.0" } }, + "cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==" + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -9453,6 +9586,11 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, + "denque": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==" + }, "depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -9549,6 +9687,11 @@ } } }, + "emittery": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.9.2.tgz", + "integrity": "sha512-sweWHu3j4dQm+NjLPu17pv+m5lCeK7g4Ov0NgfbRUEyzLc59DYDeRYXqlxEvuolaToI0VR3ThjFAghzl7Acjfw==" + }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -10852,6 +10995,37 @@ "side-channel": "^1.0.4" } }, + "ioredis": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.3.2.tgz", + "integrity": "sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA==", + "requires": { + "@ioredis/commands": "^1.1.1", + "cluster-key-slot": "^1.1.0", + "debug": "^4.3.4", + "denque": "^2.1.0", + "lodash.defaults": "^4.2.0", + "lodash.isarguments": "^3.1.0", + "redis-errors": "^1.2.0", + "redis-parser": "^3.0.0", + "standard-as-callback": "^2.1.0" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -11194,11 +11368,21 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "lodash.defaults": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==" + }, "lodash.groupby": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.groupby/-/lodash.groupby-4.6.0.tgz", "integrity": "sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E=" }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==" + }, "lodash.partition": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.partition/-/lodash.partition-4.6.0.tgz", @@ -12018,6 +12202,19 @@ "util-deprecate": "^1.0.1" } }, + "redis-errors": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", + "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==" + }, + "redis-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", + "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", + "requires": { + "redis-errors": "^1.0.0" + } + }, "regenerator-runtime": { "version": "0.13.7", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", @@ -12382,6 +12579,19 @@ "tweetnacl": "~0.14.0" } }, + "stale-while-revalidate-cache": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/stale-while-revalidate-cache/-/stale-while-revalidate-cache-3.2.1.tgz", + "integrity": "sha512-8wP7p55klckP1GrInakugfsHPBqJOhMGo26rJUwDYMyomfKbZoHWIuJKs63ikYAchHJnjG/BuVeBjPqgMmjklA==", + "requires": { + "emittery": "^0.9.2" + } + }, + "standard-as-callback": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", + "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" + }, "statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", diff --git a/package.json b/package.json index 2b992060..c0c6932f 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "form-urlencoded": "^6.0.4", "graphql": "^15.5.1", "graphql-request": "^6.1.0", + "ioredis": "^5.3.2", "lodash.groupby": "^4.6.0", "lodash.partition": "^4.6.0", "lodash.uniq": "^4.5.0", @@ -24,6 +25,7 @@ "next": "12.1.0", "react": "^17.0.2", "react-dom": "^17.0.2", + "stale-while-revalidate-cache": "^3.2.1", "web3": "^1.3.4" }, "devDependencies": { diff --git a/pages/api/getAllGauges.js b/pages/api/getAllGauges.js index 49abdf6b..b31bef69 100644 --- a/pages/api/getAllGauges.js +++ b/pages/api/getAllGauges.js @@ -14,7 +14,7 @@ import Web3 from 'web3'; import partition from 'lodash.partition'; import configs from 'constants/configs'; -import getFactoGauges from 'pages/api/getFactoGauges'; +import getFactoGaugesFn from 'pages/api/getFactoGauges/[blockchainId]'; import { fn } from 'utils/api'; import { multiCall } from 'utils/Calls'; import getAllCurvePoolsData from 'utils/data/curve-pools-data'; @@ -84,7 +84,6 @@ const getPoolShortName = (pool) => { }; export default fn(async ({ blockchainId } = {}) => { - console.log('getAllGauges CALL', blockchainId) const chainsToQuery = SIDECHAINS_WITH_FACTORY_GAUGES; const blockchainIds = [ 'ethereum', @@ -369,7 +368,7 @@ export default fn(async ({ blockchainId } = {}) => { */ const factoGauges = await sequentialPromiseMap(blockchainIds, (blockchainIdsChunk) => ( Promise.all(blockchainIdsChunk.map((blockchainId) => ( - getFactoGauges.straightCall({ blockchainId }).then(({ gauges }) => ( + getFactoGaugesFn.straightCall({ blockchainId }).then(({ gauges }) => ( gauges.map((gaugeData) => ({ ...gaugeData, blockchainId, @@ -456,5 +455,5 @@ export default fn(async ({ blockchainId } = {}) => { return gauges; }, { maxAge: 5 * 60, - name: 'getAllGauges', + cacheKey: ({ blockchainId }) => `getAllGauges-${blockchainId}`, }); diff --git a/pages/api/getFactoGauges/[blockchainId].js b/pages/api/getFactoGauges/[blockchainId].js index 1c3e5209..52115577 100644 --- a/pages/api/getFactoGauges/[blockchainId].js +++ b/pages/api/getFactoGauges/[blockchainId].js @@ -1,8 +1,301 @@ -import { fn } from 'utils/api'; -import getFactoGaugesApiFn from './index'; +import Web3 from 'web3'; +import uniq from 'lodash.uniq'; +import { NotFoundError, fn } from 'utils/api'; +import GAUGE_REGISTRY_ABI from 'constants/abis/gauge-registry.json'; +import GAUGE_REGISTRY_SIDECHAIN_ABI from 'constants/abis/gauge-registry-sidechain.json'; +import GAUGE_FACTORY_ABI from 'constants/abis/gauge-factory-sidechain.json'; +import sideChainGauge from 'constants/abis/sidechain-gauge.json'; +import sideChainRootGauge from 'constants/abis/sidechain-root-gauge.json'; +import gaugeControllerAbi from 'constants/abis/gauge_controller.json'; +import factorypool3Abi from 'constants/abis/factory_swap.json'; +import { multiCall } from 'utils/Calls'; +import { lc } from 'utils/String'; +import { arrayToHashmap, arrayOfIncrements, flattenArray } from 'utils/Array'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; +import configs from 'constants/configs'; +import getFactoryV2SidechainGaugeRewards from 'utils/data/getFactoryV2SidechainGaugeRewards'; -export default fn(async ({ blockchainId }) => ( - getFactoGaugesApiFn.straightCall({ blockchainId }) -), { - maxAge: 60, +export default fn(async ({ blockchainId }) => { + if (typeof blockchainId === 'undefined') blockchainId = 'ethereum'; // Default value + + if (blockchainId === 'ethereum') { + return { + gauges: [], + }; + } + + const config = configs[blockchainId]; + const configEth = configs.ethereum; + + if (typeof config === 'undefined') { + throw new NotFoundError(`No factory data for blockchainId "${blockchainId}"`); + } + if (!config.chainId) { + throw new NotFoundError(`Missing chain id in config for "${blockchainId}"`); + } + + const web3 = new Web3(configEth.rpcUrl); + const web3Side = new Web3(config.rpcUrl); + + const gaugeRegistryAddress = '0xabc000d88f23bb45525e447528dbf656a9d55bf5'; + const gaugeRegistry = new web3.eth.Contract(GAUGE_REGISTRY_ABI, gaugeRegistryAddress); + const gaugeRegistrySidechain = new web3Side.eth.Contract(GAUGE_REGISTRY_SIDECHAIN_ABI, gaugeRegistryAddress); + + const [mirroredGaugeCount, unmirroredGaugeCount] = await Promise.all([ + gaugeRegistry.methods.get_gauge_count(config.chainId).call(), + gaugeRegistrySidechain.methods.get_gauge_count().call(), + ]); + if (Number(mirroredGaugeCount) === 0 && Number(unmirroredGaugeCount) === 0) { + return { + gauges: [], + }; + } + + const unfilteredMirroredGaugeList = await multiCall(arrayOfIncrements(mirroredGaugeCount).map((gaugeIndex) => ({ + address: gaugeRegistryAddress, + abi: GAUGE_REGISTRY_ABI, + methodName: 'get_gauge', + params: [config.chainId, gaugeIndex], + }))); + + const unfilteredUnmirroredGaugeList = await multiCall(arrayOfIncrements(unmirroredGaugeCount).map((gaugeIndex) => ({ + address: gaugeRegistryAddress, + abi: GAUGE_REGISTRY_SIDECHAIN_ABI, + methodName: 'get_gauge', + params: [gaugeIndex], + networkSettings: { web3: web3Side, multicall2Address: config.multicall2Address }, + }))); + + const unfilteredGaugeList = uniq([ + ...unfilteredMirroredGaugeList, + ...unfilteredUnmirroredGaugeList, + ]); + + const gaugesKilledInfo = await multiCall(unfilteredGaugeList.map((gaugeAddress) => ({ + address: gaugeAddress, + abi: sideChainRootGauge, + methodName: 'is_killed', + }))); + + const gaugeList = unfilteredGaugeList; + + const weekSeconds = 86400 * 7; + const nowTs = +Date.now() / 1000; + const startOfWeekTs = Math.trunc(nowTs / weekSeconds); + const endOfWeekTs = (startOfWeekTs + 1) * weekSeconds; + + /** + * Root gauges with emissions meant for their side gauge, but not passed on to it yet + * (will be passed to side gauge as soon as someone interacts with it). We thus + * use those pending emissions as the basis to calculate apys for this side gauge. + */ + const pendingEmissionsRaw = await multiCall(gaugeList.map((gaugeAddress) => ({ + address: gaugeAddress, + abi: sideChainRootGauge, + methodName: 'total_emissions', + metaData: { gaugeAddress }, + networkSettings: { web3, multicall2Address: configs.ethereum.multicall2Address }, + }))); + const pendingEmissions = arrayToHashmap(pendingEmissionsRaw.map(({ data, metaData }) => { + const inflationRate = data / (endOfWeekTs - nowTs); + + return [ + metaData.gaugeAddress, + inflationRate, + ]; + })); + + const gaugesDataFromSidechain = await multiCall(flattenArray(gaugeList.map((gaugeAddress) => { + const baseConfigData = { + address: gaugeAddress, + abi: sideChainGauge, + networkSettings: { web3: web3Side, multicall2Address: config.multicall2Address }, + }; + + return [{ + ...baseConfigData, + methodName: 'lp_token', + metaData: { gaugeAddress, type: 'lpTokenAddress' }, + }, { + ...baseConfigData, + methodName: 'name', + metaData: { gaugeAddress, type: 'name' }, + }, { + ...baseConfigData, + methodName: 'symbol', + metaData: { gaugeAddress, type: 'symbol' }, + }, { + ...baseConfigData, + methodName: 'working_supply', + metaData: { gaugeAddress, type: 'workingSupply' }, + }, { + ...baseConfigData, + methodName: 'totalSupply', + metaData: { gaugeAddress, type: 'totalSupply' }, + }, { + ...baseConfigData, + methodName: 'inflation_rate', + params: [startOfWeekTs], + metaData: { gaugeAddress, type: 'inflationRate' }, + }, { + address: gaugeRegistryAddress, + abi: GAUGE_FACTORY_ABI, + methodName: 'is_mirrored', + params: [gaugeAddress], + metaData: { gaugeAddress, type: 'isMirrored' }, + }, { + address: gaugeRegistryAddress, + abi: GAUGE_FACTORY_ABI, + methodName: 'last_request', + params: [gaugeAddress], + metaData: { gaugeAddress, type: 'lastRequest' }, + }]; + }))); + + const gaugeControllerAddress = '0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB'; + const gaugesDataFromMainnet = await multiCall(flattenArray(gaugeList.map((gaugeAddress) => { + const baseConfigData = { + address: gaugeControllerAddress, + abi: gaugeControllerAbi, + }; + + return [{ + ...baseConfigData, + methodName: 'gauge_types', + params: [gaugeAddress], + metaData: { gaugeAddress, type: 'hasCrv' }, + superSettings: { returnSuccessState: true }, + }, { + ...baseConfigData, + methodName: 'gauge_relative_weight', + params: [gaugeAddress], + metaData: { gaugeAddress, type: 'gaugeRelativeWeight' }, + }, { + ...baseConfigData, + methodName: 'get_gauge_weight', + params: [gaugeAddress], + metaData: { gaugeAddress, type: 'getGaugeWeight' }, + }]; + }))); + + const gaugesData = gaugeList.map((gaugeAddress) => { + const gaugeDataFromSidechain = gaugesDataFromSidechain.filter(({ metaData }) => metaData.gaugeAddress === gaugeAddress); + const gaugeDataFromMainnet = gaugesDataFromMainnet.filter(({ metaData }) => metaData.gaugeAddress === gaugeAddress); + + return { + address: gaugeAddress, + ...arrayToHashmap(gaugeDataFromSidechain.map(({ data, metaData: { type } }) => [ + type, + data, + ])), + ...arrayToHashmap(gaugeDataFromMainnet.map(({ data, metaData: { type } }) => [ + type, + data, + ])), + }; + }); + + const allPools = await getAllCurvePoolsData([blockchainId]); + + const gaugesDataWithPoolAddressAndType = gaugesData.map((gaugeData) => { + const pool = allPools.find(({ lpTokenAddress, address }) => ( + lc(lpTokenAddress) === lc(gaugeData.lpTokenAddress) || + lc(address) === lc(gaugeData.lpTokenAddress) + )); + + if (typeof pool === 'undefined') return null; + + return { + ...gaugeData, + poolAddress: pool.address, + lpTokenPrice: ( + pool.usdTotal / + (pool.totalSupply / 1e18) + ), + type: ((pool.registryId === 'main' || pool.registryId === 'factory') ? 'stable' : 'crypto'), + registryId: pool.registryId, + }; + }).filter((o) => o !== null); + + const poolsVirtualPrices = await multiCall(gaugesDataWithPoolAddressAndType.map(({ poolAddress }) => ({ + address: poolAddress, + abi: factorypool3Abi, + methodName: 'get_virtual_price', + networkSettings: { web3: web3Side, multicall2Address: config.multicall2Address }, + }))); + + const gaugesDataWithPoolVprice = gaugesDataWithPoolAddressAndType.map((gaugeData, index) => ({ + ...gaugeData, + poolVirtualPrice: poolsVirtualPrices[index], + })); + + // Map to the historical data structure for compatibility purposes + const formattedGaugesData = gaugesDataWithPoolVprice.map(({ + address, + lpTokenAddress, + name, + symbol, + workingSupply, + totalSupply, + inflationRate, + hasCrv, + gaugeRelativeWeight, + getGaugeWeight, + poolAddress, + type, + lpTokenPrice, + poolVirtualPrice, + isMirrored, + lastRequest, + }) => { + const effectiveInflationRate = Number(inflationRate) || (getGaugeWeight > 0 ? pendingEmissions[address] : 0); + const rewardsNeedNudging = ( + hasCrv && + effectiveInflationRate > 0 && + isMirrored && + Math.trunc(lastRequest / weekSeconds) !== startOfWeekTs + ); + + return { + swap_token: lpTokenAddress, + gauge: address, + name, + symbol, + hasCrv, + side_chain: true, + type, + gauge_data: { + working_supply: workingSupply, + totalSupply, + gauge_relative_weight: gaugeRelativeWeight, + get_gauge_weight: getGaugeWeight, + inflation_rate: effectiveInflationRate, + }, + swap_data: { + virtual_price: poolVirtualPrice, + }, + lpTokenPrice, + swap: poolAddress, + rewardsNeedNudging, + areCrvRewardsStuckInBridge: ( + effectiveInflationRate > 0 && + Number(inflationRate) === 0 && + !rewardsNeedNudging + ), + isKilled: gaugesKilledInfo[unfilteredGaugeList.findIndex((gaugeAddress) => lc(gaugeAddress) === lc(address))], + }; + }); + + const sideGaugesRewards = await getFactoryV2SidechainGaugeRewards({ blockchainId, gauges: formattedGaugesData }); + + return { + gauges: formattedGaugesData.map(({ gauge, ...rest }) => ({ + gauge, + ...rest, + extraRewards: (sideGaugesRewards[gauge.toLowerCase()] || []), + })), + }; +}, { + maxAge: 2 * 60, + cacheKey: ({ blockchainId }) => `getFactoGauges-${blockchainId}`, }); diff --git a/pages/api/getFactoGauges/index.js b/pages/api/getFactoGauges/index.js deleted file mode 100644 index 9d8bed84..00000000 --- a/pages/api/getFactoGauges/index.js +++ /dev/null @@ -1,301 +0,0 @@ -import Web3 from 'web3'; -import uniq from 'lodash.uniq'; -import { NotFoundError, fn } from 'utils/api'; -import GAUGE_REGISTRY_ABI from 'constants/abis/gauge-registry.json'; -import GAUGE_REGISTRY_SIDECHAIN_ABI from 'constants/abis/gauge-registry-sidechain.json'; -import GAUGE_FACTORY_ABI from 'constants/abis/gauge-factory-sidechain.json'; -import sideChainGauge from 'constants/abis/sidechain-gauge.json'; -import sideChainRootGauge from 'constants/abis/sidechain-root-gauge.json'; -import gaugeControllerAbi from 'constants/abis/gauge_controller.json'; -import factorypool3Abi from 'constants/abis/factory_swap.json'; -import { multiCall } from 'utils/Calls'; -import { lc } from 'utils/String'; -import { arrayToHashmap, arrayOfIncrements, flattenArray } from 'utils/Array'; -import getAllCurvePoolsData from 'utils/data/curve-pools-data'; -import configs from 'constants/configs'; -import getFactoryV2SidechainGaugeRewards from 'utils/data/getFactoryV2SidechainGaugeRewards'; - -export default fn(async ({ blockchainId }) => { - if (typeof blockchainId === 'undefined') blockchainId = 'ethereum'; // Default value - - if (blockchainId === 'ethereum') { - return { - gauges: [], - }; - } - - const config = configs[blockchainId]; - const configEth = configs.ethereum; - - if (typeof config === 'undefined') { - throw new NotFoundError(`No factory data for blockchainId "${blockchainId}"`); - } - if (!config.chainId) { - throw new NotFoundError(`Missing chain id in config for "${blockchainId}"`); - } - - const web3 = new Web3(configEth.rpcUrl); - const web3Side = new Web3(config.rpcUrl); - - const gaugeRegistryAddress = '0xabc000d88f23bb45525e447528dbf656a9d55bf5'; - const gaugeRegistry = new web3.eth.Contract(GAUGE_REGISTRY_ABI, gaugeRegistryAddress); - const gaugeRegistrySidechain = new web3Side.eth.Contract(GAUGE_REGISTRY_SIDECHAIN_ABI, gaugeRegistryAddress); - - const [mirroredGaugeCount, unmirroredGaugeCount] = await Promise.all([ - gaugeRegistry.methods.get_gauge_count(config.chainId).call(), - gaugeRegistrySidechain.methods.get_gauge_count().call(), - ]); - if (Number(mirroredGaugeCount) === 0 && Number(unmirroredGaugeCount) === 0) { - return { - gauges: [], - }; - } - - const unfilteredMirroredGaugeList = await multiCall(arrayOfIncrements(mirroredGaugeCount).map((gaugeIndex) => ({ - address: gaugeRegistryAddress, - abi: GAUGE_REGISTRY_ABI, - methodName: 'get_gauge', - params: [config.chainId, gaugeIndex], - }))); - - const unfilteredUnmirroredGaugeList = await multiCall(arrayOfIncrements(unmirroredGaugeCount).map((gaugeIndex) => ({ - address: gaugeRegistryAddress, - abi: GAUGE_REGISTRY_SIDECHAIN_ABI, - methodName: 'get_gauge', - params: [gaugeIndex], - networkSettings: { web3: web3Side, multicall2Address: config.multicall2Address }, - }))); - - const unfilteredGaugeList = uniq([ - ...unfilteredMirroredGaugeList, - ...unfilteredUnmirroredGaugeList, - ]); - - const gaugesKilledInfo = await multiCall(unfilteredGaugeList.map((gaugeAddress) => ({ - address: gaugeAddress, - abi: sideChainRootGauge, - methodName: 'is_killed', - }))); - - const gaugeList = unfilteredGaugeList; - - const weekSeconds = 86400 * 7; - const nowTs = +Date.now() / 1000; - const startOfWeekTs = Math.trunc(nowTs / weekSeconds); - const endOfWeekTs = (startOfWeekTs + 1) * weekSeconds; - - /** - * Root gauges with emissions meant for their side gauge, but not passed on to it yet - * (will be passed to side gauge as soon as someone interacts with it). We thus - * use those pending emissions as the basis to calculate apys for this side gauge. - */ - const pendingEmissionsRaw = await multiCall(gaugeList.map((gaugeAddress) => ({ - address: gaugeAddress, - abi: sideChainRootGauge, - methodName: 'total_emissions', - metaData: { gaugeAddress }, - networkSettings: { web3, multicall2Address: configs.ethereum.multicall2Address }, - }))); - const pendingEmissions = arrayToHashmap(pendingEmissionsRaw.map(({ data, metaData }) => { - const inflationRate = data / (endOfWeekTs - nowTs); - - return [ - metaData.gaugeAddress, - inflationRate, - ]; - })); - - const gaugesDataFromSidechain = await multiCall(flattenArray(gaugeList.map((gaugeAddress) => { - const baseConfigData = { - address: gaugeAddress, - abi: sideChainGauge, - networkSettings: { web3: web3Side, multicall2Address: config.multicall2Address }, - }; - - return [{ - ...baseConfigData, - methodName: 'lp_token', - metaData: { gaugeAddress, type: 'lpTokenAddress' }, - }, { - ...baseConfigData, - methodName: 'name', - metaData: { gaugeAddress, type: 'name' }, - }, { - ...baseConfigData, - methodName: 'symbol', - metaData: { gaugeAddress, type: 'symbol' }, - }, { - ...baseConfigData, - methodName: 'working_supply', - metaData: { gaugeAddress, type: 'workingSupply' }, - }, { - ...baseConfigData, - methodName: 'totalSupply', - metaData: { gaugeAddress, type: 'totalSupply' }, - }, { - ...baseConfigData, - methodName: 'inflation_rate', - params: [startOfWeekTs], - metaData: { gaugeAddress, type: 'inflationRate' }, - }, { - address: gaugeRegistryAddress, - abi: GAUGE_FACTORY_ABI, - methodName: 'is_mirrored', - params: [gaugeAddress], - metaData: { gaugeAddress, type: 'isMirrored' }, - }, { - address: gaugeRegistryAddress, - abi: GAUGE_FACTORY_ABI, - methodName: 'last_request', - params: [gaugeAddress], - metaData: { gaugeAddress, type: 'lastRequest' }, - }]; - }))); - - const gaugeControllerAddress = '0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB'; - const gaugesDataFromMainnet = await multiCall(flattenArray(gaugeList.map((gaugeAddress) => { - const baseConfigData = { - address: gaugeControllerAddress, - abi: gaugeControllerAbi, - }; - - return [{ - ...baseConfigData, - methodName: 'gauge_types', - params: [gaugeAddress], - metaData: { gaugeAddress, type: 'hasCrv' }, - superSettings: { returnSuccessState: true }, - }, { - ...baseConfigData, - methodName: 'gauge_relative_weight', - params: [gaugeAddress], - metaData: { gaugeAddress, type: 'gaugeRelativeWeight' }, - }, { - ...baseConfigData, - methodName: 'get_gauge_weight', - params: [gaugeAddress], - metaData: { gaugeAddress, type: 'getGaugeWeight' }, - }]; - }))); - - const gaugesData = gaugeList.map((gaugeAddress) => { - const gaugeDataFromSidechain = gaugesDataFromSidechain.filter(({ metaData }) => metaData.gaugeAddress === gaugeAddress); - const gaugeDataFromMainnet = gaugesDataFromMainnet.filter(({ metaData }) => metaData.gaugeAddress === gaugeAddress); - - return { - address: gaugeAddress, - ...arrayToHashmap(gaugeDataFromSidechain.map(({ data, metaData: { type } }) => [ - type, - data, - ])), - ...arrayToHashmap(gaugeDataFromMainnet.map(({ data, metaData: { type } }) => [ - type, - data, - ])), - }; - }); - - const allPools = await getAllCurvePoolsData([blockchainId]); - - const gaugesDataWithPoolAddressAndType = gaugesData.map((gaugeData) => { - const pool = allPools.find(({ lpTokenAddress, address }) => ( - lc(lpTokenAddress) === lc(gaugeData.lpTokenAddress) || - lc(address) === lc(gaugeData.lpTokenAddress) - )); - - if (typeof pool === 'undefined') return null; - - return { - ...gaugeData, - poolAddress: pool.address, - lpTokenPrice: ( - pool.usdTotal / - (pool.totalSupply / 1e18) - ), - type: ((pool.registryId === 'main' || pool.registryId === 'factory') ? 'stable' : 'crypto'), - registryId: pool.registryId, - }; - }).filter((o) => o !== null); - - const poolsVirtualPrices = await multiCall(gaugesDataWithPoolAddressAndType.map(({ poolAddress }) => ({ - address: poolAddress, - abi: factorypool3Abi, - methodName: 'get_virtual_price', - networkSettings: { web3: web3Side, multicall2Address: config.multicall2Address }, - }))); - - const gaugesDataWithPoolVprice = gaugesDataWithPoolAddressAndType.map((gaugeData, index) => ({ - ...gaugeData, - poolVirtualPrice: poolsVirtualPrices[index], - })); - - // Map to the historical data structure for compatibility purposes - const formattedGaugesData = gaugesDataWithPoolVprice.map(({ - address, - lpTokenAddress, - name, - symbol, - workingSupply, - totalSupply, - inflationRate, - hasCrv, - gaugeRelativeWeight, - getGaugeWeight, - poolAddress, - type, - lpTokenPrice, - poolVirtualPrice, - isMirrored, - lastRequest, - }) => { - const effectiveInflationRate = Number(inflationRate) || (getGaugeWeight > 0 ? pendingEmissions[address] : 0); - const rewardsNeedNudging = ( - hasCrv && - effectiveInflationRate > 0 && - isMirrored && - Math.trunc(lastRequest / weekSeconds) !== startOfWeekTs - ); - - return { - swap_token: lpTokenAddress, - gauge: address, - name, - symbol, - hasCrv, - side_chain: true, - type, - gauge_data: { - working_supply: workingSupply, - totalSupply, - gauge_relative_weight: gaugeRelativeWeight, - get_gauge_weight: getGaugeWeight, - inflation_rate: effectiveInflationRate, - }, - swap_data: { - virtual_price: poolVirtualPrice, - }, - lpTokenPrice, - swap: poolAddress, - rewardsNeedNudging, - areCrvRewardsStuckInBridge: ( - effectiveInflationRate > 0 && - Number(inflationRate) === 0 && - !rewardsNeedNudging - ), - isKilled: gaugesKilledInfo[unfilteredGaugeList.findIndex((gaugeAddress) => lc(gaugeAddress) === lc(address))], - }; - }); - - const sideGaugesRewards = await getFactoryV2SidechainGaugeRewards({ blockchainId, gauges: formattedGaugesData }); - - return { - gauges: formattedGaugesData.map(({ gauge, ...rest }) => ({ - gauge, - ...rest, - extraRewards: (sideGaugesRewards[gauge.toLowerCase()] || []), - })), - }; -}, { - maxAge: 60, - name: 'getFactoGauges', -}); diff --git a/pages/api/getFactoGaugesCrvRewards/index.js b/pages/api/getFactoGaugesCrvRewards/index.js index 3b60e394..d6c98291 100644 --- a/pages/api/getFactoGaugesCrvRewards/index.js +++ b/pages/api/getFactoGaugesCrvRewards/index.js @@ -5,8 +5,8 @@ import { fn } from 'utils/api'; import getAssetsPrices from 'utils/data/assets-prices'; -import getFactoGauges from 'pages/api/getFactoGauges'; -import getPools from 'pages/api/getPools'; +import getFactoGauges from 'pages/api/getFactoGauges/[blockchainId]'; +import getPools from 'pages/api/getPools/[blockchainId]/[registryId]'; import configs from 'constants/configs'; import { lc } from 'utils/String'; import getAllCurvePoolsData from 'utils/data/curve-pools-data'; diff --git a/pages/api/getFactoryAPYs-base.js b/pages/api/getFactoryAPYs-base.js index 8bad4a15..b73fe4fe 100644 --- a/pages/api/getFactoryAPYs-base.js +++ b/pages/api/getFactoryAPYs-base.js @@ -10,7 +10,7 @@ import Web3 from 'web3'; import BigNumber from 'big-number'; import { BASE_API_DOMAIN } from 'constants/AppConstants'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import configs from 'constants/configs'; import { fn } from 'utils/api'; import getAllCurvePoolsData from 'utils/data/curve-pools-data'; diff --git a/pages/api/getFactoryAPYs-bsc.js b/pages/api/getFactoryAPYs-bsc.js index 1f615a80..d268cb69 100644 --- a/pages/api/getFactoryAPYs-bsc.js +++ b/pages/api/getFactoryAPYs-bsc.js @@ -10,7 +10,7 @@ import Web3 from 'web3'; import BigNumber from 'big-number'; import { BASE_API_DOMAIN } from 'constants/AppConstants'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import configs from 'constants/configs'; import { fn } from 'utils/api'; import getAllCurvePoolsData from 'utils/data/curve-pools-data'; diff --git a/pages/api/getFactoryAPYs-celo.js b/pages/api/getFactoryAPYs-celo.js index a221e5c7..20869e23 100644 --- a/pages/api/getFactoryAPYs-celo.js +++ b/pages/api/getFactoryAPYs-celo.js @@ -10,7 +10,7 @@ import Web3 from 'web3'; import BigNumber from 'big-number'; import { BASE_API_DOMAIN } from 'constants/AppConstants'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import configs from 'constants/configs'; import { fn } from 'utils/api'; import registryAbi from 'constants/abis/factory_registry.json'; @@ -25,8 +25,8 @@ export default fn(async (query) => { let registryAddress = await config.getFactoryRegistryAddress(); let multicallAddress = config.multicallAddress; - let registry = new web3.eth.Contract(registryAbi, registryAddress); - let multicall = new web3.eth.Contract(multicallAbi, multicallAddress) + let registry = new web3.eth.Contract(registryAbi, registryAddress); + let multicall = new web3.eth.Contract(multicallAbi, multicallAddress) let res = await getPoolsFn.straightCall({ blockchainId: 'celo', registryId: 'factory' }) let poolDetails = []; let totalVolume = 0 @@ -43,11 +43,11 @@ export default fn(async (query) => { let vPriceOldFetch; let vPriceOldFetchFailed = false; try { - vPriceOldFetch = await poolContract.methods.get_virtual_price().call('', latest - DAY_BLOCKS) + vPriceOldFetch = await poolContract.methods.get_virtual_price().call('', latest - DAY_BLOCKS) } catch (e) { console.error(`Couldn't fetch get_virtual_price for block ${latest - DAY_BLOCKS}: ${e.toString()}`); vPriceOldFetchFailed = true; - vPriceOldFetch = 1 * (10 ** 18) + vPriceOldFetch = 1 * (10 ** 18) } const testPool = pool.address const eventName = 'TokenExchangeUnderlying'; @@ -56,16 +56,16 @@ export default fn(async (query) => { console.log(latest - DAY_BLOCKS, latest, 'blocks') const isMetaPool = ( - pool.implementation?.startsWith('v1metausd') || - pool.implementation?.startsWith('metausd') || - pool.implementation?.startsWith('v1metabtc') || - pool.implementation?.startsWith('metabtc') + pool.implementation?.startsWith('v1metausd') || + pool.implementation?.startsWith('metausd') || + pool.implementation?.startsWith('v1metabtc') || + pool.implementation?.startsWith('metabtc') ); let decimals = ( - version === 1 ? [pool.token.decimals, 18, 18, 18] : - (version === 2 && isMetaPool) ? pool.underlyingDecimals : - pool.decimals + version === 1 ? [pool.token.decimals, 18, 18, 18] : + (version === 2 && isMetaPool) ? pool.underlyingDecimals : + pool.decimals ); let volume = 0; @@ -84,16 +84,16 @@ export default fn(async (query) => { if (version == '2') { - let events2 = await poolContract.getPastEvents(eventName2, { - filter: {}, // Using an array means OR: e.g. 20 or 23 - fromBlock: latest - DAY_BLOCKS, - toBlock: 'latest' - }) + let events2 = await poolContract.getPastEvents(eventName2, { + filter: {}, // Using an array means OR: e.g. 20 or 23 + fromBlock: latest - DAY_BLOCKS, + toBlock: 'latest' + }) - events2.map((trade) => { - let t = trade.returnValues[2] / 10 ** decimals[trade.returnValues[1]] - volume += t - }) + events2.map((trade) => { + let t = trade.returnValues[2] / 10 ** decimals[trade.returnValues[1]] + volume += t + }) } @@ -104,9 +104,9 @@ export default fn(async (query) => { let vPriceFetch try { - vPriceFetch = await poolContract.methods.get_virtual_price().call() + vPriceFetch = await poolContract.methods.get_virtual_price().call() } catch (e) { - vPriceFetch = 1 * (10 ** 18) + vPriceFetch = 1 * (10 ** 18) } let vPrice = vPriceOldFetchFailed ? vPriceFetch : vPriceOldFetch @@ -116,19 +116,19 @@ export default fn(async (query) => { totalVolume += correctedVolume let p = { - index, - 'poolAddress' : pool.address, - 'poolSymbol' : version === 1 ? pool.token.symbol : pool.symbol, - apyFormatted, - apy, - 'virtualPrice':vPriceFetch, - volume: correctedVolume, + index, + 'poolAddress': pool.address, + 'poolSymbol': version === 1 ? pool.token.symbol : pool.symbol, + apyFormatted, + apy, + 'virtualPrice': vPriceFetch, + volume: correctedVolume, } poolDetails.push(p) }) ) - poolDetails.sort((a,b) => (a.index > b.index) ? 1 : ((b.index > a.index) ? -1 : 0)) + poolDetails.sort((a, b) => (a.index > b.index) ? 1 : ((b.index > a.index) ? -1 : 0)) return { poolDetails, totalVolume, latest }; diff --git a/pages/api/getFactoryAPYs-kava.js b/pages/api/getFactoryAPYs-kava.js index b860b472..cc61404c 100644 --- a/pages/api/getFactoryAPYs-kava.js +++ b/pages/api/getFactoryAPYs-kava.js @@ -8,7 +8,7 @@ import Web3 from 'web3'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import configs from 'constants/configs'; import { fn } from 'utils/api'; import factorypool3Abi from 'constants/abis/factory_swap.json'; diff --git a/pages/api/getFactoryAPYs-zkevm.js b/pages/api/getFactoryAPYs-zkevm.js index 6999d912..16c05d7e 100644 --- a/pages/api/getFactoryAPYs-zkevm.js +++ b/pages/api/getFactoryAPYs-zkevm.js @@ -10,7 +10,7 @@ import Web3 from 'web3'; import BigNumber from 'big-number'; import { BASE_API_DOMAIN } from 'constants/AppConstants'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import configs from 'constants/configs'; import { fn } from 'utils/api'; import registryAbi from 'constants/abis/factory_registry.json'; diff --git a/pages/api/getFactoryAPYs-zksync.js b/pages/api/getFactoryAPYs-zksync.js index 130e1fed..86012e91 100644 --- a/pages/api/getFactoryAPYs-zksync.js +++ b/pages/api/getFactoryAPYs-zksync.js @@ -10,7 +10,7 @@ import Web3 from 'web3'; import BigNumber from 'big-number'; import { BASE_API_DOMAIN } from 'constants/AppConstants'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import configs from 'constants/configs'; import { fn } from 'utils/api'; import registryAbi from 'constants/abis/factory_registry.json'; diff --git a/pages/api/getFactoryCryptoPools/index.js b/pages/api/getFactoryCryptoPools/index.js index 10e5d405..2eb129f0 100644 --- a/pages/api/getFactoryCryptoPools/index.js +++ b/pages/api/getFactoryCryptoPools/index.js @@ -1,5 +1,5 @@ import { fn } from 'utils/api'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; export default fn(async ({ blockchainId }) => ( getPoolsFn.straightCall({ blockchainId, registryId: 'factory-crypto' }) diff --git a/pages/api/getFactoryV2Pools/index.js b/pages/api/getFactoryV2Pools/index.js index 57bea309..cf8d950f 100644 --- a/pages/api/getFactoryV2Pools/index.js +++ b/pages/api/getFactoryV2Pools/index.js @@ -1,5 +1,5 @@ import { fn } from 'utils/api'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; export default fn(async ({ blockchainId }) => ( getPoolsFn.straightCall({ blockchainId, registryId: 'factory' }) diff --git a/pages/api/getGauges.js b/pages/api/getGauges.js index 7c3983ca..3a36a075 100644 --- a/pages/api/getGauges.js +++ b/pages/api/getGauges.js @@ -5,7 +5,7 @@ import Web3 from 'web3'; import WEB3_CONSTANTS from 'constants/Web3'; -import getFactoGauges from 'pages/api/getFactoGauges'; +import getFactoGauges from 'pages/api/getFactoGauges/[blockchainId]'; import { fn } from 'utils/api'; import { arrayToHashmap, flattenArray } from 'utils/Array'; import { sequentialPromiseMap } from 'utils/Async'; @@ -43,1254 +43,1254 @@ export default fn(async ({ blockchainId } = {}) => { let gauges = { - compound: { - swap: '0xA2B47E3D5c44877cca798226B7B8118F9BFb7A56', - swap_token: '0x845838DF265Dcd2c412A1Dc9e959c7d08537f8a2', - name: 'compound', - gauge: '0x7ca5b0a2910B33e9759DC7dDB0413949071D7575', - type: 'stable', - }, - usdt: { - swap: '0x52EA46506B9CC5Ef470C5bf89f17Dc28bB35D85C', - swap_token: '0x9fC689CCaDa600B6DF723D9E47D84d76664a1F23', - name: 'usdt', - gauge: '0xBC89cd85491d81C6AD2954E6d0362Ee29fCa8F53', - type: 'stable', - }, - y: { - swap: '0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51', - swap_token: '0xdF5e0e81Dff6FAF3A7e52BA697820c5e32D806A8', - name: 'y', - gauge: '0xFA712EE4788C042e2B7BB55E6cb8ec569C4530c1', - type: 'stable', - }, - busd: { - swap: '0x79a8C46DeA5aDa233ABaFFD40F3A0A2B1e5A4F27', - swap_token: '0x3B3Ac5386837Dc563660FB6a0937DFAa5924333B', - name: 'busd', - gauge: '0x69Fb7c45726cfE2baDeE8317005d3F94bE838840', - type: 'stable', - }, - susdv2: { - swap: '0xA5407eAE9Ba41422680e2e00537571bcC53efBfD', - swap_token: '0xC25a3A3b969415c80451098fa907EC722572917F', - name: 'susdv2', - gauge: '0xA90996896660DEcC6E997655E065b23788857849', - type: 'stable', - }, - pax: { - swap: '0x06364f10B501e868329afBc005b3492902d6C763', - swap_token: '0xD905e2eaeBe188fc92179b6350807D8bd91Db0D8', - name: 'pax', - gauge: '0x64E3C23bfc40722d3B649844055F1D51c1ac041d', - type: 'stable', - }, - ren: { - swap: '0x93054188d876f558f4a66B2EF1d97d16eDf0895B', - swap_token: '0x49849C98ae39Fff122806C06791Fa73784FB3675', - name: 'ren', - gauge: '0xB1F2cdeC61db658F091671F5f199635aEF202CAC', - type: 'bitcoin', - }, - sbtc: { - swap: '0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714', - swap_token: '0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3', - name: 'sbtc', - gauge: '0x705350c4BcD35c9441419DdD5d2f097d7a55410F', - type: 'bitcoin', - }, - hbtc: { - swap: '0x4CA9b3063Ec5866A4B82E437059D2C43d1be596F', - swap_token: '0xb19059ebb43466C323583928285a49f558E572Fd', - name: 'hbtc', - gauge: '0x4c18E409Dc8619bFb6a1cB56D114C3f592E0aE79', - type: 'bitcoin', - }, - '3pool': { - swap: '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7', - swap_token: '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490', - name: '3pool', - gauge: '0xbFcF63294aD7105dEa65aA58F8AE5BE2D9d0952A', - type: 'stable', - }, - gusd: { - swap: '0x4f062658EaAF2C1ccf8C8e36D6824CDf41167956', - swap_token: '0xD2967f45c4f384DEEa880F807Be904762a3DeA07', - name: 'gusd', - gauge: '0xC5cfaDA84E902aD92DD40194f0883ad49639b023', - type: 'stable', - }, - husd: { - swap: '0x3eF6A01A0f81D6046290f3e2A8c5b843e738E604', - swap_token: '0x5B5CFE992AdAC0C9D48E05854B2d91C73a003858', - name: 'husd', - gauge: '0x2db0E83599a91b508Ac268a6197b8B14F5e72840', - type: 'stable', - }, - usdk: { - swap: '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb', - swap_token: '0x97E2768e8E73511cA874545DC5Ff8067eB19B787', - name: 'usdk', - gauge: '0xC2b1DF84112619D190193E48148000e3990Bf627', - type: 'stable', - }, - usdn: { - swap: '0x0f9cb53Ebe405d49A0bbdBD291A65Ff571bC83e1', - swap_token: '0x4f3E8F405CF5aFC05D68142F3783bDfE13811522', - name: 'usdn', - gauge: '0xF98450B5602fa59CC66e1379DFfB6FDDc724CfC4', - type: 'stable', - }, - musd: { - swap: '0x8474DdbE98F5aA3179B3B3F5942D724aFcdec9f6', - swap_token: '0x1AEf73d49Dedc4b1778d0706583995958Dc862e6', - name: 'musd', - gauge: '0x5f626c30EC1215f4EdCc9982265E8b1F411D1352', - type: 'stable', - }, - tbtc: { - swap: '0xC25099792E9349C7DD09759744ea681C7de2cb66', - swap_token: '0x64eda51d3Ad40D56b9dFc5554E06F94e1Dd786Fd', - name: 'tbtc', - gauge: '0x6828bcF74279eE32f2723eC536c22c51Eed383C6', - type: 'bitcoin', - is_killed: true, - }, - rsv: { - swap: '0xC18cC39da8b11dA8c3541C598eE022258F9744da', - swap_token: '0xC2Ee6b0334C261ED60C72f6054450b61B8f18E35', - name: 'rsv', - gauge: '0x4dC4A289a8E33600D8bD4cf5F6313E43a37adec7', - type: 'stable', - }, - dusd: { - swap: '0x8038C01A0390a8c547446a0b2c18fc9aEFEcc10c', - swap_token: '0x3a664Ab939FD8482048609f652f9a0B0677337B9', - name: 'dusd', - gauge: '0xAEA6c312f4b3E04D752946d329693F7293bC2e6D', - type: 'stable', - }, - pbtc: { - swap: '0x7F55DDe206dbAD629C080068923b36fe9D6bDBeF', - swap_token: '0xDE5331AC4B3630f94853Ff322B66407e0D6331E8', - name: 'pbtc', - gauge: '0xd7d147c6Bb90A718c3De8C0568F9B560C79fa416', - type: 'bitcoin', - }, - bbtc: { - swap: '0x071c661B4DeefB59E2a3DdB20Db036821eeE8F4b', - swap_token: '0x410e3E86ef427e30B9235497143881f717d93c2A', - name: 'bbtc', - gauge: '0xdFc7AdFa664b08767b735dE28f9E84cd30492aeE', - type: 'bitcoin', - }, - obtc: { - swap: '0xd81dA8D904b52208541Bade1bD6595D8a251F8dd', - swap_token: '0x2fE94ea3d5d4a175184081439753DE15AeF9d614', - name: 'obtc', - gauge: '0x11137B10C210b579405c21A07489e28F3c040AB1', - type: 'bitcoin', - }, - ust: { - swap: '0x890f4e345B1dAED0367A877a1612f86A1f86985f', - swap_token: '0x94e131324b6054c0D789b190b2dAC504e4361b53', - name: 'ust', - gauge: '0x3B7020743Bc2A4ca9EaF9D0722d42E20d6935855', - type: 'stable', - is_killed: true, - }, - eurs: { - swap: '0x0Ce6a5fF5217e38315f87032CF90686C96627CAA', - swap_token: '0x194eBd173F6cDacE046C53eACcE9B953F28411d1', - name: 'eurs', - gauge: '0x90Bb609649E0451E5aD952683D64BD2d1f245840', - type: 'tether-eurt', - }, - seth: { - swap: '0xc5424b857f758e906013f3555dad202e4bdb4567', - swap_token: '0xA3D87FffcE63B53E0d54fAa1cc983B7eB0b74A9c', - name: 'seth', - gauge: '0x3C0FFFF15EA30C35d7A85B85c0782D6c94e1d238', - type: 'ethereum', - }, - aave: { - swap: '0xDeBF20617708857ebe4F679508E7b7863a8A8EeE', - swap_token: '0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900', - name: 'aave', - gauge: '0xd662908ADA2Ea1916B3318327A97eB18aD588b5d', - type: 'stable', - }, - steth: { - swap: '0xDC24316b9AE028F1497c275EB9192a3Ea0f67022', - swap_token: '0x06325440D014e39736583c165C2963BA99fAf14E', - name: 'steth', - gauge: '0x182B723a58739a9c974cFDB385ceaDb237453c28', - type: 'ethereum', - }, - saave: { - swap: '0xEB16Ae0052ed37f479f7fe63849198Df1765a733', - swap_token: '0x02d341CcB60fAaf662bC0554d13778015d1b285C', - name: 'saave', - gauge: '0x462253b8F74B72304c145DB0e4Eebd326B22ca39', - type: 'stable', - }, - ankreth: { - swap: '0xA96A65c051bF88B4095Ee1f2451C2A9d43F53Ae2', - swap_token: '0xaA17A236F2bAdc98DDc0Cf999AbB47D47Fc0A6Cf', - name: 'ankreth', - gauge: '0x6d10ed2cF043E6fcf51A0e7b4C2Af3Fa06695707', - type: 'ethereum', - }, - ib: { - swap: '0x2dded6Da1BF5DBdF597C45fcFaa3194e53EcfeAF', - swap_token: '0x5282a4eF67D9C33135340fB3289cc1711c13638C', - name: 'ib', - gauge: '0xF5194c3325202F456c95c1Cf0cA36f8475C1949F', - type: 'stable', - }, - link: { - swap: '0xF178C0b5Bb7e7aBF4e12A4838C7b7c5bA2C623c0', - swap_token: '0xcee60cfa923170e4f8204ae08b4fa6a3f5656f3a', - name: 'link', - gauge: '0xFD4D8a17df4C27c1dD245d153ccf4499e806C87D', - type: 'chainlink', - }, - usdp: { - swap: '0x42d7025938bEc20B69cBae5A77421082407f053A', - swap_token: '0x7Eb40E450b9655f4B3cC4259BCC731c63ff55ae6', - name: 'usdp', - gauge: '0x055be5DDB7A925BfEF3417FC157f53CA77cA7222', - type: 'stable', - }, - tusd: { - swap: '0xecd5e75afb02efa118af914515d6521aabd189f1', - swap_token: '0xecd5e75afb02efa118af914515d6521aabd189f1', - name: 'tusd', - gauge: '0x359FD5d6417aE3D8D6497d9B2e7A890798262BA4', - type: 'stable', - }, - busdv2: { - swap: '0x4807862AA8b2bF68830e4C8dc86D0e9A998e085a', - swap_token: '0x4807862AA8b2bF68830e4C8dc86D0e9A998e085a', - name: 'busdv2', - gauge: '0xd4B22fEdcA85E684919955061fDf353b9d38389b', - type: 'stable', - }, - frax: { - swap: '0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B', - swap_token: '0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B', - name: 'frax', - gauge: '0x72E158d38dbd50A483501c24f792bDAAA3e7D55C', - type: 'stable', - }, - lusd: { - swap: '0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA', - swap_token: '0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA', - name: 'lusd', - gauge: '0x9B8519A9a00100720CCdC8a120fBeD319cA47a14', - type: 'stable', - }, - reth: { - swap: '0xF9440930043eb3997fc70e1339dBb11F341de7A8', - swap_token: '0x53a901d48795C58f485cBB38df08FA96a24669D5', - name: 'reth', - gauge: '0x824F13f1a2F29cFEEa81154b46C0fc820677A637', - type: 'ethereum', - }, - alusd: { - swap: '0x43b4FdFD4Ff969587185cDB6f0BD875c5Fc83f8c', - swap_token: '0x43b4FdFD4Ff969587185cDB6f0BD875c5Fc83f8c', - name: 'alusd', - gauge: '0x9582C4ADACB3BCE56Fea3e590F05c3ca2fb9C477', - type: 'stable', - }, - "polygon-a3CRV": { - swap: '0x445FE580eF8d70FF569aB36e80c647af338db351', - swap_token: '0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171', - name: 'polygon-a3CRV', - gauge: '0xC48f4653dd6a9509De44c92beb0604BEA3AEe714', - type: 'stable', - side_chain: true, - is_killed: true, - }, - "fantom-2pool": { - swap: '0x27e611fd27b276acbd5ffd632e5eaebec9761e40', - swap_token: '0x27e611fd27b276acbd5ffd632e5eaebec9761e40', - name: 'fantom-2pool', - gauge: '0xb9C05B8EE41FDCbd9956114B3aF15834FDEDCb54', - type: 'stable', - side_chain: true, - is_killed: true, - }, - "fantom-geist": { - swap: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f', - swap_token: '0xD02a30d33153877BC20e5721ee53DeDEE0422B2F', - name: 'fantom-geist', - gauge: '0xfE1A3dD8b169fB5BF0D5dbFe813d956F39fF6310', - type: 'stable', - side_chain: true, - is_killed: true, - }, - "tricrypto": { - swap: '0x80466c64868E1ab14a1Ddf27A676C3fcBE638Fe5', - swap_token: '0xcA3d75aC011BF5aD07a98d02f18225F9bD9A6BDF', - name: 'tricrypto', - gauge: '0x6955a55416a06839309018A8B0cB72c4DDC11f15', - type: 'crypto', - is_killed: true - }, - "polygon-ren": { - swap: '0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67', - swap_token: '0xf8a57c1d3b9629b77b6726a042ca48990A84Fb49', - name: 'polygon-ren', - gauge: '0x488E6ef919C2bB9de535C634a80afb0114DA8F62', - type: 'bitcoin', - side_chain: true, - is_killed: true, - }, - "fantom-ren": { - swap: '0x3eF6A01A0f81D6046290f3e2A8c5b843e738E604', - swap_token: '0x5B5CFE992AdAC0C9D48E05854B2d91C73a003858', - name: 'fantom-ren', - gauge: '0xfDb129ea4b6f557b07BcDCedE54F665b7b6Bc281', - type: 'bitcoin', - side_chain: true, - is_killed: true, - }, - "polygon-atricrypto": { - swap: '0x92577943c7aC4accb35288aB2CC84D75feC330aF', - swap_token: '0xbece5d20A8a104c54183CC316C8286E3F00ffC71', - name: 'polygon-atricrypto', - gauge: '0x060e386eCfBacf42Aa72171Af9EFe17b3993fC4F', - type: 'crypto', - side_chain: true, - is_killed: true - }, - "xdai-3pool": { - swap: '0x7f90122BF0700F9E7e1F688fe926940E8839F353', - swap_token: '0x1337BedC9D22ecbe766dF105c9623922A27963EC', - name: 'xdai-3pool', - gauge: '0x6C09F6727113543Fd061a721da512B7eFCDD0267', - type: 'stable', - side_chain: true, - is_killed: true, - }, - "tricrypto2": { - swap: '0xD51a44d3FaE010294C616388b506AcdA1bfAAE46', - swap_token: '0xc4AD29ba4B3c580e6D59105FFf484999997675Ff', - name: 'tricrypto2', - gauge: '0xDeFd8FdD20e0f34115C7018CCfb655796F6B2168', - type: 'crypto', - }, - "eurt": { - swap: '0xfd5db7463a3ab53fd211b4af195c5bccc1a03890', - swap_token: '0xfd5db7463a3ab53fd211b4af195c5bccc1a03890', - name: 'eurt', - gauge: '0xe8060Ad8971450E624d5289A10017dD30F5dA85F', - type: 'tether-eurt', - }, - "mim": { - swap: '0x5a6A4D54456819380173272A5E8E9B9904BdF41B', - swap_token: '0x5a6A4D54456819380173272A5E8E9B9904BdF41B', - name: 'mim', - gauge: '0xd8b712d29381748dB89c36BCa0138d7c75866ddF', - type: 'stable', - }, - "mim": { - swap: '0x5a6A4D54456819380173272A5E8E9B9904BdF41B', - swap_token: '0x5a6A4D54456819380173272A5E8E9B9904BdF41B', - name: 'mim', - gauge: '0xd8b712d29381748dB89c36BCa0138d7c75866ddF', - type: 'stable', - }, - "f-cvxcrv": { - swap: '0x9d0464996170c6b9e75eed71c68b99ddedf279e8', - swap_token: '0x9d0464996170c6b9e75eed71c68b99ddedf279e8', - name: 'f-cvxcrv', - gauge: '0x903dA6213a5A12B61c821598154EfAd98C3B20E4', - type: 'curve-dao-token', - factory: true - }, - "f-ibjpy": { - swap: '0x8818a9bb44fbf33502be7c15c500d0c783b73067', - swap_token: '0x8818a9bb44fbf33502be7c15c500d0c783b73067', - name: 'f-ibjpy', - gauge: '0xeFF437A56A22D7dD86C1202A308536ED8C7da7c1', - type: 'jpyc', - factory: true - }, + compound: { + swap: '0xA2B47E3D5c44877cca798226B7B8118F9BFb7A56', + swap_token: '0x845838DF265Dcd2c412A1Dc9e959c7d08537f8a2', + name: 'compound', + gauge: '0x7ca5b0a2910B33e9759DC7dDB0413949071D7575', + type: 'stable', + }, + usdt: { + swap: '0x52EA46506B9CC5Ef470C5bf89f17Dc28bB35D85C', + swap_token: '0x9fC689CCaDa600B6DF723D9E47D84d76664a1F23', + name: 'usdt', + gauge: '0xBC89cd85491d81C6AD2954E6d0362Ee29fCa8F53', + type: 'stable', + }, + y: { + swap: '0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51', + swap_token: '0xdF5e0e81Dff6FAF3A7e52BA697820c5e32D806A8', + name: 'y', + gauge: '0xFA712EE4788C042e2B7BB55E6cb8ec569C4530c1', + type: 'stable', + }, + busd: { + swap: '0x79a8C46DeA5aDa233ABaFFD40F3A0A2B1e5A4F27', + swap_token: '0x3B3Ac5386837Dc563660FB6a0937DFAa5924333B', + name: 'busd', + gauge: '0x69Fb7c45726cfE2baDeE8317005d3F94bE838840', + type: 'stable', + }, + susdv2: { + swap: '0xA5407eAE9Ba41422680e2e00537571bcC53efBfD', + swap_token: '0xC25a3A3b969415c80451098fa907EC722572917F', + name: 'susdv2', + gauge: '0xA90996896660DEcC6E997655E065b23788857849', + type: 'stable', + }, + pax: { + swap: '0x06364f10B501e868329afBc005b3492902d6C763', + swap_token: '0xD905e2eaeBe188fc92179b6350807D8bd91Db0D8', + name: 'pax', + gauge: '0x64E3C23bfc40722d3B649844055F1D51c1ac041d', + type: 'stable', + }, + ren: { + swap: '0x93054188d876f558f4a66B2EF1d97d16eDf0895B', + swap_token: '0x49849C98ae39Fff122806C06791Fa73784FB3675', + name: 'ren', + gauge: '0xB1F2cdeC61db658F091671F5f199635aEF202CAC', + type: 'bitcoin', + }, + sbtc: { + swap: '0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714', + swap_token: '0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3', + name: 'sbtc', + gauge: '0x705350c4BcD35c9441419DdD5d2f097d7a55410F', + type: 'bitcoin', + }, + hbtc: { + swap: '0x4CA9b3063Ec5866A4B82E437059D2C43d1be596F', + swap_token: '0xb19059ebb43466C323583928285a49f558E572Fd', + name: 'hbtc', + gauge: '0x4c18E409Dc8619bFb6a1cB56D114C3f592E0aE79', + type: 'bitcoin', + }, + '3pool': { + swap: '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7', + swap_token: '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490', + name: '3pool', + gauge: '0xbFcF63294aD7105dEa65aA58F8AE5BE2D9d0952A', + type: 'stable', + }, + gusd: { + swap: '0x4f062658EaAF2C1ccf8C8e36D6824CDf41167956', + swap_token: '0xD2967f45c4f384DEEa880F807Be904762a3DeA07', + name: 'gusd', + gauge: '0xC5cfaDA84E902aD92DD40194f0883ad49639b023', + type: 'stable', + }, + husd: { + swap: '0x3eF6A01A0f81D6046290f3e2A8c5b843e738E604', + swap_token: '0x5B5CFE992AdAC0C9D48E05854B2d91C73a003858', + name: 'husd', + gauge: '0x2db0E83599a91b508Ac268a6197b8B14F5e72840', + type: 'stable', + }, + usdk: { + swap: '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb', + swap_token: '0x97E2768e8E73511cA874545DC5Ff8067eB19B787', + name: 'usdk', + gauge: '0xC2b1DF84112619D190193E48148000e3990Bf627', + type: 'stable', + }, + usdn: { + swap: '0x0f9cb53Ebe405d49A0bbdBD291A65Ff571bC83e1', + swap_token: '0x4f3E8F405CF5aFC05D68142F3783bDfE13811522', + name: 'usdn', + gauge: '0xF98450B5602fa59CC66e1379DFfB6FDDc724CfC4', + type: 'stable', + }, + musd: { + swap: '0x8474DdbE98F5aA3179B3B3F5942D724aFcdec9f6', + swap_token: '0x1AEf73d49Dedc4b1778d0706583995958Dc862e6', + name: 'musd', + gauge: '0x5f626c30EC1215f4EdCc9982265E8b1F411D1352', + type: 'stable', + }, + tbtc: { + swap: '0xC25099792E9349C7DD09759744ea681C7de2cb66', + swap_token: '0x64eda51d3Ad40D56b9dFc5554E06F94e1Dd786Fd', + name: 'tbtc', + gauge: '0x6828bcF74279eE32f2723eC536c22c51Eed383C6', + type: 'bitcoin', + is_killed: true, + }, + rsv: { + swap: '0xC18cC39da8b11dA8c3541C598eE022258F9744da', + swap_token: '0xC2Ee6b0334C261ED60C72f6054450b61B8f18E35', + name: 'rsv', + gauge: '0x4dC4A289a8E33600D8bD4cf5F6313E43a37adec7', + type: 'stable', + }, + dusd: { + swap: '0x8038C01A0390a8c547446a0b2c18fc9aEFEcc10c', + swap_token: '0x3a664Ab939FD8482048609f652f9a0B0677337B9', + name: 'dusd', + gauge: '0xAEA6c312f4b3E04D752946d329693F7293bC2e6D', + type: 'stable', + }, + pbtc: { + swap: '0x7F55DDe206dbAD629C080068923b36fe9D6bDBeF', + swap_token: '0xDE5331AC4B3630f94853Ff322B66407e0D6331E8', + name: 'pbtc', + gauge: '0xd7d147c6Bb90A718c3De8C0568F9B560C79fa416', + type: 'bitcoin', + }, + bbtc: { + swap: '0x071c661B4DeefB59E2a3DdB20Db036821eeE8F4b', + swap_token: '0x410e3E86ef427e30B9235497143881f717d93c2A', + name: 'bbtc', + gauge: '0xdFc7AdFa664b08767b735dE28f9E84cd30492aeE', + type: 'bitcoin', + }, + obtc: { + swap: '0xd81dA8D904b52208541Bade1bD6595D8a251F8dd', + swap_token: '0x2fE94ea3d5d4a175184081439753DE15AeF9d614', + name: 'obtc', + gauge: '0x11137B10C210b579405c21A07489e28F3c040AB1', + type: 'bitcoin', + }, + ust: { + swap: '0x890f4e345B1dAED0367A877a1612f86A1f86985f', + swap_token: '0x94e131324b6054c0D789b190b2dAC504e4361b53', + name: 'ust', + gauge: '0x3B7020743Bc2A4ca9EaF9D0722d42E20d6935855', + type: 'stable', + is_killed: true, + }, + eurs: { + swap: '0x0Ce6a5fF5217e38315f87032CF90686C96627CAA', + swap_token: '0x194eBd173F6cDacE046C53eACcE9B953F28411d1', + name: 'eurs', + gauge: '0x90Bb609649E0451E5aD952683D64BD2d1f245840', + type: 'tether-eurt', + }, + seth: { + swap: '0xc5424b857f758e906013f3555dad202e4bdb4567', + swap_token: '0xA3D87FffcE63B53E0d54fAa1cc983B7eB0b74A9c', + name: 'seth', + gauge: '0x3C0FFFF15EA30C35d7A85B85c0782D6c94e1d238', + type: 'ethereum', + }, + aave: { + swap: '0xDeBF20617708857ebe4F679508E7b7863a8A8EeE', + swap_token: '0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900', + name: 'aave', + gauge: '0xd662908ADA2Ea1916B3318327A97eB18aD588b5d', + type: 'stable', + }, + steth: { + swap: '0xDC24316b9AE028F1497c275EB9192a3Ea0f67022', + swap_token: '0x06325440D014e39736583c165C2963BA99fAf14E', + name: 'steth', + gauge: '0x182B723a58739a9c974cFDB385ceaDb237453c28', + type: 'ethereum', + }, + saave: { + swap: '0xEB16Ae0052ed37f479f7fe63849198Df1765a733', + swap_token: '0x02d341CcB60fAaf662bC0554d13778015d1b285C', + name: 'saave', + gauge: '0x462253b8F74B72304c145DB0e4Eebd326B22ca39', + type: 'stable', + }, + ankreth: { + swap: '0xA96A65c051bF88B4095Ee1f2451C2A9d43F53Ae2', + swap_token: '0xaA17A236F2bAdc98DDc0Cf999AbB47D47Fc0A6Cf', + name: 'ankreth', + gauge: '0x6d10ed2cF043E6fcf51A0e7b4C2Af3Fa06695707', + type: 'ethereum', + }, + ib: { + swap: '0x2dded6Da1BF5DBdF597C45fcFaa3194e53EcfeAF', + swap_token: '0x5282a4eF67D9C33135340fB3289cc1711c13638C', + name: 'ib', + gauge: '0xF5194c3325202F456c95c1Cf0cA36f8475C1949F', + type: 'stable', + }, + link: { + swap: '0xF178C0b5Bb7e7aBF4e12A4838C7b7c5bA2C623c0', + swap_token: '0xcee60cfa923170e4f8204ae08b4fa6a3f5656f3a', + name: 'link', + gauge: '0xFD4D8a17df4C27c1dD245d153ccf4499e806C87D', + type: 'chainlink', + }, + usdp: { + swap: '0x42d7025938bEc20B69cBae5A77421082407f053A', + swap_token: '0x7Eb40E450b9655f4B3cC4259BCC731c63ff55ae6', + name: 'usdp', + gauge: '0x055be5DDB7A925BfEF3417FC157f53CA77cA7222', + type: 'stable', + }, + tusd: { + swap: '0xecd5e75afb02efa118af914515d6521aabd189f1', + swap_token: '0xecd5e75afb02efa118af914515d6521aabd189f1', + name: 'tusd', + gauge: '0x359FD5d6417aE3D8D6497d9B2e7A890798262BA4', + type: 'stable', + }, + busdv2: { + swap: '0x4807862AA8b2bF68830e4C8dc86D0e9A998e085a', + swap_token: '0x4807862AA8b2bF68830e4C8dc86D0e9A998e085a', + name: 'busdv2', + gauge: '0xd4B22fEdcA85E684919955061fDf353b9d38389b', + type: 'stable', + }, + frax: { + swap: '0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B', + swap_token: '0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B', + name: 'frax', + gauge: '0x72E158d38dbd50A483501c24f792bDAAA3e7D55C', + type: 'stable', + }, + lusd: { + swap: '0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA', + swap_token: '0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA', + name: 'lusd', + gauge: '0x9B8519A9a00100720CCdC8a120fBeD319cA47a14', + type: 'stable', + }, + reth: { + swap: '0xF9440930043eb3997fc70e1339dBb11F341de7A8', + swap_token: '0x53a901d48795C58f485cBB38df08FA96a24669D5', + name: 'reth', + gauge: '0x824F13f1a2F29cFEEa81154b46C0fc820677A637', + type: 'ethereum', + }, + alusd: { + swap: '0x43b4FdFD4Ff969587185cDB6f0BD875c5Fc83f8c', + swap_token: '0x43b4FdFD4Ff969587185cDB6f0BD875c5Fc83f8c', + name: 'alusd', + gauge: '0x9582C4ADACB3BCE56Fea3e590F05c3ca2fb9C477', + type: 'stable', + }, + "polygon-a3CRV": { + swap: '0x445FE580eF8d70FF569aB36e80c647af338db351', + swap_token: '0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171', + name: 'polygon-a3CRV', + gauge: '0xC48f4653dd6a9509De44c92beb0604BEA3AEe714', + type: 'stable', + side_chain: true, + is_killed: true, + }, + "fantom-2pool": { + swap: '0x27e611fd27b276acbd5ffd632e5eaebec9761e40', + swap_token: '0x27e611fd27b276acbd5ffd632e5eaebec9761e40', + name: 'fantom-2pool', + gauge: '0xb9C05B8EE41FDCbd9956114B3aF15834FDEDCb54', + type: 'stable', + side_chain: true, + is_killed: true, + }, + "fantom-geist": { + swap: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f', + swap_token: '0xD02a30d33153877BC20e5721ee53DeDEE0422B2F', + name: 'fantom-geist', + gauge: '0xfE1A3dD8b169fB5BF0D5dbFe813d956F39fF6310', + type: 'stable', + side_chain: true, + is_killed: true, + }, + "tricrypto": { + swap: '0x80466c64868E1ab14a1Ddf27A676C3fcBE638Fe5', + swap_token: '0xcA3d75aC011BF5aD07a98d02f18225F9bD9A6BDF', + name: 'tricrypto', + gauge: '0x6955a55416a06839309018A8B0cB72c4DDC11f15', + type: 'crypto', + is_killed: true + }, + "polygon-ren": { + swap: '0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67', + swap_token: '0xf8a57c1d3b9629b77b6726a042ca48990A84Fb49', + name: 'polygon-ren', + gauge: '0x488E6ef919C2bB9de535C634a80afb0114DA8F62', + type: 'bitcoin', + side_chain: true, + is_killed: true, + }, + "fantom-ren": { + swap: '0x3eF6A01A0f81D6046290f3e2A8c5b843e738E604', + swap_token: '0x5B5CFE992AdAC0C9D48E05854B2d91C73a003858', + name: 'fantom-ren', + gauge: '0xfDb129ea4b6f557b07BcDCedE54F665b7b6Bc281', + type: 'bitcoin', + side_chain: true, + is_killed: true, + }, + "polygon-atricrypto": { + swap: '0x92577943c7aC4accb35288aB2CC84D75feC330aF', + swap_token: '0xbece5d20A8a104c54183CC316C8286E3F00ffC71', + name: 'polygon-atricrypto', + gauge: '0x060e386eCfBacf42Aa72171Af9EFe17b3993fC4F', + type: 'crypto', + side_chain: true, + is_killed: true + }, + "xdai-3pool": { + swap: '0x7f90122BF0700F9E7e1F688fe926940E8839F353', + swap_token: '0x1337BedC9D22ecbe766dF105c9623922A27963EC', + name: 'xdai-3pool', + gauge: '0x6C09F6727113543Fd061a721da512B7eFCDD0267', + type: 'stable', + side_chain: true, + is_killed: true, + }, + "tricrypto2": { + swap: '0xD51a44d3FaE010294C616388b506AcdA1bfAAE46', + swap_token: '0xc4AD29ba4B3c580e6D59105FFf484999997675Ff', + name: 'tricrypto2', + gauge: '0xDeFd8FdD20e0f34115C7018CCfb655796F6B2168', + type: 'crypto', + }, + "eurt": { + swap: '0xfd5db7463a3ab53fd211b4af195c5bccc1a03890', + swap_token: '0xfd5db7463a3ab53fd211b4af195c5bccc1a03890', + name: 'eurt', + gauge: '0xe8060Ad8971450E624d5289A10017dD30F5dA85F', + type: 'tether-eurt', + }, + "mim": { + swap: '0x5a6A4D54456819380173272A5E8E9B9904BdF41B', + swap_token: '0x5a6A4D54456819380173272A5E8E9B9904BdF41B', + name: 'mim', + gauge: '0xd8b712d29381748dB89c36BCa0138d7c75866ddF', + type: 'stable', + }, + "mim": { + swap: '0x5a6A4D54456819380173272A5E8E9B9904BdF41B', + swap_token: '0x5a6A4D54456819380173272A5E8E9B9904BdF41B', + name: 'mim', + gauge: '0xd8b712d29381748dB89c36BCa0138d7c75866ddF', + type: 'stable', + }, + "f-cvxcrv": { + swap: '0x9d0464996170c6b9e75eed71c68b99ddedf279e8', + swap_token: '0x9d0464996170c6b9e75eed71c68b99ddedf279e8', + name: 'f-cvxcrv', + gauge: '0x903dA6213a5A12B61c821598154EfAd98C3B20E4', + type: 'curve-dao-token', + factory: true + }, + "f-ibjpy": { + swap: '0x8818a9bb44fbf33502be7c15c500d0c783b73067', + swap_token: '0x8818a9bb44fbf33502be7c15c500d0c783b73067', + name: 'f-ibjpy', + gauge: '0xeFF437A56A22D7dD86C1202A308536ED8C7da7c1', + type: 'jpyc', + factory: true + }, - "f-ibgbp": { - swap: '0xd6ac1cb9019137a896343da59dde6d097f710538', - swap_token: '0xd6ac1cb9019137a896343da59dde6d097f710538', - name: 'f-ibgbp', - gauge: '0x63d9f3aB7d0c528797A12a0684E50C397E9e79dC', - type: 'truegbp', - factory: true - }, - "f-ibaud": { - swap: '0x3f1b0278a9ee595635b61817630cc19de792f506', - swap_token: '0x3f1b0278a9ee595635b61817630cc19de792f506', - name: 'f-ibaud', - gauge: '0x05ca5c01629a8E5845f12ea3A03fF7331932233A', - type: 'saud', - factory: true - }, - "f-ibeur": { - swap: '0x19b080fe1ffa0553469d20ca36219f17fcf03859', - swap_token: '0x19b080fe1ffa0553469d20ca36219f17fcf03859', - name: 'f-ibeur', - gauge: '0x99fb76F75501039089AAC8f20f487bf84E51d76F', - type: 'tether-eurt', - factory: true - }, - "f-ibchf": { - swap: '0x9c2c8910f113181783c249d8f6aa41b51cde0f0c', - swap_token: '0x9c2c8910f113181783c249d8f6aa41b51cde0f0c', - name: 'f-ibchf', - gauge: '0x2fA53e8fa5fAdb81f4332C8EcE39Fe62eA2f919E', - type: 'cryptofranc', - factory: true - }, - "f-ibkrw": { - swap: '0x8461a004b50d321cb22b7d034969ce6803911899', - swap_token: '0x8461a004b50d321cb22b7d034969ce6803911899', - name: 'f-ibkrw', - gauge: '0x1750a3a3d80A3F5333BBe9c4695B0fAd41061ab1', - type: 'terra-krw', - factory: true - }, - "ousd": { - swap: '0x87650D7bbfC3A9F10587d7778206671719d9910D', - swap_token: '0x87650D7bbfC3A9F10587d7778206671719d9910D', - name: 'ousd', - gauge: '0x25f0cE4E2F8dbA112D9b115710AC297F816087CD', - type: 'stable', - factory: true, - }, - "arbitrum-tricrypto": { - swap: '0x960ea3e3C7FB317332d990873d354E18d7645590', - swap_token: '0x8e0B8c8BB9db49a46697F3a5Bb8A308e744821D2', - name: 'arbitrum-tricrypto', - gauge: '0x9044E12fB1732f88ed0c93cfa5E9bB9bD2990cE5', - type: 'crypto', - side_chain: true, - is_killed: true, - }, - "arbitrum-2pool": { - swap: '0x7f90122bf0700f9e7e1f688fe926940e8839f353', - swap_token: '0x7f90122bf0700f9e7e1f688fe926940e8839f353', - name: 'arbitrum-2pool', - gauge: '0xFf17560d746F85674FE7629cE986E949602EF948', - type: 'stable', - side_chain: true, - is_killed: true, - }, - "arbitrum-ren": { - swap: '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb', - swap_token: '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb', - name: 'arbitrum-ren', - gauge: '0x9F86c5142369B1Ffd4223E5A2F2005FC66807894', - type: 'bitcoin', - side_chain: true, - is_killed: true, - }, - "fantom-tricrypto": { - swap: '0x3a1659Ddcf2339Be3aeA159cA010979FB49155FF', - swap_token: '0x58e57cA18B7A47112b877E31929798Cd3D703b0f', - name: 'fantom-tricrypto', - gauge: '0x260e4fBb13DD91e187AE992c3435D0cf97172316', - type: 'crypto', - side_chain: true, - is_killed: true, - }, - "f-aleth": { - swap: '0xc4c319e2d4d66cca4464c0c2b32c9bd23ebe784e', - swap_token: '0xc4c319e2d4d66cca4464c0c2b32c9bd23ebe784e', - name: 'f-aleth', - gauge: '0x12dCD9E8D1577b5E4F066d8e7D404404Ef045342', - type: 'ethereum', - factory: true, - }, - "f-eurn": { - swap: '0x3fb78e61784c9c637d560ede23ad57ca1294c14a', - swap_token: '0x3fb78e61784c9c637d560ede23ad57ca1294c14a', - name: 'f-eurn', - gauge: '0xD9277b0D007464eFF133622eC0d42081c93Cef02', - type: 'tether-eurt', - factory: true, - }, - "f-usdm": { - swap: '0x5b3b5df2bf2b6543f78e053bd91c4bdd820929f1', - swap_token: '0x5b3b5df2bf2b6543f78e053bd91c4bdd820929f1', - name: 'f-usdm', - gauge: '0x9AF13a7B1f1Bbf1A2B05c6fBF23ac23A9E573b4E', - type: 'stable', - is_killed: true, - factory: true, - }, - "f-ust-mim": { - swap: '0x55a8a39bc9694714e2874c1ce77aa1e599461e18', - swap_token: '0x55a8a39bc9694714e2874c1ce77aa1e599461e18', - name: 'f-ust-mim', - gauge: '0xB518f5e3242393d4eC792BD3f44946A3b98d0E48', - type: 'stable', - factory: true, - is_killed: true, - }, - "avalanche-a3CRV": { - swap: '0x7f90122BF0700F9E7e1F688fe926940E8839F353', - swap_token: '0x1337BedC9D22ecbe766dF105c9623922A27963EC', - name: 'avalanche-a3CRV', - gauge: '0xB504b6EB06760019801a91B451d3f7BD9f027fC9', - type: 'stable', - side_chain: true, - is_killed: true, - }, - "avalanche-ren": { - swap: '0x16a7DA911A4DD1d83F3fF066fE28F3C792C50d90', - swap_token: '0xC2b1DF84112619D190193E48148000e3990Bf627', - name: 'avalanche-ren', - gauge: '0x75D05190f35567e79012c2F0a02330D3Ed8a1F74', - type: 'bitcoin', - side_chain: true, - is_killed: true, - }, - "avalanche-atricrypto": { - swap: '0xB755B949C126C04e0348DD881a5cF55d424742B2', - swap_token: '0x1daB6560494B04473A0BE3E7D83CF3Fdf3a51828', - name: 'avalanche-atricrypto', - gauge: '0xa05E565cA0a103FcD999c7A7b8de7Bd15D5f6505', - type: 'crypto', - side_chain: true, - is_killed: true, - }, - "harmony-3pool": { - swap: '0xC5cfaDA84E902aD92DD40194f0883ad49639b023', - swap_token: '0xC5cfaDA84E902aD92DD40194f0883ad49639b023', - name: 'harmony-3pool', - gauge: '0xf2Cde8c47C20aCbffC598217Ad5FE6DB9E00b163', - type: 'stable', - side_chain: true - }, - "f-d3pool": { - swap: '0xbaaa1f5dba42c3389bdbc2c9d2de134f5cd0dc89', - swap_token: '0xbaaa1f5dba42c3389bdbc2c9d2de134f5cd0dc89', - name: 'f-d3pool', - gauge: '0x16C2beE6f55dAB7F494dBa643fF52ef2D47FBA36', - type: 'stable', - factory: true, - }, - "f-usdpax": { - swap: '0xc270b3b858c335b6ba5d5b10e2da8a09976005ad', - swap_token: '0xc270b3b858c335b6ba5d5b10e2da8a09976005ad', - name: 'f-usdpax', - gauge: '0xC95bdf13A08A547E4dD9f29B00aB7fF08C5d093d', - type: 'stable', - factory: true, - }, - "f-ustw": { - swap: '0xceaf7747579696a2f0bb206a14210e3c9e6fb269', - swap_token: '0xceaf7747579696a2f0bb206a14210e3c9e6fb269', - name: 'f-ustw', - gauge: '0xb0f5d00e5916c8b8981e99191A1458704B587b2b', - type: 'stable', - factory: true, - is_killed: true, - }, - "f-ibbtc": { - swap: '0xfbdca68601f835b27790d98bbb8ec7f05fdeaa9b', - swap_token: '0xfbdca68601f835b27790d98bbb8ec7f05fdeaa9b', - name: 'f-ibbtc', - gauge: '0x346C7BB1A7a6A30c8e81c14e90FC2f0FBddc54d8', - type: 'bitcoin', - factory: true, - }, - "eursusd": { - swap: '0x98a7F18d4E56Cfe84E3D081B40001B3d5bD3eB8B', - swap_token: '0x3d229e1b4faab62f621ef2f6a610961f7bd7b23b', - name: 'eursusd', - gauge: '0x65CA7Dc5CB661fC58De57B1E1aF404649a27AD35', - type: 'crypto', - }, - "eurtusd": { - swap: '0x9838eCcC42659FA8AA7daF2aD134b53984c9427b', - swap_token: '0x3b6831c0077a1e44ED0a21841C3bC4dC11bCE833', - name: 'eurtusd', - gauge: '0x4Fd86Ce7Ecea88F7E0aA78DC12625996Fb3a04bC', - type: 'crypto', - }, - "arbitrum-eursusd": { - swap: '0xA827a652Ead76c6B0b3D19dba05452E06e25c27e', - swap_token: '0x3dFe1324A0ee9d86337d06aEB829dEb4528DB9CA', - name: 'arbitrum-eursusd', - gauge: '0x56eda719d82aE45cBB87B7030D3FB485685Bea45', - type: 'crypto', - side_chain: true, - is_killed: true, - }, - "polygon-eurtusd": { - swap: '0xB446BF7b8D6D4276d0c75eC0e3ee8dD7Fe15783A', - swap_token: '0x600743B1d8A96438bD46836fD34977a00293f6Aa', - name: 'polygon-eurtusd', - gauge: '0xAF78381216a8eCC7Ad5957f3cD12a431500E0B0D', - type: 'crypto', - side_chain: true, - is_killed: true, - }, - "f-dola": { - swap: '0xaa5a67c256e27a5d80712c51971408db3370927d', - swap_token: '0xaa5a67c256e27a5d80712c51971408db3370927d', - name: 'f-dola', - gauge: '0x8Fa728F393588E8D8dD1ca397E9a710E53fA553a', - type: 'stable', - factory: true, - }, - "f-tbtc2": { - swap: '0xfa65aa60a9d45623c57d383fb4cf8fb8b854cc4d', - swap_token: '0xfa65aa60a9d45623c57d383fb4cf8fb8b854cc4d', - name: 'f-tbtc2', - gauge: '0x29284d30bcb70e86a6C3f84CbC4de0Ce16b0f1CA', - type: 'bitcoin', - factory: true, - }, - "f-ageur": { - swap: '0xb9446c4ef5ebe66268da6700d26f96273de3d571', - swap_token: '0xb9446c4ef5ebe66268da6700d26f96273de3d571', - name: 'f-ageur', - gauge: '0x1E212e054d74ed136256fc5a5DDdB4867c6E003F', - type: 'tether-eurt', - factory: true, - }, - "crveth": { - swap: '0x8301AE4fc9c624d1D396cbDAa1ed877821D7C511', - swap_token: '0xEd4064f376cB8d68F770FB1Ff088a3d0F3FF5c4d', - name: 'crveth', - gauge: '0x1cEBdB0856dd985fAe9b8fEa2262469360B8a3a6', - type: 'crypto', - }, - rai: { - swap: '0x618788357D0EBd8A37e763ADab3bc575D54c2C7d', - swap_token: '0x6BA5b4e438FA0aAf7C1bD179285aF65d13bD3D90', - name: 'rai', - gauge: '0x66ec719045bBD62db5eBB11184c18237D3Cc2E62', - type: 'stable', - }, - "cvxeth": { - swap: '0xB576491F1E6e5E62f1d8F26062Ee822B40B0E0d4', - swap_token: '0x3A283D9c08E8b55966afb64C515f5143cf907611', - name: 'cvxeth', - gauge: '0x7E1444BA99dcdFfE8fBdb42C02F0005D14f13BE1', - type: 'crypto', - }, - "xautusd": { - swap: '0xAdCFcf9894335dC340f6Cd182aFA45999F45Fc44', - swap_token: '0x8484673cA7BfF40F82B041916881aeA15ee84834', - name: 'xautusd', - gauge: '0x1B3E14157ED33F60668f2103bCd5Db39a1573E5B', - type: 'crypto', - }, - "spelleth": { - swap: '0x98638FAcf9a3865cd033F36548713183f6996122', - swap_token: '0x8282BD15dcA2EA2bDf24163E8f2781B30C43A2ef', - name: 'spelleth', - gauge: '0x08380a4999Be1a958E2abbA07968d703C7A3027C', - type: 'crypto', - }, - "teth": { - swap: '0x752eBeb79963cf0732E9c0fec72a49FD1DEfAEAC', - swap_token: '0xCb08717451aaE9EF950a2524E33B6DCaBA60147B', - name: 'teth', - gauge: '0x6070fBD4E608ee5391189E7205d70cc4A274c017', - type: 'crypto', - }, - "f-fei": { - swap: '0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655', - swap_token: '0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655', - name: 'f-fei', - gauge: '0xdC69D4cB5b86388Fff0b51885677e258883534ae', - type: 'stable', - factory: true, - }, - "f-fxseth": { - swap: '0x941Eb6F616114e4Ecaa85377945EA306002612FE', - swap_token: '0x90244F43D548a4f8dFecfAD91a193465B1fad6F7', - name: 'f-fxseth', - gauge: '0x009aCD89535DAbC270C93F9b39D3232105Fef453', - type: 'crypto', - factory: true, - }, - "f-badgerwbtc": { - swap: '0x50f3752289e1456BfA505afd37B241bca23e685d', - swap_token: '0x137469B55D1f15651BA46A89D0588e97dD0B6562', - name: 'f-badgerwbtc', - gauge: '0x02246583870b36Be0fEf2819E1d3A771d6C07546', - type: 'crypto', - factory: true, - }, - "f-yfieth": { - swap: '0xC26b89A667578ec7b3f11b2F98d6Fd15C07C54ba', - swap_token: '0x29059568bb40344487d62f7450e78b8e6c74e0e5', - name: 'f-yfieth', - gauge: '0x05255C5BD33672b9FEA4129C13274D1E6193312d', - type: 'crypto', - factory: true, - }, - "f-ageuribeur": { - swap: '0xB37D6c07482Bc11cd28a1f11f1a6ad7b66Dec933', - swap_token: '0xB37D6c07482Bc11cd28a1f11f1a6ad7b66Dec933', - name: 'f-ageuribeur', - gauge: '0x38039dD47636154273b287F74C432Cac83Da97e2', - type: 'stable', - factory: true, - }, - "f-fei": { - swap: '0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655', - swap_token: '0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655', - name: 'f-fei', - gauge: '0xdC69D4cB5b86388Fff0b51885677e258883534ae', - type: 'stable', - factory: true, - }, - "f-pwrd": { - swap: '0xbcb91e689114b9cc865ad7871845c95241df4105', - swap_token: '0xbcb91e689114b9cc865ad7871845c95241df4105', - name: 'f-pwrd', - gauge: '0xb07d00e0eE9b1b2eb9f1B483924155Af7AF0c8Fa', - type: 'stable', - factory: true, - }, - "f-cadcusdc": { - swap: '0xE07BDe9Eb53DEFfa979daE36882014B758111a78', - swap_token: '0x1054Ff2ffA34c055a13DCD9E0b4c0cA5b3aecEB9', - name: 'f-cadcusdc', - gauge: '0xE786Df7076AFeECC3faCD841ED4AD20d0F04CF19', - type: 'crypto', - factory: true, - }, - "f-sdteth": { - swap: '0xfB8814D005C5f32874391e888da6eB2fE7a27902', - swap_token: '0x6359b6d3e327c497453d4376561ee276c6933323', - name: 'f-sdteth', - gauge: '0x60355587a8D4aa67c2E64060Ab36e566B9bCC000', - type: 'crypto', - factory: true, - }, - "f-dydxeth": { - swap: '0x8b0aFa4b63a3581b731dA9D79774a3eaE63B5ABD', - swap_token: '0x4acc1bf7d6a591016641325aa6664a1cd178f002', - name: 'f-dydxeth', - gauge: '0xB81465Ac19B9a57158a79754bDaa91C60fDA91ff', - type: 'crypto', - factory: true, - }, - "f-aavepalstkaave": { - swap: '0x48536EC5233297C367fd0b6979B75d9270bB6B15', - swap_token: '0x6085deF4343a0b5d97820F131a362Dae9fE59841', - name: 'f-aavepalstkaave', - gauge: '0x82d0aDea8C4CF2fc84A499b568F4C1194d63113d', - type: 'crypto', - factory: true, - hasNoCrv: true, // Hasn't been voted in yet, isn't in gauge controller, doesn't receive CRV - }, - "f-cvxfxs": { - swap: '0xd658A338613198204DCa1143Ac3F01A722b5d94A', - swap_token: '0xF3A43307DcAFa93275993862Aae628fCB50dC768', - name: 'f-cvxfxs', - gauge: '0xAB1927160EC7414C6Fa71763E2a9f3D107c126dd', - type: 'crypto', - factory: true, - }, - "f-rocketethwsteth": { - swap: '0x447ddd4960d9fdbf6af9a790560d0af76795cb08', - swap_token: '0x447ddd4960d9fdbf6af9a790560d0af76795cb08', - name: 'f-rocketethwsteth', - gauge: '0x8aD7e0e6EDc61bC48ca0DD07f9021c249044eD30', - type: 'ethereum', - factory: true, - }, - "f-btrflyeth": { - swap: '0xF43b15Ab692fDe1F9c24a9FCE700AdCC809D5391', - swap_token: '0xE160364FD8407FFc8b163e278300c6C5D18Ff61d', - name: 'f-btrflyeth', - gauge: '0x5AC6886Edd18ED0AD01C0B0910660637c551FBd6', - type: 'ethereum', - factory: true, - }, - "f-pbtc": { - swap: '0xc9467e453620f16b57a34a770c6bcebece002587', - swap_token: '0xc9467e453620f16b57a34a770c6bcebece002587', - name: 'f-pbtc', - gauge: '0xB5efA93d5D23642f970aF41a1ea9A26f19CbD2Eb', - type: 'bitcoin', - factory: true, - }, - "f-silofrax": { - swap: '0x9a22CDB1CA1cdd2371cD5BB5199564C4E89465eb', - swap_token: '0x2302aabe69e6e7a1b0aa23aac68fccb8a4d2b460', - name: 'f-silofrax', - gauge: '0x784342E983E9283A7108F20FcA21995534b3fE65', - type: 'crypto', - factory: true, - }, - "f-stgusdc": { - swap: '0x3211C6cBeF1429da3D0d58494938299C92Ad5860', - swap_token: '0xdf55670e27bE5cDE7228dD0A6849181891c9ebA1', - name: 'f-stgusdc', - gauge: '0x95d16646311fDe101Eb9F897fE06AC881B7Db802', - type: 'crypto', - factory: true, - }, - "f-bean": { - swap: '0x3a70dfa7d2262988064a2d051dd47521e43c9bdd', - swap_token: '0x3a70dfa7d2262988064a2d051dd47521e43c9bdd', - name: 'f-bean', - gauge: '0x6F98dA2D5098604239C07875C6B7Fd583BC520b9', - type: 'stable', - factory: true, - is_killed: true, - }, - "f-lfteth": { - swap: '0xfE4A08f22FE65759Ba91dB2E2CADa09B4415B0d7', - swap_token: '0x401322B9FDdba8c0a8D40fbCECE1D1752C12316B', - name: 'f-lfteth', - gauge: '0x46521Db0D31A62A2CBF8D1A7Cdc6bBBBC441A1fc', - type: 'crypto', - factory: true, - }, - "f-seth2steth": { - swap: '0xE95E4c2dAC312F31Dc605533D5A4d0aF42579308', - swap_token: '0xE95E4c2dAC312F31Dc605533D5A4d0aF42579308', - name: 'f-seth2steth', - gauge: '0xeCb860e54E33FEA8fAb5B076734e2591D1A9ebA4', - type: 'stable', - factory: true, - }, - "f-jpegeth": { - swap: '0x7E050cf658777cc1Da4a4508E79d71859044B60E', - swap_token: '0x34ed182d0812d119c92907852d2b429f095a9b07', - name: 'f-jpegeth', - gauge: '0xFA49B2a5D9E77f6748bf05801aa22356D514137b', - type: 'crypto', - factory: true, - }, - "f-fpifrax": { - swap: '0xf861483fa7E511fbc37487D91B6FAa803aF5d37c', - swap_token: '0x4704ab1fb693ce163f7c9d3a31b3ff4eaf797714', - name: 'f-fpifrax', - gauge: '0xdB7cbbb1d5D5124F86E92001C9dFDC068C05801D', - type: 'crypto', - factory: true, - }, - "f-ibaudusdc": { - swap: '0x5b692073F141C31384faE55856CfB6CBfFE91E60', - swap_token: '0x54c8ecf46a81496eeb0608bd3353388b5d7a2a33', - name: 'f-ibaudusdc', - gauge: '0x1779AEB087C5BdBe48749ab03575f5f25D1DEeaF', - type: 'crypto', - factory: true, - }, - "f-ibchfusdc": { - swap: '0x6Df0D77F0496CE44e72D695943950D8641fcA5Cf', - swap_token: '0x08ceA8E5B4551722dEB97113C139Dd83C26c5398', - name: 'f-ibchfusdc', - gauge: '0x36C66bC294fEf4e94B3e40A1801d0AB0085Fe96e', - type: 'crypto', - factory: true, - }, - "f-ibeurusdc": { - swap: '0x1570af3dF649Fc74872c5B8F280A162a3bdD4EB6', - swap_token: '0x8682Fbf0CbF312C891532BA9F1A91e44f81ad7DF', - name: 'f-ibeurusdc', - gauge: '0xE1D520B1263D6Be5678568BD699c84F7f9086023', - type: 'crypto', - factory: true, - }, - "f-ibgbpusdc": { - swap: '0xAcCe4Fe9Ce2A6FE9af83e7CF321a3fF7675e0AB6', - swap_token: '0x22CF19EB64226e0E1A79c69b345b31466fD273A7', - name: 'f-ibgbpusdc', - gauge: '0x1Ba86c33509013c937344f6e231DA2E63ea45197', - type: 'crypto', - factory: true, - }, - "f-ibjpyusdc": { - swap: '0xEB0265938c1190Ab4E3E1f6583bC956dF47C0F93', - swap_token: '0x127091ede112aed7bae281747771b3150bb047bb', - name: 'f-ibjpyusdc', - gauge: '0x3A748A2F4765BDFB119Cb7143b884Db7594a68c3', - type: 'crypto', - factory: true, - }, - "f-ibkrwusdc": { - swap: '0xef04f337fCB2ea220B6e8dB5eDbE2D774837581c', - swap_token: '0x80CAcCdBD3f07BbdB558DB4a9e146D099933D677', - name: 'f-ibkrwusdc', - gauge: '0xb6d7C2bda5a907832d4556AE5f7bA800FF084C2a', - type: 'crypto', - factory: true, - }, - "f-kp3reth": { - swap: '0x21410232B484136404911780bC32756D5d1a9Fa9', - swap_token: '0x4647B6D835f3B393C7A955df51EEfcf0db961606', - name: 'f-kp3reth', - gauge: '0x6d3328F0333f6FB0B2FaC87cF5a0FFa7e77beB60', - type: 'crypto', - factory: true, - }, - "f-pusd": { - swap: '0x8ee017541375f6bcd802ba119bddc94dad6911a1', - swap_token: '0x8ee017541375f6bcd802ba119bddc94dad6911a1', - name: 'f-pusd', - gauge: '0x89664D561E79Ca22Fd2eA4076b3e5deF0b219C15', - type: 'stable', - factory: true, - }, - "f-ohmeth": { - swap: '0x6ec38b3228251a0C5D491Faf66858e2E23d7728B', - swap_token: '0x3660BD168494d61ffDac21E403d0F6356cF90fD7', - name: 'f-ohmeth', - gauge: '0x8dF6FdAe05C9405853dd4cF2809D5dc2b5E77b0C', - type: 'crypto', - factory: true, - }, - "f-paleth": { - swap: '0x75A6787C7EE60424358B449B539A8b774c9B4862', - swap_token: '0xbe4f3ad6c9458b901c81b734cb22d9eae9ad8b50', - name: 'f-paleth', - gauge: '0x4fb13b55D6535584841dbBdb14EDC0258F7aC414', - type: 'crypto', - factory: true, - }, - "f-sdfxsfxs": { - swap: '0x8c524635d52bd7b1bd55e062303177a7d916c046', - swap_token: '0x8c524635d52bd7b1bd55e062303177a7d916c046', - name: 'f-sdfxsfxs', - gauge: '0xa9A9BC60fc80478059A83f516D5215185eeC2fc0', - type: 'stable', - factory: true, - }, - "f-sdagag": { - swap: '0x48ff31bbbd8ab553ebe7cbd84e1ea3dba8f54957', - swap_token: '0x48ff31bbbd8ab553ebe7cbd84e1ea3dba8f54957', - name: 'f-sdagag', - gauge: '0x03fFC218C7A9306D21193565CbDc4378952faA8c', - type: 'stable', - factory: true, - }, - "f-sdcrvcrv": { - swap: '0xf7b55c3732ad8b2c2da7c24f30a69f55c54fb717', - swap_token: '0xf7b55c3732ad8b2c2da7c24f30a69f55c54fb717', - name: 'f-sdcrvcrv', - gauge: '0x663FC22e92f26C377Ddf3C859b560C4732ee639a', - type: 'stable', - factory: true, - }, - "4pool": { - swap: '0x4e0915c88bc70750d68c481540f081fefaf22273', - swap_token: '0x4e0915c88bc70750d68c481540f081fefaf22273', - name: '4pool', - gauge: '0x34883134A39B206A451c2D3B0E7Cac44BE4D9181', - type: 'stable', - factory: false, - }, - "2pool": { - swap: '0x1005f7406f32a61bd760cfa14accd2737913d546', - swap_token: '0x1005f7406f32a61bd760cfa14accd2737913d546', - name: '2pool', - gauge: '0x9f330Db38caAAe5B61B410e2f0aaD63fff2109d8', - type: 'stable', - factory: false, - }, - "f-usdd3crv": { - swap: '0xe6b5cc1b4b47305c58392ce3d359b10282fc36ea', - swap_token: '0xe6b5cc1b4b47305c58392ce3d359b10282fc36ea', - name: 'f-usdd3crv', - gauge: '0xd5d3efC90fFB38987005FdeA303B68306aA5C624', - type: 'stable', - factory: true, - }, - "f-stethconcentrated": { - swap: '0x828b154032950C8ff7CF8085D841723Db2696056', - swap_token: '0x828b154032950C8ff7CF8085D841723Db2696056', - name: 'f-stethconcentrated', - gauge: '0xf668e6d326945d499e5b35e7cd2e82acfbcfe6f0', - type: 'stable', - factory: true, - hasNoCrv: true, // Hasn't been voted in yet, isn't in gauge controller, doesn't receive CRV - }, - "f-tokeeth": { - swap: '0xe0e970a99bc4F53804D8145beBBc7eBc9422Ba7F', - swap_token: '0x7ea4ad8c803653498bf6ac1d2debc04dce8fd2ad', - name: 'f-tokeeth', - gauge: '0xa0C08C0Aede65a0306F7dD042D2560dA174c91fC', - type: 'crypto', - factory: true, - }, - "2pool-frax": { - swap: '0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2', - swap_token: '0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC', - name: '2pool-frax', - gauge: '0xCFc25170633581Bf896CB6CDeE170e3E3Aa59503', - type: 'stable', - factory: false, - }, - "euroc": { - swap: '0xE84f5b1582BA325fDf9cE6B0c1F087ccfC924e54', - swap_token: '0x70fc957eb90E37Af82ACDbd12675699797745F68', - name: 'euroc', - gauge: '0x4329c8F09725c0e3b6884C1daB1771bcE17934F9', - type: 'crypto', - factory: false, - }, - "f-frethweth": { - swap: '0x6E77889Ff348A16547cABa3Ce011cB120Ed73bFc', - swap_token: '0x517E47a2e8c38E5A96708ED866A39CcbAA105640', - name: 'f-frethweth', - gauge: '0x25530f3c929d3f4137a766de3d37700d2fc00ff8', - type: 'crypto', - factory: true, - hasNoCrv: true, // Hasn't been voted in yet, isn't in gauge controller, doesn't receive CRV - }, - "f-staxfraxtemplelp": { - swap: '0xdaDfD00A2bBEb1abc4936b1644a3033e1B653228', - swap_token: '0xdaDfD00A2bBEb1abc4936b1644a3033e1B653228', - name: 'f-staxfraxtemplelp', - gauge: '0x8f162742a7BCDb87EB52d83c687E43356055a68B', - type: 'stable', - factory: true, - }, - "f-fraxbpsusd": { - swap: '0xe3c190c57b5959ae62efe3b6797058b76ba2f5ef', - swap_token: '0xe3c190c57b5959ae62efe3b6797058b76ba2f5ef', - name: 'f-fraxbpsusd', - gauge: '0xf6D7087D4Ae4dCf85956d743406E63cDA74D99AD', - type: 'stable', - factory: true, - }, - "f-fraxbplusd": { - swap: '0x497ce58f34605b9944e6b15ecafe6b001206fd25', - swap_token: '0x497ce58f34605b9944e6b15ecafe6b001206fd25', - name: 'f-fraxbplusd', - gauge: '0x389Fc079a15354E9cbcE8258433CC0F85B755A42', - type: 'stable', - factory: true, - }, - "f-fraxbpape": { - swap: '0x04b727c7e246ca70d496ecf52e6b6280f3c8077d', - swap_token: '0x04b727c7e246ca70d496ecf52e6b6280f3c8077d', - name: 'f-fraxbpape', - gauge: '0xD6e48Cc0597a1Ee12a8BeEB88e22bFDb81777164', - type: 'stable', - factory: true, - }, - "f-fraxbpgusd": { - swap: '0x4e43151b78b5fbb16298c1161fcbf7531d5f8d93', - swap_token: '0x4e43151b78b5fbb16298c1161fcbf7531d5f8d93', - name: 'f-fraxbpgusd', - gauge: '0xda7F9DD286577cC338047B040c289463743a474e', - type: 'stable', - factory: true, - }, - "f-fraxbpbusd": { - swap: '0x8fdb0bb9365a46b145db80d0b1c5c5e979c84190', - swap_token: '0x8fdb0bb9365a46b145db80d0b1c5c5e979c84190', - name: 'f-fraxbpbusd', - gauge: '0xAeac6Dcd12CC0BE74c8f99EfE4bB5205a1f9A608', - type: 'stable', - factory: true, - }, - "f-fraxbpalusd": { - swap: '0xb30da2376f63de30b42dc055c93fa474f31330a5', - swap_token: '0xb30da2376f63de30b42dc055c93fa474f31330a5', - name: 'f-fraxbpalusd', - gauge: '0x740BA8aa0052E07b925908B380248cb03f3DE5cB', - type: 'stable', - factory: true, - }, - "f-fraxbpusdd": { - swap: '0x4606326b4db89373f5377c316d3b0f6e55bc6a20', - swap_token: '0x4606326b4db89373f5377c316d3b0f6e55bc6a20', - name: 'f-fraxbpusdd', - gauge: '0xb8b9dfCB48614FA873ccEC72c79D728d39EC9a5c', - type: 'stable', - factory: true, - }, - "f-fraxbptusd": { - swap: '0x33baeda08b8afacc4d3d07cf31d49fc1f1f3e893', - swap_token: '0x33baeda08b8afacc4d3d07cf31d49fc1f1f3e893', - name: 'f-fraxbptusd', - gauge: '0xf865FDd6a5F307F398a94Dc40687995Cfaa77BC9', - type: 'stable', - factory: true, - }, - "f-europool": { - swap: '0xe7a3b38c39f97e977723bd1239c3470702568e7b', - swap_token: '0xe7a3b38c39f97e977723bd1239c3470702568e7b', - name: 'f-europool', - gauge: '0x9f57569EaA61d427dEEebac8D9546A745160391C', - type: 'stable', - factory: true, - }, - "f-ageureuroc": { - swap: '0xBa3436Fd341F2C8A928452Db3C5A3670d1d5Cc73', - swap_token: '0xBa3436Fd341F2C8A928452Db3C5A3670d1d5Cc73', - name: 'f-ageureuroc', - gauge: '0xF9F46eF781b9C7B76e8B505226d5E0e0E7FE2f04', - type: 'stable', - factory: true, - }, - // "f-pusdfraxbp": { - // swap: '0xC47EBd6c0f68fD5963005D28D0ba533750E5C11B', - // swap_token: '0xC47EBd6c0f68fD5963005D28D0ba533750E5C11B', - // name: 'f-pusdfraxbp', - // gauge: '0x28216318D85b2D6d8c2cB38eed08001d9348803b', - // type: 'stable', - // factory: true, - // }, - "f-dolafraxbp": { - swap: '0xE57180685E3348589E9521aa53Af0BCD497E884d', - swap_token: '0xE57180685E3348589E9521aa53Af0BCD497E884d', - name: 'f-dolafraxbp', - gauge: '0xBE266d68Ce3dDFAb366Bb866F4353B6FC42BA43c', - type: 'stable', - factory: true, - }, - "f-ageurfraxbp": { - swap: '0x58257e4291F95165184b4beA7793a1d6F8e7b627', - swap_token: '0x22e859Ee894c2068920858A60b51DC03ac5581c1', - name: 'f-ageurfraxbp', - gauge: '0xf74175aCe638E612a0a3B09E6bE89795ff48E06D', - type: 'crypto', - factory: true, - }, - "f-cvxfraxbp": { - swap: '0xBEc570d92AFB7fFc553bdD9d4B4638121000b10D', - swap_token: '0x7F17A6C77C3938D235b014818092eb6305BdA110', - name: 'f-cvxfraxbp', - gauge: '0xaa386EF96A910Ee2F9cbEf7B139e99A88DF3b2ba', - type: 'crypto', - factory: true, - }, - "f-cvxcrvfraxbp": { - swap: '0x31c325A01861c7dBd331a9270296a31296D797A0', - swap_token: '0x527331F3F550f6f85ACFEcAB9Cc0889180C6f1d5', - name: 'f-cvxcrvfraxbp', - gauge: '0xa47d0837F84Fb2d1aA08077D10d10101316a959d', - type: 'crypto', - factory: true, - }, - "f-cvxfxsfraxbp": { - swap: '0x21d158d95C2e150e144c36FC64E3653B8D6c6267', - swap_token: '0xF57ccaD8122B898A147Cc8601B1ECA88B1662c7E', - name: 'f-cvxfxsfraxbp', - gauge: '0xc7A770dE69479bEEEEf22b2C9851760BaC3630Da', - type: 'crypto', - factory: true, - }, - "f-alcxfraxbp": { - swap: '0x4149d1038575CE235E03E03B39487a80FD709D31', - swap_token: '0xf985005a3793DbA4cCe241B3C19ddcd3Fe069ff4', - name: 'f-alcxfraxbp', - gauge: '0xD5bE6A05B45aEd524730B6d1CC05F59b021f6c87', - type: 'crypto', - factory: true, - }, - } + "f-ibgbp": { + swap: '0xd6ac1cb9019137a896343da59dde6d097f710538', + swap_token: '0xd6ac1cb9019137a896343da59dde6d097f710538', + name: 'f-ibgbp', + gauge: '0x63d9f3aB7d0c528797A12a0684E50C397E9e79dC', + type: 'truegbp', + factory: true + }, + "f-ibaud": { + swap: '0x3f1b0278a9ee595635b61817630cc19de792f506', + swap_token: '0x3f1b0278a9ee595635b61817630cc19de792f506', + name: 'f-ibaud', + gauge: '0x05ca5c01629a8E5845f12ea3A03fF7331932233A', + type: 'saud', + factory: true + }, + "f-ibeur": { + swap: '0x19b080fe1ffa0553469d20ca36219f17fcf03859', + swap_token: '0x19b080fe1ffa0553469d20ca36219f17fcf03859', + name: 'f-ibeur', + gauge: '0x99fb76F75501039089AAC8f20f487bf84E51d76F', + type: 'tether-eurt', + factory: true + }, + "f-ibchf": { + swap: '0x9c2c8910f113181783c249d8f6aa41b51cde0f0c', + swap_token: '0x9c2c8910f113181783c249d8f6aa41b51cde0f0c', + name: 'f-ibchf', + gauge: '0x2fA53e8fa5fAdb81f4332C8EcE39Fe62eA2f919E', + type: 'cryptofranc', + factory: true + }, + "f-ibkrw": { + swap: '0x8461a004b50d321cb22b7d034969ce6803911899', + swap_token: '0x8461a004b50d321cb22b7d034969ce6803911899', + name: 'f-ibkrw', + gauge: '0x1750a3a3d80A3F5333BBe9c4695B0fAd41061ab1', + type: 'terra-krw', + factory: true + }, + "ousd": { + swap: '0x87650D7bbfC3A9F10587d7778206671719d9910D', + swap_token: '0x87650D7bbfC3A9F10587d7778206671719d9910D', + name: 'ousd', + gauge: '0x25f0cE4E2F8dbA112D9b115710AC297F816087CD', + type: 'stable', + factory: true, + }, + "arbitrum-tricrypto": { + swap: '0x960ea3e3C7FB317332d990873d354E18d7645590', + swap_token: '0x8e0B8c8BB9db49a46697F3a5Bb8A308e744821D2', + name: 'arbitrum-tricrypto', + gauge: '0x9044E12fB1732f88ed0c93cfa5E9bB9bD2990cE5', + type: 'crypto', + side_chain: true, + is_killed: true, + }, + "arbitrum-2pool": { + swap: '0x7f90122bf0700f9e7e1f688fe926940e8839f353', + swap_token: '0x7f90122bf0700f9e7e1f688fe926940e8839f353', + name: 'arbitrum-2pool', + gauge: '0xFf17560d746F85674FE7629cE986E949602EF948', + type: 'stable', + side_chain: true, + is_killed: true, + }, + "arbitrum-ren": { + swap: '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb', + swap_token: '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb', + name: 'arbitrum-ren', + gauge: '0x9F86c5142369B1Ffd4223E5A2F2005FC66807894', + type: 'bitcoin', + side_chain: true, + is_killed: true, + }, + "fantom-tricrypto": { + swap: '0x3a1659Ddcf2339Be3aeA159cA010979FB49155FF', + swap_token: '0x58e57cA18B7A47112b877E31929798Cd3D703b0f', + name: 'fantom-tricrypto', + gauge: '0x260e4fBb13DD91e187AE992c3435D0cf97172316', + type: 'crypto', + side_chain: true, + is_killed: true, + }, + "f-aleth": { + swap: '0xc4c319e2d4d66cca4464c0c2b32c9bd23ebe784e', + swap_token: '0xc4c319e2d4d66cca4464c0c2b32c9bd23ebe784e', + name: 'f-aleth', + gauge: '0x12dCD9E8D1577b5E4F066d8e7D404404Ef045342', + type: 'ethereum', + factory: true, + }, + "f-eurn": { + swap: '0x3fb78e61784c9c637d560ede23ad57ca1294c14a', + swap_token: '0x3fb78e61784c9c637d560ede23ad57ca1294c14a', + name: 'f-eurn', + gauge: '0xD9277b0D007464eFF133622eC0d42081c93Cef02', + type: 'tether-eurt', + factory: true, + }, + "f-usdm": { + swap: '0x5b3b5df2bf2b6543f78e053bd91c4bdd820929f1', + swap_token: '0x5b3b5df2bf2b6543f78e053bd91c4bdd820929f1', + name: 'f-usdm', + gauge: '0x9AF13a7B1f1Bbf1A2B05c6fBF23ac23A9E573b4E', + type: 'stable', + is_killed: true, + factory: true, + }, + "f-ust-mim": { + swap: '0x55a8a39bc9694714e2874c1ce77aa1e599461e18', + swap_token: '0x55a8a39bc9694714e2874c1ce77aa1e599461e18', + name: 'f-ust-mim', + gauge: '0xB518f5e3242393d4eC792BD3f44946A3b98d0E48', + type: 'stable', + factory: true, + is_killed: true, + }, + "avalanche-a3CRV": { + swap: '0x7f90122BF0700F9E7e1F688fe926940E8839F353', + swap_token: '0x1337BedC9D22ecbe766dF105c9623922A27963EC', + name: 'avalanche-a3CRV', + gauge: '0xB504b6EB06760019801a91B451d3f7BD9f027fC9', + type: 'stable', + side_chain: true, + is_killed: true, + }, + "avalanche-ren": { + swap: '0x16a7DA911A4DD1d83F3fF066fE28F3C792C50d90', + swap_token: '0xC2b1DF84112619D190193E48148000e3990Bf627', + name: 'avalanche-ren', + gauge: '0x75D05190f35567e79012c2F0a02330D3Ed8a1F74', + type: 'bitcoin', + side_chain: true, + is_killed: true, + }, + "avalanche-atricrypto": { + swap: '0xB755B949C126C04e0348DD881a5cF55d424742B2', + swap_token: '0x1daB6560494B04473A0BE3E7D83CF3Fdf3a51828', + name: 'avalanche-atricrypto', + gauge: '0xa05E565cA0a103FcD999c7A7b8de7Bd15D5f6505', + type: 'crypto', + side_chain: true, + is_killed: true, + }, + "harmony-3pool": { + swap: '0xC5cfaDA84E902aD92DD40194f0883ad49639b023', + swap_token: '0xC5cfaDA84E902aD92DD40194f0883ad49639b023', + name: 'harmony-3pool', + gauge: '0xf2Cde8c47C20aCbffC598217Ad5FE6DB9E00b163', + type: 'stable', + side_chain: true + }, + "f-d3pool": { + swap: '0xbaaa1f5dba42c3389bdbc2c9d2de134f5cd0dc89', + swap_token: '0xbaaa1f5dba42c3389bdbc2c9d2de134f5cd0dc89', + name: 'f-d3pool', + gauge: '0x16C2beE6f55dAB7F494dBa643fF52ef2D47FBA36', + type: 'stable', + factory: true, + }, + "f-usdpax": { + swap: '0xc270b3b858c335b6ba5d5b10e2da8a09976005ad', + swap_token: '0xc270b3b858c335b6ba5d5b10e2da8a09976005ad', + name: 'f-usdpax', + gauge: '0xC95bdf13A08A547E4dD9f29B00aB7fF08C5d093d', + type: 'stable', + factory: true, + }, + "f-ustw": { + swap: '0xceaf7747579696a2f0bb206a14210e3c9e6fb269', + swap_token: '0xceaf7747579696a2f0bb206a14210e3c9e6fb269', + name: 'f-ustw', + gauge: '0xb0f5d00e5916c8b8981e99191A1458704B587b2b', + type: 'stable', + factory: true, + is_killed: true, + }, + "f-ibbtc": { + swap: '0xfbdca68601f835b27790d98bbb8ec7f05fdeaa9b', + swap_token: '0xfbdca68601f835b27790d98bbb8ec7f05fdeaa9b', + name: 'f-ibbtc', + gauge: '0x346C7BB1A7a6A30c8e81c14e90FC2f0FBddc54d8', + type: 'bitcoin', + factory: true, + }, + "eursusd": { + swap: '0x98a7F18d4E56Cfe84E3D081B40001B3d5bD3eB8B', + swap_token: '0x3d229e1b4faab62f621ef2f6a610961f7bd7b23b', + name: 'eursusd', + gauge: '0x65CA7Dc5CB661fC58De57B1E1aF404649a27AD35', + type: 'crypto', + }, + "eurtusd": { + swap: '0x9838eCcC42659FA8AA7daF2aD134b53984c9427b', + swap_token: '0x3b6831c0077a1e44ED0a21841C3bC4dC11bCE833', + name: 'eurtusd', + gauge: '0x4Fd86Ce7Ecea88F7E0aA78DC12625996Fb3a04bC', + type: 'crypto', + }, + "arbitrum-eursusd": { + swap: '0xA827a652Ead76c6B0b3D19dba05452E06e25c27e', + swap_token: '0x3dFe1324A0ee9d86337d06aEB829dEb4528DB9CA', + name: 'arbitrum-eursusd', + gauge: '0x56eda719d82aE45cBB87B7030D3FB485685Bea45', + type: 'crypto', + side_chain: true, + is_killed: true, + }, + "polygon-eurtusd": { + swap: '0xB446BF7b8D6D4276d0c75eC0e3ee8dD7Fe15783A', + swap_token: '0x600743B1d8A96438bD46836fD34977a00293f6Aa', + name: 'polygon-eurtusd', + gauge: '0xAF78381216a8eCC7Ad5957f3cD12a431500E0B0D', + type: 'crypto', + side_chain: true, + is_killed: true, + }, + "f-dola": { + swap: '0xaa5a67c256e27a5d80712c51971408db3370927d', + swap_token: '0xaa5a67c256e27a5d80712c51971408db3370927d', + name: 'f-dola', + gauge: '0x8Fa728F393588E8D8dD1ca397E9a710E53fA553a', + type: 'stable', + factory: true, + }, + "f-tbtc2": { + swap: '0xfa65aa60a9d45623c57d383fb4cf8fb8b854cc4d', + swap_token: '0xfa65aa60a9d45623c57d383fb4cf8fb8b854cc4d', + name: 'f-tbtc2', + gauge: '0x29284d30bcb70e86a6C3f84CbC4de0Ce16b0f1CA', + type: 'bitcoin', + factory: true, + }, + "f-ageur": { + swap: '0xb9446c4ef5ebe66268da6700d26f96273de3d571', + swap_token: '0xb9446c4ef5ebe66268da6700d26f96273de3d571', + name: 'f-ageur', + gauge: '0x1E212e054d74ed136256fc5a5DDdB4867c6E003F', + type: 'tether-eurt', + factory: true, + }, + "crveth": { + swap: '0x8301AE4fc9c624d1D396cbDAa1ed877821D7C511', + swap_token: '0xEd4064f376cB8d68F770FB1Ff088a3d0F3FF5c4d', + name: 'crveth', + gauge: '0x1cEBdB0856dd985fAe9b8fEa2262469360B8a3a6', + type: 'crypto', + }, + rai: { + swap: '0x618788357D0EBd8A37e763ADab3bc575D54c2C7d', + swap_token: '0x6BA5b4e438FA0aAf7C1bD179285aF65d13bD3D90', + name: 'rai', + gauge: '0x66ec719045bBD62db5eBB11184c18237D3Cc2E62', + type: 'stable', + }, + "cvxeth": { + swap: '0xB576491F1E6e5E62f1d8F26062Ee822B40B0E0d4', + swap_token: '0x3A283D9c08E8b55966afb64C515f5143cf907611', + name: 'cvxeth', + gauge: '0x7E1444BA99dcdFfE8fBdb42C02F0005D14f13BE1', + type: 'crypto', + }, + "xautusd": { + swap: '0xAdCFcf9894335dC340f6Cd182aFA45999F45Fc44', + swap_token: '0x8484673cA7BfF40F82B041916881aeA15ee84834', + name: 'xautusd', + gauge: '0x1B3E14157ED33F60668f2103bCd5Db39a1573E5B', + type: 'crypto', + }, + "spelleth": { + swap: '0x98638FAcf9a3865cd033F36548713183f6996122', + swap_token: '0x8282BD15dcA2EA2bDf24163E8f2781B30C43A2ef', + name: 'spelleth', + gauge: '0x08380a4999Be1a958E2abbA07968d703C7A3027C', + type: 'crypto', + }, + "teth": { + swap: '0x752eBeb79963cf0732E9c0fec72a49FD1DEfAEAC', + swap_token: '0xCb08717451aaE9EF950a2524E33B6DCaBA60147B', + name: 'teth', + gauge: '0x6070fBD4E608ee5391189E7205d70cc4A274c017', + type: 'crypto', + }, + "f-fei": { + swap: '0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655', + swap_token: '0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655', + name: 'f-fei', + gauge: '0xdC69D4cB5b86388Fff0b51885677e258883534ae', + type: 'stable', + factory: true, + }, + "f-fxseth": { + swap: '0x941Eb6F616114e4Ecaa85377945EA306002612FE', + swap_token: '0x90244F43D548a4f8dFecfAD91a193465B1fad6F7', + name: 'f-fxseth', + gauge: '0x009aCD89535DAbC270C93F9b39D3232105Fef453', + type: 'crypto', + factory: true, + }, + "f-badgerwbtc": { + swap: '0x50f3752289e1456BfA505afd37B241bca23e685d', + swap_token: '0x137469B55D1f15651BA46A89D0588e97dD0B6562', + name: 'f-badgerwbtc', + gauge: '0x02246583870b36Be0fEf2819E1d3A771d6C07546', + type: 'crypto', + factory: true, + }, + "f-yfieth": { + swap: '0xC26b89A667578ec7b3f11b2F98d6Fd15C07C54ba', + swap_token: '0x29059568bb40344487d62f7450e78b8e6c74e0e5', + name: 'f-yfieth', + gauge: '0x05255C5BD33672b9FEA4129C13274D1E6193312d', + type: 'crypto', + factory: true, + }, + "f-ageuribeur": { + swap: '0xB37D6c07482Bc11cd28a1f11f1a6ad7b66Dec933', + swap_token: '0xB37D6c07482Bc11cd28a1f11f1a6ad7b66Dec933', + name: 'f-ageuribeur', + gauge: '0x38039dD47636154273b287F74C432Cac83Da97e2', + type: 'stable', + factory: true, + }, + "f-fei": { + swap: '0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655', + swap_token: '0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655', + name: 'f-fei', + gauge: '0xdC69D4cB5b86388Fff0b51885677e258883534ae', + type: 'stable', + factory: true, + }, + "f-pwrd": { + swap: '0xbcb91e689114b9cc865ad7871845c95241df4105', + swap_token: '0xbcb91e689114b9cc865ad7871845c95241df4105', + name: 'f-pwrd', + gauge: '0xb07d00e0eE9b1b2eb9f1B483924155Af7AF0c8Fa', + type: 'stable', + factory: true, + }, + "f-cadcusdc": { + swap: '0xE07BDe9Eb53DEFfa979daE36882014B758111a78', + swap_token: '0x1054Ff2ffA34c055a13DCD9E0b4c0cA5b3aecEB9', + name: 'f-cadcusdc', + gauge: '0xE786Df7076AFeECC3faCD841ED4AD20d0F04CF19', + type: 'crypto', + factory: true, + }, + "f-sdteth": { + swap: '0xfB8814D005C5f32874391e888da6eB2fE7a27902', + swap_token: '0x6359b6d3e327c497453d4376561ee276c6933323', + name: 'f-sdteth', + gauge: '0x60355587a8D4aa67c2E64060Ab36e566B9bCC000', + type: 'crypto', + factory: true, + }, + "f-dydxeth": { + swap: '0x8b0aFa4b63a3581b731dA9D79774a3eaE63B5ABD', + swap_token: '0x4acc1bf7d6a591016641325aa6664a1cd178f002', + name: 'f-dydxeth', + gauge: '0xB81465Ac19B9a57158a79754bDaa91C60fDA91ff', + type: 'crypto', + factory: true, + }, + "f-aavepalstkaave": { + swap: '0x48536EC5233297C367fd0b6979B75d9270bB6B15', + swap_token: '0x6085deF4343a0b5d97820F131a362Dae9fE59841', + name: 'f-aavepalstkaave', + gauge: '0x82d0aDea8C4CF2fc84A499b568F4C1194d63113d', + type: 'crypto', + factory: true, + hasNoCrv: true, // Hasn't been voted in yet, isn't in gauge controller, doesn't receive CRV + }, + "f-cvxfxs": { + swap: '0xd658A338613198204DCa1143Ac3F01A722b5d94A', + swap_token: '0xF3A43307DcAFa93275993862Aae628fCB50dC768', + name: 'f-cvxfxs', + gauge: '0xAB1927160EC7414C6Fa71763E2a9f3D107c126dd', + type: 'crypto', + factory: true, + }, + "f-rocketethwsteth": { + swap: '0x447ddd4960d9fdbf6af9a790560d0af76795cb08', + swap_token: '0x447ddd4960d9fdbf6af9a790560d0af76795cb08', + name: 'f-rocketethwsteth', + gauge: '0x8aD7e0e6EDc61bC48ca0DD07f9021c249044eD30', + type: 'ethereum', + factory: true, + }, + "f-btrflyeth": { + swap: '0xF43b15Ab692fDe1F9c24a9FCE700AdCC809D5391', + swap_token: '0xE160364FD8407FFc8b163e278300c6C5D18Ff61d', + name: 'f-btrflyeth', + gauge: '0x5AC6886Edd18ED0AD01C0B0910660637c551FBd6', + type: 'ethereum', + factory: true, + }, + "f-pbtc": { + swap: '0xc9467e453620f16b57a34a770c6bcebece002587', + swap_token: '0xc9467e453620f16b57a34a770c6bcebece002587', + name: 'f-pbtc', + gauge: '0xB5efA93d5D23642f970aF41a1ea9A26f19CbD2Eb', + type: 'bitcoin', + factory: true, + }, + "f-silofrax": { + swap: '0x9a22CDB1CA1cdd2371cD5BB5199564C4E89465eb', + swap_token: '0x2302aabe69e6e7a1b0aa23aac68fccb8a4d2b460', + name: 'f-silofrax', + gauge: '0x784342E983E9283A7108F20FcA21995534b3fE65', + type: 'crypto', + factory: true, + }, + "f-stgusdc": { + swap: '0x3211C6cBeF1429da3D0d58494938299C92Ad5860', + swap_token: '0xdf55670e27bE5cDE7228dD0A6849181891c9ebA1', + name: 'f-stgusdc', + gauge: '0x95d16646311fDe101Eb9F897fE06AC881B7Db802', + type: 'crypto', + factory: true, + }, + "f-bean": { + swap: '0x3a70dfa7d2262988064a2d051dd47521e43c9bdd', + swap_token: '0x3a70dfa7d2262988064a2d051dd47521e43c9bdd', + name: 'f-bean', + gauge: '0x6F98dA2D5098604239C07875C6B7Fd583BC520b9', + type: 'stable', + factory: true, + is_killed: true, + }, + "f-lfteth": { + swap: '0xfE4A08f22FE65759Ba91dB2E2CADa09B4415B0d7', + swap_token: '0x401322B9FDdba8c0a8D40fbCECE1D1752C12316B', + name: 'f-lfteth', + gauge: '0x46521Db0D31A62A2CBF8D1A7Cdc6bBBBC441A1fc', + type: 'crypto', + factory: true, + }, + "f-seth2steth": { + swap: '0xE95E4c2dAC312F31Dc605533D5A4d0aF42579308', + swap_token: '0xE95E4c2dAC312F31Dc605533D5A4d0aF42579308', + name: 'f-seth2steth', + gauge: '0xeCb860e54E33FEA8fAb5B076734e2591D1A9ebA4', + type: 'stable', + factory: true, + }, + "f-jpegeth": { + swap: '0x7E050cf658777cc1Da4a4508E79d71859044B60E', + swap_token: '0x34ed182d0812d119c92907852d2b429f095a9b07', + name: 'f-jpegeth', + gauge: '0xFA49B2a5D9E77f6748bf05801aa22356D514137b', + type: 'crypto', + factory: true, + }, + "f-fpifrax": { + swap: '0xf861483fa7E511fbc37487D91B6FAa803aF5d37c', + swap_token: '0x4704ab1fb693ce163f7c9d3a31b3ff4eaf797714', + name: 'f-fpifrax', + gauge: '0xdB7cbbb1d5D5124F86E92001C9dFDC068C05801D', + type: 'crypto', + factory: true, + }, + "f-ibaudusdc": { + swap: '0x5b692073F141C31384faE55856CfB6CBfFE91E60', + swap_token: '0x54c8ecf46a81496eeb0608bd3353388b5d7a2a33', + name: 'f-ibaudusdc', + gauge: '0x1779AEB087C5BdBe48749ab03575f5f25D1DEeaF', + type: 'crypto', + factory: true, + }, + "f-ibchfusdc": { + swap: '0x6Df0D77F0496CE44e72D695943950D8641fcA5Cf', + swap_token: '0x08ceA8E5B4551722dEB97113C139Dd83C26c5398', + name: 'f-ibchfusdc', + gauge: '0x36C66bC294fEf4e94B3e40A1801d0AB0085Fe96e', + type: 'crypto', + factory: true, + }, + "f-ibeurusdc": { + swap: '0x1570af3dF649Fc74872c5B8F280A162a3bdD4EB6', + swap_token: '0x8682Fbf0CbF312C891532BA9F1A91e44f81ad7DF', + name: 'f-ibeurusdc', + gauge: '0xE1D520B1263D6Be5678568BD699c84F7f9086023', + type: 'crypto', + factory: true, + }, + "f-ibgbpusdc": { + swap: '0xAcCe4Fe9Ce2A6FE9af83e7CF321a3fF7675e0AB6', + swap_token: '0x22CF19EB64226e0E1A79c69b345b31466fD273A7', + name: 'f-ibgbpusdc', + gauge: '0x1Ba86c33509013c937344f6e231DA2E63ea45197', + type: 'crypto', + factory: true, + }, + "f-ibjpyusdc": { + swap: '0xEB0265938c1190Ab4E3E1f6583bC956dF47C0F93', + swap_token: '0x127091ede112aed7bae281747771b3150bb047bb', + name: 'f-ibjpyusdc', + gauge: '0x3A748A2F4765BDFB119Cb7143b884Db7594a68c3', + type: 'crypto', + factory: true, + }, + "f-ibkrwusdc": { + swap: '0xef04f337fCB2ea220B6e8dB5eDbE2D774837581c', + swap_token: '0x80CAcCdBD3f07BbdB558DB4a9e146D099933D677', + name: 'f-ibkrwusdc', + gauge: '0xb6d7C2bda5a907832d4556AE5f7bA800FF084C2a', + type: 'crypto', + factory: true, + }, + "f-kp3reth": { + swap: '0x21410232B484136404911780bC32756D5d1a9Fa9', + swap_token: '0x4647B6D835f3B393C7A955df51EEfcf0db961606', + name: 'f-kp3reth', + gauge: '0x6d3328F0333f6FB0B2FaC87cF5a0FFa7e77beB60', + type: 'crypto', + factory: true, + }, + "f-pusd": { + swap: '0x8ee017541375f6bcd802ba119bddc94dad6911a1', + swap_token: '0x8ee017541375f6bcd802ba119bddc94dad6911a1', + name: 'f-pusd', + gauge: '0x89664D561E79Ca22Fd2eA4076b3e5deF0b219C15', + type: 'stable', + factory: true, + }, + "f-ohmeth": { + swap: '0x6ec38b3228251a0C5D491Faf66858e2E23d7728B', + swap_token: '0x3660BD168494d61ffDac21E403d0F6356cF90fD7', + name: 'f-ohmeth', + gauge: '0x8dF6FdAe05C9405853dd4cF2809D5dc2b5E77b0C', + type: 'crypto', + factory: true, + }, + "f-paleth": { + swap: '0x75A6787C7EE60424358B449B539A8b774c9B4862', + swap_token: '0xbe4f3ad6c9458b901c81b734cb22d9eae9ad8b50', + name: 'f-paleth', + gauge: '0x4fb13b55D6535584841dbBdb14EDC0258F7aC414', + type: 'crypto', + factory: true, + }, + "f-sdfxsfxs": { + swap: '0x8c524635d52bd7b1bd55e062303177a7d916c046', + swap_token: '0x8c524635d52bd7b1bd55e062303177a7d916c046', + name: 'f-sdfxsfxs', + gauge: '0xa9A9BC60fc80478059A83f516D5215185eeC2fc0', + type: 'stable', + factory: true, + }, + "f-sdagag": { + swap: '0x48ff31bbbd8ab553ebe7cbd84e1ea3dba8f54957', + swap_token: '0x48ff31bbbd8ab553ebe7cbd84e1ea3dba8f54957', + name: 'f-sdagag', + gauge: '0x03fFC218C7A9306D21193565CbDc4378952faA8c', + type: 'stable', + factory: true, + }, + "f-sdcrvcrv": { + swap: '0xf7b55c3732ad8b2c2da7c24f30a69f55c54fb717', + swap_token: '0xf7b55c3732ad8b2c2da7c24f30a69f55c54fb717', + name: 'f-sdcrvcrv', + gauge: '0x663FC22e92f26C377Ddf3C859b560C4732ee639a', + type: 'stable', + factory: true, + }, + "4pool": { + swap: '0x4e0915c88bc70750d68c481540f081fefaf22273', + swap_token: '0x4e0915c88bc70750d68c481540f081fefaf22273', + name: '4pool', + gauge: '0x34883134A39B206A451c2D3B0E7Cac44BE4D9181', + type: 'stable', + factory: false, + }, + "2pool": { + swap: '0x1005f7406f32a61bd760cfa14accd2737913d546', + swap_token: '0x1005f7406f32a61bd760cfa14accd2737913d546', + name: '2pool', + gauge: '0x9f330Db38caAAe5B61B410e2f0aaD63fff2109d8', + type: 'stable', + factory: false, + }, + "f-usdd3crv": { + swap: '0xe6b5cc1b4b47305c58392ce3d359b10282fc36ea', + swap_token: '0xe6b5cc1b4b47305c58392ce3d359b10282fc36ea', + name: 'f-usdd3crv', + gauge: '0xd5d3efC90fFB38987005FdeA303B68306aA5C624', + type: 'stable', + factory: true, + }, + "f-stethconcentrated": { + swap: '0x828b154032950C8ff7CF8085D841723Db2696056', + swap_token: '0x828b154032950C8ff7CF8085D841723Db2696056', + name: 'f-stethconcentrated', + gauge: '0xf668e6d326945d499e5b35e7cd2e82acfbcfe6f0', + type: 'stable', + factory: true, + hasNoCrv: true, // Hasn't been voted in yet, isn't in gauge controller, doesn't receive CRV + }, + "f-tokeeth": { + swap: '0xe0e970a99bc4F53804D8145beBBc7eBc9422Ba7F', + swap_token: '0x7ea4ad8c803653498bf6ac1d2debc04dce8fd2ad', + name: 'f-tokeeth', + gauge: '0xa0C08C0Aede65a0306F7dD042D2560dA174c91fC', + type: 'crypto', + factory: true, + }, + "2pool-frax": { + swap: '0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2', + swap_token: '0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC', + name: '2pool-frax', + gauge: '0xCFc25170633581Bf896CB6CDeE170e3E3Aa59503', + type: 'stable', + factory: false, + }, + "euroc": { + swap: '0xE84f5b1582BA325fDf9cE6B0c1F087ccfC924e54', + swap_token: '0x70fc957eb90E37Af82ACDbd12675699797745F68', + name: 'euroc', + gauge: '0x4329c8F09725c0e3b6884C1daB1771bcE17934F9', + type: 'crypto', + factory: false, + }, + "f-frethweth": { + swap: '0x6E77889Ff348A16547cABa3Ce011cB120Ed73bFc', + swap_token: '0x517E47a2e8c38E5A96708ED866A39CcbAA105640', + name: 'f-frethweth', + gauge: '0x25530f3c929d3f4137a766de3d37700d2fc00ff8', + type: 'crypto', + factory: true, + hasNoCrv: true, // Hasn't been voted in yet, isn't in gauge controller, doesn't receive CRV + }, + "f-staxfraxtemplelp": { + swap: '0xdaDfD00A2bBEb1abc4936b1644a3033e1B653228', + swap_token: '0xdaDfD00A2bBEb1abc4936b1644a3033e1B653228', + name: 'f-staxfraxtemplelp', + gauge: '0x8f162742a7BCDb87EB52d83c687E43356055a68B', + type: 'stable', + factory: true, + }, + "f-fraxbpsusd": { + swap: '0xe3c190c57b5959ae62efe3b6797058b76ba2f5ef', + swap_token: '0xe3c190c57b5959ae62efe3b6797058b76ba2f5ef', + name: 'f-fraxbpsusd', + gauge: '0xf6D7087D4Ae4dCf85956d743406E63cDA74D99AD', + type: 'stable', + factory: true, + }, + "f-fraxbplusd": { + swap: '0x497ce58f34605b9944e6b15ecafe6b001206fd25', + swap_token: '0x497ce58f34605b9944e6b15ecafe6b001206fd25', + name: 'f-fraxbplusd', + gauge: '0x389Fc079a15354E9cbcE8258433CC0F85B755A42', + type: 'stable', + factory: true, + }, + "f-fraxbpape": { + swap: '0x04b727c7e246ca70d496ecf52e6b6280f3c8077d', + swap_token: '0x04b727c7e246ca70d496ecf52e6b6280f3c8077d', + name: 'f-fraxbpape', + gauge: '0xD6e48Cc0597a1Ee12a8BeEB88e22bFDb81777164', + type: 'stable', + factory: true, + }, + "f-fraxbpgusd": { + swap: '0x4e43151b78b5fbb16298c1161fcbf7531d5f8d93', + swap_token: '0x4e43151b78b5fbb16298c1161fcbf7531d5f8d93', + name: 'f-fraxbpgusd', + gauge: '0xda7F9DD286577cC338047B040c289463743a474e', + type: 'stable', + factory: true, + }, + "f-fraxbpbusd": { + swap: '0x8fdb0bb9365a46b145db80d0b1c5c5e979c84190', + swap_token: '0x8fdb0bb9365a46b145db80d0b1c5c5e979c84190', + name: 'f-fraxbpbusd', + gauge: '0xAeac6Dcd12CC0BE74c8f99EfE4bB5205a1f9A608', + type: 'stable', + factory: true, + }, + "f-fraxbpalusd": { + swap: '0xb30da2376f63de30b42dc055c93fa474f31330a5', + swap_token: '0xb30da2376f63de30b42dc055c93fa474f31330a5', + name: 'f-fraxbpalusd', + gauge: '0x740BA8aa0052E07b925908B380248cb03f3DE5cB', + type: 'stable', + factory: true, + }, + "f-fraxbpusdd": { + swap: '0x4606326b4db89373f5377c316d3b0f6e55bc6a20', + swap_token: '0x4606326b4db89373f5377c316d3b0f6e55bc6a20', + name: 'f-fraxbpusdd', + gauge: '0xb8b9dfCB48614FA873ccEC72c79D728d39EC9a5c', + type: 'stable', + factory: true, + }, + "f-fraxbptusd": { + swap: '0x33baeda08b8afacc4d3d07cf31d49fc1f1f3e893', + swap_token: '0x33baeda08b8afacc4d3d07cf31d49fc1f1f3e893', + name: 'f-fraxbptusd', + gauge: '0xf865FDd6a5F307F398a94Dc40687995Cfaa77BC9', + type: 'stable', + factory: true, + }, + "f-europool": { + swap: '0xe7a3b38c39f97e977723bd1239c3470702568e7b', + swap_token: '0xe7a3b38c39f97e977723bd1239c3470702568e7b', + name: 'f-europool', + gauge: '0x9f57569EaA61d427dEEebac8D9546A745160391C', + type: 'stable', + factory: true, + }, + "f-ageureuroc": { + swap: '0xBa3436Fd341F2C8A928452Db3C5A3670d1d5Cc73', + swap_token: '0xBa3436Fd341F2C8A928452Db3C5A3670d1d5Cc73', + name: 'f-ageureuroc', + gauge: '0xF9F46eF781b9C7B76e8B505226d5E0e0E7FE2f04', + type: 'stable', + factory: true, + }, + // "f-pusdfraxbp": { + // swap: '0xC47EBd6c0f68fD5963005D28D0ba533750E5C11B', + // swap_token: '0xC47EBd6c0f68fD5963005D28D0ba533750E5C11B', + // name: 'f-pusdfraxbp', + // gauge: '0x28216318D85b2D6d8c2cB38eed08001d9348803b', + // type: 'stable', + // factory: true, + // }, + "f-dolafraxbp": { + swap: '0xE57180685E3348589E9521aa53Af0BCD497E884d', + swap_token: '0xE57180685E3348589E9521aa53Af0BCD497E884d', + name: 'f-dolafraxbp', + gauge: '0xBE266d68Ce3dDFAb366Bb866F4353B6FC42BA43c', + type: 'stable', + factory: true, + }, + "f-ageurfraxbp": { + swap: '0x58257e4291F95165184b4beA7793a1d6F8e7b627', + swap_token: '0x22e859Ee894c2068920858A60b51DC03ac5581c1', + name: 'f-ageurfraxbp', + gauge: '0xf74175aCe638E612a0a3B09E6bE89795ff48E06D', + type: 'crypto', + factory: true, + }, + "f-cvxfraxbp": { + swap: '0xBEc570d92AFB7fFc553bdD9d4B4638121000b10D', + swap_token: '0x7F17A6C77C3938D235b014818092eb6305BdA110', + name: 'f-cvxfraxbp', + gauge: '0xaa386EF96A910Ee2F9cbEf7B139e99A88DF3b2ba', + type: 'crypto', + factory: true, + }, + "f-cvxcrvfraxbp": { + swap: '0x31c325A01861c7dBd331a9270296a31296D797A0', + swap_token: '0x527331F3F550f6f85ACFEcAB9Cc0889180C6f1d5', + name: 'f-cvxcrvfraxbp', + gauge: '0xa47d0837F84Fb2d1aA08077D10d10101316a959d', + type: 'crypto', + factory: true, + }, + "f-cvxfxsfraxbp": { + swap: '0x21d158d95C2e150e144c36FC64E3653B8D6c6267', + swap_token: '0xF57ccaD8122B898A147Cc8601B1ECA88B1662c7E', + name: 'f-cvxfxsfraxbp', + gauge: '0xc7A770dE69479bEEEEf22b2C9851760BaC3630Da', + type: 'crypto', + factory: true, + }, + "f-alcxfraxbp": { + swap: '0x4149d1038575CE235E03E03B39487a80FD709D31', + swap_token: '0xf985005a3793DbA4cCe241B3C19ddcd3Fe069ff4', + name: 'f-alcxfraxbp', + gauge: '0xD5bE6A05B45aEd524730B6d1CC05F59b021f6c87', + type: 'crypto', + factory: true, + }, + } - // get pool addresses - let calls = []; + // get pool addresses + let calls = []; - Object.keys(gauges).forEach(function(key) { - if (gauges[key].gauge) { - calls.push([gaugeControllerAddress, gaugeController.methods.get_gauge_weight(gauges[key].gauge).encodeABI()]); - // calls.push([gaugeControllerAddress, gaugeController.methods.gauge_types(gauges[key].gauge).encodeABI()]); - calls.push([gaugeControllerAddress, gaugeController.methods.gauge_relative_weight(gauges[key].gauge).encodeABI()]); - calls.push([gauges[key].gauge, exampleGauge.methods.inflation_rate().encodeABI()]); - } - }); + Object.keys(gauges).forEach(function(key) { + if (gauges[key].gauge) { + calls.push([gaugeControllerAddress, gaugeController.methods.get_gauge_weight(gauges[key].gauge).encodeABI()]); + // calls.push([gaugeControllerAddress, gaugeController.methods.gauge_types(gauges[key].gauge).encodeABI()]); + calls.push([gaugeControllerAddress, gaugeController.methods.gauge_relative_weight(gauges[key].gauge).encodeABI()]); + calls.push([gauges[key].gauge, exampleGauge.methods.inflation_rate().encodeABI()]); + } + }); - let gaugeCalls = [] - let nonSideChainKeys = [] - Object.keys(gauges).forEach(function(key) { - if (!gauges[key].side_chain) { - gaugeCalls.push([gauges[key].gauge, exampleGauge.methods.working_supply().encodeABI()]); - gaugeCalls.push([gauges[key].gauge, exampleGauge.methods.inflation_rate().encodeABI()]); - nonSideChainKeys.push(key) - } - }); - let aggGaugecalls = await multicall.methods.aggregate(gaugeCalls).call(); - aggGaugecalls = aggGaugecalls[1] + let gaugeCalls = [] + let nonSideChainKeys = [] + Object.keys(gauges).forEach(function(key) { + if (!gauges[key].side_chain) { + gaugeCalls.push([gauges[key].gauge, exampleGauge.methods.working_supply().encodeABI()]); + gaugeCalls.push([gauges[key].gauge, exampleGauge.methods.inflation_rate().encodeABI()]); + nonSideChainKeys.push(key) + } + }); + let aggGaugecalls = await multicall.methods.aggregate(gaugeCalls).call(); + aggGaugecalls = aggGaugecalls[1] - let swapCalls = [] - Object.keys(gauges).forEach(function(key) { - if (!gauges[key].side_chain) { - swapCalls.push([gauges[key].swap, exampleSwap.methods.get_virtual_price().encodeABI()]); - } - }); + let swapCalls = [] + Object.keys(gauges).forEach(function(key) { + if (!gauges[key].side_chain) { + swapCalls.push([gauges[key].swap, exampleSwap.methods.get_virtual_price().encodeABI()]); + } + }); - let aggswapCalls = await multicall.methods.aggregate(swapCalls).call(); - aggswapCalls = aggswapCalls[1].map(hex => web3.eth.abi.decodeParameter('uint256', hex)) + let aggswapCalls = await multicall.methods.aggregate(swapCalls).call(); + aggswapCalls = aggswapCalls[1].map(hex => web3.eth.abi.decodeParameter('uint256', hex)) - let allGaugeWorkDetails = [] - for (var i = 0; i < aggGaugecalls.length; i++) { - let working_supply = web3.eth.abi.decodeParameter('uint256', aggGaugecalls[i]) - i += 1 - let inflation_rate = web3.eth.abi.decodeParameter('uint256', aggGaugecalls[i]) + let allGaugeWorkDetails = [] + for (var i = 0; i < aggGaugecalls.length; i++) { + let working_supply = web3.eth.abi.decodeParameter('uint256', aggGaugecalls[i]) + i += 1 + let inflation_rate = web3.eth.abi.decodeParameter('uint256', aggGaugecalls[i]) - let gaugeData = { - 'working_supply': working_supply, - 'inflation_rate': inflation_rate - } - allGaugeWorkDetails.push(gaugeData) + let gaugeData = { + 'working_supply': working_supply, + 'inflation_rate': inflation_rate } + allGaugeWorkDetails.push(gaugeData) + } - let aggcalls = await multicall.methods.aggregate(calls).call(); - aggcalls = aggcalls[1] + let aggcalls = await multicall.methods.aggregate(calls).call(); + aggcalls = aggcalls[1] - let allGaugeDetails = [] - for (var i = 0; i < aggcalls.length; i++) { - let get_gauge_weight = web3.eth.abi.decodeParameter('uint256', aggcalls[i]) - i += 1 - // let gauge_types = web3.eth.abi.decodeParameter('int128', aggcalls[i]) - // i += 1 - let gauge_relative_weight = web3.eth.abi.decodeParameter('uint256', aggcalls[i]) - i += 1 - let inflation_rate = web3.eth.abi.decodeParameter('uint256', aggcalls[i]) + let allGaugeDetails = [] + for (var i = 0; i < aggcalls.length; i++) { + let get_gauge_weight = web3.eth.abi.decodeParameter('uint256', aggcalls[i]) + i += 1 + // let gauge_types = web3.eth.abi.decodeParameter('int128', aggcalls[i]) + // i += 1 + let gauge_relative_weight = web3.eth.abi.decodeParameter('uint256', aggcalls[i]) + i += 1 + let inflation_rate = web3.eth.abi.decodeParameter('uint256', aggcalls[i]) - let gaugeData = { - 'get_gauge_weight': get_gauge_weight, - // 'gauge_types': gauge_types, - 'gauge_relative_weight': gauge_relative_weight, - inflation_rate, - } - allGaugeDetails.push(gaugeData) + let gaugeData = { + 'get_gauge_weight': get_gauge_weight, + // 'gauge_types': gauge_types, + 'gauge_relative_weight': gauge_relative_weight, + inflation_rate, } + allGaugeDetails.push(gaugeData) + } - let index = 0 - //pack data from gauge controller - Object.keys(gauges).forEach(function(key) { - gauges[key].gauge_controller = allGaugeDetails[index] - index++ - }); + let index = 0 + //pack data from gauge controller + Object.keys(gauges).forEach(function(key) { + gauges[key].gauge_controller = allGaugeDetails[index] + index++ + }); - //pack gaugeData - nonSideChainKeys.map(async (skey, index) => { - gauges[skey].gauge_data = allGaugeWorkDetails[index] - }) + //pack gaugeData + nonSideChainKeys.map(async (skey, index) => { + gauges[skey].gauge_data = allGaugeWorkDetails[index] + }) - //pack v_price - nonSideChainKeys.map(async (skey, index) => { - gauges[skey].swap_data = { - 'virtual_price': aggswapCalls[index] - } - }) + //pack v_price + nonSideChainKeys.map(async (skey, index) => { + gauges[skey].swap_data = { + 'virtual_price': aggswapCalls[index] + } + }) // Add all sidechain factory gauges const chainsToQuery = ( @@ -1327,26 +1327,26 @@ export default fn(async ({ blockchainId } = {}) => { symbol, hasCrv, }) => [ - `${blockchainId}-f-${symbol.replace('-f-gauge', '')}`, { - swap, - swap_token, - name: `${blockchainId}-f-${symbol.replace('-f-gauge', '')}`, - gauge, - type, - side_chain: true, - factory: true, - gauge_data: { - inflation_rate, - working_supply, - }, - gauge_controller: { - gauge_relative_weight, - get_gauge_weight, - inflation_rate, + `${blockchainId}-f-${symbol.replace('-f-gauge', '')}`, { + swap, + swap_token, + name: `${blockchainId}-f-${symbol.replace('-f-gauge', '')}`, + gauge, + type, + side_chain: true, + factory: true, + gauge_data: { + inflation_rate, + working_supply, + }, + gauge_controller: { + gauge_relative_weight, + get_gauge_weight, + inflation_rate, + }, + hasNoCrv: !hasCrv, }, - hasNoCrv: !hasCrv, - }, - ]) + ]) ); }))) }; diff --git a/pages/api/getMainPoolsGaugeRewards.js b/pages/api/getMainPoolsGaugeRewards.js index 909df86e..6aa3bf8b 100644 --- a/pages/api/getMainPoolsGaugeRewards.js +++ b/pages/api/getMainPoolsGaugeRewards.js @@ -1,5 +1,3 @@ -/* eslint-disable camelcase, object-curly-newline */ - import partition from 'lodash.partition'; import groupBy from 'lodash.groupby'; import { fn } from 'utils/api'; @@ -9,7 +7,6 @@ import { multiCall } from 'utils/Calls'; import { flattenArray, uniq } from 'utils/Array'; import { ZERO_ADDRESS } from 'utils/Web3/web3'; import getTokensPrices from 'utils/data/tokens-prices'; -import Request from 'utils/Request'; import getFactoryV2GaugeRewards from 'utils/data/getFactoryV2GaugeRewards'; import ERC20_ABI from 'constants/abis/erc20.json'; import getAavePoolRewardsInfo from 'utils/data/getAavePoolRewardsInfo'; @@ -393,7 +390,6 @@ export default fn(async (gauges) => { return { mainPoolsGaugeRewards: groupBy(mergedRewardsInfo, 'gaugeAddress') }; }, { - name: 'getMainPoolsGaugeRewards', - silenceParamsLog: true, + cacheKey: 'getMainPoolsGaugeRewards', maxAge: 5 * 60, // 5 min }); diff --git a/pages/api/getMainRegistryPools.js b/pages/api/getMainRegistryPools.js index f2c12ee4..2444d2ec 100644 --- a/pages/api/getMainRegistryPools.js +++ b/pages/api/getMainRegistryPools.js @@ -33,6 +33,5 @@ export default fn(async ({ blockchainId } = {}) => { return { poolList }; }, { maxAge: 3600, // 1 hour - name: 'getMainRegistryPools', - normalizer: ([{ blockchainId } = {}]) => blockchainId, + cacheKey: ({ blockchainId }) => `getMainRegistryPools-${blockchainId}`, }); diff --git a/pages/api/getMainRegistryPoolsAndLpTokens.js b/pages/api/getMainRegistryPoolsAndLpTokens.js index c1db398e..3134d049 100644 --- a/pages/api/getMainRegistryPoolsAndLpTokens.js +++ b/pages/api/getMainRegistryPoolsAndLpTokens.js @@ -52,6 +52,5 @@ export default fn(async ({ blockchainId } = {}) => { }); }, { maxAge: 3600, // 1 hour - name: 'getMainRegistryPoolsAndLpTokens', - normalizer: ([{ blockchainId } = {}]) => blockchainId, + cacheKey: ({ blockchainId }) => `getMainRegistryPoolsAndLpTokens-${blockchainId}`, }); diff --git a/pages/api/getPools/[...params].js b/pages/api/getPools/[...params].js deleted file mode 100644 index ef6fe746..00000000 --- a/pages/api/getPools/[...params].js +++ /dev/null @@ -1,9 +0,0 @@ -import { fn } from 'utils/api'; -import getPoolsApiFn from './index'; - -export default fn(async ({ params: [blockchainId, registryId], ...queryParams }) => ( - getPoolsApiFn.straightCall({ ...queryParams, blockchainId, registryId }) -), { - maxAge: 60, - name: 'getPools[...params]', -}); diff --git a/pages/api/getPools/index.js b/pages/api/getPools/[blockchainId]/[registryId].js similarity index 98% rename from pages/api/getPools/index.js rename to pages/api/getPools/[blockchainId]/[registryId].js index 110f3e1f..0fb57c0e 100644 --- a/pages/api/getPools/index.js +++ b/pages/api/getPools/[blockchainId]/[registryId].js @@ -12,6 +12,7 @@ import Web3 from 'web3'; import BN from 'bignumber.js'; import groupBy from 'lodash.groupby'; +import swr from 'utils/swr'; import { fn, ParamError } from 'utils/api'; import factoryV2RegistryAbi from 'constants/abis/factory-v2-registry.json'; import factoryPoolAbi from 'constants/abis/factory-v2/Plain2Balances.json'; @@ -41,13 +42,12 @@ import getCrvusdPrice from 'utils/data/getCrvusdPrice'; import getETHLSDAPYs from 'utils/data/getETHLSDAPYs'; import getTempleTokenPrices from 'utils/data/getTempleTokenPrices'; import getEywaTokenPrices from 'utils/data/getEywaTokenPrices'; -import getMainRegistryPools from 'pages/api/getMainRegistryPools'; +import getMainRegistryPoolsFn from 'pages/api/getMainRegistryPools'; import getMainRegistryPoolsAndLpTokensFn from 'pages/api/getMainRegistryPoolsAndLpTokens'; -import getMainPoolsGaugeRewards from 'pages/api/getMainPoolsGaugeRewards'; -import getAllGauges from 'pages/api/getAllGauges'; +import getMainPoolsGaugeRewardsFn from 'pages/api/getMainPoolsGaugeRewards'; +import getAllGaugesFn from 'pages/api/getAllGauges'; import configs from 'constants/configs'; import allCoins from 'constants/coins'; -import { BASE_API_DOMAIN } from 'constants/AppConstants'; import POOLS_ZAPS from 'constants/pools-zaps'; import COIN_ADDRESS_COINGECKO_ID_MAP from 'constants/CoinAddressCoingeckoIdMap'; import { getHardcodedPoolId } from 'constants/PoolAddressInternalIdMap'; @@ -69,6 +69,8 @@ const ORACLIZED_POOL_DETECTION_ABI = [{ "stateMutability": "view", "type": "func /* eslint-enable */ /* eslint-disable object-curly-newline, camelcase */ +const MAX_AGE = 5 * 60; + // Chains for which curve-prices is used as only data source for coins usd prices const CURVE_PRICES_AVAILABLE_CHAIN_IDS = [ // 'ethereum', @@ -147,7 +149,7 @@ const getEthereumOnlyData = async ({ preventQueryingFactoData, blockchainId }) = * every time, but takes advantages of returning cached data very quickly once * caches are hot. */ - gaugesData = await getAllGauges.straightCall({ blockchainId }); + gaugesData = await getAllGaugesFn.straightCall({ blockchainId }); if (blockchainId === 'ethereum') { const factoryGauges = Array.from(Object.values(gaugesData)).filter(({ side_chain }) => !side_chain); @@ -161,10 +163,10 @@ const getEthereumOnlyData = async ({ preventQueryingFactoData, blockchainId }) = } } - const { poolList: mainRegistryPoolList } = await getMainRegistryPools.straightCall({ blockchainId }); + const { poolList: mainRegistryPoolList } = await getMainRegistryPoolsFn.straightCall({ blockchainId }); const mainRegistryPoolGaugesRewards = ( blockchainId === 'ethereum' ? - (await getMainPoolsGaugeRewards.straightCall(gaugesData)).mainPoolsGaugeRewards : + (await getMainPoolsGaugeRewardsFn.straightCall(gaugesData)).mainPoolsGaugeRewards : {} ); @@ -202,6 +204,14 @@ const getEthereumOnlyData = async ({ preventQueryingFactoData, blockchainId }) = }; }; +const getEthereumOnlyDataSwr = async ({ preventQueryingFactoData, blockchainId }) => ( + (await swr( + `getEthereumOnlyData-${blockchainId}-${preventQueryingFactoData}`, + () => getEthereumOnlyData({ preventQueryingFactoData, blockchainId }), + { minTimeToStale: MAX_AGE * 1000 } // See CacheSettings.js + )).value +); + const isDefinedCoin = (address) => address !== '0x0000000000000000000000000000000000000000'; /** @@ -356,7 +366,7 @@ const getPools = async ({ blockchainId, registryId, preventQueryingFactoData }) !DISABLED_POOLS_ADDRESSES.includes(unfilteredPoolAddresses[id]?.toLowerCase()) )); - const ethereumOnlyData = await getEthereumOnlyData({ preventQueryingFactoData, blockchainId }); + const ethereumOnlyData = await getEthereumOnlyDataSwr({ preventQueryingFactoData, blockchainId }); const { poolsAndLpTokens: mainRegistryPoolsAndLpTokens } = await getMainRegistryPoolsAndLpTokensFn.straightCall({ blockchainId }); let mainRegistryLpTokensPricesMap; @@ -1350,8 +1360,8 @@ const getPools = async ({ blockchainId, registryId, preventQueryingFactoData }) }; const getPoolsFn = fn(getPools, { - maxAge: 5 * 60, - name: 'getPools', + maxAge: MAX_AGE, + cacheKey: ({ blockchainId, registryId, preventQueryingFactoData }) => `getPools-${blockchainId}-${registryId}-${preventQueryingFactoData}`, }); export default getPoolsFn; diff --git a/pages/api/getPools/_utils.js b/pages/api/getPools/_utils.js index 3c2cb430..a8803b44 100644 --- a/pages/api/getPools/_utils.js +++ b/pages/api/getPools/_utils.js @@ -1,8 +1,8 @@ import { flattenArray, arrayToHashmap } from 'utils/Array'; -import { IS_DEV } from 'constants/AppConstants'; import { IGNORED_TOKEN_ADDRESSES, IGNORED_POOL_ADDRESSES } from 'utils/data/curve-prices'; import { lc } from 'utils/String'; +const LOG_DEBUG = false; const getImplementation = ({ registryId, @@ -64,7 +64,7 @@ const deriveMissingCoinPricesSinglePass = async ({ ); if (canUsePriceOracle) { - if (IS_DEV) console.log('Missing coin price: using method 1 to derive price', poolInfo.id); + if (LOG_DEBUG) console.log('Missing coin price: using method 1 to derive price', poolInfo.id); return ( coins.map((coin, i) => ( @@ -104,7 +104,7 @@ const deriveMissingCoinPricesSinglePass = async ({ )); if (canUseSameCoinPriceInOtherPool) { - if (IS_DEV) console.log('Missing coin price: using method 2 to derive price', poolInfo.id); + if (LOG_DEBUG) console.log('Missing coin price: using method 2 to derive price', poolInfo.id); return ( coins.map((coin) => ( @@ -127,7 +127,7 @@ const deriveMissingCoinPricesSinglePass = async ({ ); if (canUseInternalPriceOracle) { - if (IS_DEV) console.log('Missing coin price: using method 3 to derive price', poolInfo.id); + if (LOG_DEBUG) console.log('Missing coin price: using method 3 to derive price', poolInfo.id); const coinWithKnownPrice = coins.find(({ usdPrice }) => usdPrice !== null); const coinWithKnownPriceIndex = coins.indexOf(coinWithKnownPrice); @@ -166,7 +166,7 @@ const deriveMissingCoinPricesSinglePass = async ({ )); if (canUseOtherPoolBaseLpTokenPrice) { - if (IS_DEV) console.log('Missing coin price: using method 4 to derive price', poolInfo.id); + if (LOG_DEBUG) console.log('Missing coin price: using method 4 to derive price', poolInfo.id); return ( coins.map((coin) => ( @@ -187,7 +187,7 @@ const deriveMissingCoinPricesSinglePass = async ({ )); if (canUseMainPoolBaseLpTokenPrice) { - if (IS_DEV) console.log('Missing coin price: using method 5 to derive price', poolInfo.id); + if (LOG_DEBUG) console.log('Missing coin price: using method 5 to derive price', poolInfo.id); return ( coins.map((coin) => ( diff --git a/pages/api/getPools/all/[blockchainId].js b/pages/api/getPools/all/[blockchainId].js index ae50df6a..8624a5db 100644 --- a/pages/api/getPools/all/[blockchainId].js +++ b/pages/api/getPools/all/[blockchainId].js @@ -1,15 +1,17 @@ -import { fetchAllCurvePoolsDataEndpoints } from 'utils/data/curve-pools-data'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; import { fn } from 'utils/api'; import groupBy from 'lodash.groupby'; +import { SMALL_POOLS_USDTOTAL_THRESHOLD } from 'constants/AppConstants'; export default fn(async ({ blockchainId, groupInRegistries }) => { const GROUP = groupInRegistries === ''; // Query param `?groupInRegistries` enables this behavior - const pools = await fetchAllCurvePoolsDataEndpoints([blockchainId]); + const pools = (await getAllCurvePoolsData([blockchainId])) + .filter(({ usdTotal }) => usdTotal >= SMALL_POOLS_USDTOTAL_THRESHOLD); return { poolData: GROUP ? groupBy(pools, 'registryId') : pools, }; }, { maxAge: 5 * 60, - name: 'getAllPoolsPerChain', + cacheKey: ({ blockchainId, groupInRegistries }) => `getAllPools-${blockchainId}-${groupInRegistries}`, }); diff --git a/pages/api/getPools/all/index.js b/pages/api/getPools/all/index.js index 8a388e78..826b67d0 100644 --- a/pages/api/getPools/all/index.js +++ b/pages/api/getPools/all/index.js @@ -1,13 +1,13 @@ import configs from 'constants/configs'; -import { fetchAllCurvePoolsDataEndpoints } from 'utils/data/curve-pools-data'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; import { fn } from 'utils/api'; const allBlockchainIds = Array.from(Object.keys(configs)); // Unfortunately this endpoint is stuck with object keys as return data for historical reasons, it's the only one of the getPools family export default fn(async () => ( - fetchAllCurvePoolsDataEndpoints(allBlockchainIds) + getAllCurvePoolsData(allBlockchainIds) ), { maxAge: 5 * 60, - name: 'getAllPools', + cacheKey: 'getAllPools', }); diff --git a/pages/api/getPools/big/[blockchainId].js b/pages/api/getPools/big/[blockchainId].js index ba814f8f..2fd2723c 100644 --- a/pages/api/getPools/big/[blockchainId].js +++ b/pages/api/getPools/big/[blockchainId].js @@ -1,11 +1,11 @@ -import { fetchAllCurvePoolsDataEndpoints } from 'utils/data/curve-pools-data'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; import { fn } from 'utils/api'; -import { SMALL_POOLS_USDTOTAL_THRESHOLD } from 'constants/AppConstants'; import groupBy from 'lodash.groupby'; +import { SMALL_POOLS_USDTOTAL_THRESHOLD } from 'constants/AppConstants'; export default fn(async ({ blockchainId, groupInRegistries }) => { const GROUP = groupInRegistries === ''; // Query param `?groupInRegistries` enables this behavior - const pools = (await fetchAllCurvePoolsDataEndpoints([blockchainId])) + const pools = (await getAllCurvePoolsData([blockchainId])) .filter(({ usdTotal }) => usdTotal >= SMALL_POOLS_USDTOTAL_THRESHOLD); return { @@ -13,5 +13,5 @@ export default fn(async ({ blockchainId, groupInRegistries }) => { }; }, { maxAge: 5 * 60, - name: 'getAllBigPoolsPerChain', + cacheKey: ({ blockchainId, groupInRegistries }) => `getAllBigPools-${blockchainId}-${groupInRegistries}`, }); diff --git a/pages/api/getPools/big/index.js b/pages/api/getPools/big/index.js index c27c9ab4..abfc2bb1 100644 --- a/pages/api/getPools/big/index.js +++ b/pages/api/getPools/big/index.js @@ -1,13 +1,14 @@ import configs from 'constants/configs'; -import { fetchAllCurvePoolsDataEndpoints } from 'utils/data/curve-pools-data'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; import { fn } from 'utils/api'; +import { SMALL_POOLS_USDTOTAL_THRESHOLD } from 'constants/AppConstants'; const allBlockchainIds = Array.from(Object.keys(configs)); export default fn(async () => ({ - poolData: (await fetchAllCurvePoolsDataEndpoints(allBlockchainIds)) + poolData: (await getAllCurvePoolsData(allBlockchainIds)) .filter(({ usdTotal }) => usdTotal >= SMALL_POOLS_USDTOTAL_THRESHOLD), }), { maxAge: 5 * 60, - name: 'getAllBigPools', + cacheKey: 'getAllBigPools', }); diff --git a/pages/api/getPools/empty/[blockchainId].js b/pages/api/getPools/empty/[blockchainId].js index 80b83e0b..715a0f87 100644 --- a/pages/api/getPools/empty/[blockchainId].js +++ b/pages/api/getPools/empty/[blockchainId].js @@ -1,16 +1,16 @@ -import { fetchAllCurvePoolsDataEndpoints } from 'utils/data/curve-pools-data'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; import { fn } from 'utils/api'; import groupBy from 'lodash.groupby'; export default fn(async ({ blockchainId, groupInRegistries }) => { const GROUP = groupInRegistries === ''; // Query param `?groupInRegistries` enables this behavior - const pools = (await fetchAllCurvePoolsDataEndpoints([blockchainId])) - .filter(({ usdTotal }) => usdTotal === 0); + const pools = (await getAllCurvePoolsData([blockchainId])) + .filter(({ usdTotal }) => (usdTotal === 0)); return { poolData: GROUP ? groupBy(pools, 'registryId') : pools, }; }, { maxAge: 5 * 60, - name: 'getAllSmallPoolsPerChain', + cacheKey: ({ blockchainId, groupInRegistries }) => `getAllEmptyPools-${blockchainId}-${groupInRegistries}`, }); diff --git a/pages/api/getPools/empty/index.js b/pages/api/getPools/empty/index.js index ef8ae744..e3c2e3fb 100644 --- a/pages/api/getPools/empty/index.js +++ b/pages/api/getPools/empty/index.js @@ -1,13 +1,13 @@ import configs from 'constants/configs'; -import { fetchAllCurvePoolsDataEndpoints } from 'utils/data/curve-pools-data'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; import { fn } from 'utils/api'; const allBlockchainIds = Array.from(Object.keys(configs)); export default fn(async () => ({ - poolData: (await fetchAllCurvePoolsDataEndpoints(allBlockchainIds)) - .filter(({ usdTotal }) => usdTotal === 0), + poolData: (await getAllCurvePoolsData(allBlockchainIds)) + .filter(({ usdTotal }) => (usdTotal === 0)), }), { maxAge: 5 * 60, - name: 'getAllSmallPools', + cacheKey: 'getAllEmptyPools', }); diff --git a/pages/api/getPools/small/[blockchainId].js b/pages/api/getPools/small/[blockchainId].js index 0f7ef816..715051ea 100644 --- a/pages/api/getPools/small/[blockchainId].js +++ b/pages/api/getPools/small/[blockchainId].js @@ -1,11 +1,11 @@ -import { fetchAllCurvePoolsDataEndpoints } from 'utils/data/curve-pools-data'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; import { fn } from 'utils/api'; -import { SMALL_POOLS_USDTOTAL_THRESHOLD } from 'constants/AppConstants'; import groupBy from 'lodash.groupby'; +import { SMALL_POOLS_USDTOTAL_THRESHOLD } from 'constants/AppConstants'; export default fn(async ({ blockchainId, groupInRegistries }) => { const GROUP = groupInRegistries === ''; // Query param `?groupInRegistries` enables this behavior - const pools = (await fetchAllCurvePoolsDataEndpoints([blockchainId])) + const pools = (await getAllCurvePoolsData([blockchainId])) .filter(({ usdTotal }) => (usdTotal > 0 && usdTotal < SMALL_POOLS_USDTOTAL_THRESHOLD)); return { @@ -13,5 +13,5 @@ export default fn(async ({ blockchainId, groupInRegistries }) => { }; }, { maxAge: 5 * 60, - name: 'getAllSmallPoolsPerChain', + cacheKey: ({ blockchainId, groupInRegistries }) => `getAllSmallPools-${blockchainId}-${groupInRegistries}`, }); diff --git a/pages/api/getPools/small/index.js b/pages/api/getPools/small/index.js index 4d59beb9..190031b7 100644 --- a/pages/api/getPools/small/index.js +++ b/pages/api/getPools/small/index.js @@ -1,13 +1,14 @@ import configs from 'constants/configs'; -import { fetchAllCurvePoolsDataEndpoints } from 'utils/data/curve-pools-data'; +import getAllCurvePoolsData from 'utils/data/curve-pools-data'; import { fn } from 'utils/api'; +import { SMALL_POOLS_USDTOTAL_THRESHOLD } from 'constants/AppConstants'; const allBlockchainIds = Array.from(Object.keys(configs)); export default fn(async () => ({ - poolData: (await fetchAllCurvePoolsDataEndpoints(allBlockchainIds)) + poolData: (await getAllCurvePoolsData(allBlockchainIds)) .filter(({ usdTotal }) => (usdTotal > 0 && usdTotal < SMALL_POOLS_USDTOTAL_THRESHOLD)), }), { maxAge: 5 * 60, - name: 'getAllSmallPools', + cacheKey: 'getAllSmallPools', }); diff --git a/pages/api/getTVLBase.js b/pages/api/getTVLBase.js index 30ee076d..07b464be 100644 --- a/pages/api/getTVLBase.js +++ b/pages/api/getTVLBase.js @@ -1,7 +1,7 @@ import Web3 from 'web3'; import configs from 'constants/configs'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import { fn } from 'utils/api'; import erc20Abi from 'constants/abis/erc20.json'; import aavePool from 'constants/abis/pools/aave.json'; diff --git a/pages/api/getTVLBsc.js b/pages/api/getTVLBsc.js index 70118a78..d3d78ef2 100644 --- a/pages/api/getTVLBsc.js +++ b/pages/api/getTVLBsc.js @@ -3,7 +3,7 @@ import Web3 from 'web3'; import configs from 'constants/configs'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import { fn } from 'utils/api'; import erc20Abi from 'constants/abis/erc20.json'; import aavePool from 'constants/abis/pools/aave.json'; diff --git a/pages/api/getTVLCelo.js b/pages/api/getTVLCelo.js index fc9206b6..3956ff81 100644 --- a/pages/api/getTVLCelo.js +++ b/pages/api/getTVLCelo.js @@ -1,7 +1,7 @@ import Web3 from 'web3'; import configs from 'constants/configs'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import { fn } from 'utils/api'; import erc20Abi from 'constants/abis/erc20.json'; import aavePool from 'constants/abis/pools/aave.json'; @@ -12,46 +12,46 @@ const web3 = new Web3(configs.celo.rpcUrl); export default fn(async () => { - let price_feed = await (await fetch('https://api.coingecko.com/api/v3/simple/price?ids=tether,ethereum,bitcoin&vs_currencies=usd')).json() + let price_feed = await (await fetch('https://api.coingecko.com/api/v3/simple/price?ids=tether,ethereum,bitcoin&vs_currencies=usd')).json() - let pools = { - } - let tvl = 0 - for (const [key, pool] of Object.entries(pools)) { + let pools = { + } + let tvl = 0 + for (const [key, pool] of Object.entries(pools)) { - let poolC = new web3.eth.Contract(aavePool, pool.address); + let poolC = new web3.eth.Contract(aavePool, pool.address); - let multiplier = (pool.type == 'stable' || pool.type == 'crypto')?1:price_feed[pool.type].usd + let multiplier = (pool.type == 'stable' || pool.type == 'crypto') ? 1 : price_feed[pool.type].usd - await Promise.all( - pool.decimals.map(async (decimal, index) => { - let balance = await poolC.methods.balances(index).call() - balance = balance / (10 ** decimal) + await Promise.all( + pool.decimals.map(async (decimal, index) => { + let balance = await poolC.methods.balances(index).call() + balance = balance / (10 ** decimal) - if (pool.type == 'crypto') { - multiplier = price_feed[pool.keys[index]].usd - } + if (pool.type == 'crypto') { + multiplier = price_feed[pool.keys[index]].usd + } - pools[key].tvl += (balance * multiplier) - tvl += (parseFloat(balance) * multiplier) + pools[key].tvl += (balance * multiplier) + tvl += (parseFloat(balance) * multiplier) - }) - ) + }) + ) - if (pool.type == 'crypto') { - let tokenContract = new web3.eth.Contract(erc20Abi, pool.token); - let supply = await tokenContract.methods.totalSupply().call(); - pools[key].lpPrice = pools[key].tvl / (supply / 10 ** 18) - } - } + if (pool.type == 'crypto') { + let tokenContract = new web3.eth.Contract(erc20Abi, pool.token); + let supply = await tokenContract.methods.totalSupply().call(); + pools[key].lpPrice = pools[key].tvl / (supply / 10 ** 18) + } + } - const factoDetails = await getPoolsFn.straightCall({ blockchainId: 'celo', registryId: 'factory' }) - tvl += factoDetails.tvlAll - const factory = { - tvl: factoDetails.tvlAll - }; + const factoDetails = await getPoolsFn.straightCall({ blockchainId: 'celo', registryId: 'factory' }) + tvl += factoDetails.tvlAll + const factory = { + tvl: factoDetails.tvlAll + }; - return { tvl, pools, factory }; + return { tvl, pools, factory }; }, { diff --git a/pages/api/getTVLKava.js b/pages/api/getTVLKava.js index da87e8f3..189abd53 100644 --- a/pages/api/getTVLKava.js +++ b/pages/api/getTVLKava.js @@ -1,7 +1,7 @@ import Web3 from 'web3'; import configs from 'constants/configs'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import { fn } from 'utils/api'; import erc20Abi from 'constants/abis/erc20.json'; import aavePool from 'constants/abis/pools/aave.json'; @@ -12,46 +12,46 @@ const web3 = new Web3(configs.kava.rpcUrl); export default fn(async () => { - let price_feed = await (await fetch('https://api.coingecko.com/api/v3/simple/price?ids=tether,ethereum,bitcoin&vs_currencies=usd')).json() + let price_feed = await (await fetch('https://api.coingecko.com/api/v3/simple/price?ids=tether,ethereum,bitcoin&vs_currencies=usd')).json() - let pools = { - } - let tvl = 0 - for (const [key, pool] of Object.entries(pools)) { + let pools = { + } + let tvl = 0 + for (const [key, pool] of Object.entries(pools)) { - let poolC = new web3.eth.Contract(aavePool, pool.address); + let poolC = new web3.eth.Contract(aavePool, pool.address); - let multiplier = (pool.type == 'stable' || pool.type == 'crypto')?1:price_feed[pool.type].usd + let multiplier = (pool.type == 'stable' || pool.type == 'crypto') ? 1 : price_feed[pool.type].usd - await Promise.all( - pool.decimals.map(async (decimal, index) => { - let balance = await poolC.methods.balances(index).call() - balance = balance / (10 ** decimal) + await Promise.all( + pool.decimals.map(async (decimal, index) => { + let balance = await poolC.methods.balances(index).call() + balance = balance / (10 ** decimal) - if (pool.type == 'crypto') { - multiplier = price_feed[pool.keys[index]].usd - } + if (pool.type == 'crypto') { + multiplier = price_feed[pool.keys[index]].usd + } - pools[key].tvl += (balance * multiplier) - tvl += (parseFloat(balance) * multiplier) + pools[key].tvl += (balance * multiplier) + tvl += (parseFloat(balance) * multiplier) - }) - ) + }) + ) - if (pool.type == 'crypto') { - let tokenContract = new web3.eth.Contract(erc20Abi, pool.token); - let supply = await tokenContract.methods.totalSupply().call(); - pools[key].lpPrice = pools[key].tvl / (supply / 10 ** 18) - } - } + if (pool.type == 'crypto') { + let tokenContract = new web3.eth.Contract(erc20Abi, pool.token); + let supply = await tokenContract.methods.totalSupply().call(); + pools[key].lpPrice = pools[key].tvl / (supply / 10 ** 18) + } + } - const factoDetails = await getPoolsFn.straightCall({ blockchainId: 'kava', registryId: 'factory' }) - tvl += factoDetails.tvlAll - const factory = { - tvl: factoDetails.tvlAll - }; + const factoDetails = await getPoolsFn.straightCall({ blockchainId: 'kava', registryId: 'factory' }) + tvl += factoDetails.tvlAll + const factory = { + tvl: factoDetails.tvlAll + }; - return { tvl, pools, factory }; + return { tvl, pools, factory }; }, { diff --git a/pages/api/getTVLZkevm.js b/pages/api/getTVLZkevm.js index 1bfc56bb..213608ef 100644 --- a/pages/api/getTVLZkevm.js +++ b/pages/api/getTVLZkevm.js @@ -1,7 +1,7 @@ import Web3 from 'web3'; import configs from 'constants/configs'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import { fn } from 'utils/api'; import erc20Abi from 'constants/abis/erc20.json'; import aavePool from 'constants/abis/pools/aave.json'; diff --git a/pages/api/getTVLZksync.js b/pages/api/getTVLZksync.js index 76e4a850..de4eaacc 100644 --- a/pages/api/getTVLZksync.js +++ b/pages/api/getTVLZksync.js @@ -1,7 +1,7 @@ import Web3 from 'web3'; import configs from 'constants/configs'; -import getPoolsFn from 'pages/api/getPools'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import { fn } from 'utils/api'; import erc20Abi from 'constants/abis/erc20.json'; import aavePool from 'constants/abis/pools/aave.json'; diff --git a/pages/api/getWeeklyFees.js b/pages/api/getWeeklyFees.js index 9045ef9e..9f29f290 100644 --- a/pages/api/getWeeklyFees.js +++ b/pages/api/getWeeklyFees.js @@ -1,6 +1,4 @@ -import axios from 'axios'; import Web3 from 'web3'; -import BigNumber from 'big-number'; import WEB3_CONSTANTS from 'constants/Web3'; import { fn } from '../../utils/api'; import { getFeeDistributor } from '../../utils/getters'; @@ -10,60 +8,59 @@ import tripoolSwapAbi from '../../constants/abis/tripool_swap.json'; const web3 = new Web3(WEB3_CONSTANTS.RPC_URL); - export default fn(async () => { - let feeDistributorAddress = await getFeeDistributor() - let triPool = '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7' + let feeDistributorAddress = await getFeeDistributor() + let triPool = '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7' + + /* weekly fees from contract*/ + let tri_pool = new web3.eth.Contract(tripoolSwapAbi, triPool) + let distributor = new web3.eth.Contract(distributorAbi, feeDistributorAddress) + let t = await getThursdayUTCTimestamp(); + let thursday = t; - /* weekly fees from contract*/ - let tri_pool = new web3.eth.Contract(tripoolSwapAbi, triPool) - let distributor = new web3.eth.Contract(distributorAbi, feeDistributorAddress) - let t = await getThursdayUTCTimestamp(); - let thursday = t; + let currentTs = new Date().getTime() / 1000 | 0; + if (currentTs > t) { + let nextdistroTime = await distributor.methods.last_token_time().call(); + if (thursday > currentTs) { + nextdistroTime = +nextdistroTime + 86400; + let d = new Date(nextdistroTime * 1000); + this.distroTime = d.toUTCString(); + } + } - let currentTs = new Date().getTime() / 1000 | 0; - if (currentTs > t) { - let nextdistroTime = await distributor.methods.last_token_time().call(); - if (thursday > currentTs) { - nextdistroTime = +nextdistroTime + 86400; - let d = new Date(nextdistroTime * 1000); - this.distroTime = d.toUTCString(); - } - } + let total = 0; + let week = 604800; + let virtual_price = await tri_pool.methods.get_virtual_price().call() + virtual_price = virtual_price / 1e18 - let total = 0; - let week = 604800; - let virtual_price = await tri_pool.methods.get_virtual_price().call() - virtual_price = virtual_price / 1e18 - - const startTime = await distributor.methods.start_time().call(); - const weeksElapsed = Math.ceil((currentTs - startTime) / (60 * 60 * 24 * 7)); + const startTime = await distributor.methods.start_time().call(); + const weeksElapsed = Math.ceil((currentTs - startTime) / (60 * 60 * 24 * 7)); - let weeklyFeesTable = [] - for (var i = 0; i < weeksElapsed; i++) { - let thisWeekFees = await distributor.methods.tokens_per_week(t).call(); - //console.log('Checking fees for timestamp', t, thisWeekFees); - if (thisWeekFees > 0 || i < 10) { - total += thisWeekFees * virtual_price / 1e18 - let thisWeek = { - 'date': new Date(t * 1000).toDateString(), - 'ts': t * 1000, - 'rawFees': thisWeekFees * virtual_price / 1e18 - } - weeklyFeesTable.push(thisWeek) - } else { - break; - } - t = t - week; - } + let weeklyFeesTable = [] + for (var i = 0; i < weeksElapsed; i++) { + let thisWeekFees = await distributor.methods.tokens_per_week(t).call(); + //console.log('Checking fees for timestamp', t, thisWeekFees); + if (thisWeekFees > 0 || i < 10) { + total += thisWeekFees * virtual_price / 1e18 + let thisWeek = { + 'date': new Date(t * 1000).toDateString(), + 'ts': t * 1000, + 'rawFees': thisWeekFees * virtual_price / 1e18 + } + weeklyFeesTable.push(thisWeek) + } else { + break; + } + t = t - week; + } - //add total at end of array - let totalFees = { - 'fees': total - } + //add total at end of array + let totalFees = { + 'fees': total + } - return { weeklyFeesTable, totalFees }; + return { weeklyFeesTable, totalFees }; }, { maxAge: 15 * 60, // 15 min diff --git a/utils/api.js b/utils/api.js index a8e5695b..3ad2116e 100644 --- a/utils/api.js +++ b/utils/api.js @@ -1,4 +1,4 @@ -import memoize from 'memoizee'; +import swr from 'utils/swr'; import { IS_DEV } from 'constants/AppConstants'; const getNowMs = () => Number(Date.now()); @@ -19,16 +19,13 @@ const addGeneratedTime = async (res) => ({ generatedTimeMs: getNowMs(), }); -const logRuntime = async (fn, name, query, silenceParamsLog) => { +const logRuntime = async (fn, cacheKey) => { const startMs = getNowMs(); const res = await fn(); const endMs = getNowMs(); - if (IS_DEV) { - const queryText = silenceParamsLog ? 'QUERY_LOGGING_SILENCED' : query; - console.log('Run time (ms):', endMs - startMs, name, queryText); - } + console.log('Run time (ms):', endMs - startMs, cacheKey); return res; }; @@ -50,21 +47,32 @@ class NotFoundError extends Error { const fn = (cb, options = {}) => { const { maxAge: maxAgeSec = null, // Caching duration, in seconds - name = null, // Name, used for logging purposes + cacheKey, // Either a function that's passed the call's params and returns a string, or a static string returnFlatData = false, - silenceParamsLog = false, // Don't log params (can be used because the fn is passed a huge object that creates noise) } = options; - const callback = maxAgeSec !== null ? - memoize(async (query) => logRuntime(() => addGeneratedTime(cb(query)), name, query, silenceParamsLog), { - promise: true, - maxAge: maxAgeSec * 1000, - normalizer: ([query]) => JSON.stringify(query), // Separate cache entries for each route & query params, - }) : - async (query) => logRuntime(() => addGeneratedTime(cb(query)), name, query, silenceParamsLog); + if (maxAgeSec !== null && !cacheKey) { + console.trace(); + throw new Error('cacheKey not defined: a cacheKey must be set when using maxAge (trace above)'); + } + + const callback = ( + maxAgeSec !== null ? ( + async (query) => (await swr( + (typeof cacheKey === 'function' ? cacheKey(query) : cacheKey), + async () => logRuntime(() => addGeneratedTime(cb(query)), (typeof cacheKey === 'function' ? cacheKey(query) : cacheKey)), + { minTimeToStale: maxAgeSec * 1000 } // See CacheSettings.js + )).value + ) : ( + async (query) => logRuntime(() => addGeneratedTime(cb(query)), (typeof cacheKey === 'function' ? cacheKey(query) : cacheKey)) + ) + ); const apiCall = async (req, res) => ( - Promise.resolve(callback(req.query)) + Promise.resolve(callback({ + ...req.query, + ...req.params, + })) .then((data) => { if (maxAgeSec !== null) res.setHeader('Cache-Control', `max-age=0, s-maxage=${maxAgeSec}, stale-while-revalidate`); res.status(200).json( diff --git a/utils/data/curve-pools-data.js b/utils/data/curve-pools-data.js index 9f4e58f0..89892ef5 100644 --- a/utils/data/curve-pools-data.js +++ b/utils/data/curve-pools-data.js @@ -1,10 +1,8 @@ import memoize from 'memoizee'; import { flattenArray } from 'utils/Array'; import { sequentialPromiseFlatMap } from 'utils/Async'; -import getPools from 'pages/api/getPools'; -import { BASE_API_DOMAIN } from 'constants/AppConstants'; +import getPoolsFn from 'pages/api/getPools/[blockchainId]/[registryId]'; import getPlatformRegistries from './curve-platform-registries'; -import Request from 'utils/Request'; const attachBlockchainId = (blockchainId, poolData) => ({ ...poolData, @@ -24,7 +22,7 @@ const attachFactoryTag = (poolData) => ({ const getAllCurvePoolsData = memoize(async (blockchainIds) => ( flattenArray(await sequentialPromiseFlatMap(blockchainIds, async (blockchainId) => ( Promise.all((await getPlatformRegistries(blockchainId)).registryIds.map((registryId) => ( - (getPools.straightCall({ blockchainId, registryId, preventQueryingFactoData: true })) + (getPoolsFn.straightCall({ blockchainId, registryId, preventQueryingFactoData: true })) .then((res) => res.poolData.map((poolData) => attachBlockchainId(blockchainId, poolData)).map((poolData) => attachRegistryId(registryId, poolData)).map((poolData) => ( registryId.startsWith('factory') ? attachFactoryTag(poolData) : @@ -37,18 +35,4 @@ const getAllCurvePoolsData = memoize(async (blockchainIds) => ( maxAge: 60 * 1000, // 60s }); -const fetchAllCurvePoolsDataEndpoints = async (blockchainIds) => ( - flattenArray(await sequentialPromiseFlatMap(blockchainIds, async (blockchainId) => ( - Promise.all((await getPlatformRegistries(blockchainId)).registryIds.map(async (registryId) => ( - Promise.resolve((await (await Request.get(`${BASE_API_DOMAIN}/api/getPools/${blockchainId}/${registryId}`)).json()).data) - .then((res) => res.poolData.map((poolData) => attachBlockchainId(blockchainId, poolData)).map((poolData) => attachRegistryId(registryId, poolData)).map((poolData) => ( - registryId.startsWith('factory') ? - attachFactoryTag(poolData) : - poolData - ))) - ))) - ))) -); - export default getAllCurvePoolsData; -export { fetchAllCurvePoolsDataEndpoints }; diff --git a/utils/data/getEywaTokenPrices.js b/utils/data/getEywaTokenPrices.js index 7950da32..53793185 100644 --- a/utils/data/getEywaTokenPrices.js +++ b/utils/data/getEywaTokenPrices.js @@ -17,12 +17,9 @@ const getEywaTokenPrices = memoize(async ( blockchainId, coinAddressesAndPricesMapFallback, allCoinAddresses -) => { +) => { const firstTokenOfEachEywaPool = Array.from(Object.values(groupBy(allCoinAddresses, 'poolId'))).map(([{ address }]) => address); - console.log('firstTokenOfEachEywaPool', firstTokenOfEachEywaPool) - const prices = await Promise.all(firstTokenOfEachEywaPool.map(getEywaTokenPrice)) - console.log('prices', prices) const EywaTokensPrices = arrayToHashmap(firstTokenOfEachEywaPool.map((address, i) => [address.toLowerCase(), prices[i]])); diff --git a/utils/swr.js b/utils/swr.js new file mode 100644 index 00000000..1179e047 --- /dev/null +++ b/utils/swr.js @@ -0,0 +1,48 @@ +/** + * Returns a Promise-wrapped instance of a stale-while-revalidate cache helper that + * takes care of serving fresh data, caching it, and revalidating as needed, using + * memcached hosts as cache storage. + */ + +import { createStaleWhileRevalidateCache } from 'stale-while-revalidate-cache'; +import { Redis } from 'ioredis'; +import CACHE_SETTINGS from 'constants/CacheSettings'; +import { IS_DEV } from 'constants/AppConstants'; + +const swrPromise = new Promise(async (resolve, reject) => { + // const cacheNode = IS_DEV ? process.env.DEV_REDIS_HOST : process.env.PROD_REDIS_HOST + const cacheNode = process.env.UPSTASH_ENDPOINT + + console.log('Using memcached store nodes:'); + console.log(cacheNode); + + // const redis = new Redis('curve-api-redis-cache-u5vzqb.serverless.usw1.cache.amazonaws.com:6379'); // To update prod redis server + + const redis = new Redis(cacheNode); + + const storage = { + async getItem(key) { + return redis.get(key); + }, + async setItem(key, value) { + // update using PR + await redis.set(key, value, 'EX', (CACHE_SETTINGS.maxTimeToLive / 1000)); + }, + async removeItem(key) { + await redis.del(key); + }, + }; + + const swr = createStaleWhileRevalidateCache({ + storage, + ...CACHE_SETTINGS, + }); + + resolve(swr); +}); + +// Wrapper that exposes the same intuitive api as naked swr, while +// making up for the async nature of memcached nodes retrieval +const swr = async (key, fn, configOverrides) => (await swrPromise)(key, fn, configOverrides); + +export default swr;