TokenApproveProxy

0x3d60c4d60f4b804b258b07dfa79d44b2e01bb403

Verification
Verified
v0.8.17+commit.8df45f5f
Type
Contract
1,887 bytes
ABI entries
16
4 read · 7 write
License
none

Contract information

Address
0x3d60c4d60f4b804b258b07dfa79d44b2e01bb403
Chain
Robinhood Chain (4663)
Compiler
v0.8.17+commit.8df45f5f
Optimization
Enabled
Creation tx
0xddd411eab4…1ed437a9d2

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (4)

allowedApprove(address)bool
isAllowedProxy(address)bool
owner()address
tokenApprove()address

Events (5)

AddNewProxyInitializedOwnershipTransferredRemoveNewProxyTokenApproveChanged

ABI

[
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "address",
        "name": "newProxy",
        "type": "address"
      }
    ],
    "name": "AddNewProxy",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "uint8",
        "name": "version",
        "type": "uint8"
      }
    ],
    "name": "Initialized",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "previousOwner",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "newOwner",
        "type": "address"
      }
    ],
    "name": "OwnershipTransferred",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "address",
        "name": "oldProxy",
        "type": "address"
      }
    ],
    "name": "RemoveNewProxy",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "address",
        "name": "newTokenApprove",
        "type": "address"
      }
    ],
    "name": "TokenApproveChanged",
    "type": "event"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_newProxy",
        "type": "address"
      }
    ],
    "name": "addProxy",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "name": "allowedApprove",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_token",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_who",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_dest",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "_amount",
        "type": "uint256"
      }
    ],
    "name": "claimTokens",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "initialize",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_proxy",
        "type": "address"
      }
    ],
    "name": "isAllowedProxy",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "owner",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_oldProxy",
        "type": "address"
      }
    ],
    "name": "removeProxy",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "renounceOwnership",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_tokenApprove",
        "type": "address"
      }
    ],
    "name": "setTokenApprove",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "tokenApprove",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "newOwner",
        "type": "address"
      }
    ],
    "name": "transferOwnership",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]

Source code

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma abicoder v2;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./interfaces/IApprove.sol";
import "./interfaces/IApproveProxy.sol";

/// @title Allow different version dexproxy to claim from Approve
/// @notice This contract acts as a proxy to manage and execute token approvals and transfers, ensuring that only authorized proxies can perform these operations. It is used in a DEX platform to handle token approvals and transfers securely.
/// @dev This contract implements the IApproveProxy interface and uses the OwnableUpgradeable pattern for access control. It maintains a list of allowed proxies and interacts with the IApprove contract to execute token transfers.
contract TokenApproveProxy is IApproveProxy, OwnableUpgradeable {
    /// @notice A mapping to keep track of addresses that are allowed to use this proxy for token approval and transfer.
    mapping(address => bool) public allowedApprove;

    /// @notice The address of the TokenApprove contract that this proxy interacts with.
    address public override tokenApprove;

    /// @notice Initializes the contract, setting up the owner.
    function initialize() public initializer {
        __Ownable_init();
    }

    //-------------------------------
    //------- Events ----------------
    //-------------------------------

    /// @notice Emitted when a new proxy address is added to the allowed list.
    /// @param newProxy The address of the new proxy added.
    event AddNewProxy(address newProxy);

    /// @notice Emitted when a proxy address is removed from the allowed list.
    /// @param oldProxy The address of the proxy removed.
    event RemoveNewProxy(address oldProxy);

    /// @notice Emitted when the TokenApprove contract address is updated.
    /// @param newTokenApprove The address of the new TokenApprove contract.
    event TokenApproveChanged(address newTokenApprove);

    //-------------------------------
    //------- Admin functions -------
    //-------------------------------

    /// @notice Adds a new proxy address to the list of allowed proxies.
    /// @param _newProxy The address of the new proxy to add.
    /// @dev Can only be called by the contract owner.
    function addProxy(address _newProxy) external onlyOwner {
        allowedApprove[_newProxy] = true;
        emit AddNewProxy(_newProxy);
    }

    /// @notice Removes a proxy address from the list of allowed proxies.
    /// @param _oldProxy The address of the proxy to remove.
    /// @dev Can only be called by the contract owner.
    function removeProxy(address _oldProxy) public onlyOwner {
        allowedApprove[_oldProxy] = false;
        emit RemoveNewProxy(_oldProxy);
    }

    /// @notice Sets the address of the TokenApprove contract that this proxy interacts with.
    /// @param _tokenApprove The address of the TokenApprove contract.
    /// @dev Can only be called by the contract owner.
    function setTokenApprove(address _tokenApprove) external onlyOwner {
        tokenApprove = _tokenApprove;
        emit TokenApproveChanged(_tokenApprove);
    }

    //-------------------------------
    //------- Users Functions -------
    //-------------------------------

    /// @notice Claims tokens on behalf of a user, transferring them from the user's account to a destination address.
    /// @param _token The address of the token to be transferred.
    /// @param _who The address of the token owner (the sender).
    /// @param _dest The address of the recipient (the receiver).
    /// @param _amount The amount of tokens to be transferred.
    /// @dev This function can only be called by an address that is in the list of allowed proxies. It delegates the actual transfer operation to the TokenApprove contract.
    function claimTokens(
        address _token,
        address _who,
        address _dest,
        uint256 _amount
    ) external override {
        require(allowedApprove[msg.sender], "ApproveProxy: Access restricted");
        IApprove(tokenApprove).claimTokens(_token, _who, _dest, _amount);
    }

    /// @notice Checks if a given address is an allowed proxy.
    /// @param _proxy The address to check.
    /// @return A boolean indicating if the address is an allowed proxy.
    /// @dev Provides a view function to check if a specific address is in the list of allowed proxies.
    function isAllowedProxy(
        address _proxy
    ) external view override returns (bool) {
        return allowedApprove[_proxy];
    }
}
Chain explorer3426msChain node78ms