Merge branch 'new-tests' of github.com:InstaDApp/dsl-polygon-migration into new-tests

This commit is contained in:
Mubaris NK 2021-04-16 21:35:09 +05:30
commit c22f42e68e
No known key found for this signature in database
GPG Key ID: 9AC09AD0F8D68561
2 changed files with 33 additions and 32 deletions

View File

@ -51,8 +51,7 @@ contract MigrateResolver is Helpers, Events {
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
for (uint i = 0; i < supportedTokens.length; i++) {
address _token = supportedTokens[i];
if (_token == maticAddr) {
_token = wmaticAddr;
if (_token == wmaticAddr) {
if (address(this).balance > 0) {
TokenInterface(wmaticAddr).deposit{value: address(this).balance}();
}

View File

@ -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);
}
}