SimpleSwap

Git Source

Inherits: Core

This logic contract has all the custom logic for the SimpleSwap contract.

This contract accepts ETH, swaps it to USDC using UniswapV3 and returns the USDC to the sender.

Functions

receive

Function to receive ETH when no msg.data is sent.

Calls the swapTokens function with ETH as the input token and automatically swaps it to USDC. Ignores ETH sent from the WETH contract to avoid loops when unwrapping WETH.

receive() external payable;

fallback

Revert calls to functions that do not exist.

fallback() external payable;

swapUsdc

Function to swap USDC to ETH.

function swapUsdc(uint256 _value) external returns (uint256 amountOut);

swapTokens

Function to swap tokens using UniswapV3.

function swapTokens(
    string memory _uniswapV3PoolIdentifier,
    string memory _tokenInIdentifier,
    string memory _tokenOutIdentifier,
    uint256 _amountIn
) internal returns (uint256 amountOut);

_isIdentifierEth

Checks if the identifier is for ETH.

Compares the identifier to the ETH identifier and returns true if they match.

function _isIdentifierEth(string memory _identifier) internal pure returns (bool isEth);

Parameters

NameTypeDescription
_identifierstringThe identifier to check.

Returns

NameTypeDescription
isEthboolTrue if the identifier is for ETH.