IFrictionlessTransferManager
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.
The IFrictionlessTransferManager is responsible for the management of the various transfer methodologies, fees processing, and defined control paradigm for DvP for all tokens in the Frictionless protocol. The tokens and their lifecycles are defined in the public README for the Frictionless protocol at https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/-/blob/main/README.md?ref_type=heads#funds-flows
Functions
updateMinRedeemAmount
Set a minimum redemption amount, to ensure there is meaningful settlement amounts, generally this is used to ensure FIAT transfers are above a minimum banking threshold, such as 1 USD.
Parameters
Name | Type | Description |
---|---|---|
|
| the minimum redemption amount, if not reached , typically throws |
setTransferFees
Set the transfer fees for the exchange/settlement of a 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 fees associated with the transfer of token0 (first token) in the exchange/settlement of the token pair. |
|
| The fees associated with the transfer of token1 (second token) in the exchange/settlement of the token pair. throws |
setTokenFee
Set the fee associated with the transfer of a Token and manages the mapping of the key to this set of Fees. Can only be set by the Owner (PROTOCOL_ADMIN).
Parameters
Name | Type | Description |
---|---|---|
|
| the key, generated by the function |
|
| The fees associated with the transfer of token, used in the calculation and disbursement of fees during exchange/settlement of a token pair. throws |
exchangeTokens
Executes a token pair exchange. This function can only be invoked by the PROTOCOL_TREASURY
Parameters
Name | Type | Description |
---|---|---|
|
| the transfer data for the first token in the exchange |
|
| the transfer data for the second token in the exchange throws |
createTransferOffer
Initiates/Creates a transferOffer between a token pair exchange. Setting the transfer status to PENDING for state management of the overall transfer. This function generates a transferOfferId_ which is returned so invokers of the function can perform further functions such as confirmTransferOffer
or cancelOffer
.
Parameters
Name | Type | Description |
---|---|---|
|
| the transfer data for the first token in the exchange |
|
| the transfer data for the second token in the exchange |
Returns
Name | Type | Description |
---|---|---|
|
| transferOfferId_ representing the stored transfer in this contract for future operations such as |
redeemTokens
Redeem/Burn an amount for tokens for the specified tokenAddr_ and msg.sender
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token |
|
| the amount of the token to burn (redeem) throws |
redeemERC20Tokens
Redeem/Burn an amount for tokens for the specified ERC20 tokenAddr_ and msg.sender, this will convert the ERC20 token to a FrictionlessFundDepositToken first, then redeem See {IFrictionlessERC20ConverterManager-isTokenSupported} {IFrictionlessERC20ConverterManager-convertFromERC20}
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the ERC20 token |
|
| the address of the FundDeposit token |
|
| the amount of the token to convert & burn (redeem) throws FrictionlessTransferManagerZeroAddress if the token address or the msg.sender is a zero address throws FrictionlessTransferManagerZeroAmount if the tokenRedeemAmount_ is zero throws |
redeemTokensFrom
Redeem/Burn an amount for tokens for the specified tokenAddr_ and userAddr_. This function can only be invoked by the PROTOCOL_TREASURY
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token |
|
| the address of the holder of the token |
|
| the amount of the token to burn (redeem) throws FrictionlessTransferManagerZeroAddress if the token address or the userAddr_ is a zero address throws FrictionlessTransferManagerZeroAmount if the redeemAmount_ is zero throws |
redeemERC20TokensFrom
Redeem/Burn an amount for tokens for the specified ERC20 tokenAddr_ and userAddr_. This will convert the ERC20 token to a FrictionlessFundDepositToken first, then reedem. This function can only be invoked by the PROTOCOL_TREASURY See {IFrictionlessERC20ConverterManager-isTokenSupported} {IFrictionlessERC20ConverterManager-convertFromERC20}
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the ERC20 token |
|
| the address of the FundDeposit token |
|
| the address of the holder of the token |
|
| the amount of the token to convert and burn (redeem) throws FrictionlessTransferManagerZeroAddress if the token address or the userAddr_ is a zero address throws FrictionlessTransferManagerZeroAmount if the tokenRedeemAmount_ is zero throws |
confirmTransferOffer
Confirms and processes the transfer for the respective transferOfferId_, which results int he compliant token transfers under ERC-3643 specification to occur.
Parameters
Name | Type | Description |
---|---|---|
|
| the id of the transfer returned/emitted in the function |
cancelTransferOffer
Cancels a transfer for the given transferOfferId_, which results in the transfer status being set to TransferStatuses.CANCELED
and the relevant FrictionlessTransferOfferCanceled
being emitted.
Parameters
Name | Type | Description |
---|---|---|
|
| the generated transferOfferId_ used to store the state of transfers in the contract. requires the Transfer to be in a PENDING state. throws |
nextTransferOfferId
Generates the next transferOfferId in the smart contract, used to store state of a transfer.
Returns
Name | Type | Description |
---|---|---|
|
| the next transferOfferId in the smart contract, used to store state of a transfer. |
minRedeemAmount
Get the minimum redemption amount configured
Returns
Name | Type | Description |
---|---|---|
|
| minimum redemption amount, to ensure there is meaningful settlement amounts, generally this is used to ensure FIAT transfers are above a minimum banking threshold, such as 1 USD. |
getTransferData
Returns the transfer data stored for the given transferOfferId_
Parameters
Name | Type | Description |
---|---|---|
|
| the generated transferOfferId_ used to store the state of transfers in the contract |
Returns
Name | Type | Description |
---|---|---|
|
| TransferData, the transfer data for the given transferOfferId_ |
getTransferFeesInfo
get the tokenFeeInfo set for the fees associated per token in an exchange.
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the first token in an exchange |
|
| the address of the second token in an exchange |
Returns
Name | Type | Description |
---|---|---|
|
| FeeInfo set for the fees associated per token in an exchange. |
|
|
getTransferFeeKeys
Generates keys based on the packed encoding of the addresses of sets of tokens using the keccak256 hashing function. Used to store tokenFees in mappings.
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token 0 in a transfer fee calculation |
|
| the address of the token 1 in a transfer fee calculation |
Returns
Name | Type | Description |
---|---|---|
|
| keys based on the packed encoding of the addresses of sets of tokens using the keccak256 hashing function. |
|
|
getTokenFeeKey
Generates a key based on the packed encoding of the addresses of both tokens using the keccak256 hashing function. Used to store tokenFees in mappings.
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the token 0 in a transfer fee calculation |
|
| the address of the token 1 in a transfer fee calculation |
Returns
Name | Type | Description |
---|---|---|
|
| generates a key based on the packed encoding of the addresses of both tokens using the keccak256 hashing function. |
Events
FrictionlessTransferOfferCreated
Event emitted during createTransferOffer
FrictionlessTransferOfferConfirmed
Event emitted during confirmTransferOffer
FrictionlessTransferOfferCanceled
Event emitted during cancelOffer
FrictionlessTokensExchanged
Event emitted during exchangeTokens
FrictionlessTokensRedeemed
Event emitted during redeemTokens
and redeemTokensFrom
Errors
FrictionlessTransferManagerInvalidTokenAddresses
error thrown during setTransferFees
, setTransferFees
, exchangeTokens
or createTransferOffer
if any of the token addresses are zero.
FrictionlessTransferManagerInvalidTokenSenderAddresses
error thrown during exchangeTokens
or createTransferOffer
if any of the tokenSender address in an exchange is a zero address
FrictionlessTransferManagerInvalidTokensPairForRedeem
FrictionlessTransferManagerCannotTransferToken
error thrown during createTransferOffer
if the token transfer is prohibited under Compliance contract rules
FrictionlessTransferManagerZeroAddress
error thrown during redeemTokens
or redeemTokensFrom
if the token address or the msg.sender is a zero address
FrictionlessTransferManagerZeroAmount
error thrown during exchangeTokens
, createTransferOffer
, redeemTokens
or redeemTokensFrom
if any of the token amounts are zero
FrictionlessTransferManagerRedeemAmountIsLessThanMinimum
error thrown when the redemption amount is below the configured minimum, during redeemTokens
or redeemERC20Tokens
FrictionlessTransferManagerNotEnoughTokens
error thrown during exchangeTokens
, createTransferOffer
, redeemTokens
or redeemTokensFrom
if the balance of any of the tokens held by any users in the transfer is below the transfer amount
FrictionlessTransferManagerInvalidTransferStatus
error thrown during confirmTransferOffer
or cancelOffer
if the transfer status expectedStatus does not match the actualStatus
FrictionlessTransferManagerNotEnoughPermissions
error thrown during createTransferOffer
or confirmTransferOffer
if any of the msg.sender is not an Agent of the tokens in the transfer.
Structs
TokenFeeInfo
TokenFeeInfo represents the fee (zero or otherwise) that is associated with the transfer of a token in the Transfer Manager exchange.
TokenTransferData
TokenTransferData represents the data set in a transfer of a token
TransferData
TransferData represents a maker/taker model of transfer, where 1 token is exchanged for another
Enums
TransferStatuses
Enumeration to track transfer statuses