Lossless Wrapped ERC20 Extensible

Overview

The Lossless Wrapped ERC20 Extensible 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. 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. The Lossless Core Extension 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

Variables

admin

Type

address

Visibility

public

Description

Address of the admin.

underlying

Type

IERC20

Visibility

public immutable

Description

Address of the underlying token allowed for wrapping.

Functions

supportsInterface

Type

external view

Restrictions

-

Parameters

bytes4

Returns

bool

Description

Returns true if the smart contract supports an interface ID.

registerExtension

Type

external

Restrictions

Only Admin

Parameters

address

Returns

-

Description

Registers an extension to be used by the lwERC20

unregisterExtension

Type

external

Restrictions

Only Admin

Parameters

address

Returns

-

Description

Removes an extension to be used by the lwERC20

Last updated