Frictionless FX Swaps enable Investors to invest instantly, securely and risk-free at super low cost in multiple currencies.
The FX Swap contracts in the Frictionless protocol provide an instant/atomic swap of a currency pair at a quoted spot or forward rate.
Built on cash custody with G-SIB banking providers and FX partners in the EU, the list of supported currencies and currency pairs is maintained in our Frictionless Institutional Deposit Tokens listing.
Frictionless FX Swaps remove the complexity of investing in multi-currency, whilst providing ultimate flexibility and transparency of FX rates and settlement.
FX Swaps work by automating the treasury operations in an FX transaction, namely:
Establishment of optional FX fees to be paid by the seller of currency A
,
Utilization of the buying rate for currency Z
in the swap. The rate utilized in the Frictionless protocol is obtained from our FX partners, the Frictionless Markets team support both spot and forward rates for FX Swaps offering clients the ultimate flexibility and transparency in FX swaps.
Execution of the swap as a single atomic transaction whereby currency A
and currency Z
are burned and minted from/to two counterparties with the automatic collection of optional fees. This operation can only be directed by the PROTOCOL_TREASURY to avoid market manipulation of FX rates.
An example of a live FX Swap on the Avalanche C-Chain is at https://snowtrace.io/tx/0x115570645b70ac573e9ce2f2d4e03f0bd71f502e4dd7019bab6a155417138851?chainId=43114.
In this FX Swap USD was sold for 5,000 EUR. The rate used was a spot rate provided to the Frictionless Markets team. In the block explorer, you can see the collection of fees, burn of fsUSD and mint of fsEUR. The swap and fee collection ran as a single atomic transaction and cost 0.80 USD to execute on the Avalanche C-Chain.
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.
Sets the address of the FXDesk fee recipient Only Owner (PROTOCOL_ADMIN) can call this function
Parameters
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
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
Swaps tokens between addresses at a specified exchange rate Only PROTOCOL_TREASURY can call this function
Parameters
Retrieves the address of the FXDesk fee recipient
Returns
Retrieves the Frictionless Treasury Manager contract
Returns
Retrieves the Frictionless Permissions Manager contract
Returns
get the tokenFeeInfo set for the fees associated per token in an exchange.
Parameters
Returns
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
Returns
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
Returns
Calculates the amount of selling tokens based on the buying amount and exchange rate
Parameters
Returns
Event emitted upon successful token swaps
error thrown during setSwapFees
if token adresses are invalid (zero addresses, equals addresses and etc.).
error thrown during setSwapFees
, setTokenFee
and swapTokens
if the fxDeskFeeRecipient doesn't equal to the stored fxDeskFeeAddr
error thrown during swapTokens
if the msg.sender is not a PROTOCOL_TREASURY.
Structure representing token fee information including the token address and fee information
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
newFXDeskFeeAddr_
address
The new address of the FXDesk fee recipient
token0FeeInfo_
FrictionlessTokenFXFeeInfo
The fees associated with the token0 (first token) in the token pair during the swap.
token1FeeInfo_
FrictionlessTokenFXFeeInfo
The fees associated with the token1 (second token) in the token pair during the swap. throws FrictionlessFXSwapInvalidTokenAddresses
if the token addresses are invalid. throws FrictionlessFXSwapInvalidFeeRecipientAddr
if the feeRecipientAddr doesn't equal to the fxDeskFeeAddr
. 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 FrictionlessFeeSet
upon completion of the setting of the fee info for the token in either set of fees
tokenFeeKey_
bytes32
The key, generated by the function getTokenFeeKey
, which is used to map a specific swap polarity for tokens.
tokenFeeInfo_
FrictionlessTokenFXFeeInfo
The fees associated with the swap of token, used in the calculation and disbursement of fees during swap of a token pair. throws FrictionlessFXSwapInvalidTokenAddresses
if the token addresses are invalid. throws FrictionlessFXSwapInvalidFeeRecipientAddr
if the feeRecipientAddr doesn't equal to the fxDeskFeeAddr
. 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
sellingTokenAddr_
address
The address of the token to be sold
buyingTokenAddr_
address
The address of the token to be bought
tokenSender_
address
The address of the sender initiating the swap
tokenRecipient_
address
The address where the bought tokens will be sent
buyingTokensAmount_
uint256
The amount of tokens being bought
buyingTokenExchangeRate_
uint256
The exchange rate of the token being bought to the token being sold
<none>
address
The address of the FXDesk fee recipient
<none>
IFrictionlessTreasuryManager
The address of the Frictionless Treasury Manager contract
<none>
IFrictionlessPermissionsManager
The address of the Frictionless Permissions Manager contract
token0_
address
the address of the first token in an exchange
token1_
address
the address of the second token in an exchange
<none>
FeeInfo
FeeInfo set for the fees associated per token in an exchange.
<none>
FeeInfo
token0_
address
the address of the token 0 in a transfer fee calculation
token1_
address
the address of the token 1 in a transfer fee calculation
<none>
bytes32
keys based on the packed encoding of the addresses of sets of tokens using the keccak256 hashing function.
<none>
bytes32
token0_
address
the address of the token 0 in a transfer fee calculation
token1_
address
the address of the token 1 in a transfer fee calculation
<none>
bytes32
generates a key based on the packed encoding of the addresses of both tokens using the keccak256 hashing function.
buyingTokensAmount_
uint256
The amount of tokens being bought
buyingTokenExchangeRate_
uint256
The exchange rate of the token being bought to the token being sold
<none>
uint256
The amount of selling tokens