> 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="https://2406906599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWd1iFH2pSxHtVxpot5%2Fuploads%2Fsk21TXb3OajDnXSRFcYu%2Fimage.png?alt=media&amp;token=3380d041-1b52-4716-a0bf-26d7da99ed51" 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 |
