IFrictionlessERC20ConverterManager
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}
unpause
See {PausableUpgradeable-_unpause}
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).
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the ERC20 token. |
|
| the address of the FundDeposit token. |
|
| The fees associated with the conversion of the token pair. throws |
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).
Parameters
Name | Type | Description |
---|---|---|
|
| the tokenFeeKey as determined |
|
| The fees associated with the conversion of the token pair. throws |
removeFrictionlessTokensConvertInfo
Removes the conversion fees for the token pair using the tokenFeeKey_. Fees can only be set by the Owner (PROTOCOL_ADMIN).
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the ERC20 token. |
|
| 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.
Parameters
Name | Type | Description |
---|---|---|
|
| the array of token conversions to set. throws |
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
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the ERC20 token to convert from, which must exist in a |
|
| the address of the FundDeposit token to convert to, which must exist in a |
|
| the amount of tokens to convert throws |
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_
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the ERC20 token to convert from, which must exist in a |
|
| the address of the FundDeposit token to convert to, which must exist in a |
|
| the destination of the converted |
|
| the amount of tokens to convert |
Returns
Name | Type | Description |
---|---|---|
|
| the amount of |
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.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| the address of the FrictionlessFundDepositToken token to convert from, which must exist in a |
|
| the amount of tokens to convert |
Returns
Name | Type | Description |
---|---|---|
|
| the amount of ERC20 converted throws |
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.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| the address of the |
|
| the destination of the converted ERC20 token |
|
| the amount of tokens to convert |
Returns
Name | Type | Description |
---|---|---|
|
| the amount of ERC20 converted throws |
getConvertTokenInfo
Returns the FrictionlessTokensConvertInfo
for the given conversion key
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token to validate. |
Returns
Name | Type | Description |
---|---|---|
|
| the |
getConvertTokenKeysByToken
Returns the conversion keys for the given tokenAddr_
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token to validate. |
Returns
Name | Type | Description |
---|---|---|
|
| the conversion keys arr for the given tokenAddr_ |
getConvertTokenKeysCountByToken
Returns the count of conversion keys for the given tokenAddr_
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token to validate. |
Returns
Name | Type | Description |
---|---|---|
|
| the count of conversion keys arr for the given tokenAddr_ |
getConvertTokenInfosByToken
Returns the FrictionlessTokensConvertInfo
for the given tokenAddr_
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token to validate. |
Returns
Name | Type | Description |
---|---|---|
|
| the |
isTokenSupported
Returns true if the token specified by the tokenAddr_
has been registered as a valid convertible pair.
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token to validate. |
Returns
Name | Type | Description |
---|---|---|
|
| true if the token specified by the |
isTokenPairSupported
Returns true if the token pair specified have been registered as a valid convertible pair.
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the ERC20 token. |
|
| the address of the FundDeposit token. |
Returns
Name | Type | Description |
---|---|---|
|
| 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.
Parameters
Name | Type | Description |
---|---|---|
|
| the conversion key as defined by |
Returns
Name | Type | Description |
---|---|---|
|
| true if Returns true if the conversion key is supported, otherwise false |
getConvertTokensKey
Returns the conversion key for the given token pair.
Parameters
Name | Type | Description |
---|---|---|
|
| the first token in the convertible pair |
|
| the second token in the convertible pair |
Returns
Name | Type | Description |
---|---|---|
|
| the conversion key for the given token pair throws |
Events
FrictionlessTokensConverted
Event emitted when a successful conversion occurs between an ERC20 and a FrictionlessFuncDepositToken.
Errors
FrictionlessERC20ConverterManagerInvalidTokenConvertInfo
thrown during addFrictionlessTokensConvertInfo
if the tokensConvertInfoArr_ contains zero addresses
FrictionlessERC20ConverterManagerUnableToUpdateConvertInfo
thrown during addFrictionlessTokensConvertInfo
if the tokensConvertInfoArr_ cannot be updated
FrictionlessERC20ConverterManagerUnsupportedPair
FrictionlessERC20ConverterManagerInvalidTokensAmountAfterConversion
thrown during a convert to/from an ERC20 if the conversion resolves to zero
FrictionlessERC20ConverterManagerIdenticalAddresses
thrown during a convert to/from an ERC20 if the conversion is attempted for the same token
FrictionlessERC20ConverterManagerZeroAddress
thrown if the IFrictionlessERC20ConverterManager
is configured as a zero address
Structs
FrictionlessTokensConvertInfo
Struct to represent the conversion between an ERC20 token and a FrictionlessFundDepositToken
on the Frictionless protocol