Skip to main content
PulseScanner.io

Address

0xe8cd8a657b95bca51dd7bc35cd9d5dfbf9c05596
Current Holdings
$0.00
TXs sent
not counted
First Active
2026-03-19
block 26,060,564
Last Active
147 days ago
block 26,329,135
Funded By
not identified

Net worth historyi

No net-worth snapshots recorded yet
partial matchPaiRegistrysolc 0.8.20+commit.a1b79de6runtime partial · creation not verified
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title PaiRegistry
 * @notice A central registry for Core and Ilk contracts.
 * @dev Uses DSAuth style authentication (wards). 
 * Allows governance to update addresses without requiring a UI rebuild.
 */
contract PaiRegistry {
    // --- Auth ---
    mapping(address => uint256) public wards;
    function rely(address usr) external auth { wards[usr] = 1; emit Rely(usr); }
    function deny(address usr) external auth { wards[usr] = 0; emit Deny(usr); }
    modifier auth {
        require(wards[msg.sender] == 1, "PaiRegistry/not-authorized");
        _;
    }

    // --- Data Structures ---
    
    /**
     * @notice Stores addresses for a specific collateral type (Ilk).
     * @dev Matches the IlkContracts interface in your UI.
     */
    struct IlkInfo {
        address gem;      // The underlying token (Token)
        address join;     // GemJoin adapter
        address pip;      // PipJoin / Oracle
        address clip;     // Clipper (Liquidation engine)
        address pair;     // LP Pair address
        address psm;      // Peg Stability Module (optional, address(0) if none)
    }

    // --- State Variables ---

    // Core contracts: Mapping of a name hash (e.g., keccak256("Vat")) to an address.
    mapping(bytes32 => address) public core;
    
    // Ilk contracts: Mapping of an ilk identifier (bytes32) to the IlkInfo struct.
    mapping(bytes32 => IlkInfo) public ilks;
    
    // A list of all added ilk identifiers for UI enumeration.
    bytes32[] public ilkList;
    
    // Helper mapping to check if an ilk exists (prevents duplicates).
    mapping(bytes32 => bool) public isIlk;

    // --- Events ---
    event Rely(address indexed usr);
    event Deny(address indexed usr);
    event UpdateCore(bytes32 indexed key, address indexed val);
    event AddIlk(bytes32 indexed ilk);
    event UpdateIlk(bytes32 indexed ilk);

    // --- Constructor ---
    constructor() {
        wards[msg.sender] = 1;
        emit Rely(msg.sender);
    }

    // --- Core Management ---

    /**
     * @notice Update or add a core contract address.
     * @param key The name of the contract (e.g., "Vat", "Dog", "Pot").
     * @param val The address of the contract.
     */
    function setCore(bytes32 key, address val) external auth {
        core[key] = val;
        emit UpdateCore(key, val);
    }

    // --- Ilk Management ---

    /**
     * @notice Add a new Ilk (Collateral Type).
     * @dev Reverts if the ilk already exists.
     */
    function addIlk(
        bytes32 ilk, 
        address gem, 
        address join, 
        address pip, 
        address clip, 
        address pair, 
        address psm
    ) external auth {
        require(!isIlk[ilk], "PaiRegistry/ilk-already-exists");
        
        ilks[ilk] = IlkInfo({
            gem: gem,
            join: join,
            pip: pip,
            clip: clip,
            pair: pair,
            psm: psm
        });

        ilkList.push(ilk);
        isIlk[ilk] = true;
        emit AddIlk(ilk);
    }

    /**
     * @notice Update an existing Ilk's addresses.
     * @dev Reverts if the ilk does not exist.
     */
    function updateIlk(
        bytes32 ilk, 
        address gem, 
        address join, 
        address pip, 
        address clip, 
        address pair, 
        address psm
    ) external auth {
        require(isIlk[ilk], "PaiRegistry/ilk-does-not-exist");
        
        ilks[ilk] = IlkInfo({
            gem: gem,
            join: join,
            pip: pip,
            clip: clip,
            pair: pair,
            psm: psm
        });
        
        emit UpdateIlk(ilk);
    }

    // --- View Functions for UI ---

    /**
     * @notice Get the total number of registered ilks.
     * @return count The number of ilks.
     */
    function getIlkCount() external view returns (uint256) {
        return ilkList.length;
    }

    /**
     * @notice Get the struct data for a specific ilk.
     * @param ilk The identifier of the ilk (e.g., "WPLS-A").
     * @return info The IlkInfo struct.
     */
    function getIlk(bytes32 ilk) external view returns (IlkInfo memory) {
        return ilks[ilk];
    }

    /**
     * @notice Get an ilk identifier by its index in the list.
     * @dev Used for iterating through all ilks in the UI.
     */
    function getIlkIdAtIndex(uint256 index) external view returns (bytes32) {
        return ilkList[index];
    }
}