# WERC20

The WERC20 contract is an ERC1155 compliant contract that wraps ERC20 tokens. This contract is used to hold Leveraged LP Tokens in the BlueberryBank and do not generate yields. LP Tokens are identified by tokenIds encoded from the lp token address.

### Functions

#### initialize

{% code overflow="wrap" %}

```solidity
function initialize() external initializer
```

{% endcode %}

Initializes the contract by initializing ReentrancyGuard and setting the name of the token as WERC20.

#### \_encodeTokenId

{% code overflow="wrap" %}

```solidity
function _encodeTokenId(address uToken) internal pure returns (uint)
```

{% endcode %}

This function encodes the underlying token address to tokenId.

#### \_decodeTokenId

{% code overflow="wrap" %}

```solidity
function _decodeTokenId(uint tokenId) internal pure returns (address)
```

{% endcode %}

This function decodes the given tokenId to underlyingToken address.

#### getUnderlyingToken

{% code overflow="wrap" %}

```solidity
function getUnderlyingToken(uint256 tokenId) external pure override returns (address token)
```

{% endcode %}

This function returns the underlying ERC-20 token for the given ERC-1155 token id. It takes `tokenId` as input and returns `token` which is the underlying ERC-20 token.

#### pendingRewards

{% code overflow="wrap" %}

```solidity
function pendingRewards(uint256 tokenId, uint amount) public view override returns (address[] memory, uint256[] memory)
```

{% endcode %}

This function returns the pending rewards from the farming pool. Reward tokens can be multiple tokens. It takes `tokenId` and `amount` as input and returns two arrays, `address[] memory` and `uint256[] memory`.

#### balanceOfERC20

{% code overflow="wrap" %}

```solidity
function balanceOfERC20(address token, address user) external view override returns (uint256)
```

{% endcode %}

This function returns the underlying ERC20 balance for the user. It takes `token` and `user` as input and returns `uint256` which is the balance of the user.

#### mint

{% code overflow="wrap" %}

```solidity
function mint(address token, uint256 amount) external override nonReentrant returns (uint256 id)
```

{% endcode %}

This function mints ERC1155 token for the given ERC20 token. It takes `token` and `amount` as input and mints ERC1155 token.

#### burn

{% code overflow="wrap" %}

```solidity
function burn(address token, uint256 amount) external override nonReentrant
```

{% endcode %}

This function burns ERC1155 token to redeem ERC20 token back. It takes `token` and `amount` as input and burns ERC1155 token.


---

# 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://v1.docs.blueberry.garden/developer-guides/contracts/wrapper/werc20.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.
