Files
smom-dbis-138/contracts/hybx-omnl/InstrumentRegistry.sol
defiQUG f3d2961b97
Some checks failed
CI/CD Pipeline / Lint and Format (push) Failing after 46s
CI/CD Pipeline / Terraform Validation (push) Failing after 35s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 37s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 1m50s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 2m19s
Validation / validate-genesis (push) Successful in 51s
Validation / validate-terraform (push) Failing after 39s
Validation / validate-kubernetes (push) Failing after 10s
CI/CD Pipeline / Solidity Contracts (push) Failing after 12m56s
Validation / validate-smart-contracts (push) Failing after 12s
CI/CD Pipeline / Security Scanning (push) Failing after 15m52s
Validation / validate-security (push) Failing after 10m59s
Validation / validate-documentation (push) Failing after 17s
Validate Token List / validate (push) Failing after 30s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 26s
Verify Deployment / Verify Deployment (push) Failing after 56s
feat: add hybx omnl stack and gas pmm tooling
2026-04-24 12:56:40 -07:00

93 lines
3.0 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
/**
* @title InstrumentRegistry
* @notice Maps lineId → M0/M1 ERC-20s, ISO-4217 metadata, and pause per line.
*/
contract InstrumentRegistry is AccessControl {
bytes32 public constant REGISTRY_ADMIN_ROLE = keccak256("REGISTRY_ADMIN_ROLE");
struct Line {
address tokenM0;
address tokenM1;
uint8 decimals;
uint16 iso4217Numeric;
bool isXAU;
bool active;
}
mapping(bytes32 lineId => Line) private _lines;
bytes32[] private _allLineIds;
event LineRegistered(
bytes32 indexed lineId,
address tokenM0,
address tokenM1,
uint8 decimals,
uint16 iso4217Numeric,
bool isXAU
);
event LineUpdated(bytes32 indexed lineId, bool active);
event LineTokensUpdated(bytes32 indexed lineId, address tokenM0, address tokenM1);
constructor(address admin) {
require(admin != address(0), "InstrumentRegistry: zero admin");
_grantRole(DEFAULT_ADMIN_ROLE, admin);
_grantRole(REGISTRY_ADMIN_ROLE, admin);
}
function registerLine(
bytes32 lineId,
address tokenM0,
address tokenM1,
uint8 decimals_,
uint16 iso4217Numeric,
bool isXAU
) external onlyRole(REGISTRY_ADMIN_ROLE) {
require(lineId != bytes32(0), "InstrumentRegistry: zero lineId");
require(tokenM0 != address(0) && tokenM1 != address(0), "InstrumentRegistry: zero token");
require(_lines[lineId].tokenM0 == address(0), "InstrumentRegistry: exists");
_lines[lineId] = Line({
tokenM0: tokenM0,
tokenM1: tokenM1,
decimals: decimals_,
iso4217Numeric: iso4217Numeric,
isXAU: isXAU,
active: true
});
_allLineIds.push(lineId);
emit LineRegistered(lineId, tokenM0, tokenM1, decimals_, iso4217Numeric, isXAU);
}
/// @notice All registered line ids (order of registration).
function allLineIds() external view returns (bytes32[] memory) {
return _allLineIds;
}
function setLineActive(bytes32 lineId, bool active) external onlyRole(REGISTRY_ADMIN_ROLE) {
require(_lines[lineId].tokenM0 != address(0), "InstrumentRegistry: unknown line");
_lines[lineId].active = active;
emit LineUpdated(lineId, active);
}
function setLineTokens(bytes32 lineId, address tokenM0, address tokenM1)
external
onlyRole(REGISTRY_ADMIN_ROLE)
{
require(_lines[lineId].tokenM0 != address(0), "InstrumentRegistry: unknown line");
require(tokenM0 != address(0) && tokenM1 != address(0), "InstrumentRegistry: zero token");
_lines[lineId].tokenM0 = tokenM0;
_lines[lineId].tokenM1 = tokenM1;
emit LineTokensUpdated(lineId, tokenM0, tokenM1);
}
function getLine(bytes32 lineId) external view returns (Line memory) {
return _lines[lineId];
}
}