mirror of
https://github.com/Instadapp/dsa-polygon-migration.git
synced 2024-07-29 22:27:58 +00:00
Update Polygon Token mapping contract
This commit is contained in:
parent
af8563d14f
commit
9693f5ffb2
|
@ -5,42 +5,47 @@ interface IndexInterface {
|
|||
function master() external view returns (address);
|
||||
}
|
||||
|
||||
interface ConnectorsInterface {
|
||||
function chief(address) external view returns (bool);
|
||||
}
|
||||
|
||||
interface CTokenInterface {
|
||||
function isCToken() external view returns (bool);
|
||||
function underlying() external view returns (address);
|
||||
}
|
||||
|
||||
abstract contract Helpers {
|
||||
|
||||
// struct TokenMap {
|
||||
// address ctoken;
|
||||
// address token;
|
||||
// }
|
||||
|
||||
// event LogCTokenAdded(string indexed name, address indexed token, address indexed ctoken);
|
||||
// event LogCTokenUpdated(string indexed name, address indexed token, address indexed ctoken);
|
||||
|
||||
// ConnectorsInterface public immutable connectors;
|
||||
event LogTokenMapAdded(address indexed L1_token, address indexed L2_token);
|
||||
event LogTokenMapUpdated(address indexed L1_token, address indexed L2_token_new, address indexed L2_token_old);
|
||||
|
||||
// InstaIndex Address.
|
||||
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
|
||||
IndexInterface public constant instaIndex = IndexInterface(0xA9B99766E6C676Cf1975c0D3166F96C0848fF5ad);
|
||||
|
||||
address public constant ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||
|
||||
mapping (address => address) public tokenMapping;
|
||||
|
||||
// modifier isChief {
|
||||
// require(msg.sender == instaIndex.master() || connectors.chief(msg.sender), "not-an-chief");
|
||||
// _;
|
||||
// }
|
||||
modifier isMaster {
|
||||
require(msg.sender == instaIndex.master(), "not-a-master");
|
||||
_;
|
||||
}
|
||||
|
||||
// constructor(address _connectors) {
|
||||
// connectors = ConnectorsInterface(_connectors);
|
||||
// }
|
||||
function _addTokenMaps(address[] memory L1, address[] memory L2) internal {
|
||||
uint len = L1.length;
|
||||
require(len == L2.length, "addTokenMaps: Length not same");
|
||||
for (uint256 i = 0; i < len; i++) {
|
||||
require(tokenMapping[L1[i]] == address(0), "addTokenMaps: Token map already added");
|
||||
tokenMapping[L1[i]] = L2[i];
|
||||
emit LogTokenMapAdded(L1[i], L2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function addTokenMaps(address[] memory L1, address[] memory L2) external isMaster {
|
||||
_addTokenMaps(L1, L2);
|
||||
}
|
||||
|
||||
function updateTokenMaps(address[] memory L1, address[] memory L2) external isMaster {
|
||||
uint len = L1.length;
|
||||
require(len == L2.length, "updateTokenMaps: Length not same");
|
||||
for (uint256 i = 0; i < len; i++) {
|
||||
require(tokenMapping[L1[i]] != address(0), "updateTokenMaps: Token map already added");
|
||||
require(tokenMapping[L1[i]] != L2[i], "updateTokenMaps: L1 Token is mapped to same L2 Token");
|
||||
emit LogTokenMapUpdated(L1[i], tokenMapping[L1[i]], L2[i]);
|
||||
tokenMapping[L1[i]] = L2[i];
|
||||
}
|
||||
}
|
||||
|
||||
function getMapping(address L1Address) external view returns (address) {
|
||||
return tokenMapping[L1Address];
|
||||
|
@ -49,10 +54,7 @@ abstract contract Helpers {
|
|||
}
|
||||
|
||||
contract InstaPolygonTokenMapping is Helpers {
|
||||
|
||||
constructor(address[] memory L1, address[] memory L2) {
|
||||
for (uint256 i = 0; i < L1.length; i++) {
|
||||
tokenMapping[L1[i]] = L2[i];
|
||||
}
|
||||
_addTokenMaps(L1, L2);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user