From a1451ea09d7a2d4a37603b30acee65252aa03acc Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Mon, 5 Aug 2024 16:02:13 -0300 Subject: [PATCH 01/11] refactor: create one package for all bots --- .eslintignore | 4 +- .github/workflows/cd.yaml | 8 +- .github/workflows/ci.yaml | 8 +- .gitignore | 4 +- package.json | 2 +- .../cli/source/commands/conversionPairs.tsx | 2 +- packages/cli/source/commands/convert.tsx | 2 +- packages/cli/source/commands/releaseFunds.tsx | 2 +- packages/cli/source/state/convert.ts | 2 +- packages/cli/source/state/releaseFunds.ts | 2 +- .../.env.example | 0 .../.env.test | 0 .../.eslint-tsconfig | 0 .../.eslintignore | 0 .../.prettierignore | 0 .../.releaserc | 0 .../README.md | 0 .../jest.config.js | 0 .../package.json | 4 +- .../prepare.sh | 0 .../@pancakeswap/smart-router/evm/index.ts | 0 .../src/__mocks__/index.ts | 0 .../src/config/addresses.ts | 0 .../src/config/chains.ts | 0 .../config/clients/__mocks__/publicClient.ts | 0 .../config/clients/__mocks__/walletClient.ts | 0 .../src/config/clients/publicClient.ts | 0 .../src/config/clients/walletClient.ts | 2 +- .../src/config/index.ts | 0 .../src/converter-bot/TokenConverter.test.ts | 0 .../src/converter-bot/TokenConverter.ts | 0 .../src/converter-bot/constants/index.ts | 0 .../src/converter-bot/logger/index.ts | 0 .../src/converter-bot/providers/index.ts | 0 .../converter-bot/providers/pancake-swap.ts | 0 .../converter-bot/providers/swap-provider.ts | 0 .../src/converter-bot/providers/uniswap.ts | 0 .../converter-bot/queries/getCoreMarkets.ts | 0 .../queries/getIsolatedMarkets.ts | 0 .../getAllConverterConfigs.ts | 0 .../getConverterConfigByAssetIn.ts | 0 .../getConverterConfigByAssetInAndAssetOut.ts | 0 ...rConfigByAssetInAndAssetOutAndConverter.ts | 0 .../getConverterConfigByAssetOut.ts | 0 .../getConverterConfigsByConverter.ts | 0 .../queries/getTokenConverterConfigs/index.ts | 0 .../getTokenConvertersTokenBalances.ts | 0 .../queries/getVTokensFromUnderlying.ts | 0 .../src/converter-bot/queries/index.ts | 0 .../src/converter-bot/types.ts | 0 .../src/environment.d.ts | 0 .../src/index.ts | 0 .../src/module.d.ts | 0 .../src/subgraph-client/.graphclientrc.js | 0 .../src/subgraph-client/__mocks__/index.ts | 0 .../src/subgraph-client/index.ts | 0 .../queries/CoreVTokensFromUnderlying.graphql | 0 .../IsolatedVTokensFromUnderlying.graphql | 0 ...ssetInAndAssetOutAndConverterQuery.graphql | 0 ...erConfigsByAssetInAndAssetOutQuery.graphql | 0 ...okenConverterConfigsByAssetInQuery.graphql | 0 ...kenConverterConfigsByAssetOutQuery.graphql | 0 ...verterConfigsByTokenConverterQuery.graphql | 0 .../TokenConverterConfigsQuery.graphql | 0 .../tsconfig.json | 0 .../wagmi.config.ts | 0 yarn.lock | 73 +++++++++++++------ 67 files changed, 70 insertions(+), 45 deletions(-) rename packages/{token-converter-bot => keeper-bots}/.env.example (100%) rename packages/{token-converter-bot => keeper-bots}/.env.test (100%) rename packages/{token-converter-bot => keeper-bots}/.eslint-tsconfig (100%) rename packages/{token-converter-bot => keeper-bots}/.eslintignore (100%) rename packages/{token-converter-bot => keeper-bots}/.prettierignore (100%) rename packages/{token-converter-bot => keeper-bots}/.releaserc (100%) rename packages/{token-converter-bot => keeper-bots}/README.md (100%) rename packages/{token-converter-bot => keeper-bots}/jest.config.js (100%) rename packages/{token-converter-bot => keeper-bots}/package.json (96%) rename packages/{token-converter-bot => keeper-bots}/prepare.sh (100%) rename packages/{token-converter-bot => keeper-bots}/src/__mocks__/@pancakeswap/smart-router/evm/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/__mocks__/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/config/addresses.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/config/chains.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/config/clients/__mocks__/publicClient.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/config/clients/__mocks__/walletClient.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/config/clients/publicClient.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/config/clients/walletClient.ts (96%) rename packages/{token-converter-bot => keeper-bots}/src/config/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/TokenConverter.test.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/TokenConverter.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/constants/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/logger/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/providers/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/providers/pancake-swap.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/providers/swap-provider.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/providers/uniswap.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getCoreMarkets.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getIsolatedMarkets.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getTokenConverterConfigs/getAllConverterConfigs.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetIn.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOut.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOutAndConverter.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetOut.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigsByConverter.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getTokenConverterConfigs/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getTokenConvertersTokenBalances.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/getVTokensFromUnderlying.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/queries/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/converter-bot/types.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/environment.d.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/module.d.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/.graphclientrc.js (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/__mocks__/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/index.ts (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/queries/CoreVTokensFromUnderlying.graphql (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/queries/IsolatedVTokensFromUnderlying.graphql (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutAndConverterQuery.graphql (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutQuery.graphql (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/queries/TokenConverterConfigsByAssetInQuery.graphql (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/queries/TokenConverterConfigsByAssetOutQuery.graphql (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/queries/TokenConverterConfigsByTokenConverterQuery.graphql (100%) rename packages/{token-converter-bot => keeper-bots}/src/subgraph-client/queries/TokenConverterConfigsQuery.graphql (100%) rename packages/{token-converter-bot => keeper-bots}/tsconfig.json (100%) rename packages/{token-converter-bot => keeper-bots}/wagmi.config.ts (100%) diff --git a/.eslintignore b/.eslintignore index 6e9f63c1..28badb2b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,5 +4,5 @@ cache coverage dist typechain -packages/token-converter-bot/src/config/abis/generated.ts -packages/token-converter-bot/subgraph-client/.graphqlclient +packages/keeper-bots/src/config/abis/generated.ts +packages/keeper-bots/subgraph-client/.graphqlclient diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index ca382e8e..16bd722e 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -28,8 +28,8 @@ jobs: env: THE_GRAPH_STUDIO_API_KEY: ${{ secrets.THE_GRAPH_STUDIO_API_KEY }} run: | - yarn workspace @venusprotocol/token-converter-bot run generate-abis - yarn workspace @venusprotocol/token-converter-bot run generate-subgraph-types + yarn workspace @venusprotocol/keeper-bots run generate-abis + yarn workspace @venusprotocol/keeper-bots run generate-subgraph-types - name: Build Keeper Bot Contracts run: yarn workspace @venusprotocol/keeper-bot-contracts run build @@ -53,7 +53,7 @@ jobs: - name: Build Token Converter Bots env: THE_GRAPH_STUDIO_API_KEY: ${{ secrets.THE_GRAPH_STUDIO_API_KEY }} - run: yarn workspace @venusprotocol/token-converter-bot run build + run: yarn workspace @venusprotocol/keeper-bots run build - name: Release Token Converter Bot if: ${{ always() }} @@ -65,7 +65,7 @@ jobs: GIT_AUTHOR_EMAIL: tools@venus.io GIT_COMMITTER_NAME: Venus Tools GIT_COMMITTER_EMAIL: tools@venus.io - run: yarn workspace @venusprotocol/token-converter-bot run semantic-release + run: yarn workspace @venusprotocol/keeper-bots run semantic-release - name: Install dependencies run: yarn diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a3f77519..2e68366e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,8 +26,8 @@ jobs: - name: Prepare run: | - yarn workspace @venusprotocol/token-converter-bot run generate-abis - yarn workspace @venusprotocol/token-converter-bot run generate-subgraph-types + yarn workspace @venusprotocol/keeper-bots run generate-abis + yarn workspace @venusprotocol/keeper-bots run generate-subgraph-types - name: Check linting of solidity and typescript run: yarn lint @@ -51,8 +51,8 @@ jobs: - name: Prepare tests run: | - yarn workspace @venusprotocol/token-converter-bot run generate-abis - yarn workspace @venusprotocol/token-converter-bot run generate-subgraph-types + yarn workspace @venusprotocol/keeper-bots run generate-abis + yarn workspace @venusprotocol/keeper-bots run generate-subgraph-types - name: Run hardhat compile and tests coverage run: | diff --git a/.gitignore b/.gitignore index 51bed6a7..ddd41997 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,8 @@ artifacts !.yarn/versions # Generated files -packages/token-converter-bot/src/config/abis/generated.ts -packages/token-converter-bot/src/subgraph-client/.graphclient +packages/keeper-bots/src/config/abis/generated.ts +packages/keeper-bots/src/subgraph-client/.graphclient # Build dist diff --git a/package.json b/package.json index a985e9db..a1c93b12 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@venusprotocol/keeper-bots", + "name": "@venusprotocol/keeper-bots-monorepo", "version": "1.1.1", "description": "Keeper bots for Venus Protocol", "private": true, diff --git a/packages/cli/source/commands/conversionPairs.tsx b/packages/cli/source/commands/conversionPairs.tsx index 93f438ce..9b5cc274 100644 --- a/packages/cli/source/commands/conversionPairs.tsx +++ b/packages/cli/source/commands/conversionPairs.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { Box, Text, useApp } from "ink"; -import { TokenConverterConfigs, getAllConverterConfigs } from "@venusprotocol/token-converter-bot"; +import { TokenConverterConfigs, getAllConverterConfigs } from "@venusprotocol/keeper-bots"; /** * Helper command to list available conversion pairs diff --git a/packages/cli/source/commands/convert.tsx b/packages/cli/source/commands/convert.tsx index a5115da2..7a93a705 100644 --- a/packages/cli/source/commands/convert.tsx +++ b/packages/cli/source/commands/convert.tsx @@ -3,7 +3,7 @@ import { option } from "pastel"; import { Box, Spacer, Text, useApp, useStderr } from "ink"; import zod from "zod"; import { parseUnits } from "viem"; -import { TokenConverter, PancakeSwapProvider, UniswapProvider } from "@venusprotocol/token-converter-bot"; +import { TokenConverter, PancakeSwapProvider, UniswapProvider } from "@venusprotocol/keeper-bots"; import { stringifyBigInt, getConverterConfigId } from "../utils/index.js"; import { Options, Title, BorderBox } from "../components/index.js"; import { reducer, defaultState } from "../state/convert.js"; diff --git a/packages/cli/source/commands/releaseFunds.tsx b/packages/cli/source/commands/releaseFunds.tsx index 5da777d5..2b051ef2 100644 --- a/packages/cli/source/commands/releaseFunds.tsx +++ b/packages/cli/source/commands/releaseFunds.tsx @@ -11,7 +11,7 @@ import { getAddresses, PancakeSwapProvider, UniswapProvider, -} from "@venusprotocol/token-converter-bot"; +} from "@venusprotocol/keeper-bots"; import usePublicClient from "../queries/usePublicClient.js"; import { Options, BorderBox } from "../components/index.js"; import { reducer, defaultState } from "../state/releaseFunds.js"; diff --git a/packages/cli/source/state/convert.ts b/packages/cli/source/state/convert.ts index 9bbc27a6..319f8044 100644 --- a/packages/cli/source/state/convert.ts +++ b/packages/cli/source/state/convert.ts @@ -4,7 +4,7 @@ import { GetBestTradeMessage, ArbitrageMessage, PotentialConversionsMessage, -} from "@venusprotocol/token-converter-bot"; +} from "@venusprotocol/keeper-bots"; interface ExecuteTradeMessage { type: "ExecuteTrade"; diff --git a/packages/cli/source/state/releaseFunds.ts b/packages/cli/source/state/releaseFunds.ts index 87e4afc4..fcbf6d8c 100644 --- a/packages/cli/source/state/releaseFunds.ts +++ b/packages/cli/source/state/releaseFunds.ts @@ -1,4 +1,4 @@ -import { Message } from "@venusprotocol/token-converter-bot"; +import { Message } from "@venusprotocol/keeper-bots"; interface State { releasedFunds: { diff --git a/packages/token-converter-bot/.env.example b/packages/keeper-bots/.env.example similarity index 100% rename from packages/token-converter-bot/.env.example rename to packages/keeper-bots/.env.example diff --git a/packages/token-converter-bot/.env.test b/packages/keeper-bots/.env.test similarity index 100% rename from packages/token-converter-bot/.env.test rename to packages/keeper-bots/.env.test diff --git a/packages/token-converter-bot/.eslint-tsconfig b/packages/keeper-bots/.eslint-tsconfig similarity index 100% rename from packages/token-converter-bot/.eslint-tsconfig rename to packages/keeper-bots/.eslint-tsconfig diff --git a/packages/token-converter-bot/.eslintignore b/packages/keeper-bots/.eslintignore similarity index 100% rename from packages/token-converter-bot/.eslintignore rename to packages/keeper-bots/.eslintignore diff --git a/packages/token-converter-bot/.prettierignore b/packages/keeper-bots/.prettierignore similarity index 100% rename from packages/token-converter-bot/.prettierignore rename to packages/keeper-bots/.prettierignore diff --git a/packages/token-converter-bot/.releaserc b/packages/keeper-bots/.releaserc similarity index 100% rename from packages/token-converter-bot/.releaserc rename to packages/keeper-bots/.releaserc diff --git a/packages/token-converter-bot/README.md b/packages/keeper-bots/README.md similarity index 100% rename from packages/token-converter-bot/README.md rename to packages/keeper-bots/README.md diff --git a/packages/token-converter-bot/jest.config.js b/packages/keeper-bots/jest.config.js similarity index 100% rename from packages/token-converter-bot/jest.config.js rename to packages/keeper-bots/jest.config.js diff --git a/packages/token-converter-bot/package.json b/packages/keeper-bots/package.json similarity index 96% rename from packages/token-converter-bot/package.json rename to packages/keeper-bots/package.json index 98747a7d..68a255b4 100644 --- a/packages/token-converter-bot/package.json +++ b/packages/keeper-bots/package.json @@ -1,6 +1,6 @@ { - "name": "@venusprotocol/token-converter-bot", - "version": "1.2.0", + "name": "@venusprotocol/keeper-bots", + "version": "1.0.0", "description": "", "scripts": { "dev": "tsc --watch", diff --git a/packages/token-converter-bot/prepare.sh b/packages/keeper-bots/prepare.sh similarity index 100% rename from packages/token-converter-bot/prepare.sh rename to packages/keeper-bots/prepare.sh diff --git a/packages/token-converter-bot/src/__mocks__/@pancakeswap/smart-router/evm/index.ts b/packages/keeper-bots/src/__mocks__/@pancakeswap/smart-router/evm/index.ts similarity index 100% rename from packages/token-converter-bot/src/__mocks__/@pancakeswap/smart-router/evm/index.ts rename to packages/keeper-bots/src/__mocks__/@pancakeswap/smart-router/evm/index.ts diff --git a/packages/token-converter-bot/src/__mocks__/index.ts b/packages/keeper-bots/src/__mocks__/index.ts similarity index 100% rename from packages/token-converter-bot/src/__mocks__/index.ts rename to packages/keeper-bots/src/__mocks__/index.ts diff --git a/packages/token-converter-bot/src/config/addresses.ts b/packages/keeper-bots/src/config/addresses.ts similarity index 100% rename from packages/token-converter-bot/src/config/addresses.ts rename to packages/keeper-bots/src/config/addresses.ts diff --git a/packages/token-converter-bot/src/config/chains.ts b/packages/keeper-bots/src/config/chains.ts similarity index 100% rename from packages/token-converter-bot/src/config/chains.ts rename to packages/keeper-bots/src/config/chains.ts diff --git a/packages/token-converter-bot/src/config/clients/__mocks__/publicClient.ts b/packages/keeper-bots/src/config/clients/__mocks__/publicClient.ts similarity index 100% rename from packages/token-converter-bot/src/config/clients/__mocks__/publicClient.ts rename to packages/keeper-bots/src/config/clients/__mocks__/publicClient.ts diff --git a/packages/token-converter-bot/src/config/clients/__mocks__/walletClient.ts b/packages/keeper-bots/src/config/clients/__mocks__/walletClient.ts similarity index 100% rename from packages/token-converter-bot/src/config/clients/__mocks__/walletClient.ts rename to packages/keeper-bots/src/config/clients/__mocks__/walletClient.ts diff --git a/packages/token-converter-bot/src/config/clients/publicClient.ts b/packages/keeper-bots/src/config/clients/publicClient.ts similarity index 100% rename from packages/token-converter-bot/src/config/clients/publicClient.ts rename to packages/keeper-bots/src/config/clients/publicClient.ts diff --git a/packages/token-converter-bot/src/config/clients/walletClient.ts b/packages/keeper-bots/src/config/clients/walletClient.ts similarity index 96% rename from packages/token-converter-bot/src/config/clients/walletClient.ts rename to packages/keeper-bots/src/config/clients/walletClient.ts index dbff56cc..a648c54c 100644 --- a/packages/token-converter-bot/src/config/clients/walletClient.ts +++ b/packages/keeper-bots/src/config/clients/walletClient.ts @@ -1,7 +1,7 @@ import { createWalletClient, http } from "viem"; import { PrivateKeyAccount, privateKeyToAccount } from "viem/accounts"; -import getConfig from "../"; +import getConfig from ".."; import { chains } from "../chains"; const readPrivateKeyFromEnv = (chainName: string): PrivateKeyAccount => { diff --git a/packages/token-converter-bot/src/config/index.ts b/packages/keeper-bots/src/config/index.ts similarity index 100% rename from packages/token-converter-bot/src/config/index.ts rename to packages/keeper-bots/src/config/index.ts diff --git a/packages/token-converter-bot/src/converter-bot/TokenConverter.test.ts b/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/TokenConverter.test.ts rename to packages/keeper-bots/src/converter-bot/TokenConverter.test.ts diff --git a/packages/token-converter-bot/src/converter-bot/TokenConverter.ts b/packages/keeper-bots/src/converter-bot/TokenConverter.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/TokenConverter.ts rename to packages/keeper-bots/src/converter-bot/TokenConverter.ts diff --git a/packages/token-converter-bot/src/converter-bot/constants/index.ts b/packages/keeper-bots/src/converter-bot/constants/index.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/constants/index.ts rename to packages/keeper-bots/src/converter-bot/constants/index.ts diff --git a/packages/token-converter-bot/src/converter-bot/logger/index.ts b/packages/keeper-bots/src/converter-bot/logger/index.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/logger/index.ts rename to packages/keeper-bots/src/converter-bot/logger/index.ts diff --git a/packages/token-converter-bot/src/converter-bot/providers/index.ts b/packages/keeper-bots/src/converter-bot/providers/index.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/providers/index.ts rename to packages/keeper-bots/src/converter-bot/providers/index.ts diff --git a/packages/token-converter-bot/src/converter-bot/providers/pancake-swap.ts b/packages/keeper-bots/src/converter-bot/providers/pancake-swap.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/providers/pancake-swap.ts rename to packages/keeper-bots/src/converter-bot/providers/pancake-swap.ts diff --git a/packages/token-converter-bot/src/converter-bot/providers/swap-provider.ts b/packages/keeper-bots/src/converter-bot/providers/swap-provider.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/providers/swap-provider.ts rename to packages/keeper-bots/src/converter-bot/providers/swap-provider.ts diff --git a/packages/token-converter-bot/src/converter-bot/providers/uniswap.ts b/packages/keeper-bots/src/converter-bot/providers/uniswap.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/providers/uniswap.ts rename to packages/keeper-bots/src/converter-bot/providers/uniswap.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getCoreMarkets.ts b/packages/keeper-bots/src/converter-bot/queries/getCoreMarkets.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getCoreMarkets.ts rename to packages/keeper-bots/src/converter-bot/queries/getCoreMarkets.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getIsolatedMarkets.ts b/packages/keeper-bots/src/converter-bot/queries/getIsolatedMarkets.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getIsolatedMarkets.ts rename to packages/keeper-bots/src/converter-bot/queries/getIsolatedMarkets.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getAllConverterConfigs.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getAllConverterConfigs.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getAllConverterConfigs.ts rename to packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getAllConverterConfigs.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetIn.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetIn.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetIn.ts rename to packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetIn.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOut.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOut.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOut.ts rename to packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOut.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOutAndConverter.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOutAndConverter.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOutAndConverter.ts rename to packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetInAndAssetOutAndConverter.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetOut.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetOut.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetOut.ts rename to packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigByAssetOut.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigsByConverter.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigsByConverter.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigsByConverter.ts rename to packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/getConverterConfigsByConverter.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/index.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/index.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getTokenConverterConfigs/index.ts rename to packages/keeper-bots/src/converter-bot/queries/getTokenConverterConfigs/index.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getTokenConvertersTokenBalances.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConvertersTokenBalances.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getTokenConvertersTokenBalances.ts rename to packages/keeper-bots/src/converter-bot/queries/getTokenConvertersTokenBalances.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/getVTokensFromUnderlying.ts b/packages/keeper-bots/src/converter-bot/queries/getVTokensFromUnderlying.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/getVTokensFromUnderlying.ts rename to packages/keeper-bots/src/converter-bot/queries/getVTokensFromUnderlying.ts diff --git a/packages/token-converter-bot/src/converter-bot/queries/index.ts b/packages/keeper-bots/src/converter-bot/queries/index.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/queries/index.ts rename to packages/keeper-bots/src/converter-bot/queries/index.ts diff --git a/packages/token-converter-bot/src/converter-bot/types.ts b/packages/keeper-bots/src/converter-bot/types.ts similarity index 100% rename from packages/token-converter-bot/src/converter-bot/types.ts rename to packages/keeper-bots/src/converter-bot/types.ts diff --git a/packages/token-converter-bot/src/environment.d.ts b/packages/keeper-bots/src/environment.d.ts similarity index 100% rename from packages/token-converter-bot/src/environment.d.ts rename to packages/keeper-bots/src/environment.d.ts diff --git a/packages/token-converter-bot/src/index.ts b/packages/keeper-bots/src/index.ts similarity index 100% rename from packages/token-converter-bot/src/index.ts rename to packages/keeper-bots/src/index.ts diff --git a/packages/token-converter-bot/src/module.d.ts b/packages/keeper-bots/src/module.d.ts similarity index 100% rename from packages/token-converter-bot/src/module.d.ts rename to packages/keeper-bots/src/module.d.ts diff --git a/packages/token-converter-bot/src/subgraph-client/.graphclientrc.js b/packages/keeper-bots/src/subgraph-client/.graphclientrc.js similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/.graphclientrc.js rename to packages/keeper-bots/src/subgraph-client/.graphclientrc.js diff --git a/packages/token-converter-bot/src/subgraph-client/__mocks__/index.ts b/packages/keeper-bots/src/subgraph-client/__mocks__/index.ts similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/__mocks__/index.ts rename to packages/keeper-bots/src/subgraph-client/__mocks__/index.ts diff --git a/packages/token-converter-bot/src/subgraph-client/index.ts b/packages/keeper-bots/src/subgraph-client/index.ts similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/index.ts rename to packages/keeper-bots/src/subgraph-client/index.ts diff --git a/packages/token-converter-bot/src/subgraph-client/queries/CoreVTokensFromUnderlying.graphql b/packages/keeper-bots/src/subgraph-client/queries/CoreVTokensFromUnderlying.graphql similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/queries/CoreVTokensFromUnderlying.graphql rename to packages/keeper-bots/src/subgraph-client/queries/CoreVTokensFromUnderlying.graphql diff --git a/packages/token-converter-bot/src/subgraph-client/queries/IsolatedVTokensFromUnderlying.graphql b/packages/keeper-bots/src/subgraph-client/queries/IsolatedVTokensFromUnderlying.graphql similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/queries/IsolatedVTokensFromUnderlying.graphql rename to packages/keeper-bots/src/subgraph-client/queries/IsolatedVTokensFromUnderlying.graphql diff --git a/packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutAndConverterQuery.graphql b/packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutAndConverterQuery.graphql similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutAndConverterQuery.graphql rename to packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutAndConverterQuery.graphql diff --git a/packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutQuery.graphql b/packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutQuery.graphql similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutQuery.graphql rename to packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByAssetInAndAssetOutQuery.graphql diff --git a/packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByAssetInQuery.graphql b/packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByAssetInQuery.graphql similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByAssetInQuery.graphql rename to packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByAssetInQuery.graphql diff --git a/packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByAssetOutQuery.graphql b/packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByAssetOutQuery.graphql similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByAssetOutQuery.graphql rename to packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByAssetOutQuery.graphql diff --git a/packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByTokenConverterQuery.graphql b/packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByTokenConverterQuery.graphql similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsByTokenConverterQuery.graphql rename to packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsByTokenConverterQuery.graphql diff --git a/packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsQuery.graphql b/packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsQuery.graphql similarity index 100% rename from packages/token-converter-bot/src/subgraph-client/queries/TokenConverterConfigsQuery.graphql rename to packages/keeper-bots/src/subgraph-client/queries/TokenConverterConfigsQuery.graphql diff --git a/packages/token-converter-bot/tsconfig.json b/packages/keeper-bots/tsconfig.json similarity index 100% rename from packages/token-converter-bot/tsconfig.json rename to packages/keeper-bots/tsconfig.json diff --git a/packages/token-converter-bot/wagmi.config.ts b/packages/keeper-bots/wagmi.config.ts similarity index 100% rename from packages/token-converter-bot/wagmi.config.ts rename to packages/keeper-bots/wagmi.config.ts diff --git a/yarn.lock b/yarn.lock index ceebaa79..2704c64f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7300,9 +7300,9 @@ __metadata: languageName: unknown linkType: soft -"@venusprotocol/keeper-bots@workspace:.": +"@venusprotocol/keeper-bots-monorepo@workspace:.": version: 0.0.0-use.local - resolution: "@venusprotocol/keeper-bots@workspace:." + resolution: "@venusprotocol/keeper-bots-monorepo@workspace:." dependencies: "@commitlint/cli": ^17.0.3 "@commitlint/config-conventional": ^17.0.3 @@ -7329,6 +7329,47 @@ __metadata: languageName: unknown linkType: soft +"@venusprotocol/keeper-bots@workspace:packages/keeper-bots": + version: 0.0.0-use.local + resolution: "@venusprotocol/keeper-bots@workspace:packages/keeper-bots" + dependencies: + "@graphprotocol/client-cli": 3.0.0 + "@pancakeswap/sdk": ^5.8.0 + "@pancakeswap/smart-router": ^5.1.3 + "@pancakeswap/v3-core": ^1.0.2 + "@typechain/hardhat": ^6.1.2 + "@types/chai": ^4.3.11 + "@types/jest": ^29.5.12 + "@types/mocha": ^10.0.6 + "@types/node": ^20.10.0 + "@typescript-eslint/eslint-plugin": ^6.13.1 + "@typescript-eslint/parser": ^6.13.1 + "@uniswap/sdk": ^3.0.3 + "@uniswap/sdk-core": ^5.3.1 + "@uniswap/smart-order-router": ^3.36.0 + "@venusprotocol/keeper-bot-contracts": 1.2.0-dev.4 + "@venusprotocol/oracle": ^2.0.0 + "@wagmi/cli": ^2.0.4 + abitype: 0.10.0 + eslint: ^7.32.0 + eslint-plugin-jest: ^27.9.0 + graphql: ^16.8.1 + hardhat: ^2.19.5 + jest: ^29.7.0 + jsbi: ^3.2.5 + prettier: 2.7.1 + semantic-release: ^23.1.1 + semantic-release-monorepo: ^8.0.2 + ts-jest: ^29.1.2 + ts-node: ^10.9.1 + typechain: ^8.3.2 + typescript: ^5.3.2 + urql: ^3.0.3 + viem: ^2.7.1 + winston: ^3.11.0 + languageName: unknown + linkType: soft + "@venusprotocol/oracle@npm:^2.0.0": version: 2.4.0 resolution: "@venusprotocol/oracle@npm:2.4.0" @@ -7454,21 +7495,14 @@ __metadata: languageName: node linkType: hard -"@venusprotocol/token-converter-bot@^1.2.0-dev.1, @venusprotocol/token-converter-bot@workspace:packages/token-converter-bot": - version: 0.0.0-use.local - resolution: "@venusprotocol/token-converter-bot@workspace:packages/token-converter-bot" +"@venusprotocol/token-converter-bot@npm:^1.2.0-dev.1": + version: 1.2.0-dev.1 + resolution: "@venusprotocol/token-converter-bot@npm:1.2.0-dev.1" dependencies: "@graphprotocol/client-cli": 3.0.0 "@pancakeswap/sdk": ^5.8.0 "@pancakeswap/smart-router": ^5.1.3 "@pancakeswap/v3-core": ^1.0.2 - "@typechain/hardhat": ^6.1.2 - "@types/chai": ^4.3.11 - "@types/jest": ^29.5.12 - "@types/mocha": ^10.0.6 - "@types/node": ^20.10.0 - "@typescript-eslint/eslint-plugin": ^6.13.1 - "@typescript-eslint/parser": ^6.13.1 "@uniswap/sdk": ^3.0.3 "@uniswap/sdk-core": ^5.3.1 "@uniswap/smart-order-router": ^3.36.0 @@ -7476,24 +7510,15 @@ __metadata: "@venusprotocol/oracle": ^2.0.0 "@wagmi/cli": ^2.0.4 abitype: 0.10.0 - eslint: ^7.32.0 - eslint-plugin-jest: ^27.9.0 graphql: ^16.8.1 hardhat: ^2.19.5 - jest: ^29.7.0 jsbi: ^3.2.5 - prettier: 2.7.1 - semantic-release: ^23.1.1 - semantic-release-monorepo: ^8.0.2 - ts-jest: ^29.1.2 - ts-node: ^10.9.1 - typechain: ^8.3.2 - typescript: ^5.3.2 urql: ^3.0.3 viem: ^2.7.1 winston: ^3.11.0 - languageName: unknown - linkType: soft + checksum: b3e9ed37570c823a1c60b6cbb2c1236be00abda060f5423f29c6c261c1c3d2abd08b7c782a22c8c206b18089d4a0fa3d7bfd2922b95ecf705ccd02519275b70b + languageName: node + linkType: hard "@venusprotocol/venus-protocol@npm:^6.0.0": version: 6.0.0 From 5bbb994d4fd80bfbe68cebebe671a9f3811df917 Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Wed, 7 Aug 2024 09:49:04 -0300 Subject: [PATCH 02/11] refactor: remove liquidation bot package --- packages/liquidation-bot/.eslint-tsconfig | 12 ------ packages/liquidation-bot/.eslintignore | 4 -- packages/liquidation-bot/.prettierignore | 4 -- .../AccountsBorrowAndCollateral.graphql | 38 ------------------- 4 files changed, 58 deletions(-) delete mode 100644 packages/liquidation-bot/.eslint-tsconfig delete mode 100644 packages/liquidation-bot/.eslintignore delete mode 100644 packages/liquidation-bot/.prettierignore delete mode 100644 packages/liquidation-bot/src/subgraph-client/queries/AccountsBorrowAndCollateral.graphql diff --git a/packages/liquidation-bot/.eslint-tsconfig b/packages/liquidation-bot/.eslint-tsconfig deleted file mode 100644 index 5d7c42b0..00000000 --- a/packages/liquidation-bot/.eslint-tsconfig +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "allowJs": true - }, - "include": [ - "./src", - "wagmi.config.ts", - "src/environment.d.ts", - "jest.config.js" - ] -} diff --git a/packages/liquidation-bot/.eslintignore b/packages/liquidation-bot/.eslintignore deleted file mode 100644 index dc1ba39a..00000000 --- a/packages/liquidation-bot/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -dist -coverage -src/config/abis/generated.ts -subgraph-client/.graphqlclient diff --git a/packages/liquidation-bot/.prettierignore b/packages/liquidation-bot/.prettierignore deleted file mode 100644 index dc1ba39a..00000000 --- a/packages/liquidation-bot/.prettierignore +++ /dev/null @@ -1,4 +0,0 @@ -dist -coverage -src/config/abis/generated.ts -subgraph-client/.graphqlclient diff --git a/packages/liquidation-bot/src/subgraph-client/queries/AccountsBorrowAndCollateral.graphql b/packages/liquidation-bot/src/subgraph-client/queries/AccountsBorrowAndCollateral.graphql deleted file mode 100644 index b3e9cece..00000000 --- a/packages/liquidation-bot/src/subgraph-client/queries/AccountsBorrowAndCollateral.graphql +++ /dev/null @@ -1,38 +0,0 @@ -query AccountsBorrowAndCollateral($first: Int!, $skip: Int!) { - accountPools(first: $first, skip: $skip) { - id - account { - id - } - pool { - id - priceOracleAddress - liquidationIncentiveMantissa - closeFactorMantissa - minLiquidatableCollateralMantissa - } - collateral: tokens(where: { enteredMarket: true, accountVTokenSupplyBalanceMantissa_gt: 0 }) { - id - accountVTokenSupplyBalanceMantissa - market { - id - liquidationThresholdMantissa - exchangeRateMantissa - underlyingAddress - vTokenDecimals - underlyingDecimals - } - } - borrows: tokens(where: { accountBorrowBalanceMantissa_gt: 0 }) { - id - accountBorrowBalanceMantissa - accountBorrowIndexMantissa - market { - id - underlyingAddress - vTokenDecimals - underlyingDecimals - } - } - } -} From ef6197b0d377bb013051c657a32f43569f09c79d Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Fri, 9 Aug 2024 18:50:23 -0300 Subject: [PATCH 03/11] refactor: update pancakeswap package and subgraph url --- packages/cli/package.json | 2 +- .../cli/source/commands/conversionPairs.tsx | 8 +- packages/keeper-bots/package.json | 4 +- packages/keeper-bots/src/config/index.ts | 44 ++- .../queries/getVTokensFromUnderlying.ts | 6 +- yarn.lock | 293 +++--------------- 6 files changed, 90 insertions(+), 267 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index d9a39a19..f54cf9c6 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -28,7 +28,7 @@ "@graphql-mesh/cli": "^0.90.5", "@graphql-mesh/config": "^0.100.5", "@graphql-mesh/graphql": "^0.98.4", - "@venusprotocol/token-converter-bot": "^1.2.0-dev.1", + "@venusprotocol/keeper-bots": "^1.0.0", "@venusprotocol/venus-protocol": "^9.1.0", "dotenv": "^16.3.1", "graphql": "^16.8.1", diff --git a/packages/cli/source/commands/conversionPairs.tsx b/packages/cli/source/commands/conversionPairs.tsx index 9b5cc274..eb5d7df9 100644 --- a/packages/cli/source/commands/conversionPairs.tsx +++ b/packages/cli/source/commands/conversionPairs.tsx @@ -22,8 +22,12 @@ export default function ConversionPairs() { {configs.map(c => ( Token Converter: {c.tokenConverter.id} - Token In: {c.tokenIn.address} - Token Out: {c.tokenOut.address} + + Token In: {c.tokenIn.symbol} {c.tokenIn.address}{" "} + + + Token Out: {c.tokenOut.symbol} {c.tokenOut.address} + ))} diff --git a/packages/keeper-bots/package.json b/packages/keeper-bots/package.json index 68a255b4..2a8dabdf 100644 --- a/packages/keeper-bots/package.json +++ b/packages/keeper-bots/package.json @@ -28,8 +28,8 @@ "typings": "dist/index.d.ts", "dependencies": { "@graphprotocol/client-cli": "3.0.0", - "@pancakeswap/sdk": "^5.8.0", - "@pancakeswap/smart-router": "^5.1.3", + "@pancakeswap/sdk": "^5.8.8", + "@pancakeswap/smart-router": "^6.0.17", "@pancakeswap/v3-core": "^1.0.2", "@uniswap/sdk": "^3.0.3", "@uniswap/sdk-core": "^5.3.1", diff --git a/packages/keeper-bots/src/config/index.ts b/packages/keeper-bots/src/config/index.ts index d2dc5999..6e9a7a0a 100644 --- a/packages/keeper-bots/src/config/index.ts +++ b/packages/keeper-bots/src/config/index.ts @@ -10,28 +10,50 @@ const safelyGetEnvVar = (key: T) => { export const swapSubgraphUrlByNetwork = { bsctestnet: "https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-chapel", - bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV`, - ethereum: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV`, - sepolia: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/B4QeFHkfWXjKCDzNn3BJtDRDfG6VeHzGXgkf4Jt3fRn5`, + bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/Hv1GncLY5docZoGtXjo4kwbTvxm3MAhVZqBZE4sUT9eZ`, + ethereum: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV`, + sepolia: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/B4QeFHkfWXjKCDzNn3BJtDRDfG6VeHzGXgkf4Jt3fRn5`, }; export const protocolReserveSubgraphUrlByNetwork = { - bsctestnet: `https://gateway-testnet-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/56kKcG5fTJfmCncsvq9n2quExvFUfSEds3Lpk5dkWkgE`, - bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/2ZCWgaBc8KoWW8kh7MRzf9KPdr7NTZ5cda9bxpFDk4wG`, + bsctestnet: `https://gateway-testnet-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/56kKcG5fTJfmCncsvq9n2quExvFUfSEds3Lpk5dkWkgE`, + bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/2ZCWgaBc8KoWW8kh7MRzf9KPdr7NTZ5cda9bxpFDk4wG`, ethereum: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/QmcFbWExHdYuV3XQNPrX5PA467jRvSrtUfMLxoA6t95nSn`, sepolia: `https://api.studio.thegraph.com/query/${process.env.TESTNET_GRAPH_ID}/venus-protocol-reserve-sepolia/version/latest`, }; export const isolatedPoolsSubgraphUrlByNetwork = { - bsctestnet: `https://gateway-testnet-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/mkXvkAme9PyDnSrLkajVHKVX7eG2HHATcYPE1qGF7gc`, - bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/H2a3D64RV4NNxyJqx9jVFQRBpQRzD6zNZjLDotgdCrTC`, - ethereum: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/Htf6Hh1qgkvxQxqbcv4Jp5AatsaiY5dNLVcySkpCaxQ8`, - sepolia: `https://gateway-testnet-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/6YURB3bABVUNusgjtY7fNMkELGmKm9aaWirMQ9UZeDFj`, + bsctestnet: `https://gateway-testnet-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/mkXvkAme9PyDnSrLkajVHKVX7eG2HHATcYPE1qGF7gc`, + bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/H2a3D64RV4NNxyJqx9jVFQRBpQRzD6zNZjLDotgdCrTC`, + ethereum: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/Htf6Hh1qgkvxQxqbcv4Jp5AatsaiY5dNLVcySkpCaxQ8`, + sepolia: `https://gateway-testnet-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/6YURB3bABVUNusgjtY7fNMkELGmKm9aaWirMQ9UZeDFj`, }; export const corePoolSubgraphUrlByNetwork = { - bsctestnet: `https://gateway-testnet-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/AK258nTjNqNk8dKZwmPFiuxWX3yNfV7rYztXpegCmZ6A`, - bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/7h65Zf3pXXPmf8g8yZjjj2bqYiypVxems5d8riLK1DyR`, + bsctestnet: `https://gateway-testnet-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/AK258nTjNqNk8dKZwmPFiuxWX3yNfV7rYztXpegCmZ6A`, + bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/subgraphs/id/7h65Zf3pXXPmf8g8yZjjj2bqYiypVxems5d8riLK1DyR`, ethereum: "", sepolia: "", }; diff --git a/packages/keeper-bots/src/converter-bot/queries/getVTokensFromUnderlying.ts b/packages/keeper-bots/src/converter-bot/queries/getVTokensFromUnderlying.ts index b8c96372..7a05f882 100644 --- a/packages/keeper-bots/src/converter-bot/queries/getVTokensFromUnderlying.ts +++ b/packages/keeper-bots/src/converter-bot/queries/getVTokensFromUnderlying.ts @@ -11,11 +11,11 @@ const getVTokensFromUnderlying = async ( isolatedVTokens: IsolatedVTokensFromUnderlyingQuery["markets"]; }> => { const isolatedPoolSubgraphClient = new SubgraphClient(getConfig().isolatedPoolsSubgraphUrl); - const corePoolSubgraphClient = new SubgraphClient(getConfig().isolatedPoolsSubgraphUrl); + const corePoolSubgraphClient = new SubgraphClient(getConfig().corePoolSubgraphUrl); const { data: { markets: isolatedVTokens = [] } = { isolatedVTokens: [] } } = - await corePoolSubgraphClient.getIsolatedVTokensFromUnderlying(underlyingAddress); + await isolatedPoolSubgraphClient.getIsolatedVTokensFromUnderlying(underlyingAddress); const { data: { markets: coreVTokens = [] } = { coreVTokens: [] } } = - await isolatedPoolSubgraphClient.getCoreVTokensFromUnderlying(underlyingAddress); + await corePoolSubgraphClient.getCoreVTokensFromUnderlying(underlyingAddress); return { coreVTokens, isolatedVTokens }; }; diff --git a/yarn.lock b/yarn.lock index 2704c64f..2b6d0000 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4438,15 +4438,6 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.2.0, @noble/curves@npm:~1.2.0": - version: 1.2.0 - resolution: "@noble/curves@npm:1.2.0" - dependencies: - "@noble/hashes": 1.3.2 - checksum: bb798d7a66d8e43789e93bc3c2ddff91a1e19fdb79a99b86cd98f1e5eff0ee2024a2672902c2576ef3577b6f282f3b5c778bebd55761ddbb30e36bf275e83dd0 - languageName: node - linkType: hard - "@noble/curves@npm:1.4.0": version: 1.4.0 resolution: "@noble/curves@npm:1.4.0" @@ -4472,13 +4463,6 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.2": - version: 1.3.2 - resolution: "@noble/hashes@npm:1.3.2" - checksum: fe23536b436539d13f90e4b9be843cc63b1b17666a07634a2b1259dded6f490be3d050249e6af98076ea8f2ea0d56f578773c2197f2aa0eeaa5fba5bc18ba474 - languageName: node - linkType: hard - "@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.4.0, @noble/hashes@npm:~1.4.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" @@ -4486,13 +4470,6 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:~1.3.0, @noble/hashes@npm:~1.3.2": - version: 1.3.3 - resolution: "@noble/hashes@npm:1.3.3" - checksum: 8a6496d1c0c64797339bc694ad06cdfaa0f9e56cd0c3f68ae3666cfb153a791a55deb0af9c653c7ed2db64d537aa3e3054629740d2f2338bb1dcb7ab60cd205b - languageName: node - linkType: hard - "@noble/secp256k1@npm:1.7.1, @noble/secp256k1@npm:~1.7.0": version: 1.7.1 resolution: "@noble/secp256k1@npm:1.7.1" @@ -5352,60 +5329,37 @@ __metadata: languageName: node linkType: hard -"@pancakeswap/chains@npm:0.4.1": - version: 0.4.1 - resolution: "@pancakeswap/chains@npm:0.4.1" - checksum: 8b49a6232f06ac12a04012e80da17ebe41ce65aa5b98f293988cef074bb424f8437ffd601d43f9194b4c8b9f41039b1ad91673b7f22a62454b35d743d971e077 - languageName: node - linkType: hard - -"@pancakeswap/chains@npm:0.4.6, @pancakeswap/chains@npm:^0.4.1, @pancakeswap/chains@npm:^0.4.6": +"@pancakeswap/chains@npm:0.4.6, @pancakeswap/chains@npm:^0.4.6": version: 0.4.6 resolution: "@pancakeswap/chains@npm:0.4.6" checksum: 1aa4cea9aefb74d12811abbe67a5699ce7d4fda319ed2be2dbee4f346102aaf88cabad0511a74ed771ac2d615a94699a59a9c4e0d3707906cd61d57557d415a0 languageName: node linkType: hard -"@pancakeswap/gauges@npm:1.1.7": - version: 1.1.7 - resolution: "@pancakeswap/gauges@npm:1.1.7" - dependencies: - "@pancakeswap/chains": ^0.4.1 - "@pancakeswap/tokens": ^0.6.11 - "@pancakeswap/v3-sdk": ^3.8.0 - viem: 1.19.11 - checksum: d310bf1bb2567f93b1b2e949d0b64e1bbc3e61f2fc37c6aeebcadb7c1441c2df641926090121e2747da47621d950aa58ee87acf576bbd31781c8c173ad4b5dc3 - languageName: node - linkType: hard - -"@pancakeswap/multicall@npm:3.5.0": - version: 3.5.0 - resolution: "@pancakeswap/multicall@npm:3.5.0" +"@pancakeswap/gauges@npm:1.2.13": + version: 1.2.13 + resolution: "@pancakeswap/gauges@npm:1.2.13" dependencies: - "@pancakeswap/chains": 0.4.1 - "@pancakeswap/sdk": 5.8.0 - viem: 1.19.11 - checksum: 1ba8cef9cd8513b29b9c535a16bd5fa58f9d32706475b31e0de672b8cfe9b6684c0dd510825d1cedbb7479231b0fb66cf4d2371f6ca17c187a2151427317f458 + "@pancakeswap/chains": ^0.4.6 + "@pancakeswap/tokens": ^0.6.23 + "@pancakeswap/v3-sdk": ^3.8.11 + viem: ^2.17.3 + checksum: a2d34a442c51d4d8167d32cd31a6af010b4d5f59d0544ba7e613fcc71cbb746e3613f4277662f59a43b345a55667dfaa3f17619b710651a799f16fa17ca37bcc languageName: node linkType: hard -"@pancakeswap/sdk@npm:5.8.0": - version: 5.8.0 - resolution: "@pancakeswap/sdk@npm:5.8.0" +"@pancakeswap/multicall@npm:3.5.8": + version: 3.5.8 + resolution: "@pancakeswap/multicall@npm:3.5.8" dependencies: - "@pancakeswap/chains": ^0.4.1 - "@pancakeswap/swap-sdk-core": 1.1.0 - big.js: ^5.2.2 - decimal.js-light: ^2.5.0 - tiny-invariant: ^1.3.0 - tiny-warning: ^1.0.3 - toformat: ^2.0.0 - viem: 1.19.11 - checksum: 4ff444c47911bf43dd4b67e46e94645fd92875c06ef43ab4bc837c1d425afaedeaaadf8b7fbee19e6cc84dd15a22cb197ce389b2d483ba98619c23629e1323a6 + "@pancakeswap/chains": 0.4.6 + "@pancakeswap/sdk": 5.8.8 + viem: ^2.17.3 + checksum: 19fc854602f947d3bcbdd4cb659f055a14bd9f56458a26ce1416c4a2811a16d00ac4a81c45f880e31753547e89059376e108a33b9cd1d43bdf9aca4526a99c04 languageName: node linkType: hard -"@pancakeswap/sdk@npm:5.8.8, @pancakeswap/sdk@npm:^5.8.0": +"@pancakeswap/sdk@npm:5.8.8, @pancakeswap/sdk@npm:^5.8.8": version: 5.8.8 resolution: "@pancakeswap/sdk@npm:5.8.8" dependencies: @@ -5423,19 +5377,19 @@ __metadata: languageName: node linkType: hard -"@pancakeswap/smart-router@npm:^5.1.3": - version: 5.1.8 - resolution: "@pancakeswap/smart-router@npm:5.1.8" +"@pancakeswap/smart-router@npm:^6.0.17": + version: 6.0.17 + resolution: "@pancakeswap/smart-router@npm:6.0.17" dependencies: - "@pancakeswap/chains": 0.4.1 - "@pancakeswap/gauges": 1.1.7 - "@pancakeswap/multicall": 3.5.0 - "@pancakeswap/sdk": 5.8.0 - "@pancakeswap/stable-swap-sdk": 1.0.3 - "@pancakeswap/swap-sdk-core": 1.1.0 - "@pancakeswap/token-lists": 0.0.11 - "@pancakeswap/tokens": 0.6.11 - "@pancakeswap/v3-sdk": 3.8.0 + "@pancakeswap/chains": 0.4.6 + "@pancakeswap/gauges": 1.2.13 + "@pancakeswap/multicall": 3.5.8 + "@pancakeswap/sdk": 5.8.8 + "@pancakeswap/stable-swap-sdk": 1.0.15 + "@pancakeswap/swap-sdk-core": 1.2.0 + "@pancakeswap/token-lists": 0.0.12 + "@pancakeswap/tokens": 0.6.23 + "@pancakeswap/v3-sdk": 3.8.11 async-retry: ^1.3.1 debug: ^4.3.4 graphql: ^16.8.1 @@ -5444,34 +5398,21 @@ __metadata: mnemonist: ^0.38.3 stats-lite: ^2.2.0 tiny-invariant: ^1.3.0 - viem: 1.19.11 + viem: ^2.17.3 zod: ^3.22.3 - checksum: 34179cf477deddea5cb9dd3ae68755600be5f8d0dd27d0d47b2e2d66ce0aad173a55f419b314c757c2fc425b29a326a50a778598c3dbae9ef5fe6e0b74b0e33c + checksum: 7910e28d45f405a5e896d11353d5feeab3db4208bd74c3b7f0ce5a689d172351699aa0d8340ef0a751a923e3ecc7e9cc34af576ce4fb80fd610978a9df5bc3a6 languageName: node linkType: hard -"@pancakeswap/stable-swap-sdk@npm:1.0.3": - version: 1.0.3 - resolution: "@pancakeswap/stable-swap-sdk@npm:1.0.3" - dependencies: - "@pancakeswap/chains": 0.4.1 - "@pancakeswap/swap-sdk-core": 1.1.0 - "@pancakeswap/tokens": 0.6.11 - tiny-invariant: ^1.3.0 - checksum: 0e44ef3ec979d7441dac97d0698e55f2b2074ea4ba28deb6bd15ac04288e3d1b7e4748733bf8b417cc6b553bfc64a95fd8df325bd1ccfced38cb6dcfd8a55492 - languageName: node - linkType: hard - -"@pancakeswap/swap-sdk-core@npm:1.1.0": - version: 1.1.0 - resolution: "@pancakeswap/swap-sdk-core@npm:1.1.0" +"@pancakeswap/stable-swap-sdk@npm:1.0.15": + version: 1.0.15 + resolution: "@pancakeswap/stable-swap-sdk@npm:1.0.15" dependencies: - big.js: ^5.2.2 - decimal.js-light: ^2.5.0 + "@pancakeswap/chains": 0.4.6 + "@pancakeswap/swap-sdk-core": 1.2.0 + "@pancakeswap/tokens": 0.6.23 tiny-invariant: ^1.3.0 - tiny-warning: ^1.0.3 - toformat: ^2.0.0 - checksum: 064ffd19d447057eef5c569cb250511eb1c134e6fe8af302efdd7a9eee57bd36444933ce825bdec3acb1955cfb3873f419237fa50ab69a1bed0907cdf12711e2 + checksum: fcfad3d46f33a822ae257390d21f0428f4e35dbd7c9d870e5dddee68ca2be887c61d87be311145c7722f36bf14bbf20b6882b0ad9810627492434d3059e68a56 languageName: node linkType: hard @@ -5501,31 +5442,6 @@ __metadata: languageName: node linkType: hard -"@pancakeswap/token-lists@npm:0.0.11": - version: 0.0.11 - resolution: "@pancakeswap/token-lists@npm:0.0.11" - dependencies: - "@pancakeswap/swap-sdk-core": 1.1.0 - ajv: ^6.12.3 - lodash: ^4.17.21 - peerDependencies: - "@reduxjs/toolkit": ^1.9.1 - jotai: ^2.4.3 - localforage: ^1.10.0 - react: ^18.2.0 - peerDependenciesMeta: - "@reduxjs/toolkit": - optional: true - jotai: - optional: true - localforage: - optional: true - react: - optional: true - checksum: 555b55ee290234e2e347e1b0118d2793b1d60da6ceb413c4cfe27d36b6c7e73bb004129fb6defcc5f644f121f062465a2b1e5c22e774fdc50136f7572bbddc5b - languageName: node - linkType: hard - "@pancakeswap/token-lists@npm:0.0.12": version: 0.0.12 resolution: "@pancakeswap/token-lists@npm:0.0.12" @@ -5551,18 +5467,7 @@ __metadata: languageName: node linkType: hard -"@pancakeswap/tokens@npm:0.6.11": - version: 0.6.11 - resolution: "@pancakeswap/tokens@npm:0.6.11" - dependencies: - "@pancakeswap/chains": 0.4.1 - "@pancakeswap/sdk": 5.8.0 - "@pancakeswap/token-lists": 0.0.11 - checksum: b8aa8984f7c730031f81ef5b7313a32d6c8e8fa39bed7e3e57e05da4ac05a6b19a29180b51d50c092bd98ae695dfb1b7b7b17903b03af1faab7961a508625623 - languageName: node - linkType: hard - -"@pancakeswap/tokens@npm:^0.6.11": +"@pancakeswap/tokens@npm:0.6.23, @pancakeswap/tokens@npm:^0.6.23": version: 0.6.23 resolution: "@pancakeswap/tokens@npm:0.6.23" dependencies: @@ -5593,24 +5498,7 @@ __metadata: languageName: node linkType: hard -"@pancakeswap/v3-sdk@npm:3.8.0": - version: 3.8.0 - resolution: "@pancakeswap/v3-sdk@npm:3.8.0" - dependencies: - "@pancakeswap/chains": 0.4.1 - "@pancakeswap/sdk": 5.8.0 - "@pancakeswap/swap-sdk-core": 1.1.0 - big.js: ^5.2.2 - decimal.js-light: ^2.5.0 - tiny-invariant: ^1.3.0 - tiny-warning: ^1.0.3 - toformat: ^2.0.0 - viem: 1.19.11 - checksum: 64e97c64d0e57c12dcc78118e21953606d5d7024f6b8ae2e210f363af9f17c4fbd2b131baf5b762ac4d2adc465c197a085ebbce9b22e5ee25fe96015eb680a15 - languageName: node - linkType: hard - -"@pancakeswap/v3-sdk@npm:^3.8.0": +"@pancakeswap/v3-sdk@npm:3.8.11, @pancakeswap/v3-sdk@npm:^3.8.11": version: 3.8.11 resolution: "@pancakeswap/v3-sdk@npm:3.8.11" dependencies: @@ -5708,7 +5596,7 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:~1.1.0, @scure/base@npm:~1.1.2, @scure/base@npm:~1.1.6": +"@scure/base@npm:~1.1.0, @scure/base@npm:~1.1.6": version: 1.1.7 resolution: "@scure/base@npm:1.1.7" checksum: d9084be9a2f27971df1684af9e40bb750e86f549345e1bb3227fb61673c0c83569c92c1cb0a4ddccb32650b39d3cd3c145603b926ba751c9bc60c27317549b20 @@ -5726,17 +5614,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip32@npm:1.3.2": - version: 1.3.2 - resolution: "@scure/bip32@npm:1.3.2" - dependencies: - "@noble/curves": ~1.2.0 - "@noble/hashes": ~1.3.2 - "@scure/base": ~1.1.2 - checksum: c5ae84fae43490853693b481531132b89e056d45c945fc8b92b9d032577f753dfd79c5a7bbcbf0a7f035951006ff0311b6cf7a389e26c9ec6335e42b20c53157 - languageName: node - linkType: hard - "@scure/bip32@npm:1.4.0": version: 1.4.0 resolution: "@scure/bip32@npm:1.4.0" @@ -5758,16 +5635,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip39@npm:1.2.1": - version: 1.2.1 - resolution: "@scure/bip39@npm:1.2.1" - dependencies: - "@noble/hashes": ~1.3.0 - "@scure/base": ~1.1.0 - checksum: c5bd6f1328fdbeae2dcdd891825b1610225310e5e62a4942714db51066866e4f7bef242c7b06a1b9dcc8043a4a13412cf5c5df76d3b10aa9e36b82e9b6e3eeaa - languageName: node - linkType: hard - "@scure/bip39@npm:1.3.0": version: 1.3.0 resolution: "@scure/bip39@npm:1.3.0" @@ -7171,7 +7038,7 @@ __metadata: "@graphql-mesh/graphql": ^0.98.4 "@sindresorhus/tsconfig": ^3.0.1 "@types/react": ^18.2.55 - "@venusprotocol/token-converter-bot": ^1.2.0-dev.1 + "@venusprotocol/keeper-bots": ^1.0.0 "@venusprotocol/venus-protocol": ^9.1.0 ava: ^5.2.0 chalk: ^5.2.0 @@ -7329,13 +7196,13 @@ __metadata: languageName: unknown linkType: soft -"@venusprotocol/keeper-bots@workspace:packages/keeper-bots": +"@venusprotocol/keeper-bots@^1.0.0, @venusprotocol/keeper-bots@workspace:packages/keeper-bots": version: 0.0.0-use.local resolution: "@venusprotocol/keeper-bots@workspace:packages/keeper-bots" dependencies: "@graphprotocol/client-cli": 3.0.0 - "@pancakeswap/sdk": ^5.8.0 - "@pancakeswap/smart-router": ^5.1.3 + "@pancakeswap/sdk": ^5.8.8 + "@pancakeswap/smart-router": ^6.0.17 "@pancakeswap/v3-core": ^1.0.2 "@typechain/hardhat": ^6.1.2 "@types/chai": ^4.3.11 @@ -7495,31 +7362,6 @@ __metadata: languageName: node linkType: hard -"@venusprotocol/token-converter-bot@npm:^1.2.0-dev.1": - version: 1.2.0-dev.1 - resolution: "@venusprotocol/token-converter-bot@npm:1.2.0-dev.1" - dependencies: - "@graphprotocol/client-cli": 3.0.0 - "@pancakeswap/sdk": ^5.8.0 - "@pancakeswap/smart-router": ^5.1.3 - "@pancakeswap/v3-core": ^1.0.2 - "@uniswap/sdk": ^3.0.3 - "@uniswap/sdk-core": ^5.3.1 - "@uniswap/smart-order-router": ^3.36.0 - "@venusprotocol/keeper-bot-contracts": 1.2.0-dev.4 - "@venusprotocol/oracle": ^2.0.0 - "@wagmi/cli": ^2.0.4 - abitype: 0.10.0 - graphql: ^16.8.1 - hardhat: ^2.19.5 - jsbi: ^3.2.5 - urql: ^3.0.3 - viem: ^2.7.1 - winston: ^3.11.0 - checksum: b3e9ed37570c823a1c60b6cbb2c1236be00abda060f5423f29c6c261c1c3d2abd08b7c782a22c8c206b18089d4a0fa3d7bfd2922b95ecf705ccd02519275b70b - languageName: node - linkType: hard - "@venusprotocol/venus-protocol@npm:^6.0.0": version: 6.0.0 resolution: "@venusprotocol/venus-protocol@npm:6.0.0" @@ -7866,21 +7708,6 @@ __metadata: languageName: node linkType: hard -"abitype@npm:0.9.8": - version: 0.9.8 - resolution: "abitype@npm:0.9.8" - peerDependencies: - typescript: ">=5.0.4" - zod: ^3 >=3.19.1 - peerDependenciesMeta: - typescript: - optional: true - zod: - optional: true - checksum: d7d887f29d6821e3f7a400de9620511b80ead3f85c5c87308aaec97965d3493e6687ed816e88722b4f512249bd66dee9e69231b49af0e1db8f69400a62c87cf6 - languageName: node - linkType: hard - "abitype@npm:1.0.5": version: 1.0.5 resolution: "abitype@npm:1.0.5" @@ -15005,15 +14832,6 @@ __metadata: languageName: node linkType: hard -"isows@npm:1.0.3": - version: 1.0.3 - resolution: "isows@npm:1.0.3" - peerDependencies: - ws: "*" - checksum: 9cacd5cf59f67deb51e825580cd445ab1725ecb05a67c704050383fb772856f3cd5e7da8ad08f5a3bd2823680d77d099459d0c6a7037972a74d6429af61af440 - languageName: node - linkType: hard - "isows@npm:1.0.4": version: 1.0.4 resolution: "isows@npm:1.0.4" @@ -22215,27 +22033,6 @@ __metadata: languageName: node linkType: hard -"viem@npm:1.19.11": - version: 1.19.11 - resolution: "viem@npm:1.19.11" - dependencies: - "@adraffy/ens-normalize": 1.10.0 - "@noble/curves": 1.2.0 - "@noble/hashes": 1.3.2 - "@scure/bip32": 1.3.2 - "@scure/bip39": 1.2.1 - abitype: 0.9.8 - isows: 1.0.3 - ws: 8.13.0 - peerDependencies: - typescript: ">=5.0.4" - peerDependenciesMeta: - typescript: - optional: true - checksum: 33a26f361bb2597fe0b02dc98382eb66b83473c3a9765833969a45ac7b4017fa62d7ddc42f9d4d0f3473bec7096eb081651851473b4d0ff4ab56f71a2f6378a2 - languageName: node - linkType: hard - "viem@npm:2.x, viem@npm:^2.10.5, viem@npm:^2.17.3, viem@npm:^2.7.1": version: 2.18.8 resolution: "viem@npm:2.18.8" From 68e89bdd76b15d1fe699b0071528b9515d74b44b Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Mon, 12 Aug 2024 14:26:26 -0600 Subject: [PATCH 04/11] feat: filter conversion pairs list by converter --- .../cli/source/commands/conversionPairs.tsx | 53 +++++++++++++++---- packages/cli/source/commands/convert.tsx | 11 ++-- .../src/converter-bot/TokenConverter.test.ts | 8 +-- .../getTokenConvertersTokenBalances.ts | 16 +++--- 4 files changed, 64 insertions(+), 24 deletions(-) diff --git a/packages/cli/source/commands/conversionPairs.tsx b/packages/cli/source/commands/conversionPairs.tsx index eb5d7df9..b0931fb4 100644 --- a/packages/cli/source/commands/conversionPairs.tsx +++ b/packages/cli/source/commands/conversionPairs.tsx @@ -1,32 +1,67 @@ +import { option } from "pastel"; +import zod from "zod"; import { useEffect, useState } from "react"; import { Box, Text, useApp } from "ink"; -import { TokenConverterConfigs, getAllConverterConfigs } from "@venusprotocol/keeper-bots"; +import { + BalanceResult, + getAllConverterConfigs, + getConverterConfigsByConverter, + getTokenConvertersTokenBalances, +} from "@venusprotocol/keeper-bots"; +import { addressValidation } from "../utils/validation.js"; + +export const options = zod.object({ + converter: addressValidation + .describe( + option({ + description: "Token converter address", + alias: "c", + }), + ) + .optional(), +}); + +interface Props { + options: zod.infer; +} /** * Helper command to list available conversion pairs */ -export default function ConversionPairs() { - const [configs, setConfigs] = useState([]); +export default function ConversionPairs({ options }: Props) { + const { converter } = options; + const [configs, setConfigs] = useState([]); const { exit } = useApp(); useEffect(() => { (async () => { - const configs = await getAllConverterConfigs(); - setConfigs(configs); + let configs = []; + if (converter) { + configs = await getConverterConfigsByConverter(converter); + } else { + configs = await getAllConverterConfigs(); + } + const { results } = await getTokenConvertersTokenBalances( + configs, + "0x0000000000000000000000000000000000000000", + false, + ); + + setConfigs(results); })().finally(exit); }, []); return ( {configs.map(c => ( - - Token Converter: {c.tokenConverter.id} + + Token Converter: {c.tokenConverter} - Token In: {c.tokenIn.symbol} {c.tokenIn.address}{" "} + Token In: {c.assetIn.symbol} {c.assetIn.address}{" "} - Token Out: {c.tokenOut.symbol} {c.tokenOut.address} + Token Out: {c.assetOut.symbol} {c.assetOut.address} (Balance {c.assetOut.balance.toString()}) ))} diff --git a/packages/cli/source/commands/convert.tsx b/packages/cli/source/commands/convert.tsx index 7a93a705..160525d0 100644 --- a/packages/cli/source/commands/convert.tsx +++ b/packages/cli/source/commands/convert.tsx @@ -176,7 +176,8 @@ export default function Convert({ options }: Props) { await Promise.allSettled( potentialConversions.map(async (t: any) => { let amountOut = t.assetOut.balance; - const vTokenAddress = t.assetOutVTokens.core || t.assetOutVTokens.isolated[1]; + + const vTokenAddress = t.assetOutVTokens.core || t.assetOutVTokens.isolated[0][1]; const { underlyingPriceUsd, underlyingUsdValue, underlyingDecimals } = await tokenConverter.getUsdValue( t.assetOut.address, vTokenAddress, @@ -191,7 +192,7 @@ export default function Convert({ options }: Props) { const arbitrageArgs = await tokenConverter.prepareConversion( t.tokenConverter, t.assetOut.address, - t.assetIn, + t.assetIn.address, amountOut, ); @@ -209,7 +210,7 @@ export default function Convert({ options }: Props) { context: { converter: t.tokenConverter, tokenToReceiveFromConverter: t.assetOut.address, - tokenToSendToConverter: t.assetIn, + tokenToSendToConverter: t.assetIn.address, amount, minIncome, percentage: Number((minIncome * 10000000n) / amount) / 10000000, @@ -225,7 +226,7 @@ export default function Convert({ options }: Props) { context: { converter: t.tokenConverter.id, tokenToReceiveFromConverter: t.assetOut.address, - tokenToSendToConverter: t.assetIn, + tokenToSendToConverter: t.assetIn.address, amount, minIncome, percentage: Number((minIncome * 10000000n) / amount) / 10000000, @@ -239,7 +240,7 @@ export default function Convert({ options }: Props) { context: { converter: t.tokenConverter.id, tokenToReceiveFromConverter: t.assetOut.address, - tokenToSendToConverter: t.assetIn, + tokenToSendToConverter: t.assetIn.address, amount, minIncome, percentage: Number((minIncome * 10000000n) / amount) / 10000000, diff --git a/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts b/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts index aea1c08e..8a2188ea 100644 --- a/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts +++ b/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts @@ -530,15 +530,15 @@ describe("Token Converter", () => { const balanceResults: BalanceResult[] = [ { tokenConverter: addresses.USDCPrimeConverter, - assetIn: addresses.USDC, - assetOut: { address: addresses.BUSD, balance: 600000000000000000000n }, + assetIn: { address: addresses.USDC, symbol: "USDC", decimals: 18 }, + assetOut: { address: addresses.BUSD, balance: 600000000000000000000n, symbol: "BUSD", decimals: 18 }, assetOutVTokens: { core: addresses.vBNBCore, isolated: [] }, accountBalanceAssetOut: 6000000000000000000n, }, { tokenConverter: addresses.USDTPrimeConverter, - assetIn: addresses.USDT, - assetOut: { address: addresses.WBNB, balance: 400000000000000000000n }, + assetIn: { address: addresses.USDT, symbol: "USDT", decimals: 18 }, + assetOut: { address: addresses.WBNB, balance: 400000000000000000000n, symbol: "BUSD", decimals: 18 }, assetOutVTokens: { core: undefined, isolated: [[addresses.stableCoinComptroller, addresses.vBNBIL]] }, accountBalanceAssetOut: 4000000000000000000n, }, diff --git a/packages/keeper-bots/src/converter-bot/queries/getTokenConvertersTokenBalances.ts b/packages/keeper-bots/src/converter-bot/queries/getTokenConvertersTokenBalances.ts index d94912dc..c116b44b 100644 --- a/packages/keeper-bots/src/converter-bot/queries/getTokenConvertersTokenBalances.ts +++ b/packages/keeper-bots/src/converter-bot/queries/getTokenConvertersTokenBalances.ts @@ -13,8 +13,12 @@ import getVTokensFromUnderlying from "./getVTokensFromUnderlying"; export interface BalanceResult { tokenConverter: Address; - assetIn: Address; - assetOut: { address: Address; balance: bigint }; + assetIn: { + address: Address; + symbol?: string | null; + decimals: number; + }; + assetOut: { address: Address; balance: bigint; symbol?: string | null; decimals: number }; assetOutVTokens: { core: `0x${string}` | undefined; isolated: [`0x${string}`, `0x${string}`][] | undefined; @@ -32,12 +36,12 @@ const formatResults = async ( for (let i = 0; i < results.length; i += chunkSize) { const index = (i + chunkSize) / chunkSize - 1; const tokenConverter = tokenConverterConfigs[index].tokenConverter.id as Address; - const assetIn = tokenConverterConfigs[index].tokenIn.address; - const assetOut = tokenConverterConfigs[index].tokenOut.address; + const assetIn = tokenConverterConfigs[index].tokenIn; + const assetOut = tokenConverterConfigs[index].tokenOut; const curr = results.slice(i, i + chunkSize); - const { coreVTokens, isolatedVTokens } = await getVTokensFromUnderlying(assetOut); + const { coreVTokens, isolatedVTokens } = await getVTokensFromUnderlying(assetOut.address); const balance = { assetOutVTokens: { core: coreVTokens[0]?.id as Address, @@ -45,7 +49,7 @@ const formatResults = async ( }, tokenConverter, assetIn, - assetOut: { address: assetOut, balance: BigInt(curr[0].toString()) }, + assetOut: { ...assetOut, balance: BigInt(curr[0].toString()) }, accountBalanceAssetOut: BigInt(curr[1].toString()), }; From d508e42a4e94c98dff7a8323e25f5932dafcb379 Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Thu, 15 Aug 2024 07:03:06 -0600 Subject: [PATCH 05/11] refactor: create trade with token amounts as fractions --- packages/keeper-bots/src/__mocks__/index.ts | 6 +- .../src/converter-bot/TokenConverter.test.ts | 173 +++++++++++++----- .../src/converter-bot/TokenConverter.ts | 15 +- .../converter-bot/providers/pancake-swap.ts | 6 +- .../converter-bot/providers/swap-provider.ts | 1 - .../src/converter-bot/providers/uniswap.ts | 13 +- .../keeper-bots/src/converter-bot/types.ts | 5 +- 7 files changed, 150 insertions(+), 69 deletions(-) diff --git a/packages/keeper-bots/src/__mocks__/index.ts b/packages/keeper-bots/src/__mocks__/index.ts index f6aed07d..b61f2859 100644 --- a/packages/keeper-bots/src/__mocks__/index.ts +++ b/packages/keeper-bots/src/__mocks__/index.ts @@ -1,4 +1,4 @@ -import { CurrencyAmount, Percent, Token } from "@pancakeswap/sdk"; +import { CurrencyAmount, Fraction, Percent, Token } from "@pancakeswap/sdk"; import { RouteV3 } from "@uniswap/router-sdk"; import { Token as UniswapToken } from "@uniswap/sdk-core"; import { FeeAmount, Pool, Route as V3RouteSDK } from "@uniswap/v3-sdk"; @@ -113,11 +113,11 @@ export const mockTrade = { path: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c000cf6bb5389c92bdda8a3747ddb454cb7a64626c63" as const, inputToken: { address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c" as const, - amount: 8904975230019520420n, + amount: new Fraction(8904975230019520420n, 1), }, outputToken: { address: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63" as const, - amount: 517926942058379677423n, + amount: new Fraction(517926942058379677423n, 1), }, }; diff --git a/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts b/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts index aea1c08e..02f6869c 100644 --- a/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts +++ b/packages/keeper-bots/src/converter-bot/TokenConverter.test.ts @@ -121,28 +121,53 @@ describe("Token Converter", () => { (tokenConverter.publicClient.simulateContract as jest.Mock).mockImplementation(() => ({ result: [1000000000000000000n, 1000000000000000000n], })); + const [trade, updatedAmountIn] = await tokenConverter.getBestTrade( + addresses.USDCPrimeConverter, + addresses.WBNB, + addresses.USDC, + 1000000000000000000000n, + ); - expect( - await tokenConverter.getBestTrade( - addresses.USDCPrimeConverter, - addresses.WBNB, - addresses.USDC, - 1000000000000000000000n, - ), - ).toEqual([ - { - inputToken: { + expect(trade.inputToken).toEqual({ + address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + amount: { + currency: { address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", - amount: "8", + chainId: 56, + decimals: 18, + isNative: false, + isToken: true, + name: undefined, + projectLink: undefined, + symbol: "WBNB", }, - outputToken: { + decimalScale: 1000000000000000000n, + denominator: 1n, + numerator: 8904975230019520420n, + }, + }); + expect(trade.outputToken).toEqual({ + address: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63", + amount: { + currency: { address: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63", - amount: "517", + chainId: 56, + decimals: 18, + isNative: false, + isToken: true, + name: undefined, + projectLink: undefined, + symbol: "XVS", }, - path: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c630009c4bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + decimalScale: 1000000000000000000n, + denominator: 1n, + numerator: 517926942058379677423n, }, - [1000000000000000000n, 1000000000000000000n], - ]); + }); + expect(trade.path).toEqual( + "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c630009c4bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + ); + expect(updatedAmountIn).toEqual([1000000000000000000n, 1000000000000000000n]); }); test("should call getBestTrade again if price impact is high with lower amount", async () => { @@ -168,27 +193,53 @@ describe("Token Converter", () => { return new Percent(9n, 1000n); }); - expect( - await pancakeSwapProvider.getBestTrade( - addresses.USDCPrimeConverter, - addresses.WBNB, - addresses.USDC, - 1000000000000000000000n, - ), - ).toEqual([ - { - inputToken: { + const [trade, updatedAmountIn] = await pancakeSwapProvider.getBestTrade( + addresses.USDCPrimeConverter, + addresses.WBNB, + addresses.USDC, + 1000000000000000000000n, + ); + + expect(trade.inputToken).toEqual({ + address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + amount: { + currency: { address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", - amount: "8", + chainId: 56, + decimals: 18, + isNative: false, + isToken: true, + name: undefined, + projectLink: undefined, + symbol: "WBNB", }, - outputToken: { + decimalScale: 1000000000000000000n, + denominator: 1n, + numerator: 8904975230019520420n, + }, + }); + expect(trade.outputToken).toEqual({ + address: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63", + amount: { + currency: { address: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63", - amount: "517", + chainId: 56, + decimals: 18, + isNative: false, + isToken: true, + name: undefined, + projectLink: undefined, + symbol: "XVS", }, - path: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c630009c4bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + decimalScale: 1000000000000000000n, + denominator: 1n, + numerator: 517926942058379677423n, }, - [1000000000000000000n, 1000000000000000000n], - ]); + }); + expect(trade.path).toEqual( + "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c630009c4bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + ); + expect(updatedAmountIn).toEqual([1000000000000000000n, 1000000000000000000n]); expect(pancakeSwapProviderMock).toHaveBeenNthCalledWith( 3, @@ -840,28 +891,54 @@ describe("Token Converter", () => { result: [1000000000000000000n, 1000000000000000000n], })); - expect( - await tokenConverter.prepareConversion( - addresses.USDCPrimeConverter, - addresses.WBNB, - addresses.USDC, - 1000000000000000000000n, - ), - ).toEqual({ - trade: { - inputToken: { - amount: "8", + const arbitrageArgs = await tokenConverter.prepareConversion( + addresses.USDCPrimeConverter, + addresses.WBNB, + addresses.USDC, + 1000000000000000000000n, + ); + + expect(arbitrageArgs?.amount).toEqual(1000000000000000000n); + expect(arbitrageArgs?.trade.inputToken).toEqual({ + address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + amount: { + currency: { address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + chainId: 56, + decimals: 18, + isNative: false, + isToken: true, + name: undefined, + projectLink: undefined, + symbol: "WBNB", }, - outputToken: { - amount: "517", + decimalScale: 1000000000000000000n, + denominator: 1n, + numerator: 8904975230019520420n, + }, + }); + expect(arbitrageArgs?.trade.outputToken).toEqual({ + address: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63", + amount: { + currency: { address: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c63", + chainId: 56, + decimals: 18, + isNative: false, + isToken: true, + name: undefined, + projectLink: undefined, + symbol: "XVS", }, - path: "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c630009c4bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + decimalScale: 1000000000000000000n, + denominator: 1n, + numerator: 517926942058379677423n, }, - amount: 1000000000000000000n, - minIncome: 999999999999999992n, }); + expect(arbitrageArgs?.trade.path).toEqual( + "0xcf6bb5389c92bdda8a3747ddb454cb7a64626c630009c4bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c", + ); + expect(arbitrageArgs?.minIncome).toEqual(-7904975230019520420n); expect(subscriberMock).toHaveBeenCalledWith({ type: "GetBestTrade", diff --git a/packages/keeper-bots/src/converter-bot/TokenConverter.ts b/packages/keeper-bots/src/converter-bot/TokenConverter.ts index 796559f2..f4603c6b 100644 --- a/packages/keeper-bots/src/converter-bot/TokenConverter.ts +++ b/packages/keeper-bots/src/converter-bot/TokenConverter.ts @@ -327,14 +327,14 @@ export class TokenConverter { * @param amount Amount to check/ request if an allowance has been granted */ async checkAndRequestAllowance(token: Address, owner: Address, spender: Address, amount: bigint) { - const approvalAmount = await this.publicClient.readContract({ + const allowance = await this.publicClient.readContract({ address: token, abi: erc20Abi, functionName: "allowance", args: [owner, spender], }); - if (approvalAmount < amount) { + if (allowance < amount) { const trx = await this.walletClient.writeContract({ address: token, abi: erc20Abi, @@ -444,16 +444,17 @@ export class TokenConverter { tradeAmount: { amountOut: tradeAmount && tradeAmount[0], amountIn: tradeAmount && tradeAmount[1] }, swap: { inputToken: { - amount: trade.inputToken.amount.toString(), + amount: trade.inputToken.amount.toFixed(0), token: trade.inputToken.address, }, outputToken: { - amount: trade.outputToken.amount.toString(), + amount: trade.outputToken.amount.toFixed(0), token: trade.outputToken.address, }, }, }; } + this.sendMessage({ type: "GetBestTrade", error, @@ -468,13 +469,11 @@ export class TokenConverter { if (trade && tradeAmount) { // the difference between the token you get from TokenConverter and the token you pay to the MM - const minIncome = BigInt( - new Fraction(tradeAmount[0], 1).subtract(trade.inputToken.amount).toFixed(0, { groupSeparator: "" }), - ); + const minIncome = new Fraction(tradeAmount[0], 1).subtract(trade.inputToken.amount); return { trade, amount: tradeAmount[0], - minIncome, + minIncome: BigInt(minIncome.toFixed(0, { groupSeparator: "" })), }; } } diff --git a/packages/keeper-bots/src/converter-bot/providers/pancake-swap.ts b/packages/keeper-bots/src/converter-bot/providers/pancake-swap.ts index 22da5c5c..d93d65e5 100644 --- a/packages/keeper-bots/src/converter-bot/providers/pancake-swap.ts +++ b/packages/keeper-bots/src/converter-bot/providers/pancake-swap.ts @@ -93,6 +93,7 @@ class PancakeSwapProvider extends SwapProvider { functionName: "getUpdatedAmountIn", args: [amount, swapToToken.address, swapFromToken.address], }); + try { const response = await SmartRouter.getBestTrade( CurrencyAmount.fromRawAmount(swapToToken, updatedAmountIn[1]), @@ -107,14 +108,15 @@ class PancakeSwapProvider extends SwapProvider { quoterOptimization: true, }, ); + if (response) { trade = { inputToken: { - amount: response.inputAmount.toFixed(0, { groupSeparator: "" }), + amount: response.inputAmount, address: response.inputAmount.currency.address, }, outputToken: { - amount: response.outputAmount.toFixed(0, { groupSeparator: "" }), + amount: response.outputAmount, address: response.outputAmount.currency.address, }, path: this.encodeExactInputPath(response.routes[0]), diff --git a/packages/keeper-bots/src/converter-bot/providers/swap-provider.ts b/packages/keeper-bots/src/converter-bot/providers/swap-provider.ts index 7cfcbe7a..0480ece0 100644 --- a/packages/keeper-bots/src/converter-bot/providers/swap-provider.ts +++ b/packages/keeper-bots/src/converter-bot/providers/swap-provider.ts @@ -26,7 +26,6 @@ class SwapProvider { getOutputCurrency =

(pool: P, inputToken: T): T => { // @ts-expect-error library types don't match const { token0, token1 } = pool; - console.log("token0.equals(inputToken)", token0.equals(inputToken)); return token0.equals(inputToken) ? token1 : token0; }; diff --git a/packages/keeper-bots/src/converter-bot/providers/uniswap.ts b/packages/keeper-bots/src/converter-bot/providers/uniswap.ts index 488e01e6..ef30add8 100644 --- a/packages/keeper-bots/src/converter-bot/providers/uniswap.ts +++ b/packages/keeper-bots/src/converter-bot/providers/uniswap.ts @@ -1,5 +1,6 @@ +import { Fraction } from "@pancakeswap/sdk"; import { IRoute } from "@uniswap/router-sdk"; -import { ChainId, Currency, CurrencyAmount, Fraction, Percent, Token, TradeType } from "@uniswap/sdk-core"; +import { ChainId, Currency, CurrencyAmount, Percent, Token, TradeType } from "@uniswap/sdk-core"; import { AlphaRouter, SwapOptionsSwapRouter02, SwapType } from "@uniswap/smart-order-router"; import { Pool, Route } from "@uniswap/v3-sdk"; import { ethers } from "ethers"; @@ -103,14 +104,16 @@ class UniswapProvider extends SwapProvider { trade = { inputToken: { - amount: BigInt( - new Fraction(inputCurrency.numerator, inputCurrency.denominator).toFixed(0, { groupSeparator: "" }), + amount: new Fraction( + BigInt(inputCurrency.numerator.toString()), + BigInt(inputCurrency.denominator.toString()), ), address: (inputCurrency?.currency as Token).address as Address, }, outputToken: { - amount: BigInt( - new Fraction(outputCurrency.numerator, outputCurrency.denominator).toFixed(0, { groupSeparator: "" }), + amount: new Fraction( + BigInt(outputCurrency.numerator.toString()), + BigInt(outputCurrency.denominator.toString()), ), address: (outputCurrency?.currency as Token).address as Address, }, diff --git a/packages/keeper-bots/src/converter-bot/types.ts b/packages/keeper-bots/src/converter-bot/types.ts index 84422525..07198424 100644 --- a/packages/keeper-bots/src/converter-bot/types.ts +++ b/packages/keeper-bots/src/converter-bot/types.ts @@ -1,3 +1,4 @@ +import { Fraction } from "@pancakeswap/sdk"; import { Address } from "viem"; import { BalanceResult } from "./queries/getTokenConvertersTokenBalances"; @@ -74,11 +75,11 @@ export type Message = export interface TradeRoute { inputToken: { - amount: bigint; + amount: Fraction; address: Address; }; outputToken: { - amount: bigint; + amount: Fraction; address: Address; }; path: Address; From 59bba4ffabc56a889b92a91da0302e3d996eccd8 Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Thu, 15 Aug 2024 11:57:30 -0600 Subject: [PATCH 06/11] fix: set keeper bot dev package version --- .github/workflows/cd.yaml | 4 ++-- packages/cli/package.json | 2 +- packages/keeper-bots/package.json | 2 +- yarn.lock | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 16bd722e..aeef69c5 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -50,12 +50,12 @@ jobs: - name: Install dependencies run: yarn - - name: Build Token Converter Bots + - name: Build Keeper Bots env: THE_GRAPH_STUDIO_API_KEY: ${{ secrets.THE_GRAPH_STUDIO_API_KEY }} run: yarn workspace @venusprotocol/keeper-bots run build - - name: Release Token Converter Bot + - name: Release Keeper Bot if: ${{ always() }} env: THE_GRAPH_STUDIO_API_KEY: ${{ secrets.THE_GRAPH_STUDIO_API_KEY }} diff --git a/packages/cli/package.json b/packages/cli/package.json index f54cf9c6..4fc1d389 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -28,7 +28,7 @@ "@graphql-mesh/cli": "^0.90.5", "@graphql-mesh/config": "^0.100.5", "@graphql-mesh/graphql": "^0.98.4", - "@venusprotocol/keeper-bots": "^1.0.0", + "@venusprotocol/keeper-bots": "1.0.0-dev.1", "@venusprotocol/venus-protocol": "^9.1.0", "dotenv": "^16.3.1", "graphql": "^16.8.1", diff --git a/packages/keeper-bots/package.json b/packages/keeper-bots/package.json index 2a8dabdf..092d201a 100644 --- a/packages/keeper-bots/package.json +++ b/packages/keeper-bots/package.json @@ -1,6 +1,6 @@ { "name": "@venusprotocol/keeper-bots", - "version": "1.0.0", + "version": "1.0.0-dev.1", "description": "", "scripts": { "dev": "tsc --watch", diff --git a/yarn.lock b/yarn.lock index 2b6d0000..72e1bf0d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7038,7 +7038,7 @@ __metadata: "@graphql-mesh/graphql": ^0.98.4 "@sindresorhus/tsconfig": ^3.0.1 "@types/react": ^18.2.55 - "@venusprotocol/keeper-bots": ^1.0.0 + "@venusprotocol/keeper-bots": 1.0.0-dev.1 "@venusprotocol/venus-protocol": ^9.1.0 ava: ^5.2.0 chalk: ^5.2.0 @@ -7196,7 +7196,7 @@ __metadata: languageName: unknown linkType: soft -"@venusprotocol/keeper-bots@^1.0.0, @venusprotocol/keeper-bots@workspace:packages/keeper-bots": +"@venusprotocol/keeper-bots@1.0.0-dev.1, @venusprotocol/keeper-bots@workspace:packages/keeper-bots": version: 0.0.0-use.local resolution: "@venusprotocol/keeper-bots@workspace:packages/keeper-bots" dependencies: From 08e0babfd4cc5a892792bbb227a496415a48f8fa Mon Sep 17 00:00:00 2001 From: Venus Tools Date: Thu, 15 Aug 2024 18:06:44 +0000 Subject: [PATCH 07/11] chore(release): 1.5.0-dev.1 [skip ci] ## [@venusprotocol/cli-v1.5.0-dev.1](https://github.com/VenusProtocol/keeper-bots/compare/@venusprotocol/cli-v1.4.0...@venusprotocol/cli-v1.5.0-dev.1) (2024-08-15) ### Features * filter conversion pairs list by converter ([68e89bd](https://github.com/VenusProtocol/keeper-bots/commit/68e89bdd76b15d1fe699b0071528b9515d74b44b)) ### Bug Fixes * set keeper bot dev package version ([59bba4f](https://github.com/VenusProtocol/keeper-bots/commit/59bba4ffabc56a889b92a91da0302e3d996eccd8)) --- packages/cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 4fc1d389..02f48492 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@venusprotocol/cli", - "version": "1.4.0", + "version": "1.5.0-dev.1", "license": "MIT", "bin": { "venus": "dist/venus.js" From 513c3f08aa683ef2caf491263c96903372b7ac17 Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Thu, 15 Aug 2024 11:02:38 -0600 Subject: [PATCH 08/11] fix: update ethereum PR subgraph to point to specific deployment --- packages/keeper-bots/src/config/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/keeper-bots/src/config/index.ts b/packages/keeper-bots/src/config/index.ts index 6e9a7a0a..71fcacd6 100644 --- a/packages/keeper-bots/src/config/index.ts +++ b/packages/keeper-bots/src/config/index.ts @@ -28,7 +28,9 @@ export const protocolReserveSubgraphUrlByNetwork = { bscmainnet: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( "THE_GRAPH_STUDIO_API_KEY", )}/subgraphs/id/2ZCWgaBc8KoWW8kh7MRzf9KPdr7NTZ5cda9bxpFDk4wG`, - ethereum: `https://gateway-arbitrum.network.thegraph.com/api/${process.env.THE_GRAPH_STUDIO_API_KEY}/subgraphs/id/QmcFbWExHdYuV3XQNPrX5PA467jRvSrtUfMLxoA6t95nSn`, + ethereum: `https://gateway-arbitrum.network.thegraph.com/api/${safelyGetEnvVar( + "THE_GRAPH_STUDIO_API_KEY", + )}/deployments/id/QmcFbWExHdYuV3XQNPrX5PA467jRvSrtUfMLxoA6t95nSn`, sepolia: `https://api.studio.thegraph.com/query/${process.env.TESTNET_GRAPH_ID}/venus-protocol-reserve-sepolia/version/latest`, }; From 1848a4a4f9d5a47bd2a9b31d8d6939da00c4729c Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Thu, 15 Aug 2024 11:37:45 -0600 Subject: [PATCH 09/11] refactor: remove any type --- packages/cli/source/commands/convert.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/source/commands/convert.tsx b/packages/cli/source/commands/convert.tsx index 160525d0..5aba717d 100644 --- a/packages/cli/source/commands/convert.tsx +++ b/packages/cli/source/commands/convert.tsx @@ -3,7 +3,7 @@ import { option } from "pastel"; import { Box, Spacer, Text, useApp, useStderr } from "ink"; import zod from "zod"; import { parseUnits } from "viem"; -import { TokenConverter, PancakeSwapProvider, UniswapProvider } from "@venusprotocol/keeper-bots"; +import { TokenConverter, PancakeSwapProvider, UniswapProvider, BalanceResult } from "@venusprotocol/keeper-bots"; import { stringifyBigInt, getConverterConfigId } from "../utils/index.js"; import { Options, Title, BorderBox } from "../components/index.js"; import { reducer, defaultState } from "../state/convert.js"; @@ -174,10 +174,10 @@ export default function Convert({ options }: Props) { await tokenConverter.releaseFundsForConversions(potentialConversions); } await Promise.allSettled( - potentialConversions.map(async (t: any) => { + potentialConversions.map(async (t: BalanceResult) => { let amountOut = t.assetOut.balance; - const vTokenAddress = t.assetOutVTokens.core || t.assetOutVTokens.isolated[0][1]; + const vTokenAddress = t.assetOutVTokens.core || t.assetOutVTokens.isolated![0]![1]; const { underlyingPriceUsd, underlyingUsdValue, underlyingDecimals } = await tokenConverter.getUsdValue( t.assetOut.address, vTokenAddress, @@ -224,7 +224,7 @@ export default function Convert({ options }: Props) { type: "ExecuteTrade", error: "Insufficient wallet balance to pay min income", context: { - converter: t.tokenConverter.id, + converter: t.tokenConverter, tokenToReceiveFromConverter: t.assetOut.address, tokenToSendToConverter: t.assetIn.address, amount, @@ -238,7 +238,7 @@ export default function Convert({ options }: Props) { type: "ExecuteTrade", error: "Min income too high", context: { - converter: t.tokenConverter.id, + converter: t.tokenConverter, tokenToReceiveFromConverter: t.assetOut.address, tokenToSendToConverter: t.assetIn.address, amount, From ee4e263380625439ef632327773c72a32522d105 Mon Sep 17 00:00:00 2001 From: Venus Tools Date: Thu, 15 Aug 2024 18:13:53 +0000 Subject: [PATCH 10/11] chore(release): 1.0.0-dev.2 [skip ci] ## [@venusprotocol/keeper-bots-v1.0.0-dev.2](https://github.com/VenusProtocol/keeper-bots/compare/@venusprotocol/keeper-bots-v1.0.0-dev.1...@venusprotocol/keeper-bots-v1.0.0-dev.2) (2024-08-15) ### Bug Fixes * update ethereum PR subgraph to point to specific deployment ([513c3f0](https://github.com/VenusProtocol/keeper-bots/commit/513c3f08aa683ef2caf491263c96903372b7ac17)) --- packages/keeper-bots/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/keeper-bots/package.json b/packages/keeper-bots/package.json index 092d201a..d667c957 100644 --- a/packages/keeper-bots/package.json +++ b/packages/keeper-bots/package.json @@ -1,6 +1,6 @@ { "name": "@venusprotocol/keeper-bots", - "version": "1.0.0-dev.1", + "version": "1.0.0-dev.2", "description": "", "scripts": { "dev": "tsc --watch", From d054cc5d037f7072a9a0f968138fb3a4f14c8827 Mon Sep 17 00:00:00 2001 From: Venus Tools Date: Thu, 15 Aug 2024 18:14:48 +0000 Subject: [PATCH 11/11] chore(release): 1.5.0-dev.2 [skip ci] ## [@venusprotocol/cli-v1.5.0-dev.2](https://github.com/VenusProtocol/keeper-bots/compare/@venusprotocol/cli-v1.5.0-dev.1...@venusprotocol/cli-v1.5.0-dev.2) (2024-08-15) --- packages/cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 02f48492..404473c2 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@venusprotocol/cli", - "version": "1.5.0-dev.1", + "version": "1.5.0-dev.2", "license": "MIT", "bin": { "venus": "dist/venus.js"