├── .github └── workflows │ ├── lint.yml │ └── publish.yml ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── docs └── v1 │ └── README.md ├── eslint.config.mjs ├── package-lock.json ├── package.json ├── src ├── boosting.ts ├── cached.ts ├── constants │ ├── L2Networks.ts │ ├── abis │ │ ├── 2pool │ │ │ └── swap.json │ │ ├── 3pool-optimism │ │ │ └── swap.json │ │ ├── 3pool │ │ │ ├── meta_zap_crypto.json │ │ │ └── swap.json │ │ ├── 4pool │ │ │ └── swap.json │ │ ├── ERC20.json │ │ ├── aave │ │ │ ├── rewards.json │ │ │ └── swap.json │ │ ├── address_provider.json │ │ ├── ankreth │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── anycall.json │ │ ├── atricrypto3 │ │ │ ├── base_pool_zap.json │ │ │ ├── swap.json │ │ │ └── zap.json │ │ ├── avaxcrypto │ │ │ ├── swap.json │ │ │ └── zap.json │ │ ├── bbtc │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── busd │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── cERC20.json │ │ ├── circulating_supply.json │ │ ├── compound │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── crveth │ │ │ └── swap.json │ │ ├── crypto_calc.json │ │ ├── curve_lp_token_v5.json │ │ ├── deposit_and_stake.json │ │ ├── deposit_and_stake_ng_only.json │ │ ├── dusd │ │ │ ├── deposit.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── eureusd │ │ │ ├── swap.json │ │ │ └── zap.json │ │ ├── eurs │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── eursusd │ │ │ └── swap.json │ │ ├── eursusd2 │ │ │ ├── swap.json │ │ │ └── zap.json │ │ ├── eurt │ │ │ └── swap.json │ │ ├── eurtusd │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── factory-admin.json │ │ ├── factory-crypto.json │ │ ├── factory-crypto │ │ │ └── factory-crypto-pool-2.json │ │ ├── factory-eywa.json │ │ ├── factory-stable-ng.json │ │ ├── factory-stable-ng │ │ │ ├── meta-stableswap-ng.json │ │ │ └── plain-stableswap-ng.json │ │ ├── factory-tricrypto-mainnet.json │ │ ├── factory-tricrypto-sidechain.json │ │ ├── factory-tricrypto │ │ │ ├── factory-tricrypto-pool-eth-disabled.json │ │ │ └── factory-tricrypto-pool.json │ │ ├── factory-twocrypto-ng.json │ │ ├── factory-twocrypto │ │ │ └── factory-twocrypto-pool.json │ │ ├── factory-v2 │ │ │ ├── DepositZapFantom.json │ │ │ ├── DepositZapMetaBtcPolygon.json │ │ │ ├── DepositZapMetaUsd2Fantom.json │ │ │ ├── DepositZapMetaUsdPolygon.json │ │ │ ├── MetaBTC.json │ │ │ ├── MetaBTCBalances.json │ │ │ ├── MetaBTCBalancesRen.json │ │ │ ├── MetaBTCRen.json │ │ │ ├── MetaFraxUSD.json │ │ │ ├── MetaFraxUSDBalances.json │ │ │ ├── MetaSbtc2.json │ │ │ ├── MetaSbtc2Balance.json │ │ │ ├── MetaUSD.json │ │ │ ├── MetaUSDBalances.json │ │ │ ├── MetaUSDGeist.json │ │ │ ├── Plain2Balances.json │ │ │ ├── Plain2Basic.json │ │ │ ├── Plain2BasicWithRates.json │ │ │ ├── Plain2ETH.json │ │ │ ├── Plain2ETHOracle.json │ │ │ ├── Plain2Optimized.json │ │ │ ├── Plain3Balances.json │ │ │ ├── Plain3Basic.json │ │ │ ├── Plain3ETH.json │ │ │ ├── Plain3Optimized.json │ │ │ ├── Plain4Balances.json │ │ │ ├── Plain4Basic.json │ │ │ ├── Plain4ETH.json │ │ │ ├── Plain4Optimized.json │ │ │ ├── Plain6Balances.json │ │ │ ├── Plain6Basic.json │ │ │ ├── Plain6ETH.json │ │ │ └── Plain6Optimized.json │ │ ├── factory.json │ │ ├── factoryPools │ │ │ ├── deposit.json │ │ │ ├── rewards.json │ │ │ └── swap.json │ │ ├── fee_distributor.json │ │ ├── fee_distributor_crvusd.json │ │ ├── fee_distributor_crvusd_view.json │ │ ├── fee_distributor_view.json │ │ ├── fraxusdc │ │ │ ├── meta_zap.json │ │ │ ├── meta_zap_crypto.json │ │ │ └── swap.json │ │ ├── frxeth │ │ │ └── swap.json │ │ ├── fusdt │ │ │ ├── swap.json │ │ │ └── zap.json │ │ ├── gas_oracle_optimism.json │ │ ├── gas_oracle_optimism_blob.json │ │ ├── gauge.json │ │ ├── gauge_child.json │ │ ├── gauge_factory.json │ │ ├── gauge_factory │ │ │ ├── child_gauge_factory.json │ │ │ └── root_gauge_factory.json │ │ ├── gauge_rewards_only.json │ │ ├── gauge_synthetix.json │ │ ├── gauge_v2.json │ │ ├── gauge_v3.json │ │ ├── gauge_v4.json │ │ ├── gauge_v5.json │ │ ├── gaugecontroller.json │ │ ├── gusd │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── hbtc │ │ │ └── swap.json │ │ ├── husd │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── ib │ │ │ └── swap.json │ │ ├── iearn │ │ │ ├── apr.json │ │ │ ├── deposit.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── link │ │ │ └── swap.json │ │ ├── llamma.json │ │ ├── minter_mainnet.json │ │ ├── musd │ │ │ ├── deposit.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── obtc │ │ │ ├── deposit.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── paave │ │ │ └── rewards.json │ │ ├── pax │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── pbtc │ │ │ ├── deposit.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── rai │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── ren-arbitrum │ │ │ └── swap.json │ │ ├── ren-fantom │ │ │ └── swap.json │ │ ├── ren-polygon │ │ │ └── swap.json │ │ ├── ren │ │ │ ├── adapter.json │ │ │ ├── meta_zap.json │ │ │ └── swap.json │ │ ├── reth │ │ │ └── swap.json │ │ ├── router-ng-pools-only.json │ │ ├── router.json │ │ ├── routerPolygon.json │ │ ├── rsv │ │ │ ├── deposit.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── saave │ │ │ └── swap.json │ │ ├── sbtc │ │ │ ├── adapter.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── sbtc2 │ │ │ ├── meta_zap.json │ │ │ └── swap.json │ │ ├── seth │ │ │ └── swap.json │ │ ├── stable-ng-base-pool-zap.json │ │ ├── stable_calc.json │ │ ├── steth │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── streamer.json │ │ ├── susd │ │ │ └── swap.json │ │ ├── susdv2 │ │ │ ├── deposit.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── tbtc │ │ │ ├── deposit.json │ │ │ ├── sCurveRewards.json │ │ │ └── swap.json │ │ ├── tricrypto-xdai │ │ │ ├── swap.json │ │ │ └── zap.json │ │ ├── tricrypto │ │ │ └── swapNoZap.json │ │ ├── tricrypto2 │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── usdk │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── usdn │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── usdp │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── usdt │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── ust │ │ │ ├── deposit.json │ │ │ └── swap.json │ │ ├── voting_escrow_oracle.json │ │ ├── voting_escrow_oracle_eth.json │ │ ├── voting_proposal.json │ │ ├── votingescrow.json │ │ ├── wbeth │ │ │ └── swap.json │ │ ├── wsteth │ │ │ └── swap.json │ │ └── yERC20.json │ ├── coins │ │ ├── arbitrum.ts │ │ ├── aurora.ts │ │ ├── avalanche.ts │ │ ├── base.ts │ │ ├── bsc.ts │ │ ├── celo.ts │ │ ├── ethereum.ts │ │ ├── fantom.ts │ │ ├── fraxtal.ts │ │ ├── hyperliquid.ts │ │ ├── index.ts │ │ ├── kava.ts │ │ ├── mantle.ts │ │ ├── moonbeam.ts │ │ ├── optimism.ts │ │ ├── polygon.ts │ │ ├── sonic.ts │ │ ├── xdai.ts │ │ ├── xlayer.ts │ │ └── zksync.ts │ ├── factory │ │ ├── crypto.ts │ │ ├── index.ts │ │ └── stable.ts │ ├── network_constants.ts │ ├── pools │ │ ├── arbitrum.ts │ │ ├── aurora.ts │ │ ├── avalanche.ts │ │ ├── base.ts │ │ ├── bsc.ts │ │ ├── celo.ts │ │ ├── ethereum.ts │ │ ├── fantom.ts │ │ ├── fraxtal.ts │ │ ├── hyperliquid.ts │ │ ├── index.ts │ │ ├── kava.ts │ │ ├── mantle.ts │ │ ├── moonbeam.ts │ │ ├── optimism.ts │ │ ├── polygon.ts │ │ ├── sonic.ts │ │ ├── xdai.ts │ │ ├── xlayer.ts │ │ └── zksync.ts │ ├── utils.ts │ └── volumeNetworks.ts ├── curve.ts ├── dao.ts ├── external-api.ts ├── factory │ ├── common.ts │ ├── deploy.ts │ ├── factory-api.ts │ ├── factory-crypto.ts │ ├── factory-tricrypto.ts │ ├── factory-twocrypto.ts │ └── factory.ts ├── index.ts ├── interfaces.ts ├── pools │ ├── PoolTemplate.ts │ ├── index.ts │ ├── mixins │ │ ├── common.ts │ │ ├── depositBalancedAmountsMixins.ts │ │ ├── depositMixins.ts │ │ ├── depositWrappedMixins.ts │ │ ├── poolBalancesMixin.ts │ │ ├── swapMixins.ts │ │ ├── swapWrappedMixins.ts │ │ ├── withdrawExpectedMixins.ts │ │ ├── withdrawImbalanceMixins.ts │ │ ├── withdrawImbalanceWrappedMixins.ts │ │ ├── withdrawMixins.ts │ │ ├── withdrawOneCoinExpectedMixins.ts │ │ ├── withdrawOneCoinMixins.ts │ │ ├── withdrawOneCoinWrappedExpectedMixins.ts │ │ ├── withdrawOneCoinWrappedMixins.ts │ │ └── withdrawWrappedMixins.ts │ ├── poolConstructor.ts │ ├── subClasses │ │ ├── corePool.ts │ │ ├── gaugePool.ts │ │ ├── statsPool.ts │ │ └── walletPool.ts │ └── utils.ts ├── route-finder.worker.ts ├── route-graph.worker.ts ├── router.ts └── utils.ts ├── test ├── apy.test.ts ├── balancedAmounts.test.ts ├── boosting.test.ts ├── claim │ ├── claimCrv.test.ts │ └── deposit.test.ts ├── constants.test.ts ├── deploy.test.ts ├── factoryPoolsData.test.ts ├── readme.test.ts ├── required.test.ts ├── rewards.test.ts ├── router.test.ts ├── stats.test.ts ├── underlying.test.ts └── wrapped.test.ts ├── tsconfig.build.json └── tsconfig.json /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: 3 | push: 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - uses: actions/setup-node@v4 11 | with: 12 | node-version: '22' 13 | cache: npm 14 | - run: npm ci 15 | - run: npm run build 16 | - run: npm run lint 17 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Release & Publish 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | release: 10 | name: Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v4 15 | - name: get-npm-version 16 | id: package-version 17 | uses: martinbeentjes/npm-get-version-action@main 18 | - name: Generate changelog 19 | id: changelog 20 | uses: TriPSs/conventional-changelog-action@v3 21 | with: 22 | github-token: ${{ secrets.GITHUB_TOKEN }} 23 | git-push: false 24 | output-file: false 25 | skip-version-file: true 26 | skip-commit: true 27 | - name: Create Release 28 | id: create_release 29 | uses: actions/create-release@v1 30 | env: 31 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 32 | with: 33 | tag_name: v${{ steps.package-version.outputs.current-version }} 34 | release_name: v${{ steps.package-version.outputs.current-version }} 35 | body: ${{ steps.changelog.outputs.clean_changelog }} 36 | draft: false 37 | prerelease: false 38 | 39 | publish: 40 | runs-on: ubuntu-latest 41 | permissions: 42 | contents: read 43 | id-token: write 44 | steps: 45 | - uses: actions/checkout@v4 46 | - name: Setup node version 47 | uses: actions/setup-node@v4 48 | with: 49 | node-version: '22' 50 | cache: npm 51 | registry-url: 'https://registry.npmjs.org' 52 | - name: Install modules 53 | run: npm ci 54 | - name: Build 55 | run: npm run build 56 | - name: Publish to npm 57 | run: npm publish --access public 58 | env: 59 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | dist/**/* 4 | lib/**/* 5 | pnpm-lock.yaml 6 | yarn.lock 7 | test/temp.test.ts 8 | test/rpcUrls.test.ts 9 | cache/ -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | src 4 | test 5 | dist 6 | .github 7 | .eslintrc.json 8 | package-lock.json 9 | tsconfig* 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Curve Finance 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import globals from "globals"; 2 | import parser from "vue-eslint-parser"; 3 | import typescriptEslint from "@typescript-eslint/eslint-plugin"; 4 | import tsParser from "@typescript-eslint/parser"; 5 | import path from "node:path"; 6 | import {fileURLToPath} from "node:url"; 7 | import js from "@eslint/js"; 8 | import {FlatCompat} from "@eslint/eslintrc"; 9 | 10 | const __filename = fileURLToPath(import.meta.url); 11 | const __dirname = path.dirname(__filename); 12 | const compat = new FlatCompat({ 13 | baseDirectory: __dirname, 14 | recommendedConfig: js.configs.recommended, 15 | allConfig: js.configs.all 16 | }); 17 | 18 | const config = [...compat.extends("eslint:recommended"), { 19 | languageOptions: { 20 | globals: { 21 | ...globals.browser, 22 | }, 23 | 24 | parser: parser, 25 | ecmaVersion: 5, 26 | sourceType: "module", 27 | 28 | parserOptions: { 29 | parser: "@babel/eslint-parser", 30 | allowImportExportEverywhere: false, 31 | }, 32 | }, 33 | 34 | rules: { 35 | "func-names": 0, 36 | "no-nested-ternary": 0, 37 | "max-len": 0, 38 | "arrow-parens": ["error", "always"], 39 | "no-underscore-dangle": 0, 40 | 41 | "comma-dangle": ["error", { 42 | arrays: "always-multiline", 43 | objects: "always-multiline", 44 | imports: "always-multiline", 45 | exports: "always-multiline", 46 | functions: "never", 47 | }], 48 | 49 | "no-use-before-define": ["error", "nofunc"], 50 | 51 | "no-empty": ["error", { 52 | allowEmptyCatch: true, 53 | }], 54 | 55 | "no-mixed-operators": ["error", { 56 | allowSamePrecedence: true, 57 | }], 58 | 59 | indent: ["error", 4, { 60 | flatTernaryExpressions: true, 61 | SwitchCase: 1, 62 | }], 63 | }, 64 | }, ...compat.extends( 65 | "plugin:@typescript-eslint/eslint-recommended", 66 | "plugin:@typescript-eslint/recommended", 67 | ).map(config => ({ 68 | ...config, 69 | files: ["**/*.ts"], 70 | })), { 71 | files: ["**/*.ts"], 72 | 73 | plugins: { 74 | "@typescript-eslint": typescriptEslint, 75 | }, 76 | 77 | languageOptions: { 78 | parser: tsParser, 79 | }, 80 | 81 | rules: { 82 | "@typescript-eslint/ban-ts-comment": "off", 83 | "@typescript-eslint/no-unused-vars": "warn", 84 | "@typescript-eslint/no-explicit-any": "off", 85 | }, 86 | }]; 87 | 88 | export default config; 89 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@curvefi/api", 3 | "version": "2.67.1", 4 | "description": "JavaScript library for curve.finance", 5 | "main": "lib/index.js", 6 | "author": "Macket", 7 | "license": "MIT", 8 | "private": false, 9 | "engines": { 10 | "node": "22" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/curvefi/curve-js.git" 15 | }, 16 | "bugs": { 17 | "url": "https://github.com/curvefi/curve-js/issues" 18 | }, 19 | "scripts": { 20 | "build": "rm -rf lib && tsc --project tsconfig.build.json", 21 | "lint": "eslint src --ext .ts", 22 | "lint:fix": "eslint src --fix", 23 | "watch": "tsc --watch", 24 | "watch:lib": "rm -rf lib && tsc --watch --project tsconfig.build.json" 25 | }, 26 | "type": "module", 27 | "devDependencies": { 28 | "@babel/eslint-parser": "^7.27.1", 29 | "@eslint/eslintrc": "^3.3.1", 30 | "@eslint/js": "^9.27.0", 31 | "@types/chai": "^5.2.2", 32 | "@types/memoizee": "^0.4.12", 33 | "@types/mocha": "^10.0.10", 34 | "@types/node": "^22.15.21", 35 | "@typescript-eslint/eslint-plugin": "^8.32.1", 36 | "@typescript-eslint/parser": "^8.32.1", 37 | "chai": "^5.2.0", 38 | "eslint": "^9.27.0", 39 | "globals": "^16.1.0", 40 | "mocha": "^11.4.0", 41 | "typescript": "^5.8.3", 42 | "vue-eslint-parser": "^10.1.3" 43 | }, 44 | "dependencies": { 45 | "@curvefi/ethcall": "^6.0.14", 46 | "bignumber.js": "^9.3.0", 47 | "ethers": "^6.14.1", 48 | "memoizee": "^0.4.17" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/cached.ts: -------------------------------------------------------------------------------- 1 | import {IDict, IExtendedPoolDataFromApi, INetworkName, IPoolType} from "./interfaces.js"; 2 | import {createCrvApyDict, createUsdPricesDict, uncached_getAllPoolsFromApi} from './external-api.js' 3 | 4 | /** 5 | * Memoizes a function that returns a promise. 6 | * Custom function instead of `memoizee` because we want to be able to set the cache manually based on server data. 7 | * @param fn The function that returns a promise and will be memoized 8 | * @param maxAge The maximum age of the cache in milliseconds 9 | * @param createKey A function that creates a key for the cache based on the arguments passed to the function 10 | * @returns A memoized `fn` function that includes a `set` method to set the cache manually 11 | */ 12 | const memoize = Promise>(fn: TFunc, { 13 | maxAge, 14 | createKey = (list) => list.toString(), 15 | }: { 16 | maxAge: number, 17 | createKey?: (args: TParams) => string 18 | }) => { 19 | const cache: Record> = {}; 20 | const timeouts: Record> = {}; 21 | 22 | const setCache = (key: string, promise?: Promise) => { 23 | if (promise) { 24 | cache[key] = promise; 25 | } else if (key in cache) { 26 | delete cache[key]; 27 | } 28 | if (key in timeouts) { 29 | clearTimeout(timeouts[key]); 30 | delete timeouts[key] 31 | } 32 | }; 33 | 34 | const scheduleCleanup = (key: string) => timeouts[key] = setTimeout(() => { 35 | delete timeouts[key]; 36 | delete cache[key]; 37 | }, maxAge); 38 | 39 | const cachedFn = async (...args: TParams): Promise => { 40 | const key = createKey(args); 41 | if (key in cache) { 42 | return cache[key]; 43 | } 44 | const promise = fn(...args); 45 | setCache(key, promise); 46 | try { 47 | const result = await promise; 48 | scheduleCleanup(key) 49 | return result; 50 | } catch (e) { 51 | delete cache[key]; 52 | throw e; 53 | } 54 | }; 55 | 56 | cachedFn.set = (result: TResult, ...args: TParams) => { 57 | const key = createKey(args); 58 | setCache(key, Promise.resolve(result)); 59 | scheduleCleanup(key); 60 | } 61 | 62 | return cachedFn as TFunc & { set: (result: TResult, ...args: TParams) => void }; 63 | } 64 | 65 | const createCache = (poolsDict: Record) => { 66 | const poolLists = Object.values(poolsDict) 67 | const usdPrices = createUsdPricesDict(poolLists); 68 | const crvApy = createCrvApyDict(poolLists) 69 | return {poolsDict, poolLists, usdPrices, crvApy}; 70 | }; 71 | 72 | /** 73 | * This function is used to cache the data fetched from the API and the data derived from it. 74 | * Note: do not expose this function to the outside world, instead encapsulate it in a function that returns the data you need. 75 | */ 76 | const _getCachedData = memoize(async (network: INetworkName, isLiteChain: boolean) => 77 | createCache(await uncached_getAllPoolsFromApi(network, isLiteChain)), {maxAge: 1000 * 60 * 5 /* 5 minutes */}) 78 | 79 | export const _getPoolsFromApi = 80 | async (network: INetworkName, poolType: IPoolType, isLiteChain = false): Promise => { 81 | const {poolsDict} = await _getCachedData(network, isLiteChain); 82 | return poolsDict[poolType] 83 | } 84 | 85 | export const _setPoolsFromApi = 86 | (network: INetworkName, isLiteChain: boolean, data: Record): void => 87 | _getCachedData.set(createCache(data), network, isLiteChain) 88 | 89 | export const _getAllPoolsFromApi = async (network: INetworkName, isLiteChain: boolean): Promise => { 90 | const {poolLists} = await _getCachedData(network, isLiteChain); 91 | return poolLists 92 | } 93 | 94 | export const _getUsdPricesFromApi = async (network:INetworkName, isLiteChain: boolean): Promise> => { 95 | const {usdPrices} = await _getCachedData(network, isLiteChain); 96 | return usdPrices 97 | } 98 | 99 | export const _getCrvApyFromApi = async (network:INetworkName, isLiteChain: boolean): Promise> => { 100 | const {crvApy} = await _getCachedData(network, isLiteChain); 101 | return crvApy 102 | } 103 | -------------------------------------------------------------------------------- /src/constants/L2Networks.ts: -------------------------------------------------------------------------------- 1 | export const L2Networks = [10, 8453] // 42161 (arbitrum) is L2 network, but does not need a change to estimateGas. -------------------------------------------------------------------------------- /src/constants/abis/ERC20.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [], 5 | "name": "name", 6 | "outputs": [ 7 | { 8 | "name": "", 9 | "type": "string" 10 | } 11 | ], 12 | "payable": false, 13 | "stateMutability": "view", 14 | "type": "function" 15 | }, 16 | { 17 | "constant": false, 18 | "inputs": [ 19 | { 20 | "name": "_spender", 21 | "type": "address" 22 | }, 23 | { 24 | "name": "_value", 25 | "type": "uint256" 26 | } 27 | ], 28 | "name": "approve", 29 | "outputs": [ 30 | { 31 | "name": "", 32 | "type": "bool" 33 | } 34 | ], 35 | "payable": false, 36 | "stateMutability": "nonpayable", 37 | "type": "function" 38 | }, 39 | { 40 | "constant": true, 41 | "inputs": [], 42 | "name": "totalSupply", 43 | "outputs": [ 44 | { 45 | "name": "", 46 | "type": "uint256" 47 | } 48 | ], 49 | "payable": false, 50 | "stateMutability": "view", 51 | "type": "function" 52 | }, 53 | { 54 | "constant": false, 55 | "inputs": [ 56 | { 57 | "name": "_from", 58 | "type": "address" 59 | }, 60 | { 61 | "name": "_to", 62 | "type": "address" 63 | }, 64 | { 65 | "name": "_value", 66 | "type": "uint256" 67 | } 68 | ], 69 | "name": "transferFrom", 70 | "outputs": [ 71 | { 72 | "name": "", 73 | "type": "bool" 74 | } 75 | ], 76 | "payable": false, 77 | "stateMutability": "nonpayable", 78 | "type": "function" 79 | }, 80 | { 81 | "constant": true, 82 | "inputs": [], 83 | "name": "decimals", 84 | "outputs": [ 85 | { 86 | "name": "", 87 | "type": "uint8" 88 | } 89 | ], 90 | "payable": false, 91 | "stateMutability": "view", 92 | "type": "function" 93 | }, 94 | { 95 | "constant": true, 96 | "inputs": [ 97 | { 98 | "name": "_owner", 99 | "type": "address" 100 | } 101 | ], 102 | "name": "balanceOf", 103 | "outputs": [ 104 | { 105 | "name": "balance", 106 | "type": "uint256" 107 | } 108 | ], 109 | "payable": false, 110 | "stateMutability": "view", 111 | "type": "function" 112 | }, 113 | { 114 | "constant": true, 115 | "inputs": [], 116 | "name": "symbol", 117 | "outputs": [ 118 | { 119 | "name": "", 120 | "type": "string" 121 | } 122 | ], 123 | "payable": false, 124 | "stateMutability": "view", 125 | "type": "function" 126 | }, 127 | { 128 | "constant": false, 129 | "inputs": [ 130 | { 131 | "name": "_to", 132 | "type": "address" 133 | }, 134 | { 135 | "name": "_value", 136 | "type": "uint256" 137 | } 138 | ], 139 | "name": "transfer", 140 | "outputs": [ 141 | { 142 | "name": "", 143 | "type": "bool" 144 | } 145 | ], 146 | "payable": false, 147 | "stateMutability": "nonpayable", 148 | "type": "function" 149 | }, 150 | { 151 | "constant": true, 152 | "inputs": [ 153 | { 154 | "name": "_owner", 155 | "type": "address" 156 | }, 157 | { 158 | "name": "_spender", 159 | "type": "address" 160 | } 161 | ], 162 | "name": "allowance", 163 | "outputs": [ 164 | { 165 | "name": "", 166 | "type": "uint256" 167 | } 168 | ], 169 | "payable": false, 170 | "stateMutability": "view", 171 | "type": "function" 172 | }, 173 | { 174 | "payable": true, 175 | "stateMutability": "payable", 176 | "type": "fallback" 177 | }, 178 | { 179 | "anonymous": false, 180 | "inputs": [ 181 | { 182 | "indexed": true, 183 | "name": "owner", 184 | "type": "address" 185 | }, 186 | { 187 | "indexed": true, 188 | "name": "spender", 189 | "type": "address" 190 | }, 191 | { 192 | "indexed": false, 193 | "name": "value", 194 | "type": "uint256" 195 | } 196 | ], 197 | "name": "Approval", 198 | "type": "event" 199 | }, 200 | { 201 | "anonymous": false, 202 | "inputs": [ 203 | { 204 | "indexed": true, 205 | "name": "from", 206 | "type": "address" 207 | }, 208 | { 209 | "indexed": true, 210 | "name": "to", 211 | "type": "address" 212 | }, 213 | { 214 | "indexed": false, 215 | "name": "value", 216 | "type": "uint256" 217 | } 218 | ], 219 | "name": "Transfer", 220 | "type": "event" 221 | } 222 | ] 223 | -------------------------------------------------------------------------------- /src/constants/abis/aave/rewards.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [ 6 | { 7 | "name": "_owner", 8 | "type": "address" 9 | } 10 | ], 11 | "outputs": [] 12 | }, 13 | { 14 | "stateMutability": "nonpayable", 15 | "type": "function", 16 | "name": "claim_rewards", 17 | "inputs": [], 18 | "outputs": [], 19 | "gas": "45372" 20 | }, 21 | { 22 | "stateMutability": "view", 23 | "type": "function", 24 | "name": "last_claim", 25 | "inputs": [], 26 | "outputs": [ 27 | { 28 | "name": "", 29 | "type": "uint256" 30 | } 31 | ], 32 | "gas": "2424" 33 | }, 34 | { 35 | "stateMutability": "view", 36 | "type": "function", 37 | "name": "reward_receiver", 38 | "inputs": [], 39 | "outputs": [ 40 | { 41 | "name": "", 42 | "type": "address" 43 | } 44 | ], 45 | "gas": "2658" 46 | }, 47 | { 48 | "stateMutability": "nonpayable", 49 | "type": "function", 50 | "name": "set_reward_receiver", 51 | "inputs": [ 52 | { 53 | "name": "_reward_receiver", 54 | "type": "address" 55 | } 56 | ], 57 | "outputs": [], 58 | "gas": "37635" 59 | }, 60 | { 61 | "stateMutability": "nonpayable", 62 | "type": "function", 63 | "name": "commit_transfer_ownership", 64 | "inputs": [ 65 | { 66 | "name": "_future_owner", 67 | "type": "address" 68 | } 69 | ], 70 | "outputs": [], 71 | "gas": "37665" 72 | }, 73 | { 74 | "stateMutability": "nonpayable", 75 | "type": "function", 76 | "name": "accept_transfer_ownership", 77 | "inputs": [], 78 | "outputs": [], 79 | "gas": "37610" 80 | }, 81 | { 82 | "stateMutability": "view", 83 | "type": "function", 84 | "name": "owner", 85 | "inputs": [], 86 | "outputs": [ 87 | { 88 | "name": "", 89 | "type": "address" 90 | } 91 | ], 92 | "gas": "2568" 93 | }, 94 | { 95 | "stateMutability": "view", 96 | "type": "function", 97 | "name": "future_owner", 98 | "inputs": [], 99 | "outputs": [ 100 | { 101 | "name": "", 102 | "type": "address" 103 | } 104 | ], 105 | "gas": "2598" 106 | } 107 | ] -------------------------------------------------------------------------------- /src/constants/abis/atricrypto3/base_pool_zap.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [ 6 | { 7 | "name": "_base_pool", 8 | "type": "address" 9 | }, 10 | { 11 | "name": "_base_lp_token", 12 | "type": "address" 13 | }, 14 | { 15 | "name": "_weth", 16 | "type": "address" 17 | }, 18 | { 19 | "name": "_base_coins", 20 | "type": "address[5]" 21 | } 22 | ], 23 | "outputs": [] 24 | }, 25 | { 26 | "stateMutability": "payable", 27 | "type": "fallback" 28 | }, 29 | { 30 | "stateMutability": "payable", 31 | "type": "function", 32 | "name": "exchange", 33 | "inputs": [ 34 | { 35 | "name": "_pool", 36 | "type": "address" 37 | }, 38 | { 39 | "name": "i", 40 | "type": "uint256" 41 | }, 42 | { 43 | "name": "j", 44 | "type": "uint256" 45 | }, 46 | { 47 | "name": "_dx", 48 | "type": "uint256" 49 | }, 50 | { 51 | "name": "_min_dy", 52 | "type": "uint256" 53 | }, 54 | { 55 | "name": "_use_eth", 56 | "type": "bool" 57 | } 58 | ], 59 | "outputs": [ 60 | { 61 | "name": "", 62 | "type": "uint256" 63 | } 64 | ] 65 | }, 66 | { 67 | "stateMutability": "view", 68 | "type": "function", 69 | "name": "get_dy", 70 | "inputs": [ 71 | { 72 | "name": "_pool", 73 | "type": "address" 74 | }, 75 | { 76 | "name": "i", 77 | "type": "uint256" 78 | }, 79 | { 80 | "name": "j", 81 | "type": "uint256" 82 | }, 83 | { 84 | "name": "_dx", 85 | "type": "uint256" 86 | } 87 | ], 88 | "outputs": [ 89 | { 90 | "name": "", 91 | "type": "uint256" 92 | } 93 | ] 94 | }, 95 | { 96 | "stateMutability": "payable", 97 | "type": "function", 98 | "name": "add_liquidity", 99 | "inputs": [ 100 | { 101 | "name": "_pool", 102 | "type": "address" 103 | }, 104 | { 105 | "name": "_deposit_amounts", 106 | "type": "uint256[6]" 107 | }, 108 | { 109 | "name": "_min_mint_amount", 110 | "type": "uint256" 111 | }, 112 | { 113 | "name": "_use_eth", 114 | "type": "bool" 115 | } 116 | ], 117 | "outputs": [ 118 | { 119 | "name": "", 120 | "type": "uint256" 121 | } 122 | ] 123 | }, 124 | { 125 | "stateMutability": "view", 126 | "type": "function", 127 | "name": "calc_token_amount", 128 | "inputs": [ 129 | { 130 | "name": "_pool", 131 | "type": "address" 132 | }, 133 | { 134 | "name": "_amounts", 135 | "type": "uint256[6]" 136 | } 137 | ], 138 | "outputs": [ 139 | { 140 | "name": "", 141 | "type": "uint256" 142 | } 143 | ] 144 | }, 145 | { 146 | "stateMutability": "nonpayable", 147 | "type": "function", 148 | "name": "remove_liquidity", 149 | "inputs": [ 150 | { 151 | "name": "_pool", 152 | "type": "address" 153 | }, 154 | { 155 | "name": "_burn_amount", 156 | "type": "uint256" 157 | }, 158 | { 159 | "name": "_min_amounts", 160 | "type": "uint256[6]" 161 | }, 162 | { 163 | "name": "_use_eth", 164 | "type": "bool" 165 | } 166 | ], 167 | "outputs": [ 168 | { 169 | "name": "", 170 | "type": "uint256[6]" 171 | } 172 | ] 173 | }, 174 | { 175 | "stateMutability": "nonpayable", 176 | "type": "function", 177 | "name": "remove_liquidity_one_coin", 178 | "inputs": [ 179 | { 180 | "name": "_pool", 181 | "type": "address" 182 | }, 183 | { 184 | "name": "_burn_amount", 185 | "type": "uint256" 186 | }, 187 | { 188 | "name": "i", 189 | "type": "uint256" 190 | }, 191 | { 192 | "name": "_min_amount", 193 | "type": "uint256" 194 | }, 195 | { 196 | "name": "_use_eth", 197 | "type": "bool" 198 | } 199 | ], 200 | "outputs": [ 201 | { 202 | "name": "", 203 | "type": "uint256" 204 | } 205 | ] 206 | }, 207 | { 208 | "stateMutability": "view", 209 | "type": "function", 210 | "name": "calc_withdraw_one_coin", 211 | "inputs": [ 212 | { 213 | "name": "_pool", 214 | "type": "address" 215 | }, 216 | { 217 | "name": "_token_amount", 218 | "type": "uint256" 219 | }, 220 | { 221 | "name": "i", 222 | "type": "uint256" 223 | } 224 | ], 225 | "outputs": [ 226 | { 227 | "name": "", 228 | "type": "uint256" 229 | } 230 | ] 231 | } 232 | ] -------------------------------------------------------------------------------- /src/constants/abis/busd/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputs":[], 4 | "inputs":[ 5 | { 6 | "type":"address[4]", 7 | "name":"_coins" 8 | }, 9 | { 10 | "type":"address[4]", 11 | "name":"_underlying_coins" 12 | }, 13 | { 14 | "type":"address", 15 | "name":"_curve" 16 | }, 17 | { 18 | "type":"address", 19 | "name":"_token" 20 | } 21 | ], 22 | "constant":false, 23 | "payable":false, 24 | "type":"constructor" 25 | }, 26 | { 27 | "name":"add_liquidity", 28 | "outputs":[], 29 | "inputs":[ 30 | { 31 | "type":"uint256[4]", 32 | "name":"uamounts" 33 | }, 34 | { 35 | "type":"uint256", 36 | "name":"min_mint_amount" 37 | } 38 | ], 39 | "constant":false, 40 | "payable":false, 41 | "type":"function", 42 | "gas":"3164560" 43 | }, 44 | { 45 | "name":"remove_liquidity", 46 | "outputs":[], 47 | "inputs":[ 48 | { 49 | "type":"uint256", 50 | "name":"_amount" 51 | }, 52 | { 53 | "type":"uint256[4]", 54 | "name":"min_uamounts" 55 | } 56 | ], 57 | "constant":false, 58 | "payable":false, 59 | "type":"function", 60 | "gas":"1067523" 61 | }, 62 | { 63 | "name":"remove_liquidity_imbalance", 64 | "outputs":[], 65 | "inputs":[ 66 | { 67 | "type":"uint256[4]", 68 | "name":"uamounts" 69 | }, 70 | { 71 | "type":"uint256", 72 | "name":"max_burn_amount" 73 | } 74 | ], 75 | "constant":false, 76 | "payable":false, 77 | "type":"function", 78 | "gas":"1752981" 79 | }, 80 | { 81 | "name":"calc_withdraw_one_coin", 82 | "outputs":[ 83 | { 84 | "type":"uint256", 85 | "name":"" 86 | } 87 | ], 88 | "inputs":[ 89 | { 90 | "type":"uint256", 91 | "name":"_token_amount" 92 | }, 93 | { 94 | "type":"int128", 95 | "name":"i" 96 | } 97 | ], 98 | "stateMutability": "view", 99 | "type":"function", 100 | "gas":"3881601" 101 | }, 102 | { 103 | "name":"remove_liquidity_one_coin", 104 | "outputs":[], 105 | "inputs":[ 106 | { 107 | "type":"uint256", 108 | "name":"_token_amount" 109 | }, 110 | { 111 | "type":"int128", 112 | "name":"i" 113 | }, 114 | { 115 | "type":"uint256", 116 | "name":"min_uamount" 117 | } 118 | ], 119 | "constant":false, 120 | "payable":false, 121 | "type":"function" 122 | }, 123 | { 124 | "name":"withdraw_donated_dust", 125 | "outputs":[], 126 | "inputs":[], 127 | "constant":false, 128 | "payable":false, 129 | "type":"function", 130 | "gas":"63973" 131 | }, 132 | { 133 | "name":"coins", 134 | "outputs":[ 135 | { 136 | "type":"address", 137 | "name":"" 138 | } 139 | ], 140 | "inputs":[ 141 | { 142 | "type":"int128", 143 | "name":"arg0" 144 | } 145 | ], 146 | "stateMutability": "view", 147 | "type":"function", 148 | "gas":"1680" 149 | }, 150 | { 151 | "name":"underlying_coins", 152 | "outputs":[ 153 | { 154 | "type":"address", 155 | "name":"" 156 | } 157 | ], 158 | "inputs":[ 159 | { 160 | "type":"int128", 161 | "name":"arg0" 162 | } 163 | ], 164 | "stateMutability": "view", 165 | "type":"function", 166 | "gas":"1710" 167 | }, 168 | { 169 | "name":"curve", 170 | "outputs":[ 171 | { 172 | "type":"address", 173 | "name":"" 174 | } 175 | ], 176 | "inputs":[], 177 | "stateMutability": "view", 178 | "type":"function", 179 | "gas":"1541" 180 | }, 181 | { 182 | "name":"token", 183 | "outputs":[ 184 | { 185 | "type":"address", 186 | "name":"" 187 | } 188 | ], 189 | "inputs":[], 190 | "stateMutability": "view", 191 | "type":"function", 192 | "gas":"1571" 193 | } 194 | ] 195 | -------------------------------------------------------------------------------- /src/constants/abis/circulating_supply.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [], 6 | "outputs": [] 7 | }, 8 | { 9 | "stateMutability": "nonpayable", 10 | "type": "function", 11 | "name": "add_contract", 12 | "inputs": [ 13 | { 14 | "name": "_contract", 15 | "type": "address" 16 | } 17 | ], 18 | "outputs": [] 19 | }, 20 | { 21 | "stateMutability": "view", 22 | "type": "function", 23 | "name": "circulating_supply", 24 | "inputs": [], 25 | "outputs": [ 26 | { 27 | "name": "", 28 | "type": "uint256" 29 | } 30 | ] 31 | }, 32 | { 33 | "stateMutability": "nonpayable", 34 | "type": "function", 35 | "name": "set_admin", 36 | "inputs": [ 37 | { 38 | "name": "_new_admin", 39 | "type": "address" 40 | } 41 | ], 42 | "outputs": [] 43 | }, 44 | { 45 | "stateMutability": "view", 46 | "type": "function", 47 | "name": "admin", 48 | "inputs": [], 49 | "outputs": [ 50 | { 51 | "name": "", 52 | "type": "address" 53 | } 54 | ] 55 | }, 56 | { 57 | "stateMutability": "view", 58 | "type": "function", 59 | "name": "CRV", 60 | "inputs": [], 61 | "outputs": [ 62 | { 63 | "name": "", 64 | "type": "address" 65 | } 66 | ] 67 | }, 68 | { 69 | "stateMutability": "view", 70 | "type": "function", 71 | "name": "contracts", 72 | "inputs": [ 73 | { 74 | "name": "arg0", 75 | "type": "uint256" 76 | } 77 | ], 78 | "outputs": [ 79 | { 80 | "name": "", 81 | "type": "address" 82 | } 83 | ] 84 | }, 85 | { 86 | "stateMutability": "view", 87 | "type": "function", 88 | "name": "num_contracts", 89 | "inputs": [], 90 | "outputs": [ 91 | { 92 | "name": "", 93 | "type": "uint256" 94 | } 95 | ] 96 | }, 97 | { 98 | "stateMutability": "view", 99 | "type": "function", 100 | "name": "cached_contracts", 101 | "inputs": [ 102 | { 103 | "name": "arg0", 104 | "type": "uint256" 105 | } 106 | ], 107 | "outputs": [ 108 | { 109 | "name": "", 110 | "type": "address" 111 | } 112 | ] 113 | } 114 | ] -------------------------------------------------------------------------------- /src/constants/abis/compound/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputs":[], 4 | "inputs":[ 5 | { 6 | "type":"address[2]", 7 | "name":"_coins" 8 | }, 9 | { 10 | "type":"address[2]", 11 | "name":"_underlying_coins" 12 | }, 13 | { 14 | "type":"address", 15 | "name":"_curve" 16 | }, 17 | { 18 | "type":"address", 19 | "name":"_token" 20 | } 21 | ], 22 | "constant":false, 23 | "payable":false, 24 | "type":"constructor" 25 | }, 26 | { 27 | "name":"add_liquidity", 28 | "outputs":[], 29 | "inputs":[ 30 | { 31 | "type":"uint256[2]", 32 | "name":"uamounts" 33 | }, 34 | { 35 | "type":"uint256", 36 | "name":"min_mint_amount" 37 | } 38 | ], 39 | "constant":false, 40 | "payable":false, 41 | "type":"function", 42 | "gas":"992271" 43 | }, 44 | { 45 | "name":"remove_liquidity", 46 | "outputs":[], 47 | "inputs":[ 48 | { 49 | "type":"uint256", 50 | "name":"_amount" 51 | }, 52 | { 53 | "type":"uint256[2]", 54 | "name":"min_uamounts" 55 | } 56 | ], 57 | "constant":false, 58 | "payable":false, 59 | "type":"function", 60 | "gas":"621194" 61 | }, 62 | { 63 | "name":"remove_liquidity_imbalance", 64 | "outputs":[], 65 | "inputs":[ 66 | { 67 | "type":"uint256[2]", 68 | "name":"uamounts" 69 | }, 70 | { 71 | "type":"uint256", 72 | "name":"max_burn_amount" 73 | } 74 | ], 75 | "constant":false, 76 | "payable":false, 77 | "type":"function", 78 | "gas":"840484" 79 | }, 80 | { 81 | "name":"calc_withdraw_one_coin", 82 | "outputs":[ 83 | { 84 | "type":"uint256", 85 | "name":"" 86 | } 87 | ], 88 | "inputs":[ 89 | { 90 | "type":"uint256", 91 | "name":"_token_amount" 92 | }, 93 | { 94 | "type":"int128", 95 | "name":"i" 96 | } 97 | ], 98 | "stateMutability": "view", 99 | "type":"function", 100 | "gas":"2945630" 101 | }, 102 | { 103 | "name":"remove_liquidity_one_coin", 104 | "outputs":[], 105 | "inputs":[ 106 | { 107 | "type":"uint256", 108 | "name":"_token_amount" 109 | }, 110 | { 111 | "type":"int128", 112 | "name":"i" 113 | }, 114 | { 115 | "type":"uint256", 116 | "name":"min_uamount" 117 | } 118 | ], 119 | "constant":false, 120 | "payable":false, 121 | "type":"function" 122 | }, 123 | { 124 | "name":"withdraw_donated_dust", 125 | "outputs":[], 126 | "inputs":[], 127 | "constant":false, 128 | "payable":false, 129 | "type":"function", 130 | "gas":"63973" 131 | }, 132 | { 133 | "name":"coins", 134 | "outputs":[ 135 | { 136 | "type":"address", 137 | "name":"" 138 | } 139 | ], 140 | "inputs":[ 141 | { 142 | "type":"int128", 143 | "name":"arg0" 144 | } 145 | ], 146 | "stateMutability": "view", 147 | "type":"function", 148 | "gas":"1680" 149 | }, 150 | { 151 | "name":"underlying_coins", 152 | "outputs":[ 153 | { 154 | "type":"address", 155 | "name":"" 156 | } 157 | ], 158 | "inputs":[ 159 | { 160 | "type":"int128", 161 | "name":"arg0" 162 | } 163 | ], 164 | "stateMutability": "view", 165 | "type":"function", 166 | "gas":"1710" 167 | }, 168 | { 169 | "name":"curve", 170 | "outputs":[ 171 | { 172 | "type":"address", 173 | "name":"" 174 | } 175 | ], 176 | "inputs":[], 177 | "stateMutability": "view", 178 | "type":"function", 179 | "gas":"1541" 180 | }, 181 | { 182 | "name":"token", 183 | "outputs":[ 184 | { 185 | "type":"address", 186 | "name":"" 187 | } 188 | ], 189 | "inputs":[], 190 | "stateMutability": "view", 191 | "type":"function", 192 | "gas":"1571" 193 | } 194 | ] 195 | -------------------------------------------------------------------------------- /src/constants/abis/crypto_calc.json: -------------------------------------------------------------------------------- 1 | [{"stateMutability":"view","type":"function","name":"get_dx","inputs":[{"name":"pool","type":"address"},{"name":"i","type":"uint256"},{"name":"j","type":"uint256"},{"name":"dy","type":"uint256"},{"name":"n_coins","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dx_meta_underlying","inputs":[{"name":"pool","type":"address"},{"name":"i","type":"uint256"},{"name":"j","type":"uint256"},{"name":"dy","type":"uint256"},{"name":"n_coins","type":"uint256"},{"name":"base_pool","type":"address"},{"name":"base_token","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dx_tricrypto_meta_underlying","inputs":[{"name":"pool","type":"address"},{"name":"i","type":"uint256"},{"name":"j","type":"uint256"},{"name":"dy","type":"uint256"},{"name":"n_coins","type":"uint256"},{"name":"base_pool","type":"address"},{"name":"base_token","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dx_double_meta_underlying","inputs":[{"name":"pool","type":"address"},{"name":"i","type":"uint256"},{"name":"j","type":"uint256"},{"name":"dy","type":"uint256"},{"name":"base_pool","type":"address"},{"name":"base_pool_zap","type":"address"},{"name":"second_base_pool","type":"address"},{"name":"second_base_token","type":"address"}],"outputs":[{"name":"","type":"uint256"}]}] -------------------------------------------------------------------------------- /src/constants/abis/deposit_and_stake.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "payable", 4 | "type": "function", 5 | "name": "deposit_and_stake", 6 | "inputs": [ 7 | { 8 | "name": "deposit", 9 | "type": "address" 10 | }, 11 | { 12 | "name": "lp_token", 13 | "type": "address" 14 | }, 15 | { 16 | "name": "gauge", 17 | "type": "address" 18 | }, 19 | { 20 | "name": "n_coins", 21 | "type": "uint256" 22 | }, 23 | { 24 | "name": "coins", 25 | "type": "address[]" 26 | }, 27 | { 28 | "name": "amounts", 29 | "type": "uint256[]" 30 | }, 31 | { 32 | "name": "min_mint_amount", 33 | "type": "uint256" 34 | }, 35 | { 36 | "name": "use_underlying", 37 | "type": "bool" 38 | }, 39 | { 40 | "name": "use_dynarray", 41 | "type": "bool" 42 | }, 43 | { 44 | "name": "pool", 45 | "type": "address" 46 | } 47 | ], 48 | "outputs": [] 49 | }, 50 | { 51 | "stateMutability": "payable", 52 | "type": "fallback" 53 | } 54 | ] -------------------------------------------------------------------------------- /src/constants/abis/deposit_and_stake_ng_only.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "payable", 4 | "type": "function", 5 | "name": "deposit_and_stake", 6 | "inputs": [ 7 | { 8 | "name": "deposit", 9 | "type": "address" 10 | }, 11 | { 12 | "name": "lp_token", 13 | "type": "address" 14 | }, 15 | { 16 | "name": "gauge", 17 | "type": "address" 18 | }, 19 | { 20 | "name": "n_coins", 21 | "type": "uint256" 22 | }, 23 | { 24 | "name": "coins", 25 | "type": "address[]" 26 | }, 27 | { 28 | "name": "amounts", 29 | "type": "uint256[]" 30 | }, 31 | { 32 | "name": "min_mint_amount", 33 | "type": "uint256" 34 | }, 35 | { 36 | "name": "use_dynarray", 37 | "type": "bool" 38 | }, 39 | { 40 | "name": "pool", 41 | "type": "address" 42 | } 43 | ], 44 | "outputs": [] 45 | }, 46 | { 47 | "stateMutability": "payable", 48 | "type": "fallback" 49 | } 50 | ] -------------------------------------------------------------------------------- /src/constants/abis/factory-v2/DepositZapFantom.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [], 6 | "outputs": [] 7 | }, 8 | { 9 | "stateMutability": "nonpayable", 10 | "type": "function", 11 | "name": "add_liquidity", 12 | "inputs": [ 13 | { 14 | "name": "_pool", 15 | "type": "address" 16 | }, 17 | { 18 | "name": "_deposit_amounts", 19 | "type": "uint256[3]" 20 | }, 21 | { 22 | "name": "_min_mint_amount", 23 | "type": "uint256" 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "", 29 | "type": "uint256" 30 | } 31 | ] 32 | }, 33 | { 34 | "stateMutability": "nonpayable", 35 | "type": "function", 36 | "name": "remove_liquidity", 37 | "inputs": [ 38 | { 39 | "name": "_pool", 40 | "type": "address" 41 | }, 42 | { 43 | "name": "_burn_amount", 44 | "type": "uint256" 45 | }, 46 | { 47 | "name": "_min_amounts", 48 | "type": "uint256[3]" 49 | } 50 | ], 51 | "outputs": [ 52 | { 53 | "name": "", 54 | "type": "uint256[3]" 55 | } 56 | ] 57 | }, 58 | { 59 | "stateMutability": "nonpayable", 60 | "type": "function", 61 | "name": "remove_liquidity_one_coin", 62 | "inputs": [ 63 | { 64 | "name": "_pool", 65 | "type": "address" 66 | }, 67 | { 68 | "name": "_burn_amount", 69 | "type": "uint256" 70 | }, 71 | { 72 | "name": "i", 73 | "type": "int128" 74 | }, 75 | { 76 | "name": "_min_amount", 77 | "type": "uint256" 78 | } 79 | ], 80 | "outputs": [ 81 | { 82 | "name": "", 83 | "type": "uint256" 84 | } 85 | ] 86 | }, 87 | { 88 | "stateMutability": "nonpayable", 89 | "type": "function", 90 | "name": "remove_liquidity_imbalance", 91 | "inputs": [ 92 | { 93 | "name": "_pool", 94 | "type": "address" 95 | }, 96 | { 97 | "name": "_amounts", 98 | "type": "uint256[3]" 99 | }, 100 | { 101 | "name": "_max_burn_amount", 102 | "type": "uint256" 103 | } 104 | ], 105 | "outputs": [ 106 | { 107 | "name": "", 108 | "type": "uint256" 109 | } 110 | ] 111 | }, 112 | { 113 | "stateMutability": "view", 114 | "type": "function", 115 | "name": "calc_withdraw_one_coin", 116 | "inputs": [ 117 | { 118 | "name": "_pool", 119 | "type": "address" 120 | }, 121 | { 122 | "name": "_token_amount", 123 | "type": "uint256" 124 | }, 125 | { 126 | "name": "i", 127 | "type": "int128" 128 | } 129 | ], 130 | "outputs": [ 131 | { 132 | "name": "", 133 | "type": "uint256" 134 | } 135 | ], 136 | "gas": "5753" 137 | }, 138 | { 139 | "stateMutability": "view", 140 | "type": "function", 141 | "name": "calc_token_amount", 142 | "inputs": [ 143 | { 144 | "name": "_pool", 145 | "type": "address" 146 | }, 147 | { 148 | "name": "_amounts", 149 | "type": "uint256[3]" 150 | }, 151 | { 152 | "name": "_is_deposit", 153 | "type": "bool" 154 | } 155 | ], 156 | "outputs": [ 157 | { 158 | "name": "", 159 | "type": "uint256" 160 | } 161 | ], 162 | "gas": "6289" 163 | } 164 | ] 165 | -------------------------------------------------------------------------------- /src/constants/abis/factory-v2/DepositZapMetaBtcPolygon.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [], 6 | "outputs": [] 7 | }, 8 | { 9 | "stateMutability": "nonpayable", 10 | "type": "function", 11 | "name": "add_liquidity", 12 | "inputs": [ 13 | { 14 | "name": "_pool", 15 | "type": "address" 16 | }, 17 | { 18 | "name": "_deposit_amounts", 19 | "type": "uint256[3]" 20 | }, 21 | { 22 | "name": "_min_mint_amount", 23 | "type": "uint256" 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "", 29 | "type": "uint256" 30 | } 31 | ] 32 | }, 33 | { 34 | "stateMutability": "nonpayable", 35 | "type": "function", 36 | "name": "remove_liquidity", 37 | "inputs": [ 38 | { 39 | "name": "_pool", 40 | "type": "address" 41 | }, 42 | { 43 | "name": "_burn_amount", 44 | "type": "uint256" 45 | }, 46 | { 47 | "name": "_min_amounts", 48 | "type": "uint256[3]" 49 | } 50 | ], 51 | "outputs": [ 52 | { 53 | "name": "", 54 | "type": "uint256[3]" 55 | } 56 | ] 57 | }, 58 | { 59 | "stateMutability": "nonpayable", 60 | "type": "function", 61 | "name": "remove_liquidity_one_coin", 62 | "inputs": [ 63 | { 64 | "name": "_pool", 65 | "type": "address" 66 | }, 67 | { 68 | "name": "_burn_amount", 69 | "type": "uint256" 70 | }, 71 | { 72 | "name": "i", 73 | "type": "int128" 74 | }, 75 | { 76 | "name": "_min_amount", 77 | "type": "uint256" 78 | } 79 | ], 80 | "outputs": [ 81 | { 82 | "name": "", 83 | "type": "uint256" 84 | } 85 | ] 86 | }, 87 | { 88 | "stateMutability": "nonpayable", 89 | "type": "function", 90 | "name": "remove_liquidity_imbalance", 91 | "inputs": [ 92 | { 93 | "name": "_pool", 94 | "type": "address" 95 | }, 96 | { 97 | "name": "_amounts", 98 | "type": "uint256[3]" 99 | }, 100 | { 101 | "name": "_max_burn_amount", 102 | "type": "uint256" 103 | } 104 | ], 105 | "outputs": [ 106 | { 107 | "name": "", 108 | "type": "uint256" 109 | } 110 | ] 111 | }, 112 | { 113 | "stateMutability": "view", 114 | "type": "function", 115 | "name": "calc_withdraw_one_coin", 116 | "inputs": [ 117 | { 118 | "name": "_pool", 119 | "type": "address" 120 | }, 121 | { 122 | "name": "_token_amount", 123 | "type": "uint256" 124 | }, 125 | { 126 | "name": "i", 127 | "type": "int128" 128 | } 129 | ], 130 | "outputs": [ 131 | { 132 | "name": "", 133 | "type": "uint256" 134 | } 135 | ], 136 | "gas": "5753" 137 | }, 138 | { 139 | "stateMutability": "view", 140 | "type": "function", 141 | "name": "calc_token_amount", 142 | "inputs": [ 143 | { 144 | "name": "_pool", 145 | "type": "address" 146 | }, 147 | { 148 | "name": "_amounts", 149 | "type": "uint256[3]" 150 | }, 151 | { 152 | "name": "_is_deposit", 153 | "type": "bool" 154 | } 155 | ], 156 | "outputs": [ 157 | { 158 | "name": "", 159 | "type": "uint256" 160 | } 161 | ], 162 | "gas": "6289" 163 | }, 164 | { 165 | "stateMutability": "nonpayable", 166 | "type": "function", 167 | "name": "exchange_underlying", 168 | "inputs": [ 169 | { 170 | "name": "_pool", 171 | "type": "address" 172 | }, 173 | { 174 | "name": "_i", 175 | "type": "int128" 176 | }, 177 | { 178 | "name": "_j", 179 | "type": "int128" 180 | }, 181 | { 182 | "name": "_dx", 183 | "type": "uint256" 184 | }, 185 | { 186 | "name": "_min_dy", 187 | "type": "uint256" 188 | } 189 | ], 190 | "outputs": [ 191 | { 192 | "name": "", 193 | "type": "uint256" 194 | } 195 | ] 196 | } 197 | ] 198 | -------------------------------------------------------------------------------- /src/constants/abis/factory-v2/DepositZapMetaUsd2Fantom.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [], 6 | "outputs": [] 7 | }, 8 | { 9 | "stateMutability": "nonpayable", 10 | "type": "function", 11 | "name": "add_liquidity", 12 | "inputs": [ 13 | { 14 | "name": "_pool", 15 | "type": "address" 16 | }, 17 | { 18 | "name": "_deposit_amounts", 19 | "type": "uint256[4]" 20 | }, 21 | { 22 | "name": "_min_mint_amount", 23 | "type": "uint256" 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "", 29 | "type": "uint256" 30 | } 31 | ] 32 | }, 33 | { 34 | "stateMutability": "nonpayable", 35 | "type": "function", 36 | "name": "remove_liquidity", 37 | "inputs": [ 38 | { 39 | "name": "_pool", 40 | "type": "address" 41 | }, 42 | { 43 | "name": "_burn_amount", 44 | "type": "uint256" 45 | }, 46 | { 47 | "name": "_min_amounts", 48 | "type": "uint256[4]" 49 | } 50 | ], 51 | "outputs": [ 52 | { 53 | "name": "", 54 | "type": "uint256[4]" 55 | } 56 | ] 57 | }, 58 | { 59 | "stateMutability": "nonpayable", 60 | "type": "function", 61 | "name": "remove_liquidity_one_coin", 62 | "inputs": [ 63 | { 64 | "name": "_pool", 65 | "type": "address" 66 | }, 67 | { 68 | "name": "_burn_amount", 69 | "type": "uint256" 70 | }, 71 | { 72 | "name": "i", 73 | "type": "int128" 74 | }, 75 | { 76 | "name": "_min_amount", 77 | "type": "uint256" 78 | } 79 | ], 80 | "outputs": [ 81 | { 82 | "name": "", 83 | "type": "uint256" 84 | } 85 | ] 86 | }, 87 | { 88 | "stateMutability": "nonpayable", 89 | "type": "function", 90 | "name": "remove_liquidity_imbalance", 91 | "inputs": [ 92 | { 93 | "name": "_pool", 94 | "type": "address" 95 | }, 96 | { 97 | "name": "_amounts", 98 | "type": "uint256[4]" 99 | }, 100 | { 101 | "name": "_max_burn_amount", 102 | "type": "uint256" 103 | } 104 | ], 105 | "outputs": [ 106 | { 107 | "name": "", 108 | "type": "uint256" 109 | } 110 | ] 111 | }, 112 | { 113 | "stateMutability": "view", 114 | "type": "function", 115 | "name": "calc_withdraw_one_coin", 116 | "inputs": [ 117 | { 118 | "name": "_pool", 119 | "type": "address" 120 | }, 121 | { 122 | "name": "_token_amount", 123 | "type": "uint256" 124 | }, 125 | { 126 | "name": "i", 127 | "type": "int128" 128 | } 129 | ], 130 | "outputs": [ 131 | { 132 | "name": "", 133 | "type": "uint256" 134 | } 135 | ], 136 | "gas": "5753" 137 | }, 138 | { 139 | "stateMutability": "view", 140 | "type": "function", 141 | "name": "calc_token_amount", 142 | "inputs": [ 143 | { 144 | "name": "_pool", 145 | "type": "address" 146 | }, 147 | { 148 | "name": "_amounts", 149 | "type": "uint256[4]" 150 | }, 151 | { 152 | "name": "_is_deposit", 153 | "type": "bool" 154 | } 155 | ], 156 | "outputs": [ 157 | { 158 | "name": "", 159 | "type": "uint256" 160 | } 161 | ], 162 | "gas": "6666" 163 | }, 164 | { 165 | "stateMutability": "nonpayable", 166 | "type": "function", 167 | "name": "exchange_underlying", 168 | "inputs": [ 169 | { 170 | "name": "_pool", 171 | "type": "address" 172 | }, 173 | { 174 | "name": "_i", 175 | "type": "int128" 176 | }, 177 | { 178 | "name": "_j", 179 | "type": "int128" 180 | }, 181 | { 182 | "name": "_dx", 183 | "type": "uint256" 184 | }, 185 | { 186 | "name": "_min_dy", 187 | "type": "uint256" 188 | } 189 | ], 190 | "outputs": [ 191 | { 192 | "name": "", 193 | "type": "uint256" 194 | } 195 | ] 196 | } 197 | ] 198 | -------------------------------------------------------------------------------- /src/constants/abis/factory-v2/DepositZapMetaUsdPolygon.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [], 6 | "outputs": [] 7 | }, 8 | { 9 | "stateMutability": "nonpayable", 10 | "type": "function", 11 | "name": "add_liquidity", 12 | "inputs": [ 13 | { 14 | "name": "_pool", 15 | "type": "address" 16 | }, 17 | { 18 | "name": "_deposit_amounts", 19 | "type": "uint256[4]" 20 | }, 21 | { 22 | "name": "_min_mint_amount", 23 | "type": "uint256" 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "", 29 | "type": "uint256" 30 | } 31 | ] 32 | }, 33 | { 34 | "stateMutability": "nonpayable", 35 | "type": "function", 36 | "name": "remove_liquidity", 37 | "inputs": [ 38 | { 39 | "name": "_pool", 40 | "type": "address" 41 | }, 42 | { 43 | "name": "_burn_amount", 44 | "type": "uint256" 45 | }, 46 | { 47 | "name": "_min_amounts", 48 | "type": "uint256[4]" 49 | } 50 | ], 51 | "outputs": [ 52 | { 53 | "name": "", 54 | "type": "uint256[4]" 55 | } 56 | ] 57 | }, 58 | { 59 | "stateMutability": "nonpayable", 60 | "type": "function", 61 | "name": "remove_liquidity_one_coin", 62 | "inputs": [ 63 | { 64 | "name": "_pool", 65 | "type": "address" 66 | }, 67 | { 68 | "name": "_burn_amount", 69 | "type": "uint256" 70 | }, 71 | { 72 | "name": "i", 73 | "type": "int128" 74 | }, 75 | { 76 | "name": "_min_amount", 77 | "type": "uint256" 78 | } 79 | ], 80 | "outputs": [ 81 | { 82 | "name": "", 83 | "type": "uint256" 84 | } 85 | ] 86 | }, 87 | { 88 | "stateMutability": "nonpayable", 89 | "type": "function", 90 | "name": "remove_liquidity_imbalance", 91 | "inputs": [ 92 | { 93 | "name": "_pool", 94 | "type": "address" 95 | }, 96 | { 97 | "name": "_amounts", 98 | "type": "uint256[4]" 99 | }, 100 | { 101 | "name": "_max_burn_amount", 102 | "type": "uint256" 103 | } 104 | ], 105 | "outputs": [ 106 | { 107 | "name": "", 108 | "type": "uint256" 109 | } 110 | ] 111 | }, 112 | { 113 | "stateMutability": "view", 114 | "type": "function", 115 | "name": "calc_withdraw_one_coin", 116 | "inputs": [ 117 | { 118 | "name": "_pool", 119 | "type": "address" 120 | }, 121 | { 122 | "name": "_token_amount", 123 | "type": "uint256" 124 | }, 125 | { 126 | "name": "i", 127 | "type": "int128" 128 | } 129 | ], 130 | "outputs": [ 131 | { 132 | "name": "", 133 | "type": "uint256" 134 | } 135 | ], 136 | "gas": "5753" 137 | }, 138 | { 139 | "stateMutability": "view", 140 | "type": "function", 141 | "name": "calc_token_amount", 142 | "inputs": [ 143 | { 144 | "name": "_pool", 145 | "type": "address" 146 | }, 147 | { 148 | "name": "_amounts", 149 | "type": "uint256[4]" 150 | }, 151 | { 152 | "name": "_is_deposit", 153 | "type": "bool" 154 | } 155 | ], 156 | "outputs": [ 157 | { 158 | "name": "", 159 | "type": "uint256" 160 | } 161 | ], 162 | "gas": "6666" 163 | }, 164 | { 165 | "stateMutability": "nonpayable", 166 | "type": "function", 167 | "name": "exchange_underlying", 168 | "inputs": [ 169 | { 170 | "name": "_pool", 171 | "type": "address" 172 | }, 173 | { 174 | "name": "_i", 175 | "type": "int128" 176 | }, 177 | { 178 | "name": "_j", 179 | "type": "int128" 180 | }, 181 | { 182 | "name": "_dx", 183 | "type": "uint256" 184 | }, 185 | { 186 | "name": "_min_dy", 187 | "type": "uint256" 188 | } 189 | ], 190 | "outputs": [ 191 | { 192 | "name": "", 193 | "type": "uint256" 194 | } 195 | ] 196 | } 197 | ] 198 | -------------------------------------------------------------------------------- /src/constants/abis/factoryPools/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputs": [], 4 | "inputs": [], 5 | "stateMutability": "nonpayable", 6 | "type": "constructor" 7 | }, 8 | { 9 | "name": "add_liquidity", 10 | "outputs": [ 11 | { 12 | "type": "uint256", 13 | "name": "" 14 | } 15 | ], 16 | "inputs": [ 17 | { 18 | "type": "address", 19 | "name": "_pool" 20 | }, 21 | { 22 | "type": "uint256[4]", 23 | "name": "_deposit_amounts" 24 | }, 25 | { 26 | "type": "uint256", 27 | "name": "_min_mint_amount" 28 | } 29 | ], 30 | "stateMutability": "nonpayable", 31 | "type": "function" 32 | }, 33 | { 34 | "name": "remove_liquidity", 35 | "outputs": [ 36 | { 37 | "type": "uint256[4]", 38 | "name": "" 39 | } 40 | ], 41 | "inputs": [ 42 | { 43 | "type": "address", 44 | "name": "_pool" 45 | }, 46 | { 47 | "type": "uint256", 48 | "name": "_burn_amount" 49 | }, 50 | { 51 | "type": "uint256[4]", 52 | "name": "_min_amounts" 53 | } 54 | ], 55 | "stateMutability": "nonpayable", 56 | "type": "function" 57 | }, 58 | { 59 | "name": "remove_liquidity_one_coin", 60 | "outputs": [ 61 | { 62 | "type": "uint256", 63 | "name": "" 64 | } 65 | ], 66 | "inputs": [ 67 | { 68 | "type": "address", 69 | "name": "_pool" 70 | }, 71 | { 72 | "type": "uint256", 73 | "name": "_burn_amount" 74 | }, 75 | { 76 | "type": "int128", 77 | "name": "i" 78 | }, 79 | { 80 | "type": "uint256", 81 | "name": "_min_amount" 82 | } 83 | ], 84 | "stateMutability": "nonpayable", 85 | "type": "function" 86 | }, 87 | { 88 | "name": "remove_liquidity_imbalance", 89 | "outputs": [ 90 | { 91 | "type": "uint256", 92 | "name": "" 93 | } 94 | ], 95 | "inputs": [ 96 | { 97 | "type": "address", 98 | "name": "_pool" 99 | }, 100 | { 101 | "type": "uint256[4]", 102 | "name": "_amounts" 103 | }, 104 | { 105 | "type": "uint256", 106 | "name": "_max_burn_amount" 107 | } 108 | ], 109 | "stateMutability": "nonpayable", 110 | "type": "function" 111 | }, 112 | { 113 | "name": "calc_withdraw_one_coin", 114 | "outputs": [ 115 | { 116 | "type": "uint256", 117 | "name": "" 118 | } 119 | ], 120 | "inputs": [ 121 | { 122 | "type": "address", 123 | "name": "_pool" 124 | }, 125 | { 126 | "type": "uint256", 127 | "name": "_token_amount" 128 | }, 129 | { 130 | "type": "int128", 131 | "name": "i" 132 | } 133 | ], 134 | "stateMutability": "view", 135 | "type": "function", 136 | "gas": "1650" 137 | }, 138 | { 139 | "name": "calc_token_amount", 140 | "outputs": [ 141 | { 142 | "type": "uint256", 143 | "name": "" 144 | } 145 | ], 146 | "inputs": [ 147 | { 148 | "type": "address", 149 | "name": "_pool" 150 | }, 151 | { 152 | "type": "uint256[4]", 153 | "name": "_amounts" 154 | }, 155 | { 156 | "type": "bool", 157 | "name": "_is_deposit" 158 | } 159 | ], 160 | "stateMutability": "view", 161 | "type": "function", 162 | "gas": "2717" 163 | } 164 | ] 165 | -------------------------------------------------------------------------------- /src/constants/abis/fraxusdc/meta_zap.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [], 6 | "outputs": [] 7 | }, 8 | { 9 | "stateMutability": "nonpayable", 10 | "type": "function", 11 | "name": "add_liquidity", 12 | "inputs": [ 13 | { 14 | "name": "_pool", 15 | "type": "address" 16 | }, 17 | { 18 | "name": "_deposit_amounts", 19 | "type": "uint256[3]" 20 | }, 21 | { 22 | "name": "_min_mint_amount", 23 | "type": "uint256" 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "", 29 | "type": "uint256" 30 | } 31 | ] 32 | }, 33 | { 34 | "stateMutability": "nonpayable", 35 | "type": "function", 36 | "name": "remove_liquidity", 37 | "inputs": [ 38 | { 39 | "name": "_pool", 40 | "type": "address" 41 | }, 42 | { 43 | "name": "_burn_amount", 44 | "type": "uint256" 45 | }, 46 | { 47 | "name": "_min_amounts", 48 | "type": "uint256[3]" 49 | } 50 | ], 51 | "outputs": [ 52 | { 53 | "name": "", 54 | "type": "uint256[3]" 55 | } 56 | ] 57 | }, 58 | { 59 | "stateMutability": "nonpayable", 60 | "type": "function", 61 | "name": "remove_liquidity_one_coin", 62 | "inputs": [ 63 | { 64 | "name": "_pool", 65 | "type": "address" 66 | }, 67 | { 68 | "name": "_burn_amount", 69 | "type": "uint256" 70 | }, 71 | { 72 | "name": "i", 73 | "type": "int128" 74 | }, 75 | { 76 | "name": "_min_amount", 77 | "type": "uint256" 78 | } 79 | ], 80 | "outputs": [ 81 | { 82 | "name": "", 83 | "type": "uint256" 84 | } 85 | ] 86 | }, 87 | { 88 | "stateMutability": "nonpayable", 89 | "type": "function", 90 | "name": "remove_liquidity_imbalance", 91 | "inputs": [ 92 | { 93 | "name": "_pool", 94 | "type": "address" 95 | }, 96 | { 97 | "name": "_amounts", 98 | "type": "uint256[3]" 99 | }, 100 | { 101 | "name": "_max_burn_amount", 102 | "type": "uint256" 103 | } 104 | ], 105 | "outputs": [ 106 | { 107 | "name": "", 108 | "type": "uint256" 109 | } 110 | ] 111 | }, 112 | { 113 | "stateMutability": "view", 114 | "type": "function", 115 | "name": "calc_withdraw_one_coin", 116 | "inputs": [ 117 | { 118 | "name": "_pool", 119 | "type": "address" 120 | }, 121 | { 122 | "name": "_token_amount", 123 | "type": "uint256" 124 | }, 125 | { 126 | "name": "i", 127 | "type": "int128" 128 | } 129 | ], 130 | "outputs": [ 131 | { 132 | "name": "", 133 | "type": "uint256" 134 | } 135 | ], 136 | "gas": "5753" 137 | }, 138 | { 139 | "stateMutability": "view", 140 | "type": "function", 141 | "name": "calc_token_amount", 142 | "inputs": [ 143 | { 144 | "name": "_pool", 145 | "type": "address" 146 | }, 147 | { 148 | "name": "_amounts", 149 | "type": "uint256[3]" 150 | }, 151 | { 152 | "name": "_is_deposit", 153 | "type": "bool" 154 | } 155 | ], 156 | "outputs": [ 157 | { 158 | "name": "", 159 | "type": "uint256" 160 | } 161 | ], 162 | "gas": "6289" 163 | } 164 | ] -------------------------------------------------------------------------------- /src/constants/abis/fusdt/zap.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [ 6 | { 7 | "name": "_pool", 8 | "type": "address" 9 | }, 10 | { 11 | "name": "_base_pool", 12 | "type": "address" 13 | } 14 | ], 15 | "outputs": [] 16 | }, 17 | { 18 | "stateMutability": "nonpayable", 19 | "type": "function", 20 | "name": "add_liquidity", 21 | "inputs": [ 22 | { 23 | "name": "_amounts", 24 | "type": "uint256[3]" 25 | }, 26 | { 27 | "name": "_min_mint_amount", 28 | "type": "uint256" 29 | } 30 | ], 31 | "outputs": [ 32 | { 33 | "name": "", 34 | "type": "uint256" 35 | } 36 | ], 37 | "gas": "25605" 38 | }, 39 | { 40 | "stateMutability": "nonpayable", 41 | "type": "function", 42 | "name": "remove_liquidity", 43 | "inputs": [ 44 | { 45 | "name": "_amount", 46 | "type": "uint256" 47 | }, 48 | { 49 | "name": "_min_amounts", 50 | "type": "uint256[3]" 51 | } 52 | ], 53 | "outputs": [ 54 | { 55 | "name": "", 56 | "type": "uint256[3]" 57 | } 58 | ], 59 | "gas": "26803" 60 | }, 61 | { 62 | "stateMutability": "nonpayable", 63 | "type": "function", 64 | "name": "remove_liquidity_one_coin", 65 | "inputs": [ 66 | { 67 | "name": "_token_amount", 68 | "type": "uint256" 69 | }, 70 | { 71 | "name": "i", 72 | "type": "int128" 73 | }, 74 | { 75 | "name": "_min_amount", 76 | "type": "uint256" 77 | } 78 | ], 79 | "outputs": [ 80 | { 81 | "name": "", 82 | "type": "uint256" 83 | } 84 | ], 85 | "gas": "14494" 86 | }, 87 | { 88 | "stateMutability": "nonpayable", 89 | "type": "function", 90 | "name": "remove_liquidity_imbalance", 91 | "inputs": [ 92 | { 93 | "name": "_amounts", 94 | "type": "uint256[3]" 95 | }, 96 | { 97 | "name": "_max_burn_amount", 98 | "type": "uint256" 99 | } 100 | ], 101 | "outputs": [ 102 | { 103 | "name": "", 104 | "type": "uint256" 105 | } 106 | ], 107 | "gas": "32024" 108 | }, 109 | { 110 | "stateMutability": "view", 111 | "type": "function", 112 | "name": "calc_withdraw_one_coin", 113 | "inputs": [ 114 | { 115 | "name": "_token_amount", 116 | "type": "uint256" 117 | }, 118 | { 119 | "name": "i", 120 | "type": "int128" 121 | } 122 | ], 123 | "outputs": [ 124 | { 125 | "name": "", 126 | "type": "uint256" 127 | } 128 | ], 129 | "gas": "3174" 130 | }, 131 | { 132 | "stateMutability": "view", 133 | "type": "function", 134 | "name": "calc_token_amount", 135 | "inputs": [ 136 | { 137 | "name": "_amounts", 138 | "type": "uint256[3]" 139 | }, 140 | { 141 | "name": "_is_deposit", 142 | "type": "bool" 143 | } 144 | ], 145 | "outputs": [ 146 | { 147 | "name": "", 148 | "type": "uint256" 149 | } 150 | ], 151 | "gas": "3998" 152 | }, 153 | { 154 | "stateMutability": "view", 155 | "type": "function", 156 | "name": "pool", 157 | "inputs": [], 158 | "outputs": [ 159 | { 160 | "name": "", 161 | "type": "address" 162 | } 163 | ], 164 | "gas": "1268" 165 | }, 166 | { 167 | "stateMutability": "view", 168 | "type": "function", 169 | "name": "base_pool", 170 | "inputs": [], 171 | "outputs": [ 172 | { 173 | "name": "", 174 | "type": "address" 175 | } 176 | ], 177 | "gas": "1298" 178 | }, 179 | { 180 | "stateMutability": "view", 181 | "type": "function", 182 | "name": "coins", 183 | "inputs": [ 184 | { 185 | "name": "arg0", 186 | "type": "uint256" 187 | } 188 | ], 189 | "outputs": [ 190 | { 191 | "name": "", 192 | "type": "address" 193 | } 194 | ], 195 | "gas": "1437" 196 | }, 197 | { 198 | "stateMutability": "view", 199 | "type": "function", 200 | "name": "base_coins", 201 | "inputs": [ 202 | { 203 | "name": "arg0", 204 | "type": "uint256" 205 | } 206 | ], 207 | "outputs": [ 208 | { 209 | "name": "", 210 | "type": "address" 211 | } 212 | ], 213 | "gas": "1467" 214 | } 215 | ] -------------------------------------------------------------------------------- /src/constants/abis/gas_oracle_optimism.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"gasPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"getL1Fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"getL1GasUsed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l1BaseFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overhead","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scalar","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}] -------------------------------------------------------------------------------- /src/constants/abis/gas_oracle_optimism_blob.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "DECIMALS", 5 | "outputs": [ 6 | { 7 | "internalType": "uint256", 8 | "name": "", 9 | "type": "uint256" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [], 17 | "name": "baseFee", 18 | "outputs": [ 19 | { 20 | "internalType": "uint256", 21 | "name": "", 22 | "type": "uint256" 23 | } 24 | ], 25 | "stateMutability": "view", 26 | "type": "function" 27 | }, 28 | { 29 | "inputs": [], 30 | "name": "baseFeeScalar", 31 | "outputs": [ 32 | { 33 | "internalType": "uint32", 34 | "name": "", 35 | "type": "uint32" 36 | } 37 | ], 38 | "stateMutability": "view", 39 | "type": "function" 40 | }, 41 | { 42 | "inputs": [], 43 | "name": "blobBaseFee", 44 | "outputs": [ 45 | { 46 | "internalType": "uint256", 47 | "name": "", 48 | "type": "uint256" 49 | } 50 | ], 51 | "stateMutability": "view", 52 | "type": "function" 53 | }, 54 | { 55 | "inputs": [], 56 | "name": "blobBaseFeeScalar", 57 | "outputs": [ 58 | { 59 | "internalType": "uint32", 60 | "name": "", 61 | "type": "uint32" 62 | } 63 | ], 64 | "stateMutability": "view", 65 | "type": "function" 66 | }, 67 | { 68 | "inputs": [], 69 | "name": "decimals", 70 | "outputs": [ 71 | { 72 | "internalType": "uint256", 73 | "name": "", 74 | "type": "uint256" 75 | } 76 | ], 77 | "stateMutability": "pure", 78 | "type": "function" 79 | }, 80 | { 81 | "inputs": [], 82 | "name": "gasPrice", 83 | "outputs": [ 84 | { 85 | "internalType": "uint256", 86 | "name": "", 87 | "type": "uint256" 88 | } 89 | ], 90 | "stateMutability": "view", 91 | "type": "function" 92 | }, 93 | { 94 | "inputs": [ 95 | { 96 | "internalType": "bytes", 97 | "name": "_data", 98 | "type": "bytes" 99 | } 100 | ], 101 | "name": "getL1Fee", 102 | "outputs": [ 103 | { 104 | "internalType": "uint256", 105 | "name": "", 106 | "type": "uint256" 107 | } 108 | ], 109 | "stateMutability": "view", 110 | "type": "function" 111 | }, 112 | { 113 | "inputs": [ 114 | { 115 | "internalType": "bytes", 116 | "name": "_data", 117 | "type": "bytes" 118 | } 119 | ], 120 | "name": "getL1GasUsed", 121 | "outputs": [ 122 | { 123 | "internalType": "uint256", 124 | "name": "", 125 | "type": "uint256" 126 | } 127 | ], 128 | "stateMutability": "view", 129 | "type": "function" 130 | }, 131 | { 132 | "inputs": [], 133 | "name": "isEcotone", 134 | "outputs": [ 135 | { 136 | "internalType": "bool", 137 | "name": "", 138 | "type": "bool" 139 | } 140 | ], 141 | "stateMutability": "view", 142 | "type": "function" 143 | }, 144 | { 145 | "inputs": [], 146 | "name": "l1BaseFee", 147 | "outputs": [ 148 | { 149 | "internalType": "uint256", 150 | "name": "", 151 | "type": "uint256" 152 | } 153 | ], 154 | "stateMutability": "view", 155 | "type": "function" 156 | }, 157 | { 158 | "inputs": [], 159 | "name": "overhead", 160 | "outputs": [ 161 | { 162 | "internalType": "uint256", 163 | "name": "", 164 | "type": "uint256" 165 | } 166 | ], 167 | "stateMutability": "view", 168 | "type": "function" 169 | }, 170 | { 171 | "inputs": [], 172 | "name": "scalar", 173 | "outputs": [ 174 | { 175 | "internalType": "uint256", 176 | "name": "", 177 | "type": "uint256" 178 | } 179 | ], 180 | "stateMutability": "view", 181 | "type": "function" 182 | }, 183 | { 184 | "inputs": [], 185 | "name": "setEcotone", 186 | "outputs": [], 187 | "stateMutability": "nonpayable", 188 | "type": "function" 189 | }, 190 | { 191 | "inputs": [], 192 | "name": "version", 193 | "outputs": [ 194 | { 195 | "internalType": "string", 196 | "name": "", 197 | "type": "string" 198 | } 199 | ], 200 | "stateMutability": "view", 201 | "type": "function" 202 | } 203 | ] -------------------------------------------------------------------------------- /src/constants/abis/iearn/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputs": [], 4 | "inputs": [ 5 | { 6 | "type": "address[4]", 7 | "name": "_coins" 8 | }, 9 | { 10 | "type": "address[4]", 11 | "name": "_underlying_coins" 12 | }, 13 | { 14 | "type": "address", 15 | "name": "_curve" 16 | }, 17 | { 18 | "type": "address", 19 | "name": "_token" 20 | } 21 | ], 22 | "constant": false, 23 | "payable": false, 24 | "type": "constructor" 25 | }, 26 | { 27 | "name": "add_liquidity", 28 | "outputs": [], 29 | "inputs": [ 30 | { 31 | "type": "uint256[4]", 32 | "name": "uamounts" 33 | }, 34 | { 35 | "type": "uint256", 36 | "name": "min_mint_amount" 37 | } 38 | ], 39 | "constant": false, 40 | "payable": false, 41 | "type": "function", 42 | "gas": "1890987" 43 | }, 44 | { 45 | "name": "remove_liquidity", 46 | "outputs": [], 47 | "inputs": [ 48 | { 49 | "type": "uint256", 50 | "name": "_amount" 51 | }, 52 | { 53 | "type": "uint256[4]", 54 | "name": "min_uamounts" 55 | } 56 | ], 57 | "constant": false, 58 | "payable": false, 59 | "type": "function", 60 | "gas": "1040945" 61 | }, 62 | { 63 | "name": "remove_liquidity_imbalance", 64 | "outputs": [], 65 | "inputs": [ 66 | { 67 | "type": "uint256[4]", 68 | "name": "uamounts" 69 | }, 70 | { 71 | "type": "uint256", 72 | "name": "max_burn_amount" 73 | } 74 | ], 75 | "constant": false, 76 | "payable": false, 77 | "type": "function", 78 | "gas": "1708651" 79 | }, 80 | { 81 | "name": "calc_withdraw_one_coin", 82 | "outputs": [ 83 | { 84 | "type": "uint256", 85 | "name": "" 86 | } 87 | ], 88 | "inputs": [ 89 | { 90 | "type": "uint256", 91 | "name": "_token_amount" 92 | }, 93 | { 94 | "type": "int128", 95 | "name": "i" 96 | } 97 | ], 98 | "stateMutability": "view", 99 | "type": "function", 100 | "gas": "3881601" 101 | }, 102 | { 103 | "name": "remove_liquidity_one_coin", 104 | "outputs": [], 105 | "inputs": [ 106 | { 107 | "type": "uint256", 108 | "name": "_token_amount" 109 | }, 110 | { 111 | "type": "int128", 112 | "name": "i" 113 | }, 114 | { 115 | "type": "uint256", 116 | "name": "min_uamount" 117 | } 118 | ], 119 | "constant": false, 120 | "payable": false, 121 | "type": "function" 122 | }, 123 | { 124 | "name": "withdraw_donated_dust", 125 | "outputs": [], 126 | "inputs": [], 127 | "constant": false, 128 | "payable": false, 129 | "type": "function", 130 | "gas": "63973" 131 | }, 132 | { 133 | "name": "coins", 134 | "outputs": [ 135 | { 136 | "type": "address", 137 | "name": "" 138 | } 139 | ], 140 | "inputs": [ 141 | { 142 | "type": "int128", 143 | "name": "arg0" 144 | } 145 | ], 146 | "stateMutability": "view", 147 | "type": "function", 148 | "gas": "1680" 149 | }, 150 | { 151 | "name": "underlying_coins", 152 | "outputs": [ 153 | { 154 | "type": "address", 155 | "name": "" 156 | } 157 | ], 158 | "inputs": [ 159 | { 160 | "type": "int128", 161 | "name": "arg0" 162 | } 163 | ], 164 | "stateMutability": "view", 165 | "type": "function", 166 | "gas": "1710" 167 | }, 168 | { 169 | "name": "curve", 170 | "outputs": [ 171 | { 172 | "type": "address", 173 | "name": "" 174 | } 175 | ], 176 | "inputs": [], 177 | "stateMutability": "view", 178 | "type": "function", 179 | "gas": "1541" 180 | }, 181 | { 182 | "name": "token", 183 | "outputs": [ 184 | { 185 | "type": "address", 186 | "name": "" 187 | } 188 | ], 189 | "inputs": [], 190 | "stateMutability": "view", 191 | "type": "function", 192 | "gas": "1571" 193 | } 194 | ] 195 | -------------------------------------------------------------------------------- /src/constants/abis/minter_mainnet.json: -------------------------------------------------------------------------------- 1 | [{"name":"Minted","inputs":[{"type":"address","name":"recipient","indexed":true},{"type":"address","name":"gauge","indexed":false},{"type":"uint256","name":"minted","indexed":false}],"anonymous":false,"type":"event"},{"outputs":[],"inputs":[{"type":"address","name":"_token"},{"type":"address","name":"_controller"}],"stateMutability":"nonpayable","type":"constructor"},{"name":"mint","outputs":[],"inputs":[{"type":"address","name":"gauge_addr"}],"stateMutability":"nonpayable","type":"function","gas":100038},{"name":"mint_many","outputs":[],"inputs":[{"type":"address[8]","name":"gauge_addrs"}],"stateMutability":"nonpayable","type":"function","gas":408502},{"name":"mint_for","outputs":[],"inputs":[{"type":"address","name":"gauge_addr"},{"type":"address","name":"_for"}],"stateMutability":"nonpayable","type":"function","gas":101219},{"name":"toggle_approve_mint","outputs":[],"inputs":[{"type":"address","name":"minting_user"}],"stateMutability":"nonpayable","type":"function","gas":36726},{"name":"token","outputs":[{"type":"address","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1301},{"name":"controller","outputs":[{"type":"address","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1331},{"name":"minted","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"arg0"},{"type":"address","name":"arg1"}],"stateMutability":"view","type":"function","gas":1669},{"name":"allowed_to_mint_for","outputs":[{"type":"bool","name":""}],"inputs":[{"type":"address","name":"arg0"},{"type":"address","name":"arg1"}],"stateMutability":"view","type":"function","gas":1699}] -------------------------------------------------------------------------------- /src/constants/abis/pax/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputs":[], 4 | "inputs":[ 5 | { 6 | "type":"address[4]", 7 | "name":"_coins" 8 | }, 9 | { 10 | "type":"address[4]", 11 | "name":"_underlying_coins" 12 | }, 13 | { 14 | "type":"address", 15 | "name":"_curve" 16 | }, 17 | { 18 | "type":"address", 19 | "name":"_token" 20 | } 21 | ], 22 | "constant":false, 23 | "payable":false, 24 | "type":"constructor" 25 | }, 26 | { 27 | "name":"add_liquidity", 28 | "outputs":[], 29 | "inputs":[ 30 | { 31 | "type":"uint256[4]", 32 | "name":"uamounts" 33 | }, 34 | { 35 | "type":"uint256", 36 | "name":"min_mint_amount" 37 | } 38 | ], 39 | "constant":false, 40 | "payable":false, 41 | "type":"function", 42 | "gas":"1952570" 43 | }, 44 | { 45 | "name":"remove_liquidity", 46 | "outputs":[], 47 | "inputs":[ 48 | { 49 | "type":"uint256", 50 | "name":"_amount" 51 | }, 52 | { 53 | "type":"uint256[4]", 54 | "name":"min_uamounts" 55 | } 56 | ], 57 | "constant":false, 58 | "payable":false, 59 | "type":"function", 60 | "gas":"865961" 61 | }, 62 | { 63 | "name":"remove_liquidity_imbalance", 64 | "outputs":[], 65 | "inputs":[ 66 | { 67 | "type":"uint256[4]", 68 | "name":"uamounts" 69 | }, 70 | { 71 | "type":"uint256", 72 | "name":"max_burn_amount" 73 | } 74 | ], 75 | "constant":false, 76 | "payable":false, 77 | "type":"function", 78 | "gas":"1403892" 79 | }, 80 | { 81 | "name":"calc_withdraw_one_coin", 82 | "outputs":[ 83 | { 84 | "type":"uint256", 85 | "name":"" 86 | } 87 | ], 88 | "inputs":[ 89 | { 90 | "type":"uint256", 91 | "name":"_token_amount" 92 | }, 93 | { 94 | "type":"int128", 95 | "name":"i" 96 | } 97 | ], 98 | "stateMutability": "view", 99 | "type":"function", 100 | "gas":"3881771" 101 | }, 102 | { 103 | "name":"remove_liquidity_one_coin", 104 | "outputs":[], 105 | "inputs":[ 106 | { 107 | "type":"uint256", 108 | "name":"_token_amount" 109 | }, 110 | { 111 | "type":"int128", 112 | "name":"i" 113 | }, 114 | { 115 | "type":"uint256", 116 | "name":"min_uamount" 117 | } 118 | ], 119 | "constant":false, 120 | "payable":false, 121 | "type":"function" 122 | }, 123 | { 124 | "name":"withdraw_donated_dust", 125 | "outputs":[], 126 | "inputs":[], 127 | "constant":false, 128 | "payable":false, 129 | "type":"function", 130 | "gas":"63973" 131 | }, 132 | { 133 | "name":"coins", 134 | "outputs":[ 135 | { 136 | "type":"address", 137 | "name":"" 138 | } 139 | ], 140 | "inputs":[ 141 | { 142 | "type":"int128", 143 | "name":"arg0" 144 | } 145 | ], 146 | "stateMutability": "view", 147 | "type":"function", 148 | "gas":"1680" 149 | }, 150 | { 151 | "name":"underlying_coins", 152 | "outputs":[ 153 | { 154 | "type":"address", 155 | "name":"" 156 | } 157 | ], 158 | "inputs":[ 159 | { 160 | "type":"int128", 161 | "name":"arg0" 162 | } 163 | ], 164 | "stateMutability": "view", 165 | "type":"function", 166 | "gas":"1710" 167 | }, 168 | { 169 | "name":"curve", 170 | "outputs":[ 171 | { 172 | "type":"address", 173 | "name":"" 174 | } 175 | ], 176 | "inputs":[], 177 | "stateMutability": "view", 178 | "type":"function", 179 | "gas":"1541" 180 | }, 181 | { 182 | "name":"token", 183 | "outputs":[ 184 | { 185 | "type":"address", 186 | "name":"" 187 | } 188 | ], 189 | "inputs":[], 190 | "stateMutability": "view", 191 | "type":"function", 192 | "gas":"1571" 193 | } 194 | ] 195 | -------------------------------------------------------------------------------- /src/constants/abis/rai/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [ 6 | { 7 | "name": "_pool", 8 | "type": "address" 9 | }, 10 | { 11 | "name": "_token", 12 | "type": "address" 13 | } 14 | ], 15 | "outputs": [] 16 | }, 17 | { 18 | "stateMutability": "nonpayable", 19 | "type": "function", 20 | "name": "add_liquidity", 21 | "inputs": [ 22 | { 23 | "name": "_amounts", 24 | "type": "uint256[4]" 25 | }, 26 | { 27 | "name": "_min_mint_amount", 28 | "type": "uint256" 29 | } 30 | ], 31 | "outputs": [ 32 | { 33 | "name": "", 34 | "type": "uint256" 35 | } 36 | ], 37 | "gas": "86660" 38 | }, 39 | { 40 | "stateMutability": "nonpayable", 41 | "type": "function", 42 | "name": "remove_liquidity", 43 | "inputs": [ 44 | { 45 | "name": "_amount", 46 | "type": "uint256" 47 | }, 48 | { 49 | "name": "_min_amounts", 50 | "type": "uint256[4]" 51 | } 52 | ], 53 | "outputs": [ 54 | { 55 | "name": "", 56 | "type": "uint256[4]" 57 | } 58 | ], 59 | "gas": "82960" 60 | }, 61 | { 62 | "stateMutability": "nonpayable", 63 | "type": "function", 64 | "name": "remove_liquidity_one_coin", 65 | "inputs": [ 66 | { 67 | "name": "_token_amount", 68 | "type": "uint256" 69 | }, 70 | { 71 | "name": "i", 72 | "type": "int128" 73 | }, 74 | { 75 | "name": "_min_amount", 76 | "type": "uint256" 77 | } 78 | ], 79 | "outputs": [ 80 | { 81 | "name": "", 82 | "type": "uint256" 83 | } 84 | ], 85 | "gas": "38114" 86 | }, 87 | { 88 | "stateMutability": "nonpayable", 89 | "type": "function", 90 | "name": "remove_liquidity_imbalance", 91 | "inputs": [ 92 | { 93 | "name": "_amounts", 94 | "type": "uint256[4]" 95 | }, 96 | { 97 | "name": "_max_burn_amount", 98 | "type": "uint256" 99 | } 100 | ], 101 | "outputs": [ 102 | { 103 | "name": "", 104 | "type": "uint256" 105 | } 106 | ], 107 | "gas": "88693" 108 | }, 109 | { 110 | "stateMutability": "view", 111 | "type": "function", 112 | "name": "calc_withdraw_one_coin", 113 | "inputs": [ 114 | { 115 | "name": "_token_amount", 116 | "type": "uint256" 117 | }, 118 | { 119 | "name": "i", 120 | "type": "int128" 121 | } 122 | ], 123 | "outputs": [ 124 | { 125 | "name": "", 126 | "type": "uint256" 127 | } 128 | ], 129 | "gas": "9894" 130 | }, 131 | { 132 | "stateMutability": "view", 133 | "type": "function", 134 | "name": "calc_token_amount", 135 | "inputs": [ 136 | { 137 | "name": "_amounts", 138 | "type": "uint256[4]" 139 | }, 140 | { 141 | "name": "_is_deposit", 142 | "type": "bool" 143 | } 144 | ], 145 | "outputs": [ 146 | { 147 | "name": "", 148 | "type": "uint256" 149 | } 150 | ], 151 | "gas": "10963" 152 | }, 153 | { 154 | "stateMutability": "view", 155 | "type": "function", 156 | "name": "pool", 157 | "inputs": [], 158 | "outputs": [ 159 | { 160 | "name": "", 161 | "type": "address" 162 | } 163 | ], 164 | "gas": "2568" 165 | }, 166 | { 167 | "stateMutability": "view", 168 | "type": "function", 169 | "name": "token", 170 | "inputs": [], 171 | "outputs": [ 172 | { 173 | "name": "", 174 | "type": "address" 175 | } 176 | ], 177 | "gas": "2598" 178 | }, 179 | { 180 | "stateMutability": "view", 181 | "type": "function", 182 | "name": "base_pool", 183 | "inputs": [], 184 | "outputs": [ 185 | { 186 | "name": "", 187 | "type": "address" 188 | } 189 | ], 190 | "gas": "2628" 191 | }, 192 | { 193 | "stateMutability": "view", 194 | "type": "function", 195 | "name": "coins", 196 | "inputs": [ 197 | { 198 | "name": "arg0", 199 | "type": "uint256" 200 | } 201 | ], 202 | "outputs": [ 203 | { 204 | "name": "", 205 | "type": "address" 206 | } 207 | ], 208 | "gas": "2767" 209 | }, 210 | { 211 | "stateMutability": "view", 212 | "type": "function", 213 | "name": "base_coins", 214 | "inputs": [ 215 | { 216 | "name": "arg0", 217 | "type": "uint256" 218 | } 219 | ], 220 | "outputs": [ 221 | { 222 | "name": "", 223 | "type": "address" 224 | } 225 | ], 226 | "gas": "2797" 227 | } 228 | ] -------------------------------------------------------------------------------- /src/constants/abis/ren/meta_zap.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [ 6 | { 7 | "name": "_base_pool", 8 | "type": "address" 9 | }, 10 | { 11 | "name": "_base_token", 12 | "type": "address" 13 | } 14 | ], 15 | "outputs": [] 16 | }, 17 | { 18 | "stateMutability": "nonpayable", 19 | "type": "function", 20 | "name": "add_liquidity", 21 | "inputs": [ 22 | { 23 | "name": "_pool", 24 | "type": "address" 25 | }, 26 | { 27 | "name": "_deposit_amounts", 28 | "type": "uint256[3]" 29 | }, 30 | { 31 | "name": "_min_mint_amount", 32 | "type": "uint256" 33 | } 34 | ], 35 | "outputs": [ 36 | { 37 | "name": "", 38 | "type": "uint256" 39 | } 40 | ] 41 | }, 42 | { 43 | "stateMutability": "nonpayable", 44 | "type": "function", 45 | "name": "remove_liquidity", 46 | "inputs": [ 47 | { 48 | "name": "_pool", 49 | "type": "address" 50 | }, 51 | { 52 | "name": "_burn_amount", 53 | "type": "uint256" 54 | }, 55 | { 56 | "name": "_min_amounts", 57 | "type": "uint256[3]" 58 | } 59 | ], 60 | "outputs": [ 61 | { 62 | "name": "", 63 | "type": "uint256[3]" 64 | } 65 | ] 66 | }, 67 | { 68 | "stateMutability": "nonpayable", 69 | "type": "function", 70 | "name": "remove_liquidity_one_coin", 71 | "inputs": [ 72 | { 73 | "name": "_pool", 74 | "type": "address" 75 | }, 76 | { 77 | "name": "_burn_amount", 78 | "type": "uint256" 79 | }, 80 | { 81 | "name": "i", 82 | "type": "int128" 83 | }, 84 | { 85 | "name": "_min_amount", 86 | "type": "uint256" 87 | } 88 | ], 89 | "outputs": [ 90 | { 91 | "name": "", 92 | "type": "uint256" 93 | } 94 | ] 95 | }, 96 | { 97 | "stateMutability": "nonpayable", 98 | "type": "function", 99 | "name": "remove_liquidity_imbalance", 100 | "inputs": [ 101 | { 102 | "name": "_pool", 103 | "type": "address" 104 | }, 105 | { 106 | "name": "_amounts", 107 | "type": "uint256[3]" 108 | }, 109 | { 110 | "name": "_max_burn_amount", 111 | "type": "uint256" 112 | } 113 | ], 114 | "outputs": [ 115 | { 116 | "name": "", 117 | "type": "uint256" 118 | } 119 | ] 120 | }, 121 | { 122 | "stateMutability": "view", 123 | "type": "function", 124 | "name": "calc_withdraw_one_coin", 125 | "inputs": [ 126 | { 127 | "name": "_pool", 128 | "type": "address" 129 | }, 130 | { 131 | "name": "_token_amount", 132 | "type": "uint256" 133 | }, 134 | { 135 | "name": "i", 136 | "type": "int128" 137 | } 138 | ], 139 | "outputs": [ 140 | { 141 | "name": "", 142 | "type": "uint256" 143 | } 144 | ] 145 | }, 146 | { 147 | "stateMutability": "view", 148 | "type": "function", 149 | "name": "calc_token_amount", 150 | "inputs": [ 151 | { 152 | "name": "_pool", 153 | "type": "address" 154 | }, 155 | { 156 | "name": "_amounts", 157 | "type": "uint256[3]" 158 | }, 159 | { 160 | "name": "_is_deposit", 161 | "type": "bool" 162 | } 163 | ], 164 | "outputs": [ 165 | { 166 | "name": "", 167 | "type": "uint256" 168 | } 169 | ] 170 | }, 171 | { 172 | "stateMutability": "view", 173 | "type": "function", 174 | "name": "BASE_POOL", 175 | "inputs": [], 176 | "outputs": [ 177 | { 178 | "name": "", 179 | "type": "address" 180 | } 181 | ] 182 | }, 183 | { 184 | "stateMutability": "view", 185 | "type": "function", 186 | "name": "BASE_LP_TOKEN", 187 | "inputs": [], 188 | "outputs": [ 189 | { 190 | "name": "", 191 | "type": "address" 192 | } 193 | ] 194 | } 195 | ] -------------------------------------------------------------------------------- /src/constants/abis/router-ng-pools-only.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Exchange", 4 | "inputs": [ 5 | { 6 | "name": "sender", 7 | "type": "address", 8 | "indexed": true 9 | }, 10 | { 11 | "name": "receiver", 12 | "type": "address", 13 | "indexed": true 14 | }, 15 | { 16 | "name": "route", 17 | "type": "address[11]", 18 | "indexed": false 19 | }, 20 | { 21 | "name": "swap_params", 22 | "type": "uint256[4][5]", 23 | "indexed": false 24 | }, 25 | { 26 | "name": "in_amount", 27 | "type": "uint256", 28 | "indexed": false 29 | }, 30 | { 31 | "name": "out_amount", 32 | "type": "uint256", 33 | "indexed": false 34 | } 35 | ], 36 | "anonymous": false, 37 | "type": "event" 38 | }, 39 | { 40 | "stateMutability": "payable", 41 | "type": "fallback" 42 | }, 43 | { 44 | "stateMutability": "nonpayable", 45 | "type": "constructor", 46 | "inputs": [ 47 | { 48 | "name": "_weth", 49 | "type": "address" 50 | } 51 | ], 52 | "outputs": [] 53 | }, 54 | { 55 | "stateMutability": "payable", 56 | "type": "function", 57 | "name": "exchange", 58 | "inputs": [ 59 | { 60 | "name": "_route", 61 | "type": "address[11]" 62 | }, 63 | { 64 | "name": "_swap_params", 65 | "type": "uint256[4][5]" 66 | }, 67 | { 68 | "name": "_amount", 69 | "type": "uint256" 70 | }, 71 | { 72 | "name": "_min_dy", 73 | "type": "uint256" 74 | } 75 | ], 76 | "outputs": [ 77 | { 78 | "name": "", 79 | "type": "uint256" 80 | } 81 | ] 82 | }, 83 | { 84 | "stateMutability": "view", 85 | "type": "function", 86 | "name": "get_dy", 87 | "inputs": [ 88 | { 89 | "name": "_route", 90 | "type": "address[11]" 91 | }, 92 | { 93 | "name": "_swap_params", 94 | "type": "uint256[4][5]" 95 | }, 96 | { 97 | "name": "_amount", 98 | "type": "uint256" 99 | } 100 | ], 101 | "outputs": [ 102 | { 103 | "name": "", 104 | "type": "uint256" 105 | } 106 | ] 107 | }, 108 | { 109 | "stateMutability": "view", 110 | "type": "function", 111 | "name": "get_dx", 112 | "inputs": [ 113 | { 114 | "name": "_route", 115 | "type": "address[11]" 116 | }, 117 | { 118 | "name": "_swap_params", 119 | "type": "uint256[4][5]" 120 | }, 121 | { 122 | "name": "_out_amount", 123 | "type": "uint256" 124 | } 125 | ], 126 | "outputs": [ 127 | { 128 | "name": "", 129 | "type": "uint256" 130 | } 131 | ] 132 | }, 133 | { 134 | "stateMutability": "view", 135 | "type": "function", 136 | "name": "version", 137 | "inputs": [], 138 | "outputs": [ 139 | { 140 | "name": "", 141 | "type": "string" 142 | } 143 | ] 144 | } 145 | ] -------------------------------------------------------------------------------- /src/constants/abis/sbtc2/meta_zap.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "constructor", 5 | "inputs": [], 6 | "outputs": [] 7 | }, 8 | { 9 | "stateMutability": "nonpayable", 10 | "type": "function", 11 | "name": "add_liquidity", 12 | "inputs": [ 13 | { 14 | "name": "_pool", 15 | "type": "address" 16 | }, 17 | { 18 | "name": "_deposit_amounts", 19 | "type": "uint256[3]" 20 | }, 21 | { 22 | "name": "_min_mint_amount", 23 | "type": "uint256" 24 | } 25 | ], 26 | "outputs": [ 27 | { 28 | "name": "", 29 | "type": "uint256" 30 | } 31 | ] 32 | }, 33 | { 34 | "stateMutability": "nonpayable", 35 | "type": "function", 36 | "name": "remove_liquidity", 37 | "inputs": [ 38 | { 39 | "name": "_pool", 40 | "type": "address" 41 | }, 42 | { 43 | "name": "_burn_amount", 44 | "type": "uint256" 45 | }, 46 | { 47 | "name": "_min_amounts", 48 | "type": "uint256[3]" 49 | } 50 | ], 51 | "outputs": [ 52 | { 53 | "name": "", 54 | "type": "uint256[3]" 55 | } 56 | ] 57 | }, 58 | { 59 | "stateMutability": "nonpayable", 60 | "type": "function", 61 | "name": "remove_liquidity_one_coin", 62 | "inputs": [ 63 | { 64 | "name": "_pool", 65 | "type": "address" 66 | }, 67 | { 68 | "name": "_burn_amount", 69 | "type": "uint256" 70 | }, 71 | { 72 | "name": "i", 73 | "type": "int128" 74 | }, 75 | { 76 | "name": "_min_amount", 77 | "type": "uint256" 78 | } 79 | ], 80 | "outputs": [ 81 | { 82 | "name": "", 83 | "type": "uint256" 84 | } 85 | ] 86 | }, 87 | { 88 | "stateMutability": "nonpayable", 89 | "type": "function", 90 | "name": "remove_liquidity_imbalance", 91 | "inputs": [ 92 | { 93 | "name": "_pool", 94 | "type": "address" 95 | }, 96 | { 97 | "name": "_amounts", 98 | "type": "uint256[3]" 99 | }, 100 | { 101 | "name": "_max_burn_amount", 102 | "type": "uint256" 103 | } 104 | ], 105 | "outputs": [ 106 | { 107 | "name": "", 108 | "type": "uint256" 109 | } 110 | ] 111 | }, 112 | { 113 | "stateMutability": "view", 114 | "type": "function", 115 | "name": "calc_withdraw_one_coin", 116 | "inputs": [ 117 | { 118 | "name": "_pool", 119 | "type": "address" 120 | }, 121 | { 122 | "name": "_token_amount", 123 | "type": "uint256" 124 | }, 125 | { 126 | "name": "i", 127 | "type": "int128" 128 | } 129 | ], 130 | "outputs": [ 131 | { 132 | "name": "", 133 | "type": "uint256" 134 | } 135 | ], 136 | "gas": "5753" 137 | }, 138 | { 139 | "stateMutability": "view", 140 | "type": "function", 141 | "name": "calc_token_amount", 142 | "inputs": [ 143 | { 144 | "name": "_pool", 145 | "type": "address" 146 | }, 147 | { 148 | "name": "_amounts", 149 | "type": "uint256[3]" 150 | }, 151 | { 152 | "name": "_is_deposit", 153 | "type": "bool" 154 | } 155 | ], 156 | "outputs": [ 157 | { 158 | "name": "", 159 | "type": "uint256" 160 | } 161 | ], 162 | "gas": "6289" 163 | } 164 | ] -------------------------------------------------------------------------------- /src/constants/abis/stable-ng-base-pool-zap.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "view", 4 | "type": "function", 5 | "name": "calc_token_amount", 6 | "inputs": [ 7 | { 8 | "name": "_pool", 9 | "type": "address" 10 | }, 11 | { 12 | "name": "_amounts", 13 | "type": "uint256[]" 14 | }, 15 | { 16 | "name": "_is_deposit", 17 | "type": "bool" 18 | } 19 | ], 20 | "outputs": [ 21 | { 22 | "name": "", 23 | "type": "uint256" 24 | } 25 | ] 26 | }, 27 | { 28 | "stateMutability": "nonpayable", 29 | "type": "function", 30 | "name": "add_liquidity", 31 | "inputs": [ 32 | { 33 | "name": "_pool", 34 | "type": "address" 35 | }, 36 | { 37 | "name": "_deposit_amounts", 38 | "type": "uint256[]" 39 | }, 40 | { 41 | "name": "_min_mint_amount", 42 | "type": "uint256" 43 | } 44 | ], 45 | "outputs": [ 46 | { 47 | "name": "", 48 | "type": "uint256" 49 | } 50 | ] 51 | }, 52 | { 53 | "stateMutability": "view", 54 | "type": "function", 55 | "name": "calc_withdraw_one_coin", 56 | "inputs": [ 57 | { 58 | "name": "_pool", 59 | "type": "address" 60 | }, 61 | { 62 | "name": "_token_amount", 63 | "type": "uint256" 64 | }, 65 | { 66 | "name": "i", 67 | "type": "int128" 68 | } 69 | ], 70 | "outputs": [ 71 | { 72 | "name": "", 73 | "type": "uint256" 74 | } 75 | ] 76 | }, 77 | { 78 | "stateMutability": "nonpayable", 79 | "type": "function", 80 | "name": "remove_liquidity", 81 | "inputs": [ 82 | { 83 | "name": "_pool", 84 | "type": "address" 85 | }, 86 | { 87 | "name": "_burn_amount", 88 | "type": "uint256" 89 | }, 90 | { 91 | "name": "_min_amounts", 92 | "type": "uint256[]" 93 | } 94 | ], 95 | "outputs": [ 96 | { 97 | "name": "", 98 | "type": "uint256[]" 99 | } 100 | ] 101 | }, 102 | { 103 | "stateMutability": "nonpayable", 104 | "type": "function", 105 | "name": "remove_liquidity_one_coin", 106 | "inputs": [ 107 | { 108 | "name": "_pool", 109 | "type": "address" 110 | }, 111 | { 112 | "name": "_burn_amount", 113 | "type": "uint256" 114 | }, 115 | { 116 | "name": "i", 117 | "type": "int128" 118 | }, 119 | { 120 | "name": "_min_amount", 121 | "type": "uint256" 122 | } 123 | ], 124 | "outputs": [ 125 | { 126 | "name": "", 127 | "type": "uint256" 128 | } 129 | ] 130 | }, 131 | { 132 | "stateMutability": "nonpayable", 133 | "type": "function", 134 | "name": "remove_liquidity_imbalance", 135 | "inputs": [ 136 | { 137 | "name": "_pool", 138 | "type": "address" 139 | }, 140 | { 141 | "name": "_amounts", 142 | "type": "uint256[]" 143 | }, 144 | { 145 | "name": "_max_burn_amount", 146 | "type": "uint256" 147 | } 148 | ], 149 | "outputs": [ 150 | { 151 | "name": "", 152 | "type": "uint256" 153 | } 154 | ] 155 | } 156 | ] -------------------------------------------------------------------------------- /src/constants/abis/stable_calc.json: -------------------------------------------------------------------------------- 1 | [{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_use_int128","type":"address[20]"},{"name":"_pool_type_addresses","type":"address[20]"},{"name":"_pool_types","type":"uint8[20]"},{"name":"_use_rate","type":"bool[10][20]"},{"name":"_factory","type":"address"},{"name":"_eth_implementation","type":"address"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"calc_token_amount","inputs":[{"name":"pool","type":"address"},{"name":"token","type":"address"},{"name":"amounts","type":"uint256[10]"},{"name":"n_coins","type":"uint256"},{"name":"deposit","type":"bool"},{"name":"use_underlying","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"calc_token_amount_meta","inputs":[{"name":"pool","type":"address"},{"name":"token","type":"address"},{"name":"amounts","type":"uint256[10]"},{"name":"n_coins","type":"uint256"},{"name":"base_pool","type":"address"},{"name":"base_token","type":"address"},{"name":"deposit","type":"bool"},{"name":"use_underlying","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dx","inputs":[{"name":"pool","type":"address"},{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"dy","type":"uint256"},{"name":"n_coins","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dx_underlying","inputs":[{"name":"pool","type":"address"},{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"dy","type":"uint256"},{"name":"n_coins","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dx_meta","inputs":[{"name":"pool","type":"address"},{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"dy","type":"uint256"},{"name":"n_coins","type":"uint256"},{"name":"base_pool","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dx_meta_underlying","inputs":[{"name":"pool","type":"address"},{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"dy","type":"uint256"},{"name":"n_coins","type":"uint256"},{"name":"base_pool","type":"address"},{"name":"base_token","type":"address"}],"outputs":[{"name":"","type":"uint256"}]}] -------------------------------------------------------------------------------- /src/constants/abis/susdv2/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputs":[], 4 | "inputs":[ 5 | { 6 | "type":"address[4]", 7 | "name":"_coins" 8 | }, 9 | { 10 | "type":"address[4]", 11 | "name":"_underlying_coins" 12 | }, 13 | { 14 | "type":"address", 15 | "name":"_curve" 16 | }, 17 | { 18 | "type":"address", 19 | "name":"_token" 20 | } 21 | ], 22 | "constant":false, 23 | "payable":false, 24 | "type":"constructor" 25 | }, 26 | { 27 | "name":"add_liquidity", 28 | "outputs":[], 29 | "inputs":[ 30 | { 31 | "type":"uint256[4]", 32 | "name":"uamounts" 33 | }, 34 | { 35 | "type":"uint256", 36 | "name":"min_mint_amount" 37 | } 38 | ], 39 | "constant":false, 40 | "payable":false, 41 | "type":"function", 42 | "gas":"166032" 43 | }, 44 | { 45 | "name":"remove_liquidity", 46 | "outputs":[], 47 | "inputs":[ 48 | { 49 | "type":"uint256", 50 | "name":"_amount" 51 | }, 52 | { 53 | "type":"uint256[4]", 54 | "name":"min_uamounts" 55 | } 56 | ], 57 | "constant":false, 58 | "payable":false, 59 | "type":"function", 60 | "gas":"101481" 61 | }, 62 | { 63 | "name":"remove_liquidity_imbalance", 64 | "outputs":[], 65 | "inputs":[ 66 | { 67 | "type":"uint256[4]", 68 | "name":"uamounts" 69 | }, 70 | { 71 | "type":"uint256", 72 | "name":"max_burn_amount" 73 | } 74 | ], 75 | "constant":false, 76 | "payable":false, 77 | "type":"function", 78 | "gas":"125088" 79 | }, 80 | { 81 | "name":"calc_withdraw_one_coin", 82 | "outputs":[ 83 | { 84 | "type":"uint256", 85 | "name":"" 86 | } 87 | ], 88 | "inputs":[ 89 | { 90 | "type":"uint256", 91 | "name":"_token_amount" 92 | }, 93 | { 94 | "type":"int128", 95 | "name":"i" 96 | } 97 | ], 98 | "stateMutability": "view", 99 | "type":"function", 100 | "gas":"3881771" 101 | }, 102 | { 103 | "name":"remove_liquidity_one_coin", 104 | "outputs":[], 105 | "inputs":[ 106 | { 107 | "type":"uint256", 108 | "name":"_token_amount" 109 | }, 110 | { 111 | "type":"int128", 112 | "name":"i" 113 | }, 114 | { 115 | "type":"uint256", 116 | "name":"min_uamount" 117 | } 118 | ], 119 | "constant":false, 120 | "payable":false, 121 | "type":"function" 122 | }, 123 | { 124 | "name":"withdraw_donated_dust", 125 | "outputs":[], 126 | "inputs":[], 127 | "constant":false, 128 | "payable":false, 129 | "type":"function", 130 | "gas":"63973" 131 | }, 132 | { 133 | "name":"coins", 134 | "outputs":[ 135 | { 136 | "type":"address", 137 | "name":"" 138 | } 139 | ], 140 | "inputs":[ 141 | { 142 | "type":"int128", 143 | "name":"arg0" 144 | } 145 | ], 146 | "stateMutability": "view", 147 | "type":"function", 148 | "gas":"1680" 149 | }, 150 | { 151 | "name":"underlying_coins", 152 | "outputs":[ 153 | { 154 | "type":"address", 155 | "name":"" 156 | } 157 | ], 158 | "inputs":[ 159 | { 160 | "type":"int128", 161 | "name":"arg0" 162 | } 163 | ], 164 | "stateMutability": "view", 165 | "type":"function", 166 | "gas":"1710" 167 | }, 168 | { 169 | "name":"curve", 170 | "outputs":[ 171 | { 172 | "type":"address", 173 | "name":"" 174 | } 175 | ], 176 | "inputs":[], 177 | "stateMutability": "view", 178 | "type":"function", 179 | "gas":"1541" 180 | }, 181 | { 182 | "name":"token", 183 | "outputs":[ 184 | { 185 | "type":"address", 186 | "name":"" 187 | } 188 | ], 189 | "inputs":[], 190 | "stateMutability": "view", 191 | "type":"function", 192 | "gas":"1571" 193 | } 194 | ] 195 | -------------------------------------------------------------------------------- /src/constants/abis/tricrypto2/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "payable", 4 | "type": "fallback" 5 | }, 6 | { 7 | "stateMutability": "nonpayable", 8 | "type": "constructor", 9 | "inputs": [ 10 | { 11 | "name": "_pool", 12 | "type": "address" 13 | } 14 | ], 15 | "outputs": [] 16 | }, 17 | { 18 | "stateMutability": "payable", 19 | "type": "function", 20 | "name": "add_liquidity", 21 | "inputs": [ 22 | { 23 | "name": "_amounts", 24 | "type": "uint256[3]" 25 | }, 26 | { 27 | "name": "_min_mint_amount", 28 | "type": "uint256" 29 | } 30 | ], 31 | "outputs": [ 32 | { 33 | "name": "", 34 | "type": "uint256" 35 | } 36 | ] 37 | }, 38 | { 39 | "stateMutability": "nonpayable", 40 | "type": "function", 41 | "name": "remove_liquidity", 42 | "inputs": [ 43 | { 44 | "name": "_amount", 45 | "type": "uint256" 46 | }, 47 | { 48 | "name": "_min_amounts", 49 | "type": "uint256[3]" 50 | } 51 | ], 52 | "outputs": [ 53 | { 54 | "name": "", 55 | "type": "uint256[3]" 56 | } 57 | ] 58 | }, 59 | { 60 | "stateMutability": "nonpayable", 61 | "type": "function", 62 | "name": "remove_liquidity_one_coin", 63 | "inputs": [ 64 | { 65 | "name": "_token_amount", 66 | "type": "uint256" 67 | }, 68 | { 69 | "name": "i", 70 | "type": "uint256" 71 | }, 72 | { 73 | "name": "_min_amount", 74 | "type": "uint256" 75 | } 76 | ], 77 | "outputs": [ 78 | { 79 | "name": "", 80 | "type": "uint256" 81 | } 82 | ] 83 | }, 84 | { 85 | "stateMutability": "view", 86 | "type": "function", 87 | "name": "pool", 88 | "inputs": [], 89 | "outputs": [ 90 | { 91 | "name": "", 92 | "type": "address" 93 | } 94 | ], 95 | "gas": "2568" 96 | }, 97 | { 98 | "stateMutability": "view", 99 | "type": "function", 100 | "name": "token", 101 | "inputs": [], 102 | "outputs": [ 103 | { 104 | "name": "", 105 | "type": "address" 106 | } 107 | ], 108 | "gas": "2598" 109 | }, 110 | { 111 | "stateMutability": "view", 112 | "type": "function", 113 | "name": "coins", 114 | "inputs": [ 115 | { 116 | "name": "arg0", 117 | "type": "uint256" 118 | } 119 | ], 120 | "outputs": [ 121 | { 122 | "name": "", 123 | "type": "address" 124 | } 125 | ], 126 | "gas": "2737" 127 | } 128 | ] 129 | -------------------------------------------------------------------------------- /src/constants/abis/usdt/deposit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputs":[], 4 | "inputs":[ 5 | { 6 | "type":"address[3]", 7 | "name":"_coins" 8 | }, 9 | { 10 | "type":"address[3]", 11 | "name":"_underlying_coins" 12 | }, 13 | { 14 | "type":"address", 15 | "name":"_curve" 16 | }, 17 | { 18 | "type":"address", 19 | "name":"_token" 20 | } 21 | ], 22 | "constant":false, 23 | "payable":false, 24 | "type":"constructor" 25 | }, 26 | { 27 | "name":"add_liquidity", 28 | "outputs":[], 29 | "inputs":[ 30 | { 31 | "type":"uint256[3]", 32 | "name":"uamounts" 33 | }, 34 | { 35 | "type":"uint256", 36 | "name":"min_mint_amount" 37 | } 38 | ], 39 | "constant":false, 40 | "payable":false, 41 | "type":"function", 42 | "gas":"1097072" 43 | }, 44 | { 45 | "name":"remove_liquidity", 46 | "outputs":[], 47 | "inputs":[ 48 | { 49 | "type":"uint256", 50 | "name":"_amount" 51 | }, 52 | { 53 | "type":"uint256[3]", 54 | "name":"min_uamounts" 55 | } 56 | ], 57 | "constant":false, 58 | "payable":false, 59 | "type":"function", 60 | "gas":"675496" 61 | }, 62 | { 63 | "name":"remove_liquidity_imbalance", 64 | "outputs":[], 65 | "inputs":[ 66 | { 67 | "type":"uint256[3]", 68 | "name":"uamounts" 69 | }, 70 | { 71 | "type":"uint256", 72 | "name":"max_burn_amount" 73 | } 74 | ], 75 | "constant":false, 76 | "payable":false, 77 | "type":"function", 78 | "gas":"905732" 79 | }, 80 | { 81 | "name":"calc_withdraw_one_coin", 82 | "outputs":[ 83 | { 84 | "type":"uint256", 85 | "name":"" 86 | } 87 | ], 88 | "inputs":[ 89 | { 90 | "type":"uint256", 91 | "name":"_token_amount" 92 | }, 93 | { 94 | "type":"int128", 95 | "name":"i" 96 | } 97 | ], 98 | "stateMutability": "view", 99 | "type":"function", 100 | "gas":"3413700" 101 | }, 102 | { 103 | "name":"remove_liquidity_one_coin", 104 | "outputs":[], 105 | "inputs":[ 106 | { 107 | "type":"uint256", 108 | "name":"_token_amount" 109 | }, 110 | { 111 | "type":"int128", 112 | "name":"i" 113 | }, 114 | { 115 | "type":"uint256", 116 | "name":"min_uamount" 117 | } 118 | ], 119 | "constant":false, 120 | "payable":false, 121 | "type":"function" 122 | }, 123 | { 124 | "name":"withdraw_donated_dust", 125 | "outputs":[], 126 | "inputs":[], 127 | "constant":false, 128 | "payable":false, 129 | "type":"function", 130 | "gas":"63973" 131 | }, 132 | { 133 | "name":"coins", 134 | "outputs":[ 135 | { 136 | "type":"address", 137 | "name":"" 138 | } 139 | ], 140 | "inputs":[ 141 | { 142 | "type":"int128", 143 | "name":"arg0" 144 | } 145 | ], 146 | "stateMutability": "view", 147 | "type":"function", 148 | "gas":"1680" 149 | }, 150 | { 151 | "name":"underlying_coins", 152 | "outputs":[ 153 | { 154 | "type":"address", 155 | "name":"" 156 | } 157 | ], 158 | "inputs":[ 159 | { 160 | "type":"int128", 161 | "name":"arg0" 162 | } 163 | ], 164 | "stateMutability": "view", 165 | "type":"function", 166 | "gas":"1710" 167 | }, 168 | { 169 | "name":"curve", 170 | "outputs":[ 171 | { 172 | "type":"address", 173 | "name":"" 174 | } 175 | ], 176 | "inputs":[], 177 | "stateMutability": "view", 178 | "type":"function", 179 | "gas":"1541" 180 | }, 181 | { 182 | "name":"token", 183 | "outputs":[ 184 | { 185 | "type":"address", 186 | "name":"" 187 | } 188 | ], 189 | "inputs":[], 190 | "stateMutability": "view", 191 | "type":"function", 192 | "gas":"1571" 193 | } 194 | ] 195 | -------------------------------------------------------------------------------- /src/constants/abis/voting_escrow_oracle_eth.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stateMutability": "nonpayable", 4 | "type": "function", 5 | "name": "send_blockhash", 6 | "inputs": [ 7 | { 8 | "name": "_block_number", 9 | "type": "uint256" 10 | }, 11 | { 12 | "name": "_chain_id", 13 | "type": "uint256" 14 | } 15 | ], 16 | "outputs": [], 17 | "gas": "54147" 18 | }, 19 | { 20 | "stateMutability": "view", 21 | "type": "function", 22 | "name": "block_number_bounds", 23 | "inputs": [], 24 | "outputs": [ 25 | { 26 | "name": "", 27 | "type": "uint256[2]" 28 | } 29 | ], 30 | "gas": "740" 31 | }, 32 | { 33 | "stateMutability": "view", 34 | "type": "function", 35 | "name": "generate_eth_get_proof_params", 36 | "inputs": [ 37 | { 38 | "name": "_user", 39 | "type": "address" 40 | } 41 | ], 42 | "outputs": [ 43 | { 44 | "name": "", 45 | "type": "address" 46 | }, 47 | { 48 | "name": "", 49 | "type": "uint256[20]" 50 | }, 51 | { 52 | "name": "", 53 | "type": "uint256" 54 | } 55 | ], 56 | "gas": "21089" 57 | }, 58 | { 59 | "stateMutability": "view", 60 | "type": "function", 61 | "name": "get_last_block_number_sent", 62 | "inputs": [ 63 | { 64 | "name": "_chain_id", 65 | "type": "uint256" 66 | } 67 | ], 68 | "outputs": [ 69 | { 70 | "name": "", 71 | "type": "uint256" 72 | } 73 | ], 74 | "gas": "2747" 75 | } 76 | ] -------------------------------------------------------------------------------- /src/constants/coins/arbitrum.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_ARBITRUM: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x11cDb42B0EB46D95f990BeDD4695A6e3fA034978', 5 | 6 | // --- USD --- 7 | 8 | 'usdc.e': '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', 9 | 'usdt': '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9', 10 | '2crv': '0x7f90122bf0700f9e7e1f688fe926940e8839f353', 11 | 12 | // --- EUR --- 13 | 14 | 'eurs': '0xd22a58f79e9481d1a88e00c343885a588b34b68b', 15 | 16 | // --- BTC --- 17 | 18 | 'wbtc': '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f', 19 | 'renbtc': '0xDBf31dF14B66535aF65AaC99C32e9eA844e14501', 20 | 21 | // --- ETH --- 22 | 23 | "eth": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", 24 | "weth": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", 25 | "wsteth": "0x5979D7b546E38E414F7E9822514be443A4800529", 26 | 27 | }); 28 | -------------------------------------------------------------------------------- /src/constants/coins/aurora.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_AURORA: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205', 5 | 6 | // --- USD --- 7 | 'dai': '0xe3520349F477A5F6EB06107066048508498A291b', 8 | 'usdc.e': '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802', 9 | 'usdt': '0x4988a896b1227218e4A686fdE5EabdcAbd91571f', 10 | '3crv': '0xbF7E49483881C76487b0989CD7d9A8239B20CA41', 11 | }); 12 | -------------------------------------------------------------------------------- /src/constants/coins/avalanche.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_AVALANCHE: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x47536F17F4fF30e64A96a7555826b8f9e66ec468', 5 | 'crv.e': '0x249848BeCA43aC405b8102Ec90Dd5F22CA513c06', 6 | 7 | // --- USD --- 8 | 9 | 'dai.e': '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70', 10 | 'usdc.e': '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664', 11 | 'usdt.e': '0xc7198437980c041c805A1EDcbA50c1Ce5db95118', 12 | 'usdc': '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', 13 | 'usdt': '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7', 14 | 'avdai': '0x47AFa96Cdc9fAb46904A55a6ad4bf6660B53c38a', 15 | 'avusdc': '0x46A51127C3ce23fb7AB1DE06226147F446e4a857', 16 | 'avusdt': '0x532E6537FEA298397212F09A61e03311686f548e', 17 | 'av3crv': '0x1337bedc9d22ecbe766df105c9623922a27963ec', 18 | '2crv': '0x0974D9d3bc463Fa17497aAFc3a87535553298FbE', 19 | 20 | // --- BTC --- 21 | 22 | 'wbtc.e': '0x50b7545627a5162F82A992c33b87aDc75187B218', 23 | 'renbtc': '0xDBf31dF14B66535aF65AaC99C32e9eA844e14501', 24 | 'avwbtc': '0x686bEF2417b6Dc32C50a3cBfbCC3bb60E1e9a15D', 25 | 'btc.b': '0x152b9d0FdC40C096757F570A51E494bd4b943E50', 26 | 27 | // --- ETH --- 28 | 29 | 'weth.e': '0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB', 30 | 'avweth': '0x53f7c5869a859F0AeC3D334ee8B4Cf01E3492f21', 31 | 32 | // --- AVAX --- 33 | 'avax': '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', 34 | 'wavax': '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', 35 | }); 36 | 37 | export const aTokensAvalanche = [ 38 | '0x47AFa96Cdc9fAb46904A55a6ad4bf6660B53c38a', // avDAI 39 | '0x46A51127C3ce23fb7AB1DE06226147F446e4a857', // avUSDC 40 | '0x532E6537FEA298397212F09A61e03311686f548e', // avUSDT 41 | '0x686bEF2417b6Dc32C50a3cBfbCC3bb60E1e9a15D', // avWBTC 42 | '0x53f7c5869a859F0AeC3D334ee8B4Cf01E3492f21', // avWETH 43 | ].map((a) => a.toLowerCase()); 44 | -------------------------------------------------------------------------------- /src/constants/coins/base.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | import { IDict } from "../../interfaces.js"; 3 | 4 | 5 | export const COINS_BASE: IDict = lowerCaseValues({ 6 | crv: '0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415', 7 | 8 | // --- ETH --- 9 | eth: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // ETH 10 | weth: '0x4200000000000000000000000000000000000006', 11 | }); 12 | -------------------------------------------------------------------------------- /src/constants/coins/bsc.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | import { IDict } from "../../interfaces.js"; 3 | 4 | 5 | export const COINS_BSC: IDict = lowerCaseValues({ 6 | //crv: '0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415', // <--- TODO ADD 7 | 8 | // --- BSC --- 9 | bnb: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 10 | wbnb: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', 11 | }); 12 | -------------------------------------------------------------------------------- /src/constants/coins/celo.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_CELO: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB', // <--- TODO CHANGE 5 | 6 | // --- USD --- 7 | 'dai': '0x90Ca507a5D4458a4C6C6249d186b6dCb02a5BCCd', 8 | 'usdc': '0xef4229c8c3250C675F21BCefa42f58EfbfF6002a', 9 | 'usdt': '0x88eeC49252c8cbc039DCdB394c0c2BA2f1637EA0', 10 | '3crv': '0x998395fEd908d33CF27115A1D9Ab6555def6cd45', 11 | }); -------------------------------------------------------------------------------- /src/constants/coins/fantom.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_FANTOM: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x1E4F97b9f9F913c46F1632781732927B9019C68b', 5 | 6 | // --- USD --- 7 | 8 | 'dai': '0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e', 9 | 'usdc': '0x04068da6c83afcfa0e13ba15a6696662335d5b75', 10 | 'fusdt': '0x049d68029688eabf473097a2fc38ef61633a3c7a', 11 | 12 | 'idai': '0x04c762a5dF2Fa02FE868F25359E0C259fB811CfE', 13 | 'iusdc': '0x328A7b4d538A2b3942653a9983fdA3C12c571141', 14 | 'ifusdt': '0x70faC71debfD67394D1278D98A29dea79DC6E57A', 15 | 16 | 'gdai': '0x07e6332dd090d287d3489245038daf987955dcfb', 17 | 'gusdc': '0xe578c856933d8e1082740bf7661e379aa2a30b26', 18 | 'gfusdt': '0x940f41f0ec9ba1a34cf001cc03347ac092f5f6b5', 19 | 20 | 'dai+usdc': '0x27e611fd27b276acbd5ffd632e5eaebec9761e40', // LP token 21 | 'frax': '0xdc301622e621166bd8e82f2ca0a26c13ad0be355', 22 | 23 | // --- BTC --- 24 | 25 | 'wbtc': '0x321162Cd933E2Be498Cd2267a90534A804051b11', 26 | 'renbtc': '0xDBf31dF14B66535aF65AaC99C32e9eA844e14501', 27 | 28 | // --- ETH --- 29 | 30 | 'eth': '0x74b23882a30290451A17c44f4F05243b6b58C76d', 31 | }) 32 | 33 | export const cTokensFantom = [ 34 | '0x04c762a5dF2Fa02FE868F25359E0C259fB811CfE', // iDAI 35 | '0x328A7b4d538A2b3942653a9983fdA3C12c571141', // iUSDC 36 | '0x70faC71debfD67394D1278D98A29dea79DC6E57A', // iFUSDT 37 | ].map((a) => a.toLowerCase()); 38 | 39 | export const aTokensFantom = [ 40 | '0x07e6332dd090d287d3489245038daf987955dcfb', // gDAI 41 | '0xe578c856933d8e1082740bf7661e379aa2a30b26', // gUSDC 42 | '0x940f41f0ec9ba1a34cf001cc03347ac092f5f6b5', // gfUSDT 43 | ].map((a) => a.toLowerCase()); 44 | -------------------------------------------------------------------------------- /src/constants/coins/fraxtal.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | import { IDict } from "../../interfaces.js"; 3 | 4 | 5 | export const COINS_FRAXTAL: IDict = lowerCaseValues({ 6 | crv: '0x331B9182088e2A7d6D3Fe4742AbA1fB231aEcc56', 7 | 8 | // --- FRAXTAL --- 9 | frax: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 10 | }); 11 | -------------------------------------------------------------------------------- /src/constants/coins/hyperliquid.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | import { IDict } from "../../interfaces.js"; 3 | 4 | 5 | export const COINS_HYPERLIQUID: IDict = lowerCaseValues({ 6 | crv: '0x5af79133999f7908953e94b7a5cf367740ebee35', 7 | s: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 8 | }); 9 | -------------------------------------------------------------------------------- /src/constants/coins/index.ts: -------------------------------------------------------------------------------- 1 | import { COINS_ETHEREUM, cTokensEthereum, yTokensEthereum, ycTokensEthereum, aTokensEthereum } from "./ethereum.js"; 2 | import { COINS_POLYGON, aTokensPolygon } from "./polygon.js"; 3 | import { COINS_FANTOM, cTokensFantom, aTokensFantom } from "./fantom.js"; 4 | import { COINS_AVALANCHE, aTokensAvalanche } from "./avalanche.js"; 5 | import { COINS_ARBITRUM } from "./arbitrum.js"; 6 | import { COINS_OPTIMISM } from "./optimism.js"; 7 | import { COINS_XDAI } from "./xdai.js"; 8 | import { COINS_MOONBEAM } from "./moonbeam.js"; 9 | import { COINS_AURORA } from "./aurora.js"; 10 | import { COINS_KAVA } from "./kava.js"; 11 | import { COINS_CELO } from "./celo.js"; 12 | import { COINS_ZKSYNC } from "./zksync.js"; 13 | import { COINS_BASE } from "./base.js"; 14 | import { COINS_BSC } from "./bsc.js"; 15 | import { COINS_FRAXTAL } from "./fraxtal.js"; 16 | import { COINS_XLAYER } from "./xlayer.js"; 17 | import { COINS_MANTLE } from "./mantle.js"; 18 | import { COINS_SONIC } from "./sonic.js"; 19 | import { COINS_HYPERLIQUID } from "./hyperliquid.js"; 20 | export { 21 | COINS_ETHEREUM, cTokensEthereum, yTokensEthereum, ycTokensEthereum, aTokensEthereum, 22 | COINS_POLYGON, aTokensPolygon, 23 | COINS_FANTOM, cTokensFantom, aTokensFantom, 24 | COINS_AVALANCHE, aTokensAvalanche, 25 | COINS_ARBITRUM, 26 | COINS_OPTIMISM, 27 | COINS_XDAI, 28 | COINS_MOONBEAM, 29 | COINS_AURORA, 30 | COINS_KAVA, 31 | COINS_CELO, 32 | COINS_ZKSYNC, 33 | COINS_BASE, 34 | COINS_BSC, 35 | COINS_FRAXTAL, 36 | COINS_XLAYER, 37 | COINS_MANTLE, 38 | COINS_SONIC, 39 | COINS_HYPERLIQUID, 40 | }; 41 | -------------------------------------------------------------------------------- /src/constants/coins/kava.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_KAVA: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205', // <--- TODO CHANGE 5 | 6 | // --- USD --- 7 | 'dai': '0x765277EebeCA2e31912C9946eAe1021199B39C61', 8 | 'usdc': '0xfA9343C3897324496A05fC75abeD6bAC29f8A40f', 9 | 'usdt': '0xB44a9B6905aF7c801311e8F4E76932ee959c663C', 10 | '3crv': '0x7A0e3b70b1dB0D6CA63Cac240895b2D21444A7b9', 11 | }) 12 | -------------------------------------------------------------------------------- /src/constants/coins/mantle.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | import { IDict } from "../../interfaces.js"; 3 | 4 | 5 | export const COINS_MANTLE: IDict = lowerCaseValues({ 6 | crv: '0xcfd1d50ce23c46d3cf6407487b2f8934e96dc8f9', 7 | mnt: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 8 | }); 9 | -------------------------------------------------------------------------------- /src/constants/coins/moonbeam.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_MOONBEAM: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x712b3d230f3c1c19db860d80619288b1f0bdd0bd', 5 | 6 | // --- USD --- 7 | 8 | 'dai': '0xc234A67a4F840E61adE794be47de455361b52413', 9 | 'usdc': '0x8f552a71EFE5eeFc207Bf75485b356A0b3f01eC9', 10 | 'usdt': '0x8e70cD5B4Ff3f62659049e74b6649c6603A0E594', 11 | '3crv': '0xace58a26b8db90498ef0330fdc9c2655db0c45e2', 12 | }) 13 | -------------------------------------------------------------------------------- /src/constants/coins/optimism.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_OPTIMISM: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53', 5 | 6 | // --- USD --- 7 | 8 | 'dai': '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1', 9 | 'usdc.e': '0x7f5c764cbc14f9669b88837ca1490cca17c31607', 10 | 'usdt': '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58', 11 | 'susd': '0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9', 12 | 'mim': '0xb153fb3d196a8eb25522705560ac152eeec57901', 13 | '3crv': '0x1337BedC9D22ecbe766dF105c9623922A27963EC', 14 | 15 | // --- ETH --- 16 | 17 | 'eth': '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', 18 | 'weth': '0x4200000000000000000000000000000000000006', 19 | 'seth': '0xe405de8f52ba7559f9df3c368500b6e6ae6cee49', 20 | 'wsteth': '0x1f32b1c2345538c0c6f582fcb022739c4a194ebb', 21 | }) 22 | -------------------------------------------------------------------------------- /src/constants/coins/polygon.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | 4 | export const COINS_POLYGON: { [index: string]: string } = lowerCaseValues({ 5 | crv: "0x172370d5cd63279efa6d502dab29171933a610af", // CRV 6 | 7 | // -- USD --- 8 | 9 | dai: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063", // DAI 10 | 'usdc.e': "0x2791bca1f2de4661ed88a30c99a7a9449aa84174", // USDC.e 11 | usdt: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", // USDT 12 | 13 | amdai: "0x27F8D03b3a2196956ED754baDc28D73be8830A6e", // amDAI 14 | amusdc: "0x1a13F4Ca1d028320A707D99520AbFefca3998b7F", // amUSDC 15 | amusdt: "0x60D55F02A771d515e077c9C2403a1ef324885CeC", // amUSDT 16 | 17 | am3crv: "0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171", // am3CRV 18 | 19 | // --- ETH --- 20 | 21 | weth: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", // WETH 22 | amweth: "0x28424507fefb6f7f8E9D3860F56504E4e5f5f390", // amWETH 23 | 24 | // --- BTC --- 25 | 26 | wbtc: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6", // WBTC 27 | renbtc: "0xDBf31dF14B66535aF65AaC99C32e9eA844e14501", // renBTC 28 | amwbtc: "0x5c2ed810328349100A66B82b78a1791B101C9D61", // amWBTC 29 | 30 | // --- MATIC --- 31 | 32 | matic: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // MATIC 33 | wmatic: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270", 34 | 35 | // --- EUR --- 36 | 37 | eurt: "0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f", // EURT 38 | }) 39 | 40 | export const aTokensPolygon = [ 41 | "0x27F8D03b3a2196956ED754baDc28D73be8830A6e", // amDAI 42 | "0x1a13F4Ca1d028320A707D99520AbFefca3998b7F", // amUSDC 43 | "0x60D55F02A771d515e077c9C2403a1ef324885CeC", // amUSDT 44 | "0x5c2ed810328349100A66B82b78a1791B101C9D61", // amWBTC 45 | "0x28424507fefb6f7f8E9D3860F56504E4e5f5f390", // amWETH 46 | ].map((a) => a.toLowerCase()); 47 | -------------------------------------------------------------------------------- /src/constants/coins/sonic.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | import { IDict } from "../../interfaces.js"; 3 | 4 | 5 | export const COINS_SONIC: IDict = lowerCaseValues({ 6 | crv: '0x5af79133999f7908953e94b7a5cf367740ebee35', 7 | s: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 8 | }); 9 | -------------------------------------------------------------------------------- /src/constants/coins/xdai.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | 3 | export const COINS_XDAI: { [index: string]: string } = lowerCaseValues({ 4 | 'crv': '0x712b3d230f3c1c19db860d80619288b1f0bdd0bd', 5 | 6 | // --- USD --- 7 | 8 | 'wxdai': '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', 9 | 'usdc': '0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83', 10 | 'usdt': '0x4ECaBa5870353805a9F068101A40E0f32ed605C6', 11 | 'rai': '0xd7a28aa9c470e7e9d8c676bcd5dd2f40c5683afa', 12 | 'x3crv': '0x1337BedC9D22ecbe766dF105c9623922A27963EC', 13 | 14 | // --- BTC --- 15 | 16 | 'wbtc': '0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252', 17 | 18 | // --- ETH --- 19 | 20 | 'weth': '0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1', 21 | 22 | // --- EUR --- 23 | 'eure': '0xcB444e90D8198415266c6a2724b7900fb12FC56E', 24 | }); 25 | -------------------------------------------------------------------------------- /src/constants/coins/xlayer.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | import { IDict } from "../../interfaces.js"; 3 | 4 | 5 | export const COINS_XLAYER: IDict = lowerCaseValues({ 6 | crv: '0x3d5320821bfca19fb0b5428f2c79d63bd5246f89', 7 | okb: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 8 | }); 9 | -------------------------------------------------------------------------------- /src/constants/coins/zksync.ts: -------------------------------------------------------------------------------- 1 | import { lowerCaseValues } from "../utils.js"; 2 | import { IDict } from "../../interfaces.js"; 3 | 4 | 5 | export const COINS_ZKSYNC: IDict = lowerCaseValues({ 6 | 'crv': '0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB', // <--- TODO CHANGE 7 | 8 | // --- USD --- 9 | 'weth': '0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91', 10 | }); 11 | -------------------------------------------------------------------------------- /src/constants/factory/index.ts: -------------------------------------------------------------------------------- 1 | import { STABLE_FACTORY_CONSTANTS } from "./stable.js"; 2 | import { CRYPTO_FACTORY_CONSTANTS } from "./crypto.js"; 3 | 4 | export { 5 | STABLE_FACTORY_CONSTANTS, 6 | CRYPTO_FACTORY_CONSTANTS, 7 | } -------------------------------------------------------------------------------- /src/constants/pools/aurora.ts: -------------------------------------------------------------------------------- 1 | import { IDict, IPoolData } from "../../interfaces"; 2 | import { lowerCasePoolDataAddresses } from "../utils.js"; 3 | import tripoolSwapABI from '../abis/3pool-optimism/swap.json' with { type: 'json' }; 4 | import gaugeRewardsOnlyABI from '../abis/gauge_rewards_only.json' with { type: 'json' }; 5 | 6 | export const POOLS_DATA_AURORA: IDict = lowerCasePoolDataAddresses({ 7 | '3pool': { 8 | name: "3pool", 9 | full_name: "3pool", 10 | symbol: "3pool", 11 | reference_asset: 'USD', 12 | swap_address: '0xbF7E49483881C76487b0989CD7d9A8239B20CA41', 13 | token_address: '0xbF7E49483881C76487b0989CD7d9A8239B20CA41', 14 | gauge_address: '0xC2b1DF84112619D190193E48148000e3990Bf627', 15 | is_plain: true, 16 | underlying_coins: ['DAI', 'USDC.e', 'USDT'], 17 | wrapped_coins: ['DAI', 'USDC.e', 'USDT'], 18 | underlying_coin_addresses: [ 19 | '0xe3520349F477A5F6EB06107066048508498A291b', 20 | '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802', 21 | '0x4988a896b1227218e4A686fdE5EabdcAbd91571f', 22 | ], 23 | wrapped_coin_addresses: [ 24 | '0xe3520349F477A5F6EB06107066048508498A291b', 25 | '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802', 26 | '0x4988a896b1227218e4A686fdE5EabdcAbd91571f', 27 | ], 28 | underlying_decimals: [18, 6, 6], 29 | wrapped_decimals: [18, 6, 6], 30 | swap_abi: tripoolSwapABI, 31 | gauge_abi: gaugeRewardsOnlyABI, 32 | }, 33 | }); 34 | -------------------------------------------------------------------------------- /src/constants/pools/base.ts: -------------------------------------------------------------------------------- 1 | import { lowerCasePoolDataAddresses } from "../utils.js"; 2 | import { IPoolData, IDict } from "../../interfaces.js"; 3 | 4 | export const POOLS_DATA_BASE: IDict = lowerCasePoolDataAddresses({}); 5 | -------------------------------------------------------------------------------- /src/constants/pools/bsc.ts: -------------------------------------------------------------------------------- 1 | import { lowerCasePoolDataAddresses } from "../utils.js"; 2 | import { IPoolData, IDict } from "../../interfaces.js"; 3 | 4 | export const POOLS_DATA_BSC: IDict = lowerCasePoolDataAddresses({}); 5 | -------------------------------------------------------------------------------- /src/constants/pools/celo.ts: -------------------------------------------------------------------------------- 1 | import { IDict, IPoolData } from "../../interfaces"; 2 | import { lowerCasePoolDataAddresses } from "../utils.js"; 3 | 4 | export const POOLS_DATA_CELO: IDict = lowerCasePoolDataAddresses({}); 5 | -------------------------------------------------------------------------------- /src/constants/pools/fraxtal.ts: -------------------------------------------------------------------------------- 1 | import { lowerCasePoolDataAddresses } from "../utils.js"; 2 | import { IPoolData, IDict } from "../../interfaces.js"; 3 | 4 | export const POOLS_DATA_FRAXTAL: IDict = lowerCasePoolDataAddresses({}); 5 | -------------------------------------------------------------------------------- /src/constants/pools/hyperliquid.ts: -------------------------------------------------------------------------------- 1 | import { lowerCasePoolDataAddresses } from "../utils.js"; 2 | import { IPoolData, IDict } from "../../interfaces.js"; 3 | 4 | export const POOLS_DATA_HYPERLIQUID: IDict = lowerCasePoolDataAddresses({}); -------------------------------------------------------------------------------- /src/constants/pools/index.ts: -------------------------------------------------------------------------------- 1 | import { POOLS_DATA_ETHEREUM } from "./ethereum.js"; 2 | import { LLAMMAS_DATA_ETHEREUM } from "./ethereum.js"; 3 | import { POOLS_DATA_POLYGON } from "./polygon.js"; 4 | import { POOLS_DATA_FANTOM } from "./fantom.js"; 5 | import { POOLS_DATA_AVALANCHE } from "./avalanche.js"; 6 | import { POOLS_DATA_ARBITRUM } from "./arbitrum.js"; 7 | import { POOLS_DATA_OPTIMISM } from "./optimism.js"; 8 | import { POOLS_DATA_XDAI } from "./xdai.js"; 9 | import { POOLS_DATA_MOONBEAM } from "./moonbeam.js"; 10 | import { POOLS_DATA_AURORA } from "./aurora.js"; 11 | import { POOLS_DATA_KAVA } from "./kava.js"; 12 | import { POOLS_DATA_CELO } from "./celo.js"; 13 | import { POOLS_DATA_ZKSYNC } from "./zksync.js"; 14 | import { POOLS_DATA_BASE } from "./base.js"; 15 | import { POOLS_DATA_BSC } from "./bsc.js"; 16 | import { POOLS_DATA_FRAXTAL } from "./fraxtal.js"; 17 | import { POOLS_DATA_XLAYER } from "./xlayer.js"; 18 | import { POOLS_DATA_MANTLE } from "./mantle.js"; 19 | import { POOLS_DATA_SONIC } from "./sonic.js"; 20 | import { POOLS_DATA_HYPERLIQUID } from "./hyperliquid.js"; 21 | export { 22 | POOLS_DATA_ETHEREUM, 23 | LLAMMAS_DATA_ETHEREUM, 24 | POOLS_DATA_POLYGON, 25 | POOLS_DATA_FANTOM, 26 | POOLS_DATA_AVALANCHE, 27 | POOLS_DATA_ARBITRUM, 28 | POOLS_DATA_OPTIMISM, 29 | POOLS_DATA_XDAI, 30 | POOLS_DATA_MOONBEAM, 31 | POOLS_DATA_AURORA, 32 | POOLS_DATA_KAVA, 33 | POOLS_DATA_CELO, 34 | POOLS_DATA_ZKSYNC, 35 | POOLS_DATA_BASE, 36 | POOLS_DATA_BSC, 37 | POOLS_DATA_FRAXTAL, 38 | POOLS_DATA_XLAYER, 39 | POOLS_DATA_MANTLE, 40 | POOLS_DATA_SONIC, 41 | POOLS_DATA_HYPERLIQUID, 42 | }; 43 | -------------------------------------------------------------------------------- /src/constants/pools/kava.ts: -------------------------------------------------------------------------------- 1 | import { IDict, IPoolData } from "../../interfaces"; 2 | import { lowerCasePoolDataAddresses } from "../utils.js"; 3 | 4 | export const POOLS_DATA_KAVA: IDict = lowerCasePoolDataAddresses({}); 5 | -------------------------------------------------------------------------------- /src/constants/pools/mantle.ts: -------------------------------------------------------------------------------- 1 | import { lowerCasePoolDataAddresses } from "../utils.js"; 2 | import { IPoolData, IDict } from "../../interfaces.js"; 3 | 4 | export const POOLS_DATA_MANTLE: IDict = lowerCasePoolDataAddresses({}); -------------------------------------------------------------------------------- /src/constants/pools/moonbeam.ts: -------------------------------------------------------------------------------- 1 | import { IDict, IPoolData } from "../../interfaces"; 2 | import { lowerCasePoolDataAddresses } from "../utils.js"; 3 | import tripoolSwapABI from '../abis/3pool-optimism/swap.json' with { type: 'json' }; 4 | import gaugeChildABI from '../abis/gauge_child.json' with { type: 'json' }; 5 | 6 | 7 | export const POOLS_DATA_MOONBEAM: IDict = lowerCasePoolDataAddresses({ 8 | '3pool': { 9 | name: "3pool", 10 | full_name: "3pool", 11 | symbol: "3pool", 12 | reference_asset: 'USD', 13 | swap_address: '0xace58a26b8db90498ef0330fdc9c2655db0c45e2', 14 | token_address: '0xace58a26b8db90498ef0330fdc9c2655db0c45e2', 15 | gauge_address: '0x0000000000000000000000000000000000000000', // NO GAUGE 16 | is_plain: true, 17 | underlying_coins: ['DAI', 'USDC', 'USDT'], 18 | wrapped_coins: ['DAI', 'USDC', 'USDT'], 19 | underlying_coin_addresses: [ 20 | '0xc234A67a4F840E61adE794be47de455361b52413', 21 | '0x8f552a71EFE5eeFc207Bf75485b356A0b3f01eC9', 22 | '0x8e70cD5B4Ff3f62659049e74b6649c6603A0E594', 23 | ], 24 | wrapped_coin_addresses: [ 25 | '0xc234A67a4F840E61adE794be47de455361b52413', 26 | '0x8f552a71EFE5eeFc207Bf75485b356A0b3f01eC9', 27 | '0x8e70cD5B4Ff3f62659049e74b6649c6603A0E594', 28 | ], 29 | underlying_decimals: [18, 6, 6], 30 | wrapped_decimals: [18, 6, 6], 31 | swap_abi: tripoolSwapABI, 32 | gauge_abi: gaugeChildABI, 33 | }, 34 | }); 35 | -------------------------------------------------------------------------------- /src/constants/pools/optimism.ts: -------------------------------------------------------------------------------- 1 | import { IDict, IPoolData } from "../../interfaces"; 2 | import { lowerCasePoolDataAddresses } from "../utils.js"; 3 | import tripoolSwapABI from '../abis/3pool-optimism/swap.json' with { type: 'json' }; 4 | import wstETHSwapABI from '../abis/wsteth/swap.json' with { type: 'json' }; 5 | import gaugeChildABI from '../abis/gauge_child.json' with { type: 'json' }; 6 | 7 | export const POOLS_DATA_OPTIMISM: IDict = lowerCasePoolDataAddresses({ 8 | '3pool': { 9 | name: "3pool", 10 | full_name: "3pool", 11 | symbol: "3pool", 12 | reference_asset: 'USD', 13 | is_plain: true, 14 | swap_address: '0x1337BedC9D22ecbe766dF105c9623922A27963EC', 15 | token_address: '0x1337BedC9D22ecbe766dF105c9623922A27963EC', 16 | gauge_address: '0x15F52286C0FF1d7A7dDbC9E300dd66628D46D4e6', 17 | underlying_coins: ['DAI', 'USDC.e', 'USDT'], 18 | wrapped_coins: ['DAI', 'USDC.e', 'USDT'], 19 | underlying_coin_addresses: [ 20 | '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1', 21 | '0x7f5c764cbc14f9669b88837ca1490cca17c31607', 22 | '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58', 23 | ], 24 | wrapped_coin_addresses: [ 25 | '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1', 26 | '0x7f5c764cbc14f9669b88837ca1490cca17c31607', 27 | '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58', 28 | ], 29 | underlying_decimals: [18, 6, 6], 30 | wrapped_decimals: [18, 6, 6], 31 | swap_abi: tripoolSwapABI, 32 | gauge_abi: gaugeChildABI, 33 | }, 34 | wsteth: { 35 | name: "wsteth", 36 | full_name: "wsteth", 37 | symbol: "wsteth", 38 | reference_asset: 'ETH', 39 | is_plain: true, 40 | swap_address: '0xB90B9B1F91a01Ea22A182CD84C1E22222e39B415', 41 | token_address: '0xEfDE221f306152971D8e9f181bFe998447975810', 42 | gauge_address: '0xD53cCBfED6577d8dc82987e766e75E3cb73a8563', 43 | underlying_coins: ['ETH', 'wstETH'], 44 | wrapped_coins: ['ETH', 'wstETH'], 45 | underlying_coin_addresses: [ 46 | '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', 47 | '0x1f32b1c2345538c0c6f582fcb022739c4a194ebb', 48 | ], 49 | wrapped_coin_addresses: [ 50 | '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', 51 | '0x1f32b1c2345538c0c6f582fcb022739c4a194ebb', 52 | ], 53 | underlying_decimals: [18, 18], 54 | wrapped_decimals: [18, 18], 55 | swap_abi: wstETHSwapABI, 56 | gauge_abi: gaugeChildABI, 57 | }, 58 | }); 59 | -------------------------------------------------------------------------------- /src/constants/pools/sonic.ts: -------------------------------------------------------------------------------- 1 | import { lowerCasePoolDataAddresses } from "../utils.js"; 2 | import { IPoolData, IDict } from "../../interfaces.js"; 3 | 4 | export const POOLS_DATA_SONIC: IDict = lowerCasePoolDataAddresses({}); -------------------------------------------------------------------------------- /src/constants/pools/xlayer.ts: -------------------------------------------------------------------------------- 1 | import { lowerCasePoolDataAddresses } from "../utils.js"; 2 | import { IPoolData, IDict } from "../../interfaces.js"; 3 | 4 | export const POOLS_DATA_XLAYER: IDict = lowerCasePoolDataAddresses({}); -------------------------------------------------------------------------------- /src/constants/pools/zksync.ts: -------------------------------------------------------------------------------- 1 | import { lowerCasePoolDataAddresses } from "../utils.js"; 2 | import { IPoolData, IDict } from "../../interfaces.js"; 3 | 4 | export const POOLS_DATA_ZKSYNC: IDict = lowerCasePoolDataAddresses({}); 5 | -------------------------------------------------------------------------------- /src/constants/utils.ts: -------------------------------------------------------------------------------- 1 | import {IDict, IPoolData} from "../interfaces.js"; 2 | import {BigNumberish, ethers, Numeric} from "ethers"; 3 | import memoize from "memoizee"; 4 | import {Curve} from "../curve"; 5 | 6 | export const formatUnits = (value: BigNumberish, unit?: string | Numeric): string => ethers.formatUnits(value, unit); 7 | export const parseUnits = (value: string, unit?: string | Numeric) => ethers.parseUnits(value, unit) 8 | 9 | export const lowerCasePoolDataAddresses = (poolsData: IDict): IDict => { 10 | for (const poolId in poolsData) { 11 | if (!Object.prototype.hasOwnProperty.call(poolsData, poolId)) continue; 12 | const poolData = poolsData[poolId]; 13 | poolData.swap_address = poolData.swap_address.toLowerCase(); 14 | poolData.token_address = poolData.token_address.toLowerCase(); 15 | poolData.gauge_address = poolData.gauge_address.toLowerCase(); 16 | if (poolData.deposit_address) poolData.deposit_address = poolData.deposit_address.toLowerCase(); 17 | if (poolData.sCurveRewards_address) poolData.sCurveRewards_address = poolData.sCurveRewards_address.toLowerCase(); 18 | if (poolData.reward_contract) poolData.reward_contract = poolData.reward_contract.toLowerCase(); 19 | poolData.underlying_coin_addresses = poolData.underlying_coin_addresses.map((a) => a.toLowerCase()); 20 | poolData.wrapped_coin_addresses = poolData.wrapped_coin_addresses.map((a) => a.toLowerCase()); 21 | } 22 | 23 | return poolsData 24 | } 25 | 26 | export const extractDecimals = (poolsData: IDict): IDict => { 27 | const DECIMALS: IDict = {}; 28 | for (const poolId in poolsData) { 29 | if (!Object.prototype.hasOwnProperty.call(poolsData, poolId)) continue; 30 | const poolData = poolsData[poolId]; 31 | 32 | // LP token 33 | DECIMALS[poolData.token_address] = 18; 34 | 35 | // Underlying coins 36 | for (let i = 0; i < poolData.underlying_coin_addresses.length; i++) { 37 | DECIMALS[poolData.underlying_coin_addresses[i]] = poolData.underlying_decimals[i]; 38 | } 39 | 40 | // Wrapped coins 41 | for (let i = 0; i < poolData.wrapped_coin_addresses.length; i++) { 42 | DECIMALS[poolData.wrapped_coin_addresses[i]] = poolData.wrapped_decimals[i]; 43 | } 44 | } 45 | 46 | return DECIMALS; 47 | } 48 | 49 | export function extractGauges(this: Curve, poolsData: IDict): string[] { 50 | const GAUGES: string[] = []; 51 | for (const poolData of Object.values(poolsData)) { 52 | if (poolData.gauge_address === this.constants.ZERO_ADDRESS) continue; 53 | GAUGES.push(poolData.gauge_address); 54 | } 55 | 56 | return GAUGES; 57 | } 58 | 59 | export const lowerCaseValues = (dict: IDict): IDict => { 60 | return Object.fromEntries(Object.entries(dict).map((entry) => [entry[0], entry[1].toLowerCase()])) 61 | } 62 | 63 | export const lowerCaseKeys = (dict: IDict): IDict => { 64 | return Object.fromEntries(Object.entries(dict).map((entry) => [entry[0].toLowerCase(), entry[1]])) 65 | } 66 | 67 | /** 68 | * Memoizes a method of an object by binding it to this when needed. 69 | * The memoized method will cache the result for 5 minutes. 70 | * @param obj The object to which the method belongs. 71 | * @param name The name of the method to memoize. It must be unique within the object. 72 | * @param method The method to memoize. It must be a function that returns a Promise. 73 | * @returns The memoized method. 74 | */ 75 | export const memoizeMethod = Promise>(obj: Obj, name: string, method: Method) => { 76 | if (!(name in obj)) { 77 | (obj as any)[name] = memoize(method.bind(obj), { promise: true, maxAge: 5 * 60 * 1000 /* 5m */ }); 78 | } 79 | return (obj as any)[name] as Method; 80 | } 81 | -------------------------------------------------------------------------------- /src/constants/volumeNetworks.ts: -------------------------------------------------------------------------------- 1 | import {IChainId} from "../interfaces"; 2 | 3 | export interface IVolumeNetworks { 4 | getVolumes: IChainId[]; 5 | getSubgraphData: IChainId[]; 6 | getFactoryAPYs: IChainId[]; 7 | } 8 | 9 | export const volumeNetworks: IVolumeNetworks = { 10 | getVolumes: [1,10,100,137,250,252,999,8453,42161,146], 11 | getSubgraphData: [43114], 12 | getFactoryAPYs: [56,196,324,1284,2222,5000,42220,1313161554], 13 | } -------------------------------------------------------------------------------- /src/factory/common.ts: -------------------------------------------------------------------------------- 1 | import { ICurve, IPoolDataShort } from "../interfaces"; 2 | import { getPoolIdBySwapAddress } from "../utils.js"; 3 | import {Curve} from "../curve"; 4 | 5 | export function setFactoryZapContracts(this: ICurve, isCrypto: boolean): void { 6 | const basePoolIdZapDict = (isCrypto ? this.constants.CRYPTO_FACTORY_CONSTANTS : this.constants.STABLE_FACTORY_CONSTANTS).basePoolIdZapDict ?? {}; 7 | for (const basePoolId in basePoolIdZapDict) { 8 | if (!Object.prototype.hasOwnProperty.call(basePoolIdZapDict, basePoolId)) continue; 9 | const basePool = basePoolIdZapDict[basePoolId]; 10 | 11 | if(basePool.address in this.constants) continue; 12 | 13 | this.setContract(basePool.address, basePool.ABI); 14 | } 15 | } 16 | 17 | export function getPoolIdByAddress(this: Curve, poolList: IPoolDataShort[] , address: string): string { 18 | const pool = poolList.find((item) => item.address.toLowerCase() === address.toLowerCase()) 19 | if(pool) { 20 | return pool.id; 21 | } else { 22 | return getPoolIdBySwapAddress.call(this, address.toLowerCase()) 23 | } 24 | } -------------------------------------------------------------------------------- /src/pools/index.ts: -------------------------------------------------------------------------------- 1 | import { getPool } from "./poolConstructor.js"; 2 | import { PoolTemplate } from "./PoolTemplate.js"; 3 | 4 | export { 5 | getPool, 6 | PoolTemplate, 7 | }; -------------------------------------------------------------------------------- /src/pools/mixins/common.ts: -------------------------------------------------------------------------------- 1 | import BigNumber from "bignumber.js"; 2 | import { PoolTemplate } from "../PoolTemplate.js"; 3 | import { fromBN, toBN } from "../../utils.js"; 4 | 5 | export async function _calcExpectedAmounts(this: PoolTemplate, _lpTokenAmount: bigint): Promise { 6 | const {curve} = this 7 | const coinBalancesBN: BigNumber[] = []; 8 | for (let i = 0; i < this.wrappedCoinAddresses.length; i++) { 9 | const _balance: bigint = await curve.contracts[this.address].contract.balances(i, curve.constantOptions); 10 | coinBalancesBN.push(toBN(_balance, this.wrappedDecimals[i])); 11 | } 12 | const totalSupplyBN: BigNumber = toBN(await curve.contracts[this.lpToken].contract.totalSupply(curve.constantOptions)); 13 | 14 | const expectedAmountsBN: BigNumber[] = []; 15 | for (const coinBalance of coinBalancesBN) { 16 | expectedAmountsBN.push(coinBalance.times(toBN(_lpTokenAmount)).div(totalSupplyBN)); 17 | } 18 | 19 | return expectedAmountsBN.map((amount: BigNumber, i: number) => fromBN(amount, this.wrappedDecimals[i])); 20 | } 21 | 22 | export async function _calcExpectedUnderlyingAmountsMeta(this: PoolTemplate, _lpTokenAmount: bigint): Promise { 23 | const _expectedWrappedAmounts = await _calcExpectedAmounts.call(this, _lpTokenAmount); 24 | const [_expectedMetaCoinAmount] = _expectedWrappedAmounts.splice(this.metaCoinIdx, 1); 25 | const _expectedUnderlyingAmounts = _expectedWrappedAmounts; 26 | const basePool = new PoolTemplate(this.basePool, this.curve); 27 | const _basePoolExpectedAmounts = basePool.isMeta ? 28 | await _calcExpectedUnderlyingAmountsMeta.call(basePool, _expectedMetaCoinAmount) : 29 | await _calcExpectedAmounts.call(basePool, _expectedMetaCoinAmount); 30 | _expectedUnderlyingAmounts.splice(this.metaCoinIdx, 0, ..._basePoolExpectedAmounts); 31 | 32 | return _expectedUnderlyingAmounts; 33 | } 34 | -------------------------------------------------------------------------------- /src/pools/mixins/depositBalancedAmountsMixins.ts: -------------------------------------------------------------------------------- 1 | import BigNumber from 'bignumber.js'; 2 | import { PoolTemplate } from "../PoolTemplate.js"; 3 | import { BN } from "../../utils.js"; 4 | 5 | 6 | function _depositBalancedAmounts(poolBalances: string[], walletBalances: string[], decimals: number[]): string[] { 7 | const poolBalancesBN = poolBalances.map(BN); 8 | const walletBalancesBN = walletBalances.map(BN); 9 | const poolTotalLiquidityBN = poolBalancesBN.reduce((a,b) => a.plus(b)); 10 | const poolBalancesRatiosBN = poolBalancesBN.map((b) => b.div(poolTotalLiquidityBN)); 11 | // Cross factors for each wallet balance used as reference to see the 12 | // max that can be used according to the lowest relative wallet balance 13 | const balancedAmountsForEachScenarioBN = walletBalancesBN.map((_, i) => ( 14 | walletBalancesBN.map((_, j) => ( 15 | poolBalancesRatiosBN[j].times(walletBalancesBN[i]).div(poolBalancesRatiosBN[i]) 16 | )) 17 | )); 18 | const firstCoinBalanceForEachScenarioBN = balancedAmountsForEachScenarioBN.map(([a]) => a); 19 | 20 | // get the scenario with the lowest balances, ignoring scenarios where the wallet balance is zero 21 | const nonZeroBalances = firstCoinBalanceForEachScenarioBN.filter((b) => !b.isZero()); 22 | if (nonZeroBalances.length === 0) { 23 | return poolBalances.map(() => "0") // no balances at all, return zeroes 24 | } 25 | const min = BigNumber.min(...nonZeroBalances); 26 | const scenarioWithLowestBalancesBN = firstCoinBalanceForEachScenarioBN.map(String).indexOf(min.toString()); 27 | 28 | const bestScenario = balancedAmountsForEachScenarioBN[scenarioWithLowestBalancesBN]; 29 | return bestScenario.map((a, i) => walletBalancesBN[i].isZero() ? "0" : a.toFixed(decimals[i])) 30 | } 31 | 32 | export const depositBalancedAmountsMixin = { 33 | async depositBalancedAmounts(this: PoolTemplate): Promise { 34 | const poolBalances = await this.stats.underlyingBalances(); 35 | const walletBalances = Object.values(await this.wallet.underlyingCoinBalances()); 36 | const balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals)); 37 | 38 | return balancedAmountsBN.map((b, i) => BigNumber.min(BN(b), BN(walletBalances[i])).toString()); 39 | }, 40 | } 41 | 42 | export const depositBalancedAmountsCryptoMixin = { 43 | async depositBalancedAmounts(this: PoolTemplate): Promise { 44 | const poolBalances = await this.stats.underlyingBalances(); 45 | const walletBalances = Object.values(await this.wallet.underlyingCoinBalances()); 46 | const prices = await this._underlyingPrices(); 47 | const poolBalancesUSD = poolBalances.map((b, i) => BN(b).times(prices[i]).toString()); 48 | const walletBalancesUSD = walletBalances.map((b, i) => BN(b).times(prices[i]).toString()); 49 | const balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.underlyingDecimals); 50 | 51 | return balancedAmountsUSD.map((b, i) => BigNumber.min(BN(BN(b).div(prices[i]).toFixed(this.underlyingDecimals[i])), BN(walletBalances[i])).toString()); 52 | }, 53 | } 54 | 55 | export const depositWrappedBalancedAmountsMixin = { 56 | async depositWrappedBalancedAmounts(this: PoolTemplate): Promise { 57 | const poolBalances = await this.stats.wrappedBalances(); 58 | const walletBalances = Object.values(await this.wallet.wrappedCoinBalances()); 59 | const balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals)); 60 | 61 | return balancedAmountsBN.map((b, i) => BigNumber.min(BN(b), BN(walletBalances[i])).toString()); 62 | }, 63 | } 64 | 65 | export const depositWrappedBalancedAmountsCryptoMixin = { 66 | async depositWrappedBalancedAmounts(this: PoolTemplate): Promise { 67 | const poolBalances = (await this.stats.wrappedBalances()).map(Number); 68 | const walletBalances = Object.values(await this.wallet.wrappedCoinBalances()).map(Number); 69 | const prices = await this._wrappedPrices(); 70 | const poolBalancesUSD = poolBalances.map((b, i) => BN(b).times(prices[i]).toString()); 71 | const walletBalancesUSD = walletBalances.map((b, i) => BN(b).times(prices[i]).toString()); 72 | const balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.wrappedDecimals); 73 | 74 | return balancedAmountsUSD.map((b, i) => BigNumber.min(BN(BN(b).div(prices[i]).toFixed(this.wrappedDecimals[i])), BN(walletBalances[i])).toString()); 75 | }, 76 | } 77 | -------------------------------------------------------------------------------- /src/pools/mixins/poolBalancesMixin.ts: -------------------------------------------------------------------------------- 1 | import { PoolTemplate } from "../PoolTemplate.js"; 2 | import { _calcExpectedAmounts, _calcExpectedUnderlyingAmountsMeta } from "./common.js"; 3 | import {IStatsPool} from "../subClasses/statsPool"; 4 | 5 | 6 | export const poolBalancesMetaMixin = { 7 | async underlyingBalances(this: IStatsPool): Promise { 8 | const curve = this.pool.curve; 9 | const swapContract = curve.contracts[this.pool.address].multicallContract; 10 | const contractCalls = this.pool.wrappedCoins.map((_, i) => swapContract.balances(i)); 11 | const _poolWrappedBalances: bigint[] = await curve.multicallProvider.all(contractCalls); 12 | const [_poolMetaCoinBalance] = _poolWrappedBalances.splice(this.pool.metaCoinIdx, 1); 13 | const _poolUnderlyingBalances = _poolWrappedBalances; 14 | const basePool = new PoolTemplate(this.pool.basePool, curve); 15 | const _basePoolExpectedAmounts = basePool.isMeta ? 16 | await _calcExpectedUnderlyingAmountsMeta.call(basePool, _poolMetaCoinBalance) : 17 | await _calcExpectedAmounts.call(basePool, _poolMetaCoinBalance); 18 | _poolUnderlyingBalances.splice(this.pool.metaCoinIdx, 0, ..._basePoolExpectedAmounts); 19 | 20 | return _poolUnderlyingBalances.map((_b: bigint, i: number) => curve.formatUnits(_b, this.pool.underlyingDecimals[i])) 21 | }, 22 | } 23 | 24 | export const poolBalancesLendingMixin = { 25 | async underlyingBalances(this: IStatsPool): Promise { 26 | const curve = this.pool.curve; 27 | const swapContract = curve.contracts[this.pool.address].multicallContract; 28 | const contractCalls = this.pool.wrappedCoins.map((_, i) => swapContract.balances(i)); 29 | const _poolWrappedBalances: bigint[] = await curve.multicallProvider.all(contractCalls); 30 | 31 | const _rates: bigint[] = await this.pool._getRates(); 32 | const _poolUnderlyingBalances = _poolWrappedBalances.map( 33 | (_b: bigint, i: number) => _b * _rates[i] / curve.parseUnits(String(10**18), 0)); 34 | 35 | return _poolUnderlyingBalances.map((_b: bigint, i: number) => curve.formatUnits(_b, this.pool.underlyingDecimals[i])) 36 | }, 37 | } 38 | -------------------------------------------------------------------------------- /src/pools/mixins/withdrawExpectedMixins.ts: -------------------------------------------------------------------------------- 1 | import { PoolTemplate } from "../PoolTemplate.js"; 2 | import { parseUnits } from "../../utils.js"; 3 | import { _calcExpectedAmounts, _calcExpectedUnderlyingAmountsMeta } from "./common.js"; 4 | import {formatUnits} from "../../constants/utils"; 5 | 6 | export const withdrawExpectedMixin = { 7 | async withdrawExpected(this: PoolTemplate, lpTokenAmount: number | string): Promise { 8 | const _lpTokenAmount = parseUnits(lpTokenAmount); 9 | const _expected = await _calcExpectedAmounts.call(this, _lpTokenAmount); 10 | return _expected.map((amount: bigint, i: number) => formatUnits(amount, this.underlyingDecimals[i])); 11 | }, 12 | } 13 | 14 | export const withdrawExpectedLendingOrCryptoMixin = { 15 | async withdrawExpected(this: PoolTemplate, lpTokenAmount: number | string): Promise { 16 | const _lpTokenAmount = parseUnits(lpTokenAmount); 17 | const _expectedAmounts = await _calcExpectedAmounts.call(this, _lpTokenAmount); 18 | const _rates: bigint[] = await this._getRates(); 19 | const _expected = _expectedAmounts.map((_amount: bigint, i: number) => _amount * _rates[i] / parseUnits(String(10**18), 0)); 20 | 21 | return _expected.map((amount: bigint, i: number) => formatUnits(amount, this.underlyingDecimals[i])); 22 | }, 23 | } 24 | 25 | export const withdrawExpectedMetaMixin = { 26 | async withdrawExpected(this: PoolTemplate, lpTokenAmount: number | string): Promise { 27 | const _lpTokenAmount = parseUnits(lpTokenAmount); 28 | const _expected = await _calcExpectedUnderlyingAmountsMeta.call(this, _lpTokenAmount) 29 | 30 | return _expected.map((amount: bigint, i: number) => formatUnits(amount, this.underlyingDecimals[i])); 31 | }, 32 | } 33 | 34 | export const withdrawWrappedExpectedMixin = { 35 | async withdrawWrappedExpected(this: PoolTemplate, lpTokenAmount: number | string): Promise { 36 | const _lpTokenAmount = parseUnits(lpTokenAmount); 37 | const _expected = await _calcExpectedAmounts.call(this, _lpTokenAmount) 38 | return _expected.map((amount: bigint, i: number) => formatUnits(amount, this.wrappedDecimals[i])); 39 | }, 40 | } -------------------------------------------------------------------------------- /src/pools/mixins/withdrawImbalanceWrappedMixins.ts: -------------------------------------------------------------------------------- 1 | import { PoolTemplate } from "../PoolTemplate.js"; 2 | import { fromBN, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js'; 3 | 4 | async function _withdrawImbalanceWrappedCheck(this: PoolTemplate, amounts: (number | string)[]): Promise { 5 | const lpTokenAmount = await this.withdrawImbalanceWrappedExpected(amounts); 6 | const lpTokenBalance = (await this.wallet.lpTokenBalances())['lpToken']; 7 | if (Number(lpTokenBalance) < Number(lpTokenAmount)) { 8 | throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`); 9 | } 10 | 11 | await this.curve.updateFeeData(); 12 | 13 | return amounts.map((amount, i) => parseUnits(amount, this.wrappedDecimals[i])); 14 | } 15 | 16 | async function _withdrawImbalanceWrappedMaxBurnAmount(this: PoolTemplate, _amounts: bigint[], slippage = 0.5): Promise { 17 | const _expectedLpTokenAmount = await this._calcLpTokenAmount(_amounts, false, false); 18 | const maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100); 19 | 20 | return fromBN(maxBurnAmountBN); 21 | } 22 | 23 | export const withdrawImbalanceWrapped2argsMixin = { 24 | async _withdrawImbalanceWrapped(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas = false): Promise { 25 | const _maxBurnAmount = await _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage); 26 | const contract = this.curve.contracts[this.address].contract; 27 | 28 | const gas = await contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, this.curve.constantOptions); 29 | if (estimateGas) return smartNumber(gas); 30 | 31 | const gasLimit = mulBy1_3(DIGas(gas)); 32 | return (await contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, { ...this.curve.options, gasLimit })).hash; 33 | }, 34 | 35 | async withdrawImbalanceWrappedEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise { 36 | const _amounts = await _withdrawImbalanceWrappedCheck.call(this, amounts); 37 | return await withdrawImbalanceWrapped2argsMixin._withdrawImbalanceWrapped.call(this, _amounts, 0.1, true) as number; 38 | }, 39 | 40 | async withdrawImbalanceWrapped(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise { 41 | const _amounts = await _withdrawImbalanceWrappedCheck.call(this, amounts); 42 | return await withdrawImbalanceWrapped2argsMixin._withdrawImbalanceWrapped.call(this, _amounts, slippage) as string; 43 | }, 44 | } 45 | 46 | export const withdrawImbalanceWrapped3argsMixin = { 47 | async _withdrawImbalanceWrapped(this: PoolTemplate, _amounts: bigint[], slippage?: number, estimateGas = false): Promise { 48 | const _maxBurnAmount = await _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage); 49 | const contract = this.curve.contracts[this.address].contract; 50 | 51 | const gas = await contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, false, this.curve.constantOptions); 52 | if (estimateGas) return smartNumber(gas); 53 | 54 | const gasLimit = this.curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * this.curve.parseUnits("140", 0) / this.curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas)); 55 | return (await contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, false, { ...this.curve.options, gasLimit })).hash; 56 | }, 57 | 58 | async withdrawImbalanceWrappedEstimateGas(this: PoolTemplate, amounts: (number | string)[]): Promise { 59 | const _amounts = await _withdrawImbalanceWrappedCheck.call(this, amounts); 60 | return await withdrawImbalanceWrapped3argsMixin._withdrawImbalanceWrapped.call(this, _amounts, 0.1, true) as number; 61 | }, 62 | 63 | async withdrawImbalanceWrapped(this: PoolTemplate, amounts: (number | string)[], slippage?: number): Promise { 64 | const _amounts = await _withdrawImbalanceWrappedCheck.call(this, amounts); 65 | return await withdrawImbalanceWrapped3argsMixin._withdrawImbalanceWrapped.call(this, _amounts, slippage) as string; 66 | }, 67 | } 68 | -------------------------------------------------------------------------------- /src/pools/mixins/withdrawOneCoinExpectedMixins.ts: -------------------------------------------------------------------------------- 1 | import {PoolTemplate} from "../PoolTemplate.js"; 2 | 3 | export const withdrawOneCoinExpectedMetaFactoryMixin = { 4 | async _withdrawOneCoinExpected(this: PoolTemplate,_lpTokenAmount: bigint, i: number): Promise { 5 | const contract = this.curve.contracts[this.zap as string].contract; 6 | return await contract.calc_withdraw_one_coin(this.address, _lpTokenAmount, i, this.curve.constantOptions); 7 | }, 8 | } 9 | 10 | export const withdrawOneCoinExpectedZapMixin = { 11 | async _withdrawOneCoinExpected(this: PoolTemplate,_lpTokenAmount: bigint, i: number): Promise { 12 | const contract = this.curve.contracts[this.zap as string].contract; 13 | return await contract.calc_withdraw_one_coin(_lpTokenAmount, i, this.curve.constantOptions); 14 | }, 15 | } 16 | 17 | export const withdrawOneCoinExpected3argsMixin = { 18 | async _withdrawOneCoinExpected(this: PoolTemplate,_lpTokenAmount: bigint, i: number): Promise { 19 | const contract = this.curve.contracts[this.address].contract; 20 | return await contract.calc_withdraw_one_coin(_lpTokenAmount, i, true, this.curve.constantOptions); 21 | }, 22 | } 23 | 24 | export const withdrawOneCoinExpected2argsMixin = { 25 | async _withdrawOneCoinExpected(this: PoolTemplate,_lpTokenAmount: bigint, i: number): Promise { 26 | const contract = this.curve.contracts[this.address].contract; 27 | return await contract.calc_withdraw_one_coin(_lpTokenAmount, i, this.curve.constantOptions); 28 | }, 29 | } -------------------------------------------------------------------------------- /src/pools/mixins/withdrawOneCoinWrappedExpectedMixins.ts: -------------------------------------------------------------------------------- 1 | import {PoolTemplate} from "../PoolTemplate.js"; 2 | 3 | export const withdrawOneCoinWrappedExpected2argsMixin = { 4 | async _withdrawOneCoinWrappedExpected(this: PoolTemplate, _lpTokenAmount: bigint, i: number): Promise { 5 | const contract = this.curve.contracts[this.address].contract; 6 | return await contract.calc_withdraw_one_coin(_lpTokenAmount, i, this.curve.constantOptions); 7 | }, 8 | } 9 | 10 | export const withdrawOneCoinWrappedExpected3argsMixin = { 11 | async _withdrawOneCoinWrappedExpected(this: PoolTemplate, _lpTokenAmount: bigint, i: number): Promise { 12 | const contract = this.curve.contracts[this.address].contract; 13 | return await contract.calc_withdraw_one_coin(_lpTokenAmount, i, false, this.curve.constantOptions); 14 | }, 15 | } -------------------------------------------------------------------------------- /src/pools/mixins/withdrawOneCoinWrappedMixins.ts: -------------------------------------------------------------------------------- 1 | import {PoolTemplate} from "../PoolTemplate.js"; 2 | import {DIGas, fromBN, mulBy1_3, parseUnits, smartNumber, toBN} from '../../utils.js'; 3 | 4 | async function _withdrawOneCoinWrappedCheck(this: PoolTemplate, lpTokenAmount: number | string, coin: string | number): 5 | Promise<[bigint, number]> 6 | { 7 | const lpTokenBalance = (await this.wallet.lpTokenBalances())['lpToken']; 8 | if (Number(lpTokenBalance) < Number(lpTokenAmount)) { 9 | throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`); 10 | } 11 | 12 | await this.curve.updateFeeData(); 13 | 14 | const i = this._getCoinIdx(coin, false); 15 | const _lpTokenAmount = parseUnits(lpTokenAmount); 16 | 17 | return [_lpTokenAmount, i]; 18 | } 19 | 20 | async function _withdrawOneCoinWrappedMinAmount(this: PoolTemplate, _lpTokenAmount: bigint, i: number, slippage = 0.5): Promise { 21 | const _expectedLpTokenAmount = await this._withdrawOneCoinWrappedExpected(_lpTokenAmount, i); 22 | const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100); 23 | 24 | return fromBN(minAmountBN); 25 | } 26 | 27 | export const withdrawOneCoinWrappedLendingOrCryptoMixin = { 28 | async _withdrawOneCoinWrapped(this: PoolTemplate, _lpTokenAmount: bigint, i: number, slippage?: number, estimateGas = false): Promise { 29 | const _minAmount = await _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage); 30 | const contract = this.curve.contracts[this.address].contract; 31 | 32 | const gas = await contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, false, this.curve.constantOptions); 33 | if (estimateGas) return smartNumber(gas); 34 | 35 | const gasLimit = this.curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * this.curve.parseUnits("160", 0) / this.curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas)); 36 | return (await contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, false, { ...this.curve.options, gasLimit })).hash 37 | }, 38 | 39 | async withdrawOneCoinWrappedEstimateGas(this: PoolTemplate, lpTokenAmount: number | string, coin: string | number): Promise { 40 | const [_lpTokenAmount, i] = await _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin); 41 | return await withdrawOneCoinWrappedLendingOrCryptoMixin._withdrawOneCoinWrapped.call(this, _lpTokenAmount, i, 0.1, true) as number; 42 | }, 43 | 44 | async withdrawOneCoinWrapped(this: PoolTemplate, lpTokenAmount: number | string, coin: string | number, slippage?: number): Promise { 45 | const [_lpTokenAmount, i] = await _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin); 46 | return await withdrawOneCoinWrappedLendingOrCryptoMixin._withdrawOneCoinWrapped.call(this, _lpTokenAmount, i, slippage) as string; 47 | }, 48 | } 49 | 50 | export const withdrawOneCoinWrappedMixin = { 51 | async _withdrawOneCoinWrapped(this: PoolTemplate, _lpTokenAmount: bigint, i: number, slippage?: number, estimateGas = false): Promise { 52 | const _minAmount = await _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage); 53 | const contract = this.curve.contracts[this.address].contract; 54 | 55 | const gas = await contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, this.curve.constantOptions); 56 | if (estimateGas) return smartNumber(gas); 57 | 58 | const gasLimit = mulBy1_3(DIGas(gas)); 59 | return (await contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, { ...this.curve.options, gasLimit })).hash 60 | }, 61 | 62 | async withdrawOneCoinWrappedEstimateGas(this: PoolTemplate, lpTokenAmount: number | string, coin: string | number): Promise { 63 | const [_lpTokenAmount, i] = await _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin); 64 | return await withdrawOneCoinWrappedMixin._withdrawOneCoinWrapped.call(this, _lpTokenAmount, i, 0.1, true) as number; 65 | }, 66 | 67 | async withdrawOneCoinWrapped(this: PoolTemplate, lpTokenAmount: number | string, coin: string | number, slippage?: number): Promise { 68 | const [_lpTokenAmount, i] = await _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin); 69 | return await withdrawOneCoinWrappedMixin._withdrawOneCoinWrapped.call(this, _lpTokenAmount, i, slippage) as string; 70 | }, 71 | } -------------------------------------------------------------------------------- /src/pools/mixins/withdrawWrappedMixins.ts: -------------------------------------------------------------------------------- 1 | import {PoolTemplate} from "../PoolTemplate.js"; 2 | import {DIGas, fromBN, mulBy1_3, parseUnits, smartNumber, toBN} from '../../utils.js'; 3 | 4 | async function _withdrawWrappedCheck(this: PoolTemplate, lpTokenAmount: number | string): Promise { 5 | const lpTokenBalance = (await this.wallet.lpTokenBalances())['lpToken']; 6 | if (Number(lpTokenBalance) < Number(lpTokenAmount)) { 7 | throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`); 8 | } 9 | 10 | await this.curve.updateFeeData(); 11 | 12 | return parseUnits(lpTokenAmount); 13 | } 14 | 15 | async function _withdrawWrappedMinAmounts(this: PoolTemplate, _lpTokenAmount: bigint, slippage = 0.5): Promise { 16 | const expectedAmounts = await this.withdrawWrappedExpected(this.curve.formatUnits(_lpTokenAmount)); 17 | const _expectedAmounts = expectedAmounts.map((a, i) => this.curve.parseUnits(a, this.wrappedDecimals[i])); 18 | const minRecvAmountsBN = _expectedAmounts.map((_a, i) => toBN(_a, this.wrappedDecimals[i]).times(100 - slippage).div(100)); 19 | 20 | return minRecvAmountsBN.map((a, i) => fromBN(a, this.wrappedDecimals[i])); 21 | } 22 | 23 | export const withdrawWrapped2argsMixin = { 24 | async _withdrawWrapped(this: PoolTemplate, _lpTokenAmount: bigint, slippage?: number, estimateGas = false): Promise { 25 | const _minAmounts = await _withdrawWrappedMinAmounts.call(this, _lpTokenAmount, slippage); 26 | const contract = this.curve.contracts[this.address].contract; 27 | 28 | const gas = await contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, this.curve.constantOptions); 29 | if (estimateGas) return smartNumber(gas); 30 | 31 | const gasLimit = mulBy1_3(DIGas(gas)); 32 | return (await contract.remove_liquidity(_lpTokenAmount, _minAmounts, { ...this.curve.options, gasLimit })).hash; 33 | }, 34 | 35 | async withdrawWrappedEstimateGas(this: PoolTemplate, lpTokenAmount: number | string): Promise { 36 | const _lpTokenAmount = await _withdrawWrappedCheck.call(this, lpTokenAmount); 37 | return await withdrawWrapped2argsMixin._withdrawWrapped.call(this, _lpTokenAmount, 0.1, true) as number; 38 | }, 39 | 40 | async withdrawWrapped(this: PoolTemplate, lpTokenAmount: number | string, slippage?: number): Promise { 41 | const _lpTokenAmount = await _withdrawWrappedCheck.call(this, lpTokenAmount); 42 | return await withdrawWrapped2argsMixin._withdrawWrapped.call(this, _lpTokenAmount, slippage) as string; 43 | }, 44 | } 45 | 46 | export const withdrawWrapped3argsMixin = { 47 | async _withdrawWrapped(this: PoolTemplate, _lpTokenAmount: bigint, slippage?: number, estimateGas = false): Promise { 48 | const _minAmounts = await _withdrawWrappedMinAmounts.call(this, _lpTokenAmount, slippage); 49 | const contract = this.curve.contracts[this.address].contract; 50 | 51 | const gas = await contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, false, this.curve.constantOptions); 52 | if (estimateGas) return smartNumber(gas); 53 | 54 | const gasLimit = mulBy1_3(DIGas(gas)); 55 | return (await contract.remove_liquidity(_lpTokenAmount, _minAmounts, false, { ...this.curve.options, gasLimit })).hash; 56 | }, 57 | 58 | async withdrawWrappedEstimateGas(this: PoolTemplate, lpTokenAmount: number | string): Promise { 59 | const _lpTokenAmount = await _withdrawWrappedCheck.call(this, lpTokenAmount); 60 | return await withdrawWrapped3argsMixin._withdrawWrapped.call(this, _lpTokenAmount, 0.1, true) as number; 61 | }, 62 | 63 | async withdrawWrapped(this: PoolTemplate, lpTokenAmount: number | string, slippage?: number): Promise { 64 | const _lpTokenAmount = await _withdrawWrappedCheck.call(this, lpTokenAmount); 65 | return await withdrawWrapped3argsMixin._withdrawWrapped.call(this, _lpTokenAmount, slippage) as string; 66 | }, 67 | } -------------------------------------------------------------------------------- /src/pools/subClasses/corePool.ts: -------------------------------------------------------------------------------- 1 | import {type Curve} from "../../curve.js"; 2 | import {GaugePool, IGaugePool} from "./gaugePool.js"; 3 | import {IPoolData} from "../../interfaces"; 4 | 5 | export interface ICorePool { 6 | id: string; 7 | name: string; 8 | fullName: string; 9 | symbol: string; 10 | referenceAsset: string; 11 | address: string; 12 | lpToken: string; 13 | gauge: IGaugePool; 14 | zap: string | null; 15 | sRewardContract: string | null; 16 | rewardContract: string | null; 17 | implementation: string | null; 18 | isPlain: boolean; 19 | isLending: boolean; 20 | isMeta: boolean; 21 | isCrypto: boolean; 22 | isFake: boolean; 23 | isFactory: boolean; 24 | isMetaFactory: boolean; 25 | isNg: boolean; 26 | isLlamma: boolean; 27 | basePool: string; 28 | metaCoinIdx: number; 29 | underlyingCoins: string[]; 30 | wrappedCoins: string[]; 31 | underlyingCoinAddresses: string[]; 32 | wrappedCoinAddresses: string[]; 33 | underlyingDecimals: number[]; 34 | wrappedDecimals: number[]; 35 | useLending: boolean[]; 36 | inApi: boolean; 37 | } 38 | 39 | export class CorePool implements ICorePool { 40 | id: string; 41 | name: string; 42 | fullName: string; 43 | symbol: string; 44 | referenceAsset: string; 45 | address: string; 46 | lpToken: string; 47 | gauge: IGaugePool; 48 | zap: string | null; 49 | sRewardContract: string | null; 50 | rewardContract: string | null; 51 | implementation: string | null; 52 | isPlain: boolean; 53 | isLending: boolean; 54 | isMeta: boolean; 55 | isCrypto: boolean; 56 | isFake: boolean; 57 | isFactory: boolean; 58 | isMetaFactory: boolean; 59 | isNg: boolean; 60 | isLlamma: boolean; 61 | basePool: string; 62 | metaCoinIdx: number; 63 | underlyingCoins: string[]; 64 | wrappedCoins: string[]; 65 | underlyingCoinAddresses: string[]; 66 | wrappedCoinAddresses: string[]; 67 | underlyingDecimals: number[]; 68 | wrappedDecimals: number[]; 69 | useLending: boolean[]; 70 | inApi: boolean; 71 | 72 | constructor(id: string, poolData: IPoolData, readonly curve: Curve) { 73 | if (!poolData) { 74 | throw new Error(`Pool data is required for pool ${id}`); 75 | } 76 | this.id = id; 77 | this.name = poolData.name; 78 | this.fullName = poolData.full_name; 79 | this.symbol = poolData.symbol; 80 | this.referenceAsset = poolData.reference_asset; 81 | this.address = poolData.swap_address; 82 | this.lpToken = poolData.token_address; 83 | this.gauge = new GaugePool(poolData.gauge_address, poolData.name, curve); 84 | this.zap = poolData.deposit_address || null; 85 | this.sRewardContract = poolData.sCurveRewards_address || null; 86 | this.rewardContract = poolData.reward_contract || null; 87 | this.implementation = poolData.implementation_address || null; 88 | this.isPlain = poolData.is_plain || false; 89 | this.isLending = poolData.is_lending || false; 90 | this.isMeta = poolData.is_meta || false; 91 | this.isCrypto = poolData.is_crypto || false; 92 | this.isFake = poolData.is_fake || false; 93 | this.isFactory = poolData.is_factory || false; 94 | this.isMetaFactory = (this.isMeta && this.isFactory) || this.zap === '0xa79828df1850e8a3a3064576f380d90aecdd3359'; 95 | this.isNg = poolData.is_ng || false; 96 | this.isLlamma = poolData.is_llamma || false; 97 | this.basePool = poolData.base_pool || ''; 98 | this.metaCoinIdx = this.isMeta ? poolData.meta_coin_idx ?? poolData.wrapped_coins.length - 1 : -1; 99 | this.underlyingCoins = poolData.underlying_coins; 100 | this.wrappedCoins = poolData.wrapped_coins; 101 | this.underlyingCoinAddresses = poolData.underlying_coin_addresses; 102 | this.wrappedCoinAddresses = poolData.wrapped_coin_addresses; 103 | this.underlyingDecimals = poolData.underlying_decimals; 104 | this.wrappedDecimals = poolData.wrapped_decimals; 105 | this.useLending = poolData.use_lending || poolData.underlying_coin_addresses.map(() => false); 106 | this.inApi = poolData.in_api ?? false; 107 | } 108 | } 109 | 110 | -------------------------------------------------------------------------------- /src/pools/subClasses/walletPool.ts: -------------------------------------------------------------------------------- 1 | import {IDict} from '../../interfaces'; 2 | import { 3 | _prepareAddresses, 4 | _getBalances, 5 | } from '../../utils.js'; 6 | import {PoolTemplate} from "../PoolTemplate"; 7 | 8 | export interface IWalletPool { 9 | balances: (...addresses: string[] | string[][]) => Promise> | IDict>, 10 | lpTokenBalances: (...addresses: string[] | string[][]) => Promise> | IDict>, 11 | underlyingCoinBalances: (...addresses: string[] | string[][]) => Promise> | IDict>, 12 | wrappedCoinBalances: (...addresses: string[] | string[][]) => Promise> | IDict>, 13 | allCoinBalances: (...addresses: string[] | string[][]) => Promise> | IDict>, 14 | } 15 | 16 | export class WalletPool implements IWalletPool { 17 | private pool: PoolTemplate; 18 | 19 | constructor(pool: PoolTemplate, readonly curve = pool.curve) { 20 | this.pool = pool; 21 | } 22 | 23 | private _balances = async (rawCoinNames: string[], rawCoinAddresses: string[], ...addresses: string[] | string[][]): 24 | Promise> | IDict> => { 25 | const coinNames: string[] = []; 26 | const coinAddresses: string[] = []; 27 | // removing duplicates 28 | for (let i = 0; i < rawCoinAddresses.length; i++) { 29 | if (!coinAddresses.includes(rawCoinAddresses[i])) { 30 | coinNames.push(rawCoinNames[i]); 31 | coinAddresses.push(rawCoinAddresses[i]) 32 | } 33 | } 34 | 35 | addresses = _prepareAddresses.call(this.curve, addresses); 36 | const rawBalances: IDict = await _getBalances.call(this.curve, coinAddresses, addresses); 37 | 38 | const balances: IDict> = {}; 39 | for (const address of addresses) { 40 | balances[address] = {}; 41 | for (const coinName of coinNames) { 42 | balances[address][coinName] = rawBalances[address].shift() as string; 43 | } 44 | } 45 | 46 | return addresses.length === 1 ? balances[addresses[0]] : balances 47 | } 48 | 49 | public async balances(...addresses: string[] | string[][]): Promise> | IDict> { 50 | if (this.pool.gauge.address === this.curve.constants.ZERO_ADDRESS) { 51 | return await this._balances( 52 | ['lpToken', ...this.pool.underlyingCoinAddresses, ...this.pool.wrappedCoinAddresses], 53 | [this.pool.lpToken, ...this.pool.underlyingCoinAddresses, ...this.pool.wrappedCoinAddresses], 54 | ...addresses 55 | ); 56 | } else { 57 | return await this._balances( 58 | ['lpToken', 'gauge', ...this.pool.underlyingCoinAddresses, ...this.pool.wrappedCoinAddresses], 59 | [this.pool.lpToken, this.pool.gauge.address, ...this.pool.underlyingCoinAddresses, ...this.pool.wrappedCoinAddresses], 60 | ...addresses 61 | ); 62 | } 63 | } 64 | 65 | public async lpTokenBalances(...addresses: string[] | string[][]): Promise> | IDict> { 66 | if (this.pool.gauge.address === this.curve.constants.ZERO_ADDRESS) { 67 | return await this._balances(['lpToken'], [this.pool.lpToken], ...addresses); 68 | } else { 69 | return await this._balances(['lpToken', 'gauge'], [this.pool.lpToken, this.pool.gauge.address], ...addresses); 70 | } 71 | } 72 | 73 | public async underlyingCoinBalances(...addresses: string[] | string[][]): Promise> | IDict> { 74 | return await this._balances(this.pool.underlyingCoinAddresses, this.pool.underlyingCoinAddresses, ...addresses) 75 | } 76 | 77 | public async wrappedCoinBalances(...addresses: string[] | string[][]): Promise> | IDict> { 78 | return await this._balances(this.pool.wrappedCoinAddresses, this.pool.wrappedCoinAddresses, ...addresses) 79 | } 80 | 81 | public async allCoinBalances(...addresses: string[] | string[][]): Promise> | IDict> { 82 | return await this._balances( 83 | [...this.pool.underlyingCoinAddresses, ...this.pool.wrappedCoinAddresses], 84 | [...this.pool.underlyingCoinAddresses, ...this.pool.wrappedCoinAddresses], 85 | ...addresses 86 | ) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /test/apy.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import curve from "../src/index.js"; 3 | import { curve as _curve } from "../src/curve.js"; 4 | import { getPool, PoolTemplate } from "../src/pools/index.js"; 5 | import { IReward } from "../src/interfaces.js"; 6 | import { ETH_RPC, OPTIMISM_RPC, XDAI_RPC, POLYGON_RPC, FANTOM_RPC, MOONBEAM_RPC, KAVA_RPC, ARBITRUM_RPC, CELO_RPC, AVALANCHE_RPC, AURORA_RPC } from "./rpcUrls.test.js"; 7 | 8 | 9 | const poolStatsTest = (name: string) => { 10 | describe(`${name} apy test`, function () { 11 | this.timeout(120000); 12 | let pool: PoolTemplate; 13 | 14 | before(async function () { 15 | pool = getPool(name); 16 | }); 17 | 18 | 19 | it('Token (CRV) APY', async function () { 20 | if (pool.gauge.address === _curve.constants.ZERO_ADDRESS || pool.rewardsOnly()) return; 21 | 22 | const apy = await pool.stats.tokenApy(false); 23 | const apyFromApi = await pool.stats.tokenApy(); 24 | 25 | const diff = [ 26 | Math.abs(apyFromApi[0] - apy[0]) / Math.max(apyFromApi[0], apy[0]), 27 | Math.abs(apyFromApi[1] - apy[1]) / Math.max(apyFromApi[1], apy[1]), 28 | ]; 29 | console.log(apy[0], apyFromApi[0]); 30 | console.log(apy[1], apyFromApi[1]); 31 | diff[0] = isNaN(diff[0]) ? 0 : diff[0]; 32 | diff[1] = isNaN(diff[1]) ? 0 : diff[1]; 33 | 34 | assert.isAtMost(diff[0], 0.007, `${pool.id} BASE CRV APY. Calculated: ${apy[0]}, API: ${apyFromApi[0]}`); 35 | assert.isAtMost(diff[1], 0.007, `${pool.id} BOOSTED CRV APY. Calculated: ${apy[1]}, API: ${apyFromApi[1]}`); 36 | }); 37 | 38 | it('Rewards APY', async function () { 39 | if (pool.gauge.address === _curve.constants.ZERO_ADDRESS) return; 40 | 41 | const rewardsApy = (await pool.stats.rewardsApy(false)).filter((r) => r.apy > 0); 42 | const rewardsApyFromApi = (await pool.stats.rewardsApy()).filter((r) => r.apy > 0); 43 | 44 | assert.equal(rewardsApy.length, rewardsApyFromApi.length, 45 | `${pool.id} rewards doesn't match. Rewards: \n${rewardsApy}\n. Rewards from API: \n${rewardsApyFromApi}\n`); 46 | 47 | for (const reward of rewardsApy) { 48 | const rewardFromApiMatch = rewardsApyFromApi.find((r) => r.tokenAddress.toLowerCase() === reward.tokenAddress.toLowerCase()) as IReward; 49 | 50 | console.log(reward.apy, rewardFromApiMatch.apy); 51 | let diff = Math.abs(reward.apy - (rewardFromApiMatch as IReward).apy) / Math.max(reward.apy, (rewardFromApiMatch as IReward).apy); 52 | diff = isNaN(diff) ? 0 : diff; 53 | assert.isAtMost(diff, 0.03, `${pool.id} ${reward.symbol} reward. Calculated: ${reward.apy}, API: ${rewardFromApiMatch.apy}`); 54 | } 55 | }); 56 | }) 57 | } 58 | 59 | describe('Compare calculated APY with APY from API', async function () { 60 | this.timeout(120000); 61 | let POOLS: string[] = []; 62 | 63 | before(async function () { 64 | await curve.init('JsonRpc', { url: ETH_RPC }, { gasPrice: 0 }); 65 | await curve.factory.fetchPools(); 66 | await curve.cryptoFactory.fetchPools(); 67 | POOLS = curve.getPoolList(); 68 | }); 69 | 70 | it('', async function () { 71 | for (const poolName of POOLS) { 72 | poolStatsTest(poolName); 73 | } 74 | }); 75 | }) 76 | -------------------------------------------------------------------------------- /test/balancedAmounts.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import { getPool, PoolTemplate } from "../src/pools/index.js"; 3 | import curve from "../src/index.js"; 4 | 5 | 6 | // const PLAIN_POOLS = ['susd', 'ren', 'sbtc', '3pool', 'eurs', 'steth', 'ankreth', 'link', 'reth']; 7 | const PLAIN_POOLS = ['susd', 'ren', 'sbtc', '3pool', 'steth', 'ankreth', 'link', 'reth']; // Without eurs 8 | const LENDING_POOLS = ['compound', 'usdt', 'aave', 'saave', 'ib']; 9 | const META_POOLS = ['gusd', 'usdk', 'musd', 'rsv', 'tbtc', 'dusd', 'pbtc', 'bbtc', 'obtc', 'usdp', 'tusd', 'frax', 'lusd', 'busdv2', 'alusd', 'mim']; 10 | const FACTORY_CRYPTO_META_POOLS = ['factory-crypto-116', 'factory-crypto-97']; // ['DCHF/3CRV', 'cvxCrv/FraxBP']; 11 | 12 | const POLYGON_POOLS = ['aave', 'ren', 'atricrypto3', 'eurtusd']; 13 | 14 | const AVALANCHE_POOLS = ['aave', 'ren', 'atricrypto3', 'eurtusd']; 15 | 16 | const ARBITRUM_MAIN_POOLS = ['2pool', 'tricrypto', 'ren', 'eursusd']; 17 | const ARBITRUM_FACTORY_PLAIN_POOLS = ['factory-v2-15', 'factory-v2-29']; // ['deBridge-ETH', 'Aave aDAI+aUSC+aUSDT USDFACTORY']; 18 | const ARBITRUM_FACTORY_META_POOLS = ['factory-v2-0']; // ['MIM']; 19 | const ARBITRUM_POOLS = [...ARBITRUM_MAIN_POOLS, ...ARBITRUM_FACTORY_PLAIN_POOLS, ...ARBITRUM_FACTORY_META_POOLS]; 20 | 21 | const OPTIMISM_MAIN_POOLS = ['3pool']; 22 | const OPTIMISM_FACTORY_PLAIN_POOLS = ['factory-v2-10']; // ['sETH/ETH']; 23 | const OPTIMISM_FACTORY_META_POOLS = ['factory-v2-0']; // ['sUSD Synthetix']; 24 | const OPTIMISM_POOLS = [...OPTIMISM_MAIN_POOLS, ...OPTIMISM_FACTORY_PLAIN_POOLS, ...OPTIMISM_FACTORY_META_POOLS]; 25 | 26 | const XDAI_MAIN_POOLS = ['3pool', 'rai', 'tricrypto']; 27 | const XDAI_FACTORY_PLAIN_POOLS = ['factory-v2-0']; // ['sGNO/GNO']; 28 | const XDAI_FACTORY_META_POOLS = ['factory-v2-4']; // ['MAI Stablecoin']; 29 | const XDAI_POOLS = [...XDAI_MAIN_POOLS, ...XDAI_FACTORY_PLAIN_POOLS, ...XDAI_FACTORY_META_POOLS]; 30 | 31 | const MOONBEAM_MAIN_POOLS = ['3pool']; 32 | const MOONBEAM_FACTORY_PLAIN_POOLS = ['factory-v2-6']; // ['DAI Multi Nomad']; 33 | // const MOONBEAM_FACTORY_META_POOLS = ['factory-v2-4']; // ['MAI Stablecoin']; 34 | const MOONBEAM_POOLS = [...MOONBEAM_MAIN_POOLS, ...MOONBEAM_FACTORY_PLAIN_POOLS]; 35 | 36 | const AURORA_POOLS = ['3pool']; 37 | 38 | const KAVA_POOLS = ['factory-v2-0']; 39 | 40 | // ------------------------------------------------------------------------ 41 | 42 | const POOLS_FOR_TESTING = FACTORY_CRYPTO_META_POOLS; 43 | 44 | const balancedAmountsTest = (name: string) => { 45 | describe(`${name} balanced amounts`, function () { 46 | let pool: PoolTemplate; 47 | 48 | before(async function () { 49 | pool = getPool(name); 50 | }); 51 | 52 | it('underlying', async function () { 53 | const balancedAmounts = (await pool.depositBalancedAmounts()).map(Number); 54 | console.log(balancedAmounts); 55 | 56 | assert.equal(balancedAmounts.length, pool.underlyingCoins.length); 57 | for (const amount of balancedAmounts) { 58 | assert.isAbove(amount, 0); 59 | } 60 | }); 61 | 62 | it('wrapped', async function () { 63 | if (pool.isPlain || pool.isFake) { 64 | console.log('Skip'); 65 | return; 66 | } 67 | 68 | const balancedWrappedAmounts = (await pool.depositWrappedBalancedAmounts()).map(Number); 69 | console.log(balancedWrappedAmounts); 70 | 71 | assert.equal(balancedWrappedAmounts.length, pool.wrappedCoins.length); 72 | for (const amount of balancedWrappedAmounts) { 73 | assert.isAbove(amount, 0); 74 | } 75 | }); 76 | 77 | }); 78 | } 79 | 80 | describe('Underlying test', async function () { 81 | this.timeout(120000); 82 | 83 | before(async function () { 84 | await curve.init('JsonRpc', {},{ gasPrice: 0 }); 85 | await curve.factory.fetchPools(); 86 | await curve.cryptoFactory.fetchPools(); 87 | }); 88 | 89 | for (const poolId of POOLS_FOR_TESTING) { 90 | balancedAmountsTest(poolId); 91 | } 92 | }) 93 | -------------------------------------------------------------------------------- /test/boosting.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import { BN, getAllowance } from "../src/utils.js"; 3 | import { getCrv, createLock, increaseAmount, increaseUnlockTime, getLockedAmountAndUnlockTime, calcUnlockTime } from '../src/boosting.js'; 4 | import { curve } from "../src/curve.js"; 5 | 6 | describe('Boosting', function() { 7 | this.timeout(120000); 8 | let address = ''; 9 | 10 | before(async function() { 11 | await curve.init('JsonRpc', {}, { gasPrice: 0 }); 12 | address = curve.signerAddress; 13 | }); 14 | 15 | it('Creates lock in Voting Escrow contract', async function () { 16 | const lockAmount = '1000'; 17 | 18 | const initialCrvBalance: string = await getCrv() as string; 19 | const calculatedUnlockTime = calcUnlockTime(365); 20 | await createLock(lockAmount, 365); 21 | const crvBalance = await getCrv() as string; 22 | const { lockedAmount, unlockTime } = await getLockedAmountAndUnlockTime() as { lockedAmount: string, unlockTime: number }; 23 | const [allowance] = await getAllowance(['crv'], curve.signerAddress, curve.constants.ALIASES.voting_escrow); 24 | 25 | assert.deepEqual(BN(lockedAmount), BN(initialCrvBalance).minus(BN(crvBalance))); 26 | assert.equal(unlockTime, calculatedUnlockTime); 27 | assert.equal(Number(allowance), 0); 28 | }); 29 | 30 | it('Increases amount locked in Voting Escrow contract', async function () { 31 | const increaseLockAmount = '1000'; 32 | 33 | const initialCrvBalance: string = await getCrv() as string; 34 | const { lockedAmount: initialLockedAmount } = await getLockedAmountAndUnlockTime() as { lockedAmount: string, unlockTime: number }; 35 | await increaseAmount(increaseLockAmount); 36 | const crvBalance = await getCrv() as string; 37 | const { lockedAmount } = await getLockedAmountAndUnlockTime() as { lockedAmount: string, unlockTime: number }; 38 | const [allowance] = await getAllowance(['crv'], curve.signerAddress, curve.constants.ALIASES.voting_escrow); 39 | 40 | assert.deepEqual(BN(lockedAmount).minus(BN(initialLockedAmount)), BN(initialCrvBalance).minus(BN(crvBalance))); 41 | assert.equal(Number(allowance), 0); 42 | }); 43 | 44 | it('Extends lock time', async function () { 45 | const { unlockTime: initialUnlockTime } = await getLockedAmountAndUnlockTime() as { lockedAmount: string, unlockTime: number }; 46 | const calculatedUnlockTime = calcUnlockTime(120, initialUnlockTime); 47 | await increaseUnlockTime(120); 48 | const { unlockTime } = await getLockedAmountAndUnlockTime(address) as { lockedAmount: string, unlockTime: number }; 49 | const [allowance] = await getAllowance(['crv'], curve.signerAddress, curve.constants.ALIASES.voting_escrow); 50 | 51 | assert.equal(unlockTime, calculatedUnlockTime); 52 | assert.equal(Number(allowance), 0); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /test/claim/claimCrv.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import curve from "../../src/index.js"; 3 | 4 | // ---------------- 5 | // TO MAKE THIS TEST WORKING YOU NEED TO DO THESE STEPS FIRST 6 | // 7 | // 1. Run 8 | // node deposit.test.js 9 | // 10 | // 2. Go to brownie console and run: 11 | // chain.sleep(1000000) 12 | // chain.mine(1) 13 | // 14 | // ---------------- 15 | 16 | 17 | const PLAIN_POOLS = ['susd', 'ren', 'sbtc', '3pool', 'steth', 'ankreth', 'link', 'reth', 'eurt']; // Without eurs 18 | const LENDING_POOLS = ['compound', 'usdt', 'aave', 'saave', 'ib']; 19 | const META_POOLS = ['gusd', 'usdk', 'musd', 'rsv', 'tbtc', 'dusd', 'pbtc', 'bbtc', 'obtc', 'usdp', 'tusd', 'frax', 'lusd', 'busdv2', 'alusd', 'mim']; 20 | const CRYPTO_POOLS = ['tricrypto2', 'eurtusd', 'cvxeth']; 21 | const ETHEREUM_POOLS = [...PLAIN_POOLS, ...LENDING_POOLS, ...META_POOLS, ...CRYPTO_POOLS]; 22 | 23 | const POLYGON_POOLS = ['aave', 'ren', 'atricrypto3', 'eurtusd']; 24 | 25 | const ARBITRUM_POOLS = ['2pool', 'tricrypto', 'ren', 'eursusd']; 26 | 27 | 28 | describe('Claiming CRV', function() { 29 | this.timeout(120000); 30 | 31 | before(async function() { 32 | await curve.init('JsonRpc', {}, { gasPrice: 0 }); 33 | }); 34 | 35 | for (const poolName of ARBITRUM_POOLS) { 36 | it(`Claims CRV from ${poolName.toUpperCase()}`, async function () { 37 | const pool = curve.getPool(poolName); 38 | 39 | const [crvBalanceBefore] = await curve.getBalances(['crv']) as string[]; 40 | const expected = await pool.claimableCrv(); 41 | 42 | console.log(crvBalanceBefore, "+", expected, "=", Number(crvBalanceBefore) + Number(expected)); 43 | await pool.claimCrv(); 44 | 45 | const [crvBalanceAfter] = await curve.getBalances(['crv']) as string[]; 46 | console.log(crvBalanceAfter); 47 | 48 | assert.approximately(Number(crvBalanceAfter), Number(crvBalanceBefore) + Number(expected), 1e-3); 49 | }); 50 | } 51 | }); 52 | -------------------------------------------------------------------------------- /test/claim/deposit.test.ts: -------------------------------------------------------------------------------- 1 | import curve from "../../src/index.js"; 2 | 3 | const PLAIN_POOLS = ['susd', 'ren', 'sbtc', '3pool', 'steth', 'ankreth', 'link', 'reth', 'eurt']; // Without eurs 4 | const LENDING_POOLS = ['compound', 'usdt', 'aave', 'saave', 'ib']; 5 | const META_POOLS = ['gusd', 'usdk', 'musd', 'rsv', 'tbtc', 'dusd', 'pbtc', 'bbtc', 'obtc', 'usdp', 'tusd', 'frax', 'lusd', 'busdv2', 'alusd', 'mim']; 6 | const CRYPTO_POOLS = ['tricrypto2', 'eurtusd', 'cvxeth']; 7 | const ETHEREUM_POOLS = [...PLAIN_POOLS, ...LENDING_POOLS, ...META_POOLS, ...CRYPTO_POOLS]; 8 | 9 | const POLYGON_POOLS = ['aave', 'ren', 'atricrypto3', 'eurtusd']; 10 | 11 | (async function () { 12 | await curve.init('JsonRpc', {},{ gasPrice: 0 }); 13 | 14 | for (const poolName of ['susd']) { 15 | const pool = curve.getPool(poolName); 16 | const amounts = pool.underlyingCoinAddresses.map(() => '10'); 17 | 18 | await pool.depositAndStake(amounts); 19 | 20 | console.log(`Deposited LP tokens to ${poolName.toUpperCase()} gauge`); 21 | } 22 | })() 23 | -------------------------------------------------------------------------------- /test/constants.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import { curve } from "../src/curve.js"; 3 | 4 | describe('Checking constants', async function () { 5 | this.timeout(120000); 6 | 7 | before(async function() { 8 | await curve.init('JsonRpc', {}, { gasPrice: 0 }); 9 | await curve.fetchFactoryPools(); 10 | await curve.fetchCryptoFactoryPools(); 11 | }); 12 | 13 | it('POOLS_DATA <-> COINS match', async function () { 14 | const COIN_ADDRESSES = Object.values(curve.constants.COINS); 15 | for (const poolData of Object.values(curve.constants.POOLS_DATA)) { 16 | const coinAddresses = [ 17 | ...poolData.underlying_coin_addresses, 18 | ...poolData.wrapped_coin_addresses, 19 | ] 20 | for (const coinAddr of coinAddresses) { 21 | assert.isTrue(COIN_ADDRESSES.includes(coinAddr), `Addesss: ${coinAddr}`) 22 | } 23 | } 24 | }); 25 | 26 | it('POOLS_DATA <-> DECIMALS match', async function () { 27 | for (const poolData of Object.values(curve.constants.POOLS_DATA)) { 28 | const coinAddresses = [ 29 | ...poolData.underlying_coin_addresses, 30 | ...poolData.wrapped_coin_addresses, 31 | ] 32 | const coinDecimals = [ 33 | ...poolData.underlying_decimals, 34 | ...poolData.wrapped_decimals, 35 | ] 36 | 37 | assert.equal(coinAddresses.length, coinDecimals.length, `Pool: ${poolData.name}, swap addesss: ${poolData.swap_address}`); 38 | for (let i = 0; i < coinAddresses.length; i++) { 39 | assert.equal(curve.constants.DECIMALS[coinAddresses[i]], coinDecimals[i], `Pool: ${poolData.name}, swap addesss: ${poolData.swap_address}`); 40 | } 41 | } 42 | }); 43 | 44 | it('DECIMALS are correct', async function () { 45 | for (const [address, decimals] of Object.entries(curve.constants.DECIMALS)) { 46 | if (address === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") continue; // ETH 47 | // if (address === "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f") continue; // SNX 48 | if (curve.contracts[address] === undefined) console.log(address); 49 | const contract = curve.contracts[address].contract; 50 | assert.equal(decimals, Number(curve.formatUnits(await contract.decimals(curve.constantOptions), 0)), address); 51 | } 52 | }); 53 | 54 | it('POOLS_DATA names of coins are correct', async function () { 55 | for (const poolData of Object.values(curve.constants.POOLS_DATA)) { 56 | const coins = [ 57 | ...poolData.underlying_coins, 58 | ...poolData.wrapped_coins, 59 | ] 60 | const coinAddresses = [ 61 | ...poolData.underlying_coin_addresses, 62 | ...poolData.wrapped_coin_addresses, 63 | ] 64 | 65 | assert.equal(coins.length, coinAddresses.length, poolData.swap_address); 66 | for (let i = 0; i < coins.length; i++) { 67 | if (coinAddresses[i] === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") continue; // ETH 68 | if (coins[i] === "byDAI" || coins[i] === "byUSDC" || coins[i] === "byUSDT") continue; // Actually yDAI, yUSDC, yUSDT 69 | if (coins[i] === "sbtcCrv") continue; // Actually crvRenWSBTC 70 | if (coins[i] === "ankrETH") continue; // Actually aETHc 71 | const contract = curve.contracts[coinAddresses[i]].contract; 72 | assert.equal(coins[i], await contract.symbol(), `Pool: ${poolData.name}, swap addesss: ${poolData.swap_address}`) 73 | } 74 | } 75 | }); 76 | }); -------------------------------------------------------------------------------- /test/required.test.ts: -------------------------------------------------------------------------------- 1 | import {expect} from "chai"; 2 | import curve from "../src/index.js"; 3 | import {ETH_RPC} from "./rpcUrls.test.js"; 4 | 5 | const test = (baseValue: number, resultValue: number, errorInPercentage: number) => { 6 | const difference = Math.abs(baseValue - resultValue); 7 | if ((difference / baseValue) * 100 < errorInPercentage) { 8 | return true; 9 | } else { 10 | return false; 11 | } 12 | }; 13 | 14 | const testOfSwapRequired = (pool: string, curve: any) => { 15 | describe(`${pool} swapRequired test`, function () { 16 | it(`${pool} swapRequired test`, async function () { 17 | const poolInstance = curve.getPool(pool) 18 | const to = await poolInstance.swapExpected(0, 1, 5); 19 | const result = await poolInstance.swapRequired(0, 1, to); 20 | const isTestSuccessful = test(5, Number(result), 0.5) 21 | expect(isTestSuccessful).to.be.equal(true) 22 | }) 23 | }) 24 | } 25 | 26 | const testOfSwapWrappedRequired = (pool: string, curve: any) => { 27 | describe(`${pool} swapWrappedRequired test`, function () { 28 | it(`${pool} swapWrappedRequired test`, async function () { 29 | try { 30 | const poolInstance = curve.getPool(pool) 31 | const to = await poolInstance.swapWrappedExpected(0, 1, 5); 32 | const result = await poolInstance.swapWrappedRequired(0, 1, to); 33 | const isTestSuccessful = test(5, Number(result), 0.5) 34 | expect(isTestSuccessful).to.be.equal(true) 35 | } catch (e: any) { 36 | const isTestSuccessful = e.message.startsWith(`swapWrappedExpected method doesn't exist for pool`) 37 | expect(isTestSuccessful).to.be.equal(true) 38 | } 39 | }) 40 | }) 41 | } 42 | 43 | describe('Test swapRequired and swapWrappedRequired methods in PoolTemplate', async function (){ 44 | this.timeout(120000) 45 | 46 | let allPools: string[] = []; 47 | 48 | before(async function (){ 49 | await curve.init('JsonRpc', { url: ETH_RPC }, { gasPrice: 0 }); 50 | await curve.factory.fetchPools(); 51 | await curve.crvUSDFactory.fetchPools(); 52 | await curve.EYWAFactory.fetchPools(); 53 | await curve.cryptoFactory.fetchPools(); 54 | await curve.tricryptoFactory.fetchPools(); 55 | 56 | allPools = curve.getMainPoolList(); 57 | }) 58 | 59 | it('', function () { 60 | describe('TEST', () => { 61 | it('CONNECT WITH BLOCKCHAIN', () => { 62 | for(const pool of allPools) { 63 | testOfSwapRequired(pool, curve) 64 | testOfSwapWrappedRequired(pool, curve) 65 | } 66 | }) 67 | }) 68 | }) 69 | }) -------------------------------------------------------------------------------- /test/rewards.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import curve from "../src/index.js"; 3 | 4 | 5 | const checkNumber = (n: string) => Number(n) === Number(n); 6 | 7 | describe('Rewards test', async function () { 8 | this.timeout(240000); 9 | 10 | before(async function() { 11 | await curve.init('JsonRpc', {}, { gasPrice: 0 }); 12 | await curve.factory.fetchPools(); 13 | await curve.cryptoFactory.fetchPools(); 14 | }); 15 | 16 | it('crvProfit', async function () { 17 | const pools = [ 18 | ...curve.getMainPoolList(), 19 | ...curve.factory.getPoolList().slice(0, 10), 20 | ...curve.crvUSDFactory.getPoolList(), 21 | ...curve.cryptoFactory.getPoolList().slice(0, 10), 22 | ]; 23 | for (const poolId of pools) { 24 | console.log(poolId); 25 | const pool = curve.getPool(poolId); 26 | 27 | try { 28 | if (pool.rewardsOnly()) { 29 | console.log('Rewards-Only'); 30 | continue; 31 | } 32 | 33 | const crvProfit = await pool.crvProfit(); 34 | console.log(crvProfit, '\n'); 35 | assert.isTrue(checkNumber(crvProfit.day)); 36 | assert.isTrue(checkNumber(crvProfit.week)); 37 | assert.isTrue(checkNumber(crvProfit.month)); 38 | assert.isTrue(checkNumber(crvProfit.year)); 39 | assert.equal(typeof crvProfit.token, "string"); 40 | assert.equal(typeof crvProfit.symbol, "string"); 41 | assert.isAbove(crvProfit.price, 0); 42 | } catch (err: any) { 43 | console.log(err.message, '\n'); 44 | assert.equal(err.message, `${pool.name} doesn't have gauge`); 45 | } 46 | } 47 | }); 48 | 49 | it('rewardsProfit', async function () { 50 | const pools = curve.getPoolList(); 51 | for (const poolId of pools) { 52 | console.log(poolId); 53 | const pool = curve.getPool(poolId); 54 | try { 55 | const rewardsProfit = await pool.rewardsProfit(); 56 | console.log(rewardsProfit, '\n'); 57 | 58 | for (const profit of rewardsProfit) { 59 | assert.isTrue(checkNumber(profit.day)); 60 | assert.isTrue(checkNumber(profit.week)); 61 | assert.isTrue(checkNumber(profit.month)); 62 | assert.isTrue(checkNumber(profit.year)); 63 | assert.equal(typeof profit.token, "string"); 64 | assert.equal(typeof profit.symbol, "string"); 65 | assert.isAbove(profit.price, 0); 66 | } 67 | } catch (err: any) { 68 | console.log(err.message, '\n'); 69 | assert.equal(err.message, `${pool.name} doesn't have gauge`); 70 | } 71 | } 72 | }); 73 | }); -------------------------------------------------------------------------------- /test/router.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import { BN } from "../src/utils.js"; 3 | import curve from "../src/index.js"; 4 | 5 | 6 | const AAVE_TOKENS = ['adai', 'ausdc', 'ausdt', 'asusd', 'awbtc', 'amdai', 'amusdt', 'amusdc', 'amwbtc', 'avdai', 'avusdt', 'avusdc', 'avwbtc', 'gdai', 'gusdc', 'gfusdt']; 7 | 8 | const routerSwapTest = async (coin1: string, coin2: string) => { 9 | const amount = '1'; 10 | const initialBalances = await curve.getBalances([coin1, coin2]) as string[]; 11 | 12 | const { route, output } = await curve.router.getBestRouteAndOutput(coin1, coin2, amount); 13 | assert.isTrue(route.length > 0); 14 | const required = await curve.router.required(coin1, coin2, output); 15 | 16 | let routeStr = '' 17 | for (const step of route) { 18 | routeStr += `${step.poolId} (${step.swapParams}) --> `; 19 | } 20 | routeStr = routeStr.slice(0, routeStr.length - 5) 21 | console.log(routeStr) 22 | console.log(route); 23 | console.log("Output:", output); 24 | console.log("Required:", required); 25 | 26 | await curve.router.swap(coin1, coin2, amount); 27 | 28 | const balances = await curve.getBalances([coin1, coin2]) as string[]; 29 | 30 | if (coin1 === 'steth' || coin2 === 'steth') { 31 | assert.approximately(Number(Object.values(balances)[0]), Number(BN(Object.values(initialBalances)[0]).minus(BN(amount)).toString()), 1e-18); 32 | } else if (AAVE_TOKENS.includes(coin1) || AAVE_TOKENS.includes(coin2)) { 33 | assert.approximately(Number(Object.values(balances)[0]), Number(BN(Object.values(initialBalances)[0]).minus(BN(amount)).toString()), 1e-2); 34 | } else { 35 | assert.deepStrictEqual(BN(balances[0]), BN(initialBalances[0]).minus(BN(amount))); 36 | } 37 | assert.isAtLeast(Number(balances[1]), Number(BN(initialBalances[1]).plus(BN(output).times(0.995)).toString())); 38 | assert.approximately(Number(required), Number(amount), 0.03); 39 | } 40 | 41 | describe('Router swap', async function () { 42 | this.timeout(240000); 43 | 44 | before(async function () { 45 | await curve.init('JsonRpc', {}, { gasPrice: 0 }); 46 | 47 | await curve.factory.fetchPools(); 48 | await curve.stableNgFactory.fetchPools(); 49 | await curve.crvUSDFactory.fetchPools(); 50 | await curve.EYWAFactory.fetchPools(); 51 | 52 | await curve.cryptoFactory.fetchPools(); 53 | await curve.twocryptoFactory.fetchPools(); 54 | await curve.tricryptoFactory.fetchPools(); 55 | }); 56 | 57 | // const coins = Object.keys(COINS_POLYGON).filter((c) => c !== 'snx' && c !== 'eurs'); // TODO remove eurs 58 | 59 | // ETHEREUM 60 | const coins = ['sbtc', 'susd', 'dai', 'mim', 'frax', 'crv', 'cvx', 'eth', 'steth', 'wsteth', 'frxeth', 'sfrxeth', 'wbeth', 'eurt', '3crv', '0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7', '0x045da4bfe02b320f4403674b3b7d121737727a36']; // cvxCRV, DCHF 61 | 62 | // POLYGON 63 | // const coins = ['wbtc', 'crv', 'dai', 'usdc', 'usdt', 'eurt', 'weth', 'renbtc', 'amdai', 'amusdc', 'amusdt', 'am3crv', 'matic', 64 | // '0x45c32fa6df82ead1e2ef74d17b76547eddfaff89', '0xdAD97F7713Ae9437fa9249920eC8507e5FbB23d3', '0xad326c253a84e9805559b73a08724e11e49ca651']; // frax, atricrypto3 LP, 4eur LP 65 | 66 | // AVALANCHE 67 | // const coins = ['dai.e', 'weth.e', 'wbtc.e', 'usdc', 'usdt', 'btc.b', 'avax', 'wavax', '2crv', 'avusdt', 'av3crv', '0x130966628846bfd36ff31a822705796e8cb8c18d']; // mim 68 | 69 | // FANTOM 70 | // const coins = ['dai', 'usdc', 'fusdt', 'idai', 'iusdc', 'ifusdt', 'gdai', 'gusdc', 'gfusdt', 'dai+usdc', 'eth', 'btc', 'renbtc', 'frax', 'crv', '0x666a3776b3e82f171cb1dff7428b6808d2cd7d02']; // aCRV 71 | 72 | // ARBITRUM 73 | // const coins = ['usdc', 'usdt', 'wbtc', 'eth', 'weth', 'eurs', '2crv', "0x8e0B8c8BB9db49a46697F3a5Bb8A308e744821D2"]; // tricrypto LP 74 | 75 | // OPTIMISM 76 | // const coins = ['dai', 'usdc', 'usdt', 'susd', '3crv', 'eth', 'weth', 'wsteth', 'seth']; 77 | 78 | // XDAI 79 | // const coins = ['wxdai', 'usdc', 'usdt', 'rai', 'x3crv', 'wbtc', 'weth', '0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb', '0xa4ef9da5ba71cc0d2e5e877a910a37ec43420445']; // GNO, sGNO 80 | 81 | // MOONBEAM 82 | // const coins = ['dai', 'usdc', 'usdt', '3crv', '0x765277EebeCA2e31912C9946eAe1021199B39C61']; // DAI2 83 | 84 | // AURORA && KAVA && CELO 85 | // const coins = ['dai', 'usdc', 'usdt']; 86 | 87 | for (const coin1 of coins) { 88 | for (const coin2 of coins) { 89 | if (coin1 !== coin2) { 90 | it(`${coin1} --> ${coin2}`, async function () { 91 | try { 92 | await routerSwapTest(coin1, coin2); 93 | } catch (err: any) { 94 | if (err.message != "This pair can't be exchanged") { 95 | throw err; 96 | } 97 | } 98 | }); 99 | } 100 | } 101 | } 102 | }) 103 | -------------------------------------------------------------------------------- /test/stats.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from "chai"; 2 | import curve from "../src/index.js"; 3 | import { curve as _curve } from "../src/curve.js"; 4 | import { getPool, PoolTemplate } from "../src/pools/index.js"; 5 | import { IReward } from "../src/interfaces.js"; 6 | 7 | 8 | const MAIN_POOLS_ETHEREUM = [ 9 | 'compound', 'usdt', 'y', 'busd', 10 | 'susd', 'pax', 'ren', 'sbtc', 11 | 'hbtc', '3pool', 'gusd', 'husd', 12 | 'usdk', 'usdn', 'musd', 'rsv', 13 | 'tbtc', 'dusd', 'pbtc', 'bbtc', 14 | 'obtc', 'seth', 'eurs', 'ust', 15 | 'aave', 'steth', 'saave', 'ankreth', 16 | 'usdp', 'ib', 'link', 'tusd', 17 | 'frax', 'lusd', 'busdv2', 'reth', 18 | 'alusd', 'mim', 'tricrypto2', 'eurt', 19 | 'eurtusd', 'eursusd', 'crveth', 'rai', 20 | 'cvxeth', 'xautusd', 'spelleth', 'teth', 21 | '2pool', '4pool', 'sbtc2', 'fraxusdp', 22 | ]; 23 | const FACTORY_POOLS_COUNT_ETHEREUM = 127; 24 | const CRYPTO_FACTORY_POOLS_COUNT_ETHEREUM = 132; 25 | 26 | const MAIN_POOLS_POLYGON = [ 'aave', 'ren', 'atricrypto3', 'eurtusd' ]; 27 | const FACTORY_POOLS_COUNT_POLYGON = 263; 28 | 29 | const MAIN_POOLS_AVALANCHE = [ 'aave', 'ren', 'atricrypto']; 30 | const FACTORY_POOLS_COUNT_AVALANCHE = 81; 31 | 32 | const MAIN_POOLS_FANTOM = ['2pool', 'fusdt', 'ren', 'tricrypto', 'ib', 'geist']; 33 | const FACTORY_POOLS_COUNT_FANTOM = 110; 34 | const CRYPTO_FACTORY_POOLS_COUNT_FANTOM = 6; 35 | 36 | const MAIN_POOLS_ARBITRUM = ['2pool', 'tricrypto', 'ren', 'eursusd']; 37 | const FACTORY_POOLS_COUNT_ARBITRUM = 40; 38 | 39 | const MAIN_POOLS_OPTIMISM = ['3pool']; 40 | const FACTORY_POOLS_COUNT_OPTIMISM = 16; 41 | 42 | const MAIN_POOLS_XDAI = ['3pool', 'rai', 'tricrypto']; 43 | const FACTORY_POOLS_COUNT_XDAI = 7; 44 | 45 | const MAIN_POOLS_MOONBEAM = ['3pool']; 46 | const FACTORY_POOLS_COUNT_MOONBEAM = 16; 47 | 48 | const MAIN_POOLS_AURORA = ['3pool']; 49 | 50 | const MAIN_POOLS_KAVA = ['factory-v2-0']; 51 | 52 | const MAIN_POOLS_CELO = ['factory-v2-0']; 53 | 54 | // ------------------------------------------ 55 | 56 | const MAIN_POOLS = MAIN_POOLS_ETHEREUM; 57 | const FACTORY_POOLS_COUNT = 0; 58 | const CRYPTO_FACTORY_POOLS_COUNT = 0; 59 | 60 | const checkNumber = (str: string) => { 61 | const re = /-?\d+(\.\d+)?(e-\d+)?/g 62 | const match = str.match(re); 63 | return match && str === match[0] 64 | } 65 | 66 | const poolStatsTest = (name: string) => { 67 | describe(`${name} stats test`, function () { 68 | let pool: PoolTemplate; 69 | 70 | before(async function () { 71 | pool = getPool.call(_curve, name); 72 | }); 73 | 74 | 75 | it('Total liquidity', async function () { 76 | const totalLiquidity = await pool.stats.totalLiquidity(); 77 | 78 | assert.isTrue(checkNumber(totalLiquidity)); 79 | }); 80 | 81 | it('Volume', async function () { 82 | const volume = await pool.stats.volume(); 83 | 84 | assert.isTrue(checkNumber(volume)); 85 | }); 86 | 87 | it('Base APY', async function () { 88 | const apy = await pool.stats.baseApy(); 89 | 90 | assert.isTrue(checkNumber(apy.day)); 91 | assert.isTrue(checkNumber(apy.week)); 92 | }); 93 | 94 | it('Token APY', async function () { 95 | if (pool.gauge.address === _curve.constants.ZERO_ADDRESS || pool.rewardsOnly()) { 96 | console.log("Skip"); 97 | return 98 | } 99 | 100 | const [apy, boostedApy] = await pool.stats.tokenApy(); 101 | 102 | assert.isTrue(typeof apy === "number"); 103 | assert.isTrue(typeof boostedApy === "number"); 104 | }); 105 | 106 | it('Rewards APY', async function () { 107 | const rewardsApy = await pool.stats.rewardsApy(); 108 | 109 | rewardsApy.forEach((item: IReward) => { 110 | assert.isTrue(checkNumber(String(item.apy))); 111 | }) 112 | }); 113 | }) 114 | } 115 | 116 | describe('Stats test', async function () { 117 | this.timeout(120000); 118 | 119 | 120 | before(async function () { 121 | await curve.init('JsonRpc', {},{ gasPrice: 0 }); 122 | await curve.factory.fetchPools(); 123 | await curve.cryptoFactory.fetchPools(); 124 | }); 125 | 126 | for (const poolName of MAIN_POOLS) { 127 | poolStatsTest(poolName); 128 | } 129 | 130 | for (let i = 0; i < FACTORY_POOLS_COUNT; i++) { 131 | poolStatsTest("factory-v2-" + i); 132 | } 133 | 134 | for (let i = 0; i < CRYPTO_FACTORY_POOLS_COUNT; i++) { 135 | poolStatsTest("factory-crypto-" + i); 136 | } 137 | }) 138 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./lib", 5 | "rootDir": "./src", 6 | }, 7 | "exclude": [ 8 | "**/*.test.ts" 9 | ] 10 | } 11 | --------------------------------------------------------------------------------