From e63a919973d9bed69914e03e5eb9410ae23ba664 Mon Sep 17 00:00:00 2001 From: doomsower <12031673+doomsower@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:44:36 -0300 Subject: [PATCH] docs: update env in readme --- .env.example | 15 ------- README.md | 63 +++++++++++++++------------- src/config/env.ts | 4 +- src/config/schema.ts | 98 ++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 128 insertions(+), 52 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index bac4ac8..0000000 --- a/.env.example +++ /dev/null @@ -1,15 +0,0 @@ -JSON_RPC_PROVIDER= -JSON_RPC_TIMEOUT=<120000ms is often not enough> -PRIVATE_KEY= -ADDRESS_PROVIDER= -SLIPPAGE=0.5 -WALLET_PASSWORD= -CLOUDAMQP_URL= -AMPQ_EXCHANGE= -SKIP_BLOCKS= -OPTIMISTIC_LIQUIDATIONS= -SERVER_NAME= -OUT_DIR= -OUT_ENDPOINT= -OUT_HEADERS= -FLASHBOTS_RPC= \ No newline at end of file diff --git a/README.md b/README.md index b5f0262..2e96c35 100644 --- a/README.md +++ b/README.md @@ -14,34 +14,41 @@ This mode increases protocol security showing potential problems with liquidatio Use environment variables to configure bot -| Environment Variable Name | Description | -| -------------------------------------- | --------------------------------------------------------------------------- | -| ADDRESS_PROVIDER | Address provider address override (optional) | -| APP_NAME | Application name, for logging | -| DEBUG_ACCOUNTS | Debug accounts (optional) | -| DEBUG_MANAGERS | Debug managers (optional) | -| CAST_BIN | Path to foundry/cast binary (optional) | -| DEPLOY_PARTIAL_LIQUIDATOR | Deploy partial liquidator contracts (optional) | -| JSON_RPC_PROVIDERS / JSON_RPC_PROVIDER | Ethereum provider RPCs (optional) | -| HF_TRESHOLD | HF threshold, default is 65536 | -| RESTAKING_WORKAROUND | Restaking workaround (optional) | -| MIN_BALANCE | Minimum balance for notification, default is 500000000000000000n (optional) | -| ONE_INCH_API_KEY | 1inch API key (optional) | -| OPTIMISTIC | Optimistic liquidations (optional) | -| OUT_DIR | Output directory, default is "." | -| OUT_ENDPOINT | Output endpoint URL (optional) | -| OUT_HEADERS | Output headers, default is "{}" | -| OUT_FILE_NAME | Output file name for optimistic liquidator | -| OUT_S3_BUCKET | Output S3 bucket (optional) | -| OUT_S3_PREFIX | Output S3 prefix, default is "" | -| PARTIAL_LIQUIDATOR_ADDRESS | Partial liquidator address (optional) | -| PRIVATE_KEY | Private key | -| PORT | Port number, default is 4000 | -| SLIPPAGE | Slippage, default is 50 | -| SWAP_TO_ETH | Swap to ETH method, can be "1inch" or "uniswap" (optional) | -| TELEGRAM_BOT_TOKEN | Telegram bot token (optional) | -| TELEGRAM_NOTIFICATIONS_CHANNEL | Telegram notifications channel, must start with "-" (optional) | -| TELEGRAM_ALERTS_CHANNEL | Telegram alerts channel, must start with "-" (optional) | +# Environment Variables Configuration + +| Environment Variable | Description | +| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| `JSON_RPC_PROVIDERS` | RPC providers to use. | +| `PRIVATE_KEY` | Private key used to send liquidation transactions. | +| `SLIPPAGE` | Slippage value for pathfinder. | +| `ADDRESS_PROVIDER` | By default uses address provider from @gearbox-protocol/sdk-gov. Use this option to override address provider. | +| `HF_TRESHOLD` | Filter out all accounts with HF >= threshold during scan stage. | +| `DEPLOY_AAVE_PARTIAL_LIQUIDATOR` | Deploy Aave partial liquidator contracts. | +| `DEPLOY_GHO_PARTIAL_LIQUIDATOR` | Deploy Gho partial liquidator contracts. | +| `AAVE_PARTIAL_LIQUIDATOR_ADDRESS` | Address of deployed partial liquidator contract for all credit managers except for GHO-based. | +| `GHO_PARTIAL_LIQUIDATOR_ADDRESS` | Address of deployed partial liquidator contract for GHO credit managers. | +| `DEPLOY_BATCH_LIQUIDATOR` | Deploy batch liquidator contracts. | +| `BATCH_LIQUIDATOR_ADDRESS` | Address of deployed batch liquidator contract. | +| `BATCH_SIZE` | Number of accounts to liquidate at once using batch liquidator. | +| `MIN_BALANCE` | If balance drops before this value - we should send notification. | +| `TELEGRAM_BOT_TOKEN` | Telegram bot token used to send notifications. | +| `TELEGRAM_NOTIFICATIONS_CHANNEL` | Telegram channel where bot will post non-critical notifications. | +| `TELEGRAM_ALERTS_CHANNEL` | Telegram channel where bot will post critical notifications. | +| `RESTAKING_WORKAROUND` | Flag to enable less eager liquidations for LRT tokens. | +| `SWAP_TO_ETH` | Use this mechanism to swap underlying token to ETH after the liquidation (abandoned feature). | +| `ONE_INCH_API_KEY` | 1inch API key for swapper. | +| `APP_NAME` | App name used in various messages to distinguish instances. | +| `PORT` | Port to expose some vital signals and metrics. | +| `DEBUG_ACCOUNTS` | Only check these accounts during local debug session. | +| `DEBUG_MANAGERS` | Only check these credit managers during local debug session. | +| `OPTIMISTIC` | Enable optimistic liquidations. | +| `CAST_BIN` | Path to foundry/cast binary, so that we can create tree-like traces in case of errors. Used during optimistic liquidations. | +| `OUT_DIR` | Directory to save JSON with optimistic liquidation results. | +| `OUT_ENDPOINT` | REST endpoint to POST JSON with optimistic liquidation results. | +| `OUT_HEADERS` | Headers for REST endpoint. | +| `OUT_FILE_NAME` | Filename of JSON with optimistic liquidation results for S3 or dir output. | +| `OUT_S3_BUCKET` | S3 bucket to upload JSON with optimistic liquidation results. | +| `OUT_S3_PREFIX` | S3 bucket path prefix. | ## How to launch diff --git a/src/config/env.ts b/src/config/env.ts index 595d130..9109129 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -11,12 +11,12 @@ const envConfigMapping: Record = { deployAaveLiquidatorContracts: "DEPLOY_AAVE_PARTIAL_LIQUIDATOR", deployGhoLiquidatorContracts: "DEPLOY_GHO_PARTIAL_LIQUIDATOR", deployBatchLiquidatorContracts: "DEPLOY_BATCH_LIQUIDATOR", - ethProviderRpcs: ["JSON_RPC_PROVIDERS", "JSON_RPC_PROVIDER"], + ethProviderRpcs: "JSON_RPC_PROVIDERS", hfThreshold: "HF_TRESHOLD", restakingWorkaround: "RESTAKING_WORKAROUND", minBalance: "MIN_BALANCE", oneInchApiKey: "ONE_INCH_API_KEY", - optimistic: ["OPTIMISTIC", "OPTIMISTIC_LIQUIDATIONS"], + optimistic: "OPTIMISTIC", outDir: "OUT_DIR", outEndpoint: "OUT_ENDPOINT", outHeaders: "OUT_HEADERS", diff --git a/src/config/schema.ts b/src/config/schema.ts index 03368d7..63844e5 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -14,22 +14,41 @@ const booleanLike = z const bigintLike = z.any().transform(v => BigInt(v)); export const ConfigSchema = z.object({ + /** + * By default uses address provider from @gearbox-protocol/sdk-gov + * Use this option to override address provider + */ addressProviderOverride: Address.optional(), - + /** + * App name used in various messages to distinguish instances + */ appName: z.string().default("liquidator-ts"), + /** + * Port to expose some vital signals and metrics + */ port: z.coerce.number().default(4000), - + /** + * Only check these accounts during local debug session + */ debugAccounts: stringArrayLike.optional().pipe(z.array(Address).optional()), + /** + * Only check these credit managers during local debug session + */ debugManagers: stringArrayLike.optional().pipe(z.array(Address).optional()), /** * Path to foundry/cast binary, so that we can create tree-like traces in case of errors + * Used during optimistic liquidations */ castBin: z.string().optional(), - + /** + * RPC providers to use + */ ethProviderRpcs: stringArrayLike .optional() .pipe(z.array(z.string().url()).min(1)), - + /** + * Private key used to send liquidation transactions + */ privateKey: z .string() .min(1) @@ -44,32 +63,97 @@ export const ConfigSchema = z.object({ .pipe(z.bigint().positive().default(500000000000000000n)), /** * Filter out all accounts with HF >= threshold during scan stage - * 65535 is constant for zero-debt account + * 65535 is constant for zero-debt account (kind strang, because it's in the middle of the range of allowed values) */ hfThreshold: z.coerce.bigint().min(0n).max(MAX_INT).default(MAX_INT), + /** + * Enable optimistic liquidations + */ optimistic: booleanLike.pipe(z.boolean().optional()), + /** + * The serive can deploy partial liquidator contracts. + * Usage: deploy them once from local machine then pass the address to production service + */ deployAaveLiquidatorContracts: booleanLike.pipe(z.boolean().optional()), + /** + * Address of deployed partiali liquidator contract for all credit managers except for GHO-based + */ aavePartialLiquidatorAddress: Address.optional(), + /** + * The serive can deploy partial liquidator contracts. + * Usage: deploy them once from local machine then pass the address to production service + */ deployGhoLiquidatorContracts: booleanLike.pipe(z.boolean().optional()), + /** + * Address of deployed partiali liquidator contract for GHO credit managers + */ ghoPartialLiquidatorAddress: Address.optional(), + /** + * The serive can deploy partial liquidator contracts. + * Usage: deploy them once from local machine then pass the address to production service + */ deployBatchLiquidatorContracts: booleanLike.pipe(z.boolean().optional()), - batchSize: z.coerce.number().nonnegative().default(10), + /** + * Address of deployed batch liquidator contract + */ batchLiquidatorAddress: Address.optional(), + /** + * Number of accounts to liquidate at once using batch liquidator + */ + batchSize: z.coerce.number().nonnegative().default(10), + /** + * Slippage value for pathfined + */ slippage: z.coerce.number().min(0).max(10000).int().default(50), + /** + * Flag to enable less eager liquidations for LRT tokens + */ restakingWorkaround: booleanLike.pipe(z.boolean().optional()), - + /** + * Use this mechanism to swap underlying token to ETH after the liquidation (abandoned feature) + */ swapToEth: z.enum(["1inch", "uniswap"]).optional(), + /** + * 1inch api key for swapper + */ oneInchApiKey: z.string().optional(), + /** + * Directory to save json with optimistic liquidation results + */ outDir: z.string().default("."), + /** + * REST endpoint to POST json with optimistic liquidation results + */ outEndpoint: z.string().url().optional(), + /** + * Headers for REST endpoint + */ outHeaders: z.string().default("{}"), + /** + * s3 bucket to upload json with optimistic liquidation results + */ outS3Bucket: z.string().optional(), + /** + * s3 bucket path prefix + */ outS3Prefix: z.string().default(""), + /** + * Filename of json with optimistic liquidation results for s3 or dir output + */ outFileName: z.string().optional(), + /** + * Telegram bot token used to send notifications + */ telegramBotToken: z.string().optional(), + /** + * Telegram channel where bot will post critical notifications + */ telegramAlersChannel: z.string().startsWith("-").optional(), + /** + * Telegram channel where bot will post non-critical notifications + */ telegramNotificationsChannel: z.string().startsWith("-").optional(), });