dsa-connectors/contracts/mainnet/mapping/reflexer.sol

66 lines
2.4 KiB
Solidity
Raw Normal View History

2022-03-22 15:24:40 +00:00
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
2021-03-30 10:52:29 +00:00
pragma experimental ABIEncoderV2;
interface CollateralJoinInterface {
function collateralType() external view returns (bytes32);
}
interface ConnectorsInterface {
function chief(address) external view returns (bool);
}
interface IndexInterface {
function master() external view returns (address);
}
interface MappingControllerInterface {
2021-05-14 19:16:54 +00:00
function hasRole(address,address) external view returns (bool);
}
2021-03-30 10:52:29 +00:00
contract Helpers {
2021-08-03 15:27:53 +00:00
ConnectorsInterface public constant connectors = ConnectorsInterface(0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11); // InstaConnectorsV2
2021-03-31 17:01:57 +00:00
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
2021-08-03 15:27:53 +00:00
2021-08-03 16:15:03 +00:00
MappingControllerInterface public constant mappingController = MappingControllerInterface(0xDdd075D5e1024901E4038461e1e4BbC3A48a08d4);
2021-03-30 10:52:29 +00:00
uint public version = 1;
mapping (bytes32 => address) public collateralJoinMapping;
event LogAddCollateralJoinMapping(address[] collateralJoin);
modifier hasRoleOrIsChief {
require(
msg.sender == instaIndex.master() ||
connectors.chief(msg.sender) ||
mappingController.hasRole(address(this), msg.sender),
"not-an-chief"
);
2021-03-30 10:52:29 +00:00
_;
}
function addCollateralJoinMapping(address[] memory collateralJoins) public hasRoleOrIsChief {
2021-03-30 10:52:29 +00:00
_addCollateralJoinMapping(collateralJoins);
}
function _addCollateralJoinMapping(address[] memory collateralJoins) internal {
require(collateralJoins.length > 0, "No-CollateralJoin-Address");
for(uint i = 0; i < collateralJoins.length; i++) {
address collateralJoin = collateralJoins[i];
bytes32 collateralType = CollateralJoinInterface(collateralJoin).collateralType();
require(collateralJoinMapping[collateralType] == address(0), "CollateralJoin-Already-Added");
collateralJoinMapping[collateralType] = collateralJoin;
}
emit LogAddCollateralJoinMapping(collateralJoins);
}
}
2021-08-03 16:15:03 +00:00
contract InstaReflexerGebMapping is Helpers {
string constant public name = "Reflexer-Geb-Mapping-v1";
2021-03-31 17:01:57 +00:00
2021-03-30 10:52:29 +00:00
constructor() public {
address[] memory collateralJoins = new address[](1);
collateralJoins[0] = 0x2D3cD7b81c93f188F3CB8aD87c8Acc73d6226e3A; // ETH-A Join contract address
_addCollateralJoinMapping(collateralJoins);
}
}