This Module is Useful for Understanding the ThirdFy and DexSpan Adapters which are important for Learning about Swapping Adapters. Refer this Repository for Smart Contracts.
DexSpan Adapter
The DexSpanAdapter Smart Contract is Designed to facilitate Token Swaps using the DexSpan Contract. This Tutorial Provides a Comprehensive Guide to Understanding and using the DexSpanAdapter.
Contract Structure - The DexSpanDataStore Contract is used to Store the address of the DexSpan Contract. It Inherits from OpenZeppelin’s Ownable Contract for Ownership Management. The Contract imports Several Dependencies -
DexSpanAdapter - The DexSpanAdapter Contract Inherits from RouterIntentEoaAdapterWithoutDataProvider and implements the EoaExecutorWithoutDataProvider Interface. It Provides functionality for Swapping Tokens using the DexSpan Contract.
Functions -
a) Constructor() - The Constructor initializes the DexSpanDataStore with the Owner’s address and the DexSpan Contract Address. It also Sets the Native and Wrapped Native Token Addresses.
b) name() - The name function returns the name of the Adapter.
c) execute() - The execute function is the main entry point for performing Token Swaps. It Decodes the Input Data, performs necessary Token Transfers, and Calls the _swap function.
d) _swap() - The _swap function Performs the actual Token Swap using the DexSpan Contract.
e) parseInputs() - The parseInputs function Decodes the Input Data into a SameChainSwapParams Struct.
Usage - To use the DexSpanAdapter, Deploy the Contract with the required Parameters -
Native Token Address
Wrapped Native Token Address
DexSpan Contract Address
After Deployment, you can call the execute function with the appropriate Input Data to Perform Token Swaps.
Error Handling - The DexSpanAdapter Contract uses the Errors library to handle Various error Scenarios, such as Insufficient Native funds.
Conclusion
The DexSpanAdapter Smart Contract Simplifies Token Swaps using the DexSpan Protocol. By following this Tutorial, you should be able to Understand and Utilize the Contract effectively.
ThirdFy Adapter
The ThirdFySwap Smart Contract facilitates Token Swaps using the ThirdFy Protocol. This Tutorial provides an in-depth Guide to Understanding and using the ThirdFySwap Contract.
Contract Structure - The ThirdFySwap Smart Contract enables Token Swaps via the ThirdFy Protocol. It extends RouterIntentEoaAdapterWithoutDataProvider and Utilizes SafeERC20 for Safe Token Operations and ThirdFyHelpers for Helper functions.
a) ThirdFyHelpers
- The ThirdFyHelpers Contract provides Utility functions for Interacting with the ThirdFy Protocol. It should be Deployed with the Swap Router Address.
b) ThirdFySwap
- The ThirdFySwap Contract is the Main Contract that handles Token Swaps using the ThirdFy Protocol. It Inherits from RouterIntentEoaAdapterWithoutDataProvider and ThirdFyHelpers.
Functions -
a) constructor() - The Constructor initializes the Contract with Native Token, Wrapped Native Token, and Swap Router Addresses.
b) name() - The name function returns the name of the Adapter.
c) execute() - The execute function performs the Token Swap by Parsing Input Data, handling Token Transfers, and calling the _mint function.
d) _mint() - The _mint function Performs the actual Token Swap using the swapRouter.
e) parseInputs() - The parseInputs function Decodes the Input Data into ExactInputSingleParams.
f) receive() - The receive function allows the Contract to accept Native Token Deposits.
Usage - To use the ThirdFySwap Contract -
Deploy the Contract with the Native Token, Wrapped Native Token, and Swap Router Addresses.
Call the execute function with the appropriate Input Data to Perform a Token Swap.
Error Handling - The ThirdFySwap Contract uses the Errors library to handle various error Scenarios, such as Insufficient Native Funds.
Conclusion
The ThirdFySwap Smart Contract Simplifies Token Swaps using the ThirdFy Protocol. By following this Tutorial, you should be able to Understand and Utilize the Contract effectively.