Skip to content

Commit

Permalink
docs: update env in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Sep 3, 2024
1 parent 9ab8353 commit e63a919
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 52 deletions.
15 changes: 0 additions & 15 deletions .env.example

This file was deleted.

63 changes: 35 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const envConfigMapping: Record<keyof ConfigSchema, string | string[]> = {
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",
Expand Down
98 changes: 91 additions & 7 deletions src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(),
});

Expand Down

0 comments on commit e63a919

Please sign in to comment.