> For the complete documentation index, see [llms.txt](https://docs.frictionless.markets/developer/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frictionless.markets/developer/smart-contracts/smart-contract-docs/erc20-swaps/ifrictionlesserc20convertermanager.md).

# IFrictionlessERC20ConverterManager

[Git Source](https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/blob/85f6dfa54ce0787eb1b1345bd6726f84fe766c54/contracts/interface/IFrictionlessERC20ConverterManager.sol)

**Inherits:** IAbstractFeeModule

**Author:** DEFYCA Labs S.à.r.l

Copyright © 2023 DEFYCA Labs S.à.r.l Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DEFYCA LABS S.à.r.l BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Interface defining the frictionless conversion and atomic swapping of ERC-20 tokens for `FrictionlessFundDepositToken` on the Frictionless protocol. The conversion of tokens is considered frictionless as the protocol does not impose any fee structures on the conversion itself.

## Functions

### pause

*See {PausableUpgradeable-\_pause}*

```solidity
function pause() external;
```

### unpause

*See {PausableUpgradeable-\_unpause}*

```solidity
function unpause() external;
```

### setConvertTokensFees

*Set the conversion fees for the token pair. The fees can be any combination of zero (0%) or upto 10000 bps (100%) on any directional transfer. Fees can only be set by the Owner (PROTOCOL\_ADMIN).*

```solidity
function setConvertTokensFees(address erc20Token_, address fundDepositToken_, FeeInfo calldata feeInfo_) external;
```

**Parameters**

| Name                | Type      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `erc20Token_`       | `address` | the address of the ERC20 token.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `fundDepositToken_` | `address` | the address of the FundDeposit token.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `feeInfo_`          | `FeeInfo` | The fees associated with the conversion of the token pair. throws `FrictionlessERC20ConverterManagerUnsupportedPair` if the token pair is not valid throws `AbstractFeeModuleInvalidFeeRecipient` if the feeRecipientAddr is a zero address throws `AbstractFeeModuleInvalidFee` if the feeInBps is not in the valid range (ZERO\_FEES\_IN\_BPS to MAX\_FEES\_IN\_BPS) emits `FrictionlessTokenFeeSet` upon completion of the setting of the fee info for the token in either set of fees |

### setConvertTokensFee

*Set the conversion fees for the token pair using the tokenFeeKey\_. The fees can be any combination of zero (0%) or upto 10000 bps (100%) on any directional transfer. Fees can only be set by the Owner (PROTOCOL\_ADMIN).*

```solidity
function setConvertTokensFee(bytes32 tokenFeeKey_, FeeInfo calldata feeInfo_) external;
```

**Parameters**

| Name           | Type      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| -------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tokenFeeKey_` | `bytes32` | the tokenFeeKey as determined `getConvertTokensKey`                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `feeInfo_`     | `FeeInfo` | The fees associated with the conversion of the token pair. throws `FrictionlessERC20ConverterManagerUnsupportedPair` if the token pair is not valid throws `AbstractFeeModuleInvalidFeeRecipient` if the feeRecipientAddr is a zero address throws `AbstractFeeModuleInvalidFee` if the feeInBps is not in the valid range (ZERO\_FEES\_IN\_BPS to MAX\_FEES\_IN\_BPS) emits `FrictionlessTokenFeeSet` upon completion of the setting of the fee info for the token in either set of fees |

### removeFrictionlessTokensConvertInfo

*Removes the conversion fees for the token pair using the tokenFeeKey\_. Fees can only be set by the Owner (PROTOCOL\_ADMIN).*

```solidity
function removeFrictionlessTokensConvertInfo(address erc20Token_, address fundDepositToken_) external;
```

**Parameters**

| Name                | Type      | Description                           |
| ------------------- | --------- | ------------------------------------- |
| `erc20Token_`       | `address` | the address of the ERC20 token.       |
| `fundDepositToken_` | `address` | the address of the FundDeposit token. |

### addFrictionlessTokensConvertInfo

*Sets the mapping for the convertible tokens in the contract, calling this will add a new conversion pair to the contract.*

```solidity
function addFrictionlessTokensConvertInfo(FrictionlessTokensConvertInfo[] calldata tokensConvertInfoArr_) external;
```

**Parameters**

| Name                    | Type                              | Description                                                                                                                                                                                                                                                                        |
| ----------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tokensConvertInfoArr_` | `FrictionlessTokensConvertInfo[]` | the array of token conversions to set. throws `FrictionlessERC20ConverterManagerInvalidTokenConvertInfo` if the tokensConvertInfoArr\_ contains zero addresses throws `FrictionlessERC20ConverterManagerUnableToUpdateConvertInfo` if the tokensConvertInfoArr\_ cannot be updated |

### convertFromERC20

*Converts from an ERC20 token to a `FrictionlessFundDepositToken`, using the safe precision conversion. The ERC20 token is transferred to configured treasuryAddress in the conversion and the minted `FrictionlessFundDepositToken` is sent to the `msg.sender`*

```solidity
function convertFromERC20(address erc20Token_, address fundDepositToken_, uint256 erc20TokensAmount_)
    external
    returns (uint256);
```

**Parameters**

| Name                 | Type      | Description                                                                                                                                                                                                                                                                                                                                             |
| -------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `erc20Token_`        | `address` | the address of the ERC20 token to convert from, which must exist in a `FrictionlessTokensConvertInfo` in order to succeed.                                                                                                                                                                                                                              |
| `fundDepositToken_`  | `address` | the address of the FundDeposit token to convert to, which must exist in a `FrictionlessTokensConvertInfo` in order to succeed.                                                                                                                                                                                                                          |
| `erc20TokensAmount_` | `uint256` | the amount of tokens to convert throws `FrictionlessERC20ConverterManagerInvalidTokenType` if the tokenAddr\_ is not a configured convertible erc20Token throw `FrictionlessERC20ConverterManagerInvalidTokensAmountAfterConversion` if the conversion resolves to zero Emits the event `FrictionlessTokensConverted` detailing the full convertibility |

### convertFromERC20

*Converts from an ERC20 token to a `FrictionlessFundDepositToken`, using the safe precision conversion. The ERC20 token is transferred to configured treasuryAddress in the conversion and the minted `FrictionlessFundDepositToken` is sent to the convertedTokensRecipient\_*

```solidity
function convertFromERC20(
    address erc20Token_,
    address fundDepositToken_,
    address convertedTokensRecipient_,
    uint256 erc20TokensAmount_
) external returns (uint256);
```

**Parameters**

| Name                        | Type      | Description                                                                                                                    |
| --------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `erc20Token_`               | `address` | the address of the ERC20 token to convert from, which must exist in a `FrictionlessTokensConvertInfo` in order to succeed.     |
| `fundDepositToken_`         | `address` | the address of the FundDeposit token to convert to, which must exist in a `FrictionlessTokensConvertInfo` in order to succeed. |
| `convertedTokensRecipient_` | `address` | the destination of the converted `FrictionlessFundDepositToken`                                                                |
| `erc20TokensAmount_`        | `uint256` | the amount of tokens to convert                                                                                                |

**Returns**

| Name     | Type      | Description                                                                                                                                                                                                                                                                                                                                                                    |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `<none>` | `uint256` | the amount of `FrictionlessFundDepositToken` converted throws `FrictionlessERC20ConverterManagerInvalidTokenType` if the tokenAddr\_ is not a configured convertible erc20Token throw `FrictionlessERC20ConverterManagerInvalidTokensAmountAfterConversion` if the conversion resolves to zero Emits the event `FrictionlessTokensConverted` detailing the full convertibility |

### convertToERC20

*Converts to an ERC20 token from a FrictionlessFundDepositToken, using the safe precision conversion. The FrictionlessFundDepositToken is burned in the conversion and the ERC20 is sent to the `msg.sender` from the treasuryAddress.*

```solidity
function convertToERC20(address erc20Token_, address fundDepositToken_, uint256 fundDepositTokensAmount_)
    external
    returns (uint256);
```

**Parameters**

| Name                       | Type      | Description                                                                                                                                       |
| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `erc20Token_`              | `address` |                                                                                                                                                   |
| `fundDepositToken_`        | `address` | the address of the FrictionlessFundDepositToken token to convert from, which must exist in a `FrictionlessTokensConvertInfo` in order to succeed. |
| `fundDepositTokensAmount_` | `uint256` | the amount of tokens to convert                                                                                                                   |

**Returns**

| Name     | Type      | Description                                                                                                                                                                                                                                                                                                                                                 |
| -------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `uint256` | the amount of ERC20 converted throws `FrictionlessERC20ConverterManagerInvalidTokenType` if the tokenAddr\_ is not a configured convertible fundDepositToken throw `FrictionlessERC20ConverterManagerInvalidTokensAmountAfterConversion` if the conversion resolves to zero Emits the event `FrictionlessTokensConverted` detailing the full convertibility |

### convertToERC20

*Converts to an ERC20 token from a `FrictionlessFundDepositToken`, using the safe precision conversion. The FrictionlessFundDepositToken is burned in the conversion and the ERC20 is sent to the convertedTokensRecipient\_ from the treasuryAddress.*

```solidity
function convertToERC20(
    address erc20Token_,
    address fundDepositToken_,
    address convertedTokensRecipient_,
    uint256 fundDepositTokensAmount_
) external returns (uint256);
```

**Parameters**

| Name                        | Type      | Description                                                                                                                                         |
| --------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `erc20Token_`               | `address` |                                                                                                                                                     |
| `fundDepositToken_`         | `address` | the address of the `FrictionlessFundDepositToken` token to convert from, which must exist in a `FrictionlessTokensConvertInfo` in order to succeed. |
| `convertedTokensRecipient_` | `address` | the destination of the converted ERC20 token                                                                                                        |
| `fundDepositTokensAmount_`  | `uint256` | the amount of tokens to convert                                                                                                                     |

**Returns**

| Name     | Type      | Description                                                                                                                                                                                                                                                                                                                                                 |
| -------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `uint256` | the amount of ERC20 converted throws `FrictionlessERC20ConverterManagerInvalidTokenType` if the tokenAddr\_ is not a configured convertible fundDepositToken throw `FrictionlessERC20ConverterManagerInvalidTokensAmountAfterConversion` if the conversion resolves to zero Emits the event `FrictionlessTokensConverted` detailing the full convertibility |

### getConvertTokenInfo

*Returns the `FrictionlessTokensConvertInfo` for the given conversion key*

```solidity
function getConvertTokenInfo(bytes32 convertInfoKey_) external view returns (FrictionlessTokensConvertInfo memory);
```

**Parameters**

| Name              | Type      | Description                           |
| ----------------- | --------- | ------------------------------------- |
| `convertInfoKey_` | `bytes32` | the address of the token to validate. |

**Returns**

| Name     | Type                            | Description                                                      |
| -------- | ------------------------------- | ---------------------------------------------------------------- |
| `<none>` | `FrictionlessTokensConvertInfo` | the `FrictionlessTokensConvertInfo` for the given conversion key |

### getConvertTokenKeysByToken

*Returns the conversion keys for the given tokenAddr\_*

```solidity
function getConvertTokenKeysByToken(address tokenAddr_) external view returns (bytes32[] memory);
```

**Parameters**

| Name         | Type      | Description                           |
| ------------ | --------- | ------------------------------------- |
| `tokenAddr_` | `address` | the address of the token to validate. |

**Returns**

| Name     | Type        | Description                                       |
| -------- | ----------- | ------------------------------------------------- |
| `<none>` | `bytes32[]` | the conversion keys arr for the given tokenAddr\_ |

### getConvertTokenKeysCountByToken

*Returns the count of conversion keys for the given tokenAddr\_*

```solidity
function getConvertTokenKeysCountByToken(address tokenAddr_) external view returns (uint256);
```

**Parameters**

| Name         | Type      | Description                           |
| ------------ | --------- | ------------------------------------- |
| `tokenAddr_` | `address` | the address of the token to validate. |

**Returns**

| Name     | Type      | Description                                                |
| -------- | --------- | ---------------------------------------------------------- |
| `<none>` | `uint256` | the count of conversion keys arr for the given tokenAddr\_ |

### getConvertTokenInfosByToken

*Returns the `FrictionlessTokensConvertInfo` for the given tokenAddr\_*

```solidity
function getConvertTokenInfosByToken(address tokenAddr_)
    external
    view
    returns (FrictionlessTokensConvertInfo[] memory);
```

**Parameters**

| Name         | Type      | Description                           |
| ------------ | --------- | ------------------------------------- |
| `tokenAddr_` | `address` | the address of the token to validate. |

**Returns**

| Name     | Type                              | Description                                                   |
| -------- | --------------------------------- | ------------------------------------------------------------- |
| `<none>` | `FrictionlessTokensConvertInfo[]` | the `FrictionlessTokensConvertInfo` for the given tokenAddr\_ |

### isTokenSupported

*Returns true if the token specified by the `tokenAddr_` has been registered as a valid convertible pair.*

```solidity
function isTokenSupported(address tokenAddr_) external view returns (bool);
```

**Parameters**

| Name         | Type      | Description                           |
| ------------ | --------- | ------------------------------------- |
| `tokenAddr_` | `address` | the address of the token to validate. |

**Returns**

| Name     | Type   | Description                                                                                                      |
| -------- | ------ | ---------------------------------------------------------------------------------------------------------------- |
| `<none>` | `bool` | true if the token specified by the `tokenAddr_` has been registered as a valid convertible pair, otherwise false |

### isTokenPairSupported

*Returns true if the token pair specified have been registered as a valid convertible pair.*

```solidity
function isTokenPairSupported(address erc20Token_, address fundDepositToken_) external view returns (bool);
```

**Parameters**

| Name                | Type      | Description                           |
| ------------------- | --------- | ------------------------------------- |
| `erc20Token_`       | `address` | the address of the ERC20 token.       |
| `fundDepositToken_` | `address` | the address of the FundDeposit token. |

**Returns**

| Name     | Type   | Description                                                                                        |
| -------- | ------ | -------------------------------------------------------------------------------------------------- |
| `<none>` | `bool` | true if the token pair specified have been registered as a valid convertible pair, otherwise false |

### isConvertTokenKeySupported

*Returns true if the conversion key is supported.*

```solidity
function isConvertTokenKeySupported(bytes32 convertTokenKey_) external view returns (bool);
```

**Parameters**

| Name               | Type      | Description                                            |
| ------------------ | --------- | ------------------------------------------------------ |
| `convertTokenKey_` | `bytes32` | the conversion key as defined by `getConvertTokensKey` |

**Returns**

| Name     | Type   | Description                                                              |
| -------- | ------ | ------------------------------------------------------------------------ |
| `<none>` | `bool` | true if Returns true if the conversion key is supported, otherwise false |

### getConvertTokensKey

*Returns the conversion key for the given token pair.*

```solidity
function getConvertTokensKey(address token0_, address token1_) external pure returns (bytes32);
```

**Parameters**

| Name      | Type      | Description                              |
| --------- | --------- | ---------------------------------------- |
| `token0_` | `address` | the first token in the convertible pair  |
| `token1_` | `address` | the second token in the convertible pair |

**Returns**

| Name     | Type      | Description                                                                                                                                                                                                                  |
| -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `bytes32` | the conversion key for the given token pair throws `FrictionlessERC20ConverterManagerIdenticalAddresses` if both tokens are identical throws `FrictionlessERC20ConverterManagerZeroAddress` if the tokens are a zero address |

## Events

### FrictionlessTokensConverted

*Event emitted when a successful conversion occurs between an ERC20 and a FrictionlessFuncDepositToken.*

```solidity
event FrictionlessTokensConverted(
    address fromToken, address toToken, address toTokensRecipient, uint256 fromAmount, uint256 toAmount
);
```

## Errors

### FrictionlessERC20ConverterManagerInvalidTokenConvertInfo

*thrown during `addFrictionlessTokensConvertInfo` if the tokensConvertInfoArr\_ contains zero addresses*

```solidity
error FrictionlessERC20ConverterManagerInvalidTokenConvertInfo(FrictionlessTokensConvertInfo);
```

### FrictionlessERC20ConverterManagerUnableToUpdateConvertInfo

*thrown during `addFrictionlessTokensConvertInfo` if the tokensConvertInfoArr\_ cannot be updated*

```solidity
error FrictionlessERC20ConverterManagerUnableToUpdateConvertInfo(FrictionlessTokensConvertInfo);
```

### FrictionlessERC20ConverterManagerUnsupportedPair

```solidity
error FrictionlessERC20ConverterManagerUnsupportedPair(address, address);
```

### FrictionlessERC20ConverterManagerInvalidTokensAmountAfterConversion

*thrown during a convert to/from an ERC20 if the conversion resolves to zero*

```solidity
error FrictionlessERC20ConverterManagerInvalidTokensAmountAfterConversion();
```

### FrictionlessERC20ConverterManagerIdenticalAddresses

*thrown during a convert to/from an ERC20 if the conversion is attempted for the same token*

```solidity
error FrictionlessERC20ConverterManagerIdenticalAddresses();
```

### FrictionlessERC20ConverterManagerZeroAddress

*thrown if the `IFrictionlessERC20ConverterManager` is configured as a zero address*

```solidity
error FrictionlessERC20ConverterManagerZeroAddress();
```

## Structs

### FrictionlessTokensConvertInfo

*Struct to represent the conversion between an ERC20 token and a `FrictionlessFundDepositToken` on the Frictionless protocol*

```solidity
struct FrictionlessTokensConvertInfo {
    address erc20Token;
    address fundDepositToken;
    address treasuryAddress;
}
```


---

# 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.frictionless.markets/developer/smart-contracts/smart-contract-docs/erc20-swaps/ifrictionlesserc20convertermanager.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.
