Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xE7a35fa6...F0d1707bE The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
SquidFeeCollector
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 99999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import {Upgradable} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradables/Upgradable.sol"; import {ISquidFeeCollector} from "../interfaces/ISquidFeeCollector.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract SquidFeeCollector is ISquidFeeCollector, Upgradable { bytes32 private constant BALANCES_PREFIX = keccak256("SquidFeeCollector.balances"); bytes32 private constant SPECIFIC_FEES_PREFIX = keccak256("SquidFeeCollector.specificFees"); address public immutable squidTeam; // Value expected with 2 decimals /// eg. 825 is 8.25% uint256 public immutable squidDefaultFee; error ZeroAddressProvided(); constructor(address _squidTeam, uint256 _squidDefaultFee) { if (_squidTeam == address(0)) revert ZeroAddressProvided(); squidTeam = _squidTeam; squidDefaultFee = _squidDefaultFee; } /// @param integratorFee Value expected with 2 decimals /// eg. 825 is 8.25% function collectFee(address token, uint256 amountToTax, address integratorAddress, uint256 integratorFee) external { if (integratorFee > 1000) revert ExcessiveIntegratorFee(); uint256 specificFee = getSpecificFee(integratorAddress); uint256 squidFee = specificFee == 0 ? squidDefaultFee : specificFee; uint256 baseFeeAmount = (amountToTax * integratorFee) / 10000; uint256 squidFeeAmount = (baseFeeAmount * squidFee) / 10000; uint256 integratorFeeAmount = baseFeeAmount - squidFeeAmount; _safeTransferFrom(token, msg.sender, baseFeeAmount); _setBalance(token, squidTeam, getBalance(token, squidTeam) + squidFeeAmount); _setBalance(token, integratorAddress, getBalance(token, integratorAddress) + integratorFeeAmount); emit FeeCollected(token, integratorAddress, squidFeeAmount, integratorFeeAmount); } function withdrawFee(address token) external { uint256 balance = getBalance(token, msg.sender); _setBalance(token, msg.sender, 0); _safeTransfer(token, msg.sender, balance); emit FeeWithdrawn(token, msg.sender, balance); } function setSpecificFee(address integrator, uint256 fee) external onlyOwner { bytes32 slot = _computeSpecificFeeSlot(integrator); assembly { sstore(slot, fee) } } function getBalance(address token, address account) public view returns (uint256 value) { bytes32 slot = _computeBalanceSlot(token, account); assembly { value := sload(slot) } } function getSpecificFee(address integrator) public view returns (uint256 value) { bytes32 slot = _computeSpecificFeeSlot(integrator); assembly { value := sload(slot) } } function contractId() external pure returns (bytes32 id) { id = keccak256("squid-fee-collector"); } function _setBalance(address token, address account, uint256 amount) private { bytes32 slot = _computeBalanceSlot(token, account); assembly { sstore(slot, amount) } } function _computeBalanceSlot(address token, address account) private pure returns (bytes32 slot) { slot = keccak256(abi.encodePacked(BALANCES_PREFIX, token, account)); } function _computeSpecificFeeSlot(address integrator) private pure returns (bytes32 slot) { slot = keccak256(abi.encodePacked(SPECIFIC_FEES_PREFIX, integrator)); } function _safeTransferFrom(address token, address from, uint256 amount) internal { (bool success, bytes memory returnData) = token.call( abi.encodeWithSelector(IERC20.transferFrom.selector, from, address(this), amount) ); bool transferred = success && (returnData.length == uint256(0) || abi.decode(returnData, (bool))); if (!transferred || token.code.length == 0) revert TransferFailed(); } function _safeTransfer(address token, address to, uint256 amount) internal { (bool success, bytes memory returnData) = token.call( abi.encodeWithSelector(IERC20.transfer.selector, to, amount) ); bool transferred = success && (returnData.length == uint256(0) || abi.decode(returnData, (bool))); if (!transferred || token.code.length == 0) revert TransferFailed(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // General interface for upgradable contracts interface IUpgradable { error NotOwner(); error InvalidOwner(); error InvalidCodeHash(); error InvalidImplementation(); error SetupFailed(); error NotProxy(); event Upgraded(address indexed newImplementation); event OwnershipTransferred(address indexed newOwner); // Get current owner function owner() external view returns (address); function contractId() external pure returns (bytes32); function upgrade( address newImplementation, bytes32 newImplementationCodeHash, bytes calldata params ) external; function setup(bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '../interfaces/IUpgradable.sol'; abstract contract Upgradable is IUpgradable { // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; // keccak256('owner') bytes32 internal constant _OWNER_SLOT = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0; modifier onlyOwner() { if (owner() != msg.sender) revert NotOwner(); _; } function owner() public view returns (address owner_) { // solhint-disable-next-line no-inline-assembly assembly { owner_ := sload(_OWNER_SLOT) } } function transferOwnership(address newOwner) external virtual onlyOwner { if (newOwner == address(0)) revert InvalidOwner(); emit OwnershipTransferred(newOwner); // solhint-disable-next-line no-inline-assembly assembly { sstore(_OWNER_SLOT, newOwner) } } function implementation() public view returns (address implementation_) { // solhint-disable-next-line no-inline-assembly assembly { implementation_ := sload(_IMPLEMENTATION_SLOT) } } function upgrade( address newImplementation, bytes32 newImplementationCodeHash, bytes calldata params ) external override onlyOwner { if (IUpgradable(newImplementation).contractId() != IUpgradable(this).contractId()) revert InvalidImplementation(); if (newImplementationCodeHash != newImplementation.codehash) revert InvalidCodeHash(); if (params.length > 0) { // solhint-disable-next-line avoid-low-level-calls (bool success, ) = newImplementation.delegatecall(abi.encodeWithSelector(this.setup.selector, params)); if (!success) revert SetupFailed(); } emit Upgraded(newImplementation); // solhint-disable-next-line no-inline-assembly assembly { sstore(_IMPLEMENTATION_SLOT, newImplementation) } } function setup(bytes calldata data) external override { // Prevent setup from being called on the implementation if (implementation() == address(0)) revert NotProxy(); _setup(data); } // solhint-disable-next-line no-empty-blocks function _setup(bytes calldata data) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @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 amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` 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 amount) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; interface ISquidFeeCollector { event FeeCollected(address token, address integrator, uint256 squidFee, uint256 integratorFee); event FeeWithdrawn(address token, address account, uint256 amount); error TransferFailed(); error ExcessiveIntegratorFee(); function collectFee(address token, uint256 amountToTax, address integratorAddress, uint256 integratorFee) external; function withdrawFee(address token) external; function getBalance(address token, address account) external view returns (uint256 accountBalance); }
{ "optimizer": { "enabled": true, "runs": 99999 }, "viaIR": true, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_squidTeam","type":"address"},{"internalType":"uint256","name":"_squidDefaultFee","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ExcessiveIntegratorFee","type":"error"},{"inputs":[],"name":"InvalidCodeHash","type":"error"},{"inputs":[],"name":"InvalidImplementation","type":"error"},{"inputs":[],"name":"InvalidOwner","type":"error"},{"inputs":[],"name":"NotOwner","type":"error"},{"inputs":[],"name":"NotProxy","type":"error"},{"inputs":[],"name":"SetupFailed","type":"error"},{"inputs":[],"name":"TransferFailed","type":"error"},{"inputs":[],"name":"ZeroAddressProvided","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"integrator","type":"address"},{"indexed":false,"internalType":"uint256","name":"squidFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"integratorFee","type":"uint256"}],"name":"FeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newImplementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountToTax","type":"uint256"},{"internalType":"address","name":"integratorAddress","type":"address"},{"internalType":"uint256","name":"integratorFee","type":"uint256"}],"name":"collectFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractId","outputs":[{"internalType":"bytes32","name":"id","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"integrator","type":"address"}],"name":"getSpecificFee","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"implementation_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"integrator","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"setSpecificFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"squidDefaultFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"squidTeam","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes32","name":"newImplementationCodeHash","type":"bytes32"},{"internalType":"bytes","name":"params","type":"bytes"}],"name":"upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"withdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x6040608081526004908136101561001557600080fd5b600091823560e01c80631ac3ddeb14610b7a578063369261b1146108e15780634bb965db146108885780635c60da1b146108165780638291286c146107bd5780638da5cb5b1461074b5780639ded06df1461068f578063a00ebaf314610620578063a3499c7314610318578063cb0c7179146102d4578063d4fac45d1461025f578063e8164888146101b05763f2fde38b146100b057600080fd5b346101ac5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ac576100e7610cbb565b917f02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c091825473ffffffffffffffffffffffffffffffffffffffff90813391160361018457841691821561015e5750507f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc6861638480a25580f35b517f49e27cff000000000000000000000000000000000000000000000000000000008152fd5b5090517f30cd7471000000000000000000000000000000000000000000000000000000008152fd5b8280fd5b50346101ac57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ac576101e7610cbb565b917f02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c05473ffffffffffffffffffffffffffffffffffffffff3391160361023957505061023560243591610ebe565b5580f35b517f30cd7471000000000000000000000000000000000000000000000000000000008152fd5b5050346102d057807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102d057610297610cbb565b6024359273ffffffffffffffffffffffffffffffffffffffff841684036102cd57506020926102c591610e4a565b549051908152f35b80fd5b5080fd5b5050346102d05760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102d0576020906102c5610313610cbb565b610ebe565b5090346101ac5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ac57610351610cbb565b9160443567ffffffffffffffff811161061c576103719036908301610ce3565b92907f02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c05473ffffffffffffffffffffffffffffffffffffffff9081339116036105f4578516938251907f8291286c00000000000000000000000000000000000000000000000000000000808352602092838188818b5afa9081156105bd578a916105c7575b50855191825283828881305afa9182156105bd578a9261058a575b500361056157863f60243503610538579081889392610477575b8388887fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8380a27f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5580f35b6104f6606485947fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f858a51968794898601997f9ded06df000000000000000000000000000000000000000000000000000000008b526024870152816044870152868601378885828601015201168101036044810184520182610d5c565b5190875af4610503610d9d565b5015610512578481808061042b565b517f97905dfb000000000000000000000000000000000000000000000000000000008152fd5b505050517f8f84fb24000000000000000000000000000000000000000000000000000000008152fd5b505050517f68155f9a000000000000000000000000000000000000000000000000000000008152fd5b9091508381813d83116105b6575b6105a28183610d5c565b810103126105b257519038610411565b8980fd5b503d610598565b86513d8c823e3d90fd5b90508381813d83116105ed575b6105de8183610d5c565b810103126105b25751386103f6565b503d6105d4565b5050517f30cd7471000000000000000000000000000000000000000000000000000000008152fd5b8480fd5b5050346102d057817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102d0576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000760a29c32fdde95588da1b851bc07a12106a9945168152f35b5090346101ac5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ac57813567ffffffffffffffff8111610747576106de9036908401610ce3565b505073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc541615610721578280f35b517fbf10dd3a000000000000000000000000000000000000000000000000000000008152fd5b8380fd5b5050346102d057817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102d05760209073ffffffffffffffffffffffffffffffffffffffff7f02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c054915191168152f35b5050346102d057817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102d057602090517faa5b287fe0e642fccbedbd5838dfbd85ba5294a1d91803c456dcbdaea79b6dd28152f35b5050346102d057817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102d05760209073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54915191168152f35b5050346102d057817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102d057602090517f00000000000000000000000000000000000000000000000000000000000013888152f35b5090346101ac5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126101ac5761091a610cbb565b916044359173ffffffffffffffffffffffffffffffffffffffff80841690818503610b7657606435946103e88611610b4d5761095581610ebe565b5480610b40575061099361099b7f0000000000000000000000000000000000000000000000000000000000001388975b612710928391602435610dfb565b049788610dfb565b049485870396808811610b145785517f23b872dd00000000000000000000000000000000000000000000000000000000602082019081523360248301523060448301526064808301939093529181528a9182916109f9608482610d5c565b5190828c5af1610a07610d9d565b81610ae5575b50158015610adc575b610ab557509160809593917f205442d60b70af1203d43cab62352c3b69b94f091be32fe683198057282b5c929795937f000000000000000000000000760a29c32fdde95588da1b851bc07a12106a9945610a84610a7d87610a77848c610e4a565b54610e3d565b9189610e4a565b55610a9d610a9687610a77848b610e4a565b9188610e4a565b5582519516855260208501528301526060820152a180f35b84517f90b8ec18000000000000000000000000000000000000000000000000000000008152fd5b50873b15610a16565b8051801592508215610afa575b505038610a0d565b610b0d9250602080918301019101610f36565b3880610af2565b60248a6011847f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b61099b6109939197610985565b505050517ff7627429000000000000000000000000000000000000000000000000000000008152fd5b8680fd5b508290346102d05760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102d057610bb4610cbb565b610bbe3382610e4a565b549183610bcb3384610e4a565b558380865160208101907fa9059cbb00000000000000000000000000000000000000000000000000000000825233602482015286604482015260448152610c1181610d11565b519082865af1610c1f610d9d565b81610c8c575b50158015610c83575b610ab55750925173ffffffffffffffffffffffffffffffffffffffff90931683523360208401526040830152907eed5939179dc194223f0edd1517ecee2210b22da7f82c8e4b1795e93b9f06aa90606090a180f35b50813b15610c2e565b8051801592508215610ca1575b505086610c25565b610cb49250602080918301019101610f36565b8680610c99565b6004359073ffffffffffffffffffffffffffffffffffffffff82168203610cde57565b600080fd5b9181601f84011215610cde5782359167ffffffffffffffff8311610cde5760208381860195010111610cde57565b6080810190811067ffffffffffffffff821117610d2d57604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610d2d57604052565b3d15610df6573d9067ffffffffffffffff8211610d2d5760405191610dea60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160184610d5c565b82523d6000602084013e565b606090565b81810292918115918404141715610e0e57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b91908201809211610e0e57565b6040519060208201927f54a86b6f8784ae89b8756feb4330462ac03adecff163baca460e043e4a299dcf84527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000809260601b16604084015260601b16605482015260488152610eb881610d11565b51902090565b6040517fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060208201927e31b84238094705d5038d5a044aafa3455ab4e63b020f8573b1e0d1d7568920845260601b166040820152603481526060810181811067ffffffffffffffff821117610d2d5760405251902090565b90816020910312610cde57518015158103610cde579056fea2646970667358221220092278a56d22f62ba745682b33686229fab7a0c04d372854a384c2b7902ae56764736f6c63430008140033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.