IFrictionlessFXSwap
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 any FrictionlessFundDepositToken
currency pair on the Frictionless protocol. The FX rates are set from the live spot & forward FX partners on the protocol.
Functions
setFXDeskFeeAddr
Sets the address of the FXDesk fee recipient Only Owner (PROTOCOL_ADMIN) can call this function
Parameters
Name | Type | Description |
---|---|---|
|
| The new address of the FXDesk fee recipient |
setSwapFees
Set the swap fees for the swaps 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 token0 (first token) in the token pair during the swap. |
|
| The fees associated with the token1 (second token) in the token pair during the swap. throws |
setTokenFee
Set the fee associated with the swap 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 swap of token, used in the calculation and disbursement of fees during swap of a token pair. throws |
swapTokens
Swaps tokens between addresses at a specified exchange rate Only PROTOCOL_TREASURY can call this function
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the token to be sold |
|
| The address of the token to be bought |
|
| The address of the sender initiating the swap |
|
| The address where the bought tokens will be sent |
|
| The amount of tokens being bought |
|
| The exchange rate of the token being bought to the token being sold |
fxDeskFeeAddr
Retrieves the address of the FXDesk fee recipient
Returns
Name | Type | Description |
---|---|---|
|
| The address of the FXDesk fee recipient |
treasuryManager
Retrieves the Frictionless Treasury Manager contract
Returns
Name | Type | Description |
---|---|---|
|
| The address of the Frictionless Treasury Manager contract |
permissionManager
Retrieves the Frictionless Permissions Manager contract
Returns
Name | Type | Description |
---|---|---|
|
| The address of the Frictionless Permissions Manager contract |
getSwapFeesInfo
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. |
|
|
getSwapFeeKeys
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. |
getSellingTokensAmount
Calculates the amount of selling tokens based on the buying amount and exchange rate
Parameters
Name | Type | Description |
---|---|---|
|
| The amount of tokens being bought |
|
| The exchange rate of the token being bought to the token being sold |
Returns
Name | Type | Description |
---|---|---|
|
| The amount of selling tokens |
Events
FrictionlessFXTokensSwapped
Event emitted upon successful token swaps
Errors
FrictionlessFXSwapInvalidTokenAddresses
error thrown during setSwapFees
if token adresses are invalid (zero addresses, equals addresses and etc.).
FrictionlessFXSwapInvalidFeeRecipientAddr
error thrown during setSwapFees
, setTokenFee
and swapTokens
if the fxDeskFeeRecipient doesn't equal to the stored fxDeskFeeAddr
FrictionlessFXSwapNotEnoughPermissions
error thrown during swapTokens
if the msg.sender is not a PROTOCOL_TREASURY.
Structs
FrictionlessTokenFXFeeInfo
Structure representing token fee information including the token address and fee information