SwapperAdapterData

Description:

ERC20 token contract with Factory, Oracle capabilities. Standard implementation for fungible tokens on Ethereum.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "src/SwapperAdapterData.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC20} from "../lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol";

import {ISwapper} from "./interfaces/ISwapper.sol";

interface ISwapperWithData {
    /// @dev Sells `amountIn` of `input` tokens for `output` tokens.
    /// @param input The address of the input token.
    /// @param output The address of the output token.
    /// @param amountIn The amount of input tokens to sell.
    /// @param data Additional data to pass to the swapper.
    function sell(IERC20 input, IERC20 output, uint256 amountIn, bytes calldata data) external;
}

contract SwapperAdapterData is ISwapperWithData {

    ISwapper swapper;

    constructor(ISwapper _swapper) {
        swapper = _swapper;
    }

    function sell(IERC20 input, IERC20 output, uint256 amountIn, bytes calldata data) external override {
        input.transferFrom(address(msg.sender), address(this), amountIn);
        input.approve(address(swapper), amountIn);
        swapper.sell(input, output, amountIn);
        output.transfer(address(msg.sender), output.balanceOf(address(this)));
    }
}
"
    },
    "lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";
"
    },
    "src/interfaces/ISwapper.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";

interface ISwapper {
    /**
     * @notice Sell from tokenFrom to tokenTo, need to approuve first
     * @param amountIn number of token to sell (tokenFrom), 0 means sell all
     */
    function sell(
        IERC20 tokenFrom,
        IERC20 tokenTo,
        uint256 amountIn
    ) external returns (uint256);

    /**
     * @notice Preview from tokenFrom to tokenTo and return the amount you would get
     * @param amountIn number of token to sell (tokenFrom), 0 means sell all
     */
    function previewSell(
        IERC20 tokenFrom,
        IERC20 tokenTo,
        uint256 amountIn
    ) external returns (uint256);
}
"
    },
    "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
"
    }
  },
  "settings": {
    "remappings": [
      "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
      "ds-auth/=lib/dss-psm/lib/dss/lib/ds-token/lib/ds-auth/src/",
      "ds-math/=lib/dss-psm/lib/dss/lib/ds-token/lib/ds-math/src/",
      "ds-note/=lib/dss-psm/lib/dss/lib/ds-value/lib/ds-thing/lib/ds-note/src/",
      "ds-test/=lib/forge-std/lib/ds-test/src/",
      "ds-thing/=lib/dss-psm/lib/dss/lib/ds-value/lib/ds-thing/src/",
      "ds-token/=lib/dss-psm/lib/dss/lib/ds-token/src/",
      "ds-value/=lib/dss-psm/lib/dss/lib/ds-value/src/",
      "dss-interfaces/=lib/dss-psm/lib/dss-interfaces/src/",
      "dss-psm/=lib/dss-psm/src/",
      "dss/=lib/dss-psm/lib/dss/src/",
      "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
      "forge-std/=lib/forge-std/src/",
      "morpho-blue-oracles/=lib/morpho-blue-oracles/src/",
      "@morpho-blue-oracles/=lib/morpho-blue-oracles/",
      "morpho-blue/=lib/morpho-blue/src/",
      "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
      "@uniswap/v3-periphery/=lib/v3-periphery/",
      "@uniswap/v3-core/=lib/v3-core/",
      "@ensdomains/=lib/slipstream/node_modules/@ensdomains/",
      "@nomad-xyz/=lib/slipstream/lib/ExcessivelySafeCall/",
      "@solidity-parser/=lib/slipstream/node_modules/solhint/node_modules/@solidity-parser/",
      "ExcessivelySafeCall/=lib/slipstream/lib/ExcessivelySafeCall/src/",
      "base64-sol/=lib/slipstream/lib/base64/",
      "base64/=lib/slipstream/lib/base64/",
      "hardhat/=lib/slipstream/node_modules/hardhat/",
      "pendle-core-v2-public/=lib/pendle-core-v2-public/contracts/",
      "slipstream/=lib/slipstream/",
      "solidity-lib/=lib/slipstream/lib/solidity-lib/contracts/",
      "v3-core/=lib/v3-core/",
      "v3-periphery/=lib/v3-periphery/contracts/"
    ],
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "metadata": {
      "useLiteralContent": false,
      "bytecodeHash": "ipfs",
      "appendCBOR": true
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "shanghai",
    "viaIR": true
  }
}}

Tags:
ERC20, Token, Factory, Oracle|addr:0x994c69f1ef1332dd2ea1c97f908b3d96bddb9576|verified:true|block:23413310|tx:0x0d976e417211784f7c84371aee5433670ffd70dcb4eca40222ec7beee9a64514|first_check:1758531351

Submitted on: 2025-09-22 10:55:51

Comments

Log in to comment.

No comments yet.