# Fork helpers

### Uniswap V2

There are a few different helpers for Uni V2 forks but we recommend using `uniTvlExport`.

```javascript
const { uniTvlExport } = require('../helper/unknownTokens')
const chain = 'yourChain'
const factory = '0x...' // v2 factory address

module.exports = uniTvlExport(chain, factory)
```

{% embed url="<https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/kekswap/index.js>" %}
Example Uni V2 Adapter
{% endembed %}

### Uniswap V3

There are a few different helpers for Uni V3 forks but we recommend using `uniTvlExport`.

```javascript
const { uniV3Export } = require('../helper/uniswapV3')

module.exports = uniV3Export({
  chainX: { factory: '0x...', fromBlock: 'block when factory contract was deployed' },
  chainY: { factory: '0x...', fromBlock: 'block when factory contract was deployed' },
})
```

{% embed url="<https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/beamswap-v3/index.js>" %}
Example Uni V3 Adapter
{% endembed %}

### GMX

```javascript
const { gmxExports } = require('../helper/gmx')

module.exports = {
  bsc: {
    tvl: gmxExports({ vault: '0x...', })
  }
}
```

{% embed url="<https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/nex/index.js>" %}
Example GMX Adapter
{% endembed %}

### Aave

```javascript
const { aaveExports } = require("../helper/aave")
```

{% embed url="<https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/klap/index.js>" %}
Example Aave Fork Adapter
{% endembed %}

### Compound

```javascript
const { compoundExports2 } = require("../helper/compound");
module.exports = {
  polygon: compoundExports2({ 
    comptroller: '0x...',
    cether: '0x...', // optional, needed if gas token is used
  }),
};
```

{% embed url="<https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/basilisk/index.js>" %}
Example Compound Fork Adapter
{% endembed %}

### Liquity

```javascript
const { getLiquityTvl } = require("../helper/liquity.js")

module.exports = {
  chainX: {
    tvl: getLiquityTvl('0x...'),
  }
}
```

{% embed url="<https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/liquidloans-io/index.js>" %}
Example Liquity Fork Adapter
{% endembed %}

### Balancer V2

```javascript

const { onChainTvl } = require('../helper/balancer')

module.exports = {
  metis: {
    tvl: onChainTvl('0x...', <startBlock>),
  }
}
```

{% embed url="<https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/hummus-weighted/index.js>" %}
Example Balancer V2 Fork Adapter
{% endembed %}


---

# Agent Instructions: 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:

```
GET https://docs.llama.fi/list-your-project/functions-weve-written-so-you-dont-have-to/fork-helpers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
