> For the complete documentation index, see [llms.txt](https://docs.bonzo.finance/hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bonzo.finance/hub/developer/bonzo-lend/liquidation-bots-beta/configuring-hardhat.md).

# Configuring Hardhat

The Hardhat script **`liquidate.ts`** automates the liquidation process by interacting with the deployed Liquidator contract.

### 1. Review the Script

You can find the script code [here](https://github.com/Bonzo-Labs/bonzo-finance-contracts/blob/main/scripts/liquidationFlashLoan/liquidate.ts).

#### **Key Components:**

* **Chain Data Configuration**: Contains network-specific data such as operator keys, contract addresses, and token paths.
* **Contract Setup Functions**: Functions to initialize contract instances using ABIs and addresses.
* **Liquidation Functions**: Functions that perform the liquidation using different methods (direct contract interaction, script-based).

### 2. Update Chain Data

Ensure that the **`chainData`** object in the script contains the correct addresses and keys for your environment:

```typescript
const chainData = {
  operatorId: process.env.ACCOUNT_ID,
  operatorKey: process.env.PRIVATE_KEY,
  providerUrl: process.env.PROVIDER_URL,
  liquidatorContractAddress: process.env.LIQUIDATOR_CONTRACT_ADDRESS,
  lendingPoolAddress: process.env.LENDING_POOL_ADDRESS,
  dataProviderAddress: process.env.DATA_PROVIDER_ADDRESS,
  priceOracleAddress: process.env.PRICE_ORACLE_ADDRESS,
  // Add any other required addresses and keys
};
```

### 3. Set Up Environment Variables

Ensure your **`.env`** file contains all necessary variables, as shown in the [Prerequisites](/hub/developer/bonzo-lend/liquidation-bots-beta/environment-setup.md) section.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.bonzo.finance/hub/developer/bonzo-lend/liquidation-bots-beta/configuring-hardhat.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
