EtfTokenEvents

Description:

Smart contract deployed on Ethereum with Factory, Oracle features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "hopium/etf/main/etf-token-events.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import "hopium/common/interface/imDirectory.sol";
import "hopium/etf/interface/imEtfOracle.sol";

contract EtfTokenEvents is ImDirectory, ImEtfOracle {

    event EtfTokenTransfer(
        uint256 etfId,
        address indexed fromAddress,
        address indexed toAddress,
        uint256 transferAmount,
        uint256 etfWethPrice,
        uint256 etfUsdPrice,
        uint256 totalSupply
    );

    constructor(address _directory) ImDirectory(_directory) {}

    /// @notice Emits a transfer event for ETF tokens
    function emitTransferEvent(uint256 etfId, address fromAddress, address toAddress, uint256 transferAmount, uint256 totalSupply) external {

        (uint256 etfWethPrice, uint256 etfUsdPrice) = getEtfOracle().getEtfPrice(etfId);

        emit EtfTokenTransfer(etfId, fromAddress, toAddress, transferAmount, etfWethPrice, etfUsdPrice, totalSupply);
    }
}
"
    },
    "hopium/etf/interface/imEtfOracle.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import "hopium/common/interface/imDirectory.sol";
import "hopium/etf/types/etf.sol";
import "hopium/etf/interface/iEtfOracle.sol";

abstract contract ImEtfOracle is ImDirectory {

    function getEtfOracle() internal view virtual returns (IEtfOracle) {
        return IEtfOracle(fetchFromDirectory("etf-oracle"));
    }
}"
    },
    "hopium/common/interface/imDirectory.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

/// @notice Interface used by the registry to talk to the external directory.
interface IDirectory {
    function owner() external view returns (address);
    function fetchFromDirectory(string memory _key) external view returns (address);
}

abstract contract ImDirectory {
    IDirectory public Directory;

    constructor(address _directory) {
        _setDirectory(_directory); // no modifier here
    }

    function changeDirectoryAddress(address _directory) external onlyOwner {
        _setDirectory(_directory);
    }

    function _setDirectory(address _directory) internal {
        require(_directory != address(0), "Directory cannot be zero address");
        require(_directory.code.length > 0, "Directory must be a contract");

        // Sanity check the interface
        try IDirectory(_directory).owner() returns (address) {
            Directory = IDirectory(_directory);
        } catch {
            revert("Directory address does not implement owner()");
        }
    }

    modifier onlyOwner() {
        require(msg.sender == Directory.owner(), "Caller is not the owner");
        _;
    }

    function owner() public view returns (address) {
        return Directory.owner();
    }

    function fetchFromDirectory(string memory _key) public view returns (address) {
        return Directory.fetchFromDirectory(_key);
    }
}
"
    },
    "hopium/etf/interface/iEtfOracle.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import "hopium/etf/types/etf.sol";
import "hopium/etf/types/snapshot.sol";

interface IEtfOracle {
   function getEtfWethPrice(uint256 etfId) external view returns (uint256);
   function getEtfPrice(uint256 etfId) external view returns (uint256 wethPrice18, uint256 usdPrice18);
   function snapshotVaultUnchecked(Etf memory etf, address vaultAddress) external view returns (Snapshot[] memory s, uint256 etfTvlWeth);
}"
    },
    "hopium/etf/types/etf.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

struct Asset {
    address tokenAddress;
    uint16 weightBips;
}

struct Etf {
    string name;
    string ticker;
    Asset[] assets;
}
"
    },
    "hopium/etf/types/snapshot.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

struct Snapshot {
    address tokenAddress;
    uint8   tokenDecimals;
    uint16  currentWeight;
    uint256 tokenRawBalance;          // vault raw balance
    uint256 tokenPriceWeth18;  // WETH per 1 token (1e18)
    uint256 tokenValueWeth18;  // raw * price / 10^dec
}

struct SnapshotWithUsd {
    address tokenAddress;
    uint8   tokenDecimals;
    uint16  currentWeight;
    uint256 tokenRawBalance;          // vault raw balance
    uint256 tokenPriceWeth18;  // WETH per 1 token (1e18)
    uint256 tokenPriceUsd18;
    uint256 tokenValueWeth18;  // raw * price / 10^dec
    uint256 tokenValueUsd18;
}"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  }
}}

Tags:
Factory, Oracle|addr:0xf7250b3ab7acff15dd1003e058108a92af75930c|verified:true|block:23668245|tx:0x7015ad4a05250827f9c30fb32985a3cfac7199ab6b15acf49df4e164d4ddea38|first_check:1761567290

Submitted on: 2025-10-27 13:14:50

Comments

Log in to comment.

No comments yet.