> For the complete documentation index, see [llms.txt](https://docs.lossless.io/protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lossless.io/protocol/technical-reference/wrapped-tokens/extensible-wrapped-tokens/lossless-wrapped-erc20-extensible.md).

# Lossless Wrapped ERC20 Extensible

## Overview <a href="#overview" id="overview"></a>

The [Lossless Wrapped ERC20 Extensible](https://github.com/Lossless-Cash/wrapped-lossless-erc20/blob/master/src/LosslessWrappedERC20Extensible.sol) smart contract is one of the types of wrapping a protocol is able to choose.

This particular smart contract provides a base to be able to extend its logic by registering [extensions](https://lossless.atlassian.net/wiki/spaces/LOSSLESSCO/pages/254083080/Lossless+Extensions+Core#Extensions). The contract itself, when launched, doesn’t provide any type of protection. Only the logic required to add extensions is provided.

Lossless will provide a set of extensions for the protocol to chose in the [wrapped tokens repository](https://github.com/Lossless-Cash/wrapped-lossless-erc20/tree/master/src/Extensions). The [Lossless Core Extension](https://github.com/Lossless-Cash/wrapped-lossless-erc20/blob/master/src/Extensions/LosslessCoreExtension.sol) is the most popular one as it add Lossless Core Protocol protection to the wrapped token. Nonetheless, other extensions such as Aegis Extension and Rugpull prevention are provided. They can also be taken as an example for the protocol to write and deploy their own extensions.

Once the protocol choses, or writes their own, extension it has to be deployed to the blockchain. When the deployment process is done, first the admin can register the extension by using the `registerExtension` function. As a second step, the admin has to interact from the extension itself with the wrapped token in order to configure what type of extension it is. For example, the Lossless Core Extension will provide before and after transfer logic, so the function `setBeforeTransfer` must be called.

In this scenario, when a transfer takes place, the lwERC20 Extensible will check if there is a transfer base set and if that’s true it will divert the first part of the call to the extension. Effectively applying the logic written in the extension.

Extra logic can be added via extensions for the following scenarios:

* Before Transfer
* After Transfer
* Before Mint
* After Mint
* Before Burn
* After Burn

## Workflow <a href="#workflow" id="workflow"></a>

<figure><img src="/files/3FsPIYieHlwA6Tsdz8dm" alt=""><figcaption></figcaption></figure>

## Variables <a href="#variables" id="variables"></a>

#### `admin` <a href="#admin" id="admin"></a>

| Type        | `address`             |
| ----------- | --------------------- |
| Visibility  | `public`              |
| Description | Address of the admin. |

#### `underlying` <a href="#underlying" id="underlying"></a>

| Type        | `IERC20`                                              |
| ----------- | ----------------------------------------------------- |
| Visibility  | `public immutable`                                    |
| Description | Address of the underlying token allowed for wrapping. |

## Functions <a href="#functions" id="functions"></a>

#### `supportsInterface` <a href="#supportsinterface" id="supportsinterface"></a>

| Type         | external view                                                |
| ------------ | ------------------------------------------------------------ |
| Restrictions | -                                                            |
| Parameters   | bytes4                                                       |
| Returns      | bool                                                         |
| Description  | Returns true if the smart contract supports an interface ID. |

#### `registerExtension` <a href="#registerextension" id="registerextension"></a>

| Type         | external                                         |
| ------------ | ------------------------------------------------ |
| Restrictions | Only Admin                                       |
| Parameters   | address                                          |
| Returns      | -                                                |
| Description  | Registers an extension to be used by the lwERC20 |

#### `unregisterExtension` <a href="#unregisterextension" id="unregisterextension"></a>

| Type         | external                                       |
| ------------ | ---------------------------------------------- |
| Restrictions | Only Admin                                     |
| Parameters   | address                                        |
| Returns      | -                                              |
| Description  | Removes an extension to be used by the lwERC20 |


---

# 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.lossless.io/protocol/technical-reference/wrapped-tokens/extensible-wrapped-tokens/lossless-wrapped-erc20-extensible.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.
