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()); AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
for (uint i = 0; i < supportedTokens.length; i++) { for (uint i = 0; i < supportedTokens.length; i++) {
address _token = supportedTokens[i]; address _token = supportedTokens[i];
if (_token == maticAddr) { if (_token == wmaticAddr) {
_token = wmaticAddr;
if (address(this).balance > 0) { if (address(this).balance > 0) {
TokenInterface(wmaticAddr).deposit{value: address(this).balance}(); TokenInterface(wmaticAddr).deposit{value: address(this).balance}();
} }

View File

@ -5,42 +5,47 @@ interface IndexInterface {
function master() external view returns (address); 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 { abstract contract Helpers {
// struct TokenMap { event LogTokenMapAdded(address indexed L1_token, address indexed L2_token);
// address ctoken; event LogTokenMapUpdated(address indexed L1_token, address indexed L2_token_new, address indexed L2_token_old);
// 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;
// InstaIndex Address. // InstaIndex Address.
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723); IndexInterface public constant instaIndex = IndexInterface(0xA9B99766E6C676Cf1975c0D3166F96C0848fF5ad);
address public constant ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address public constant ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
mapping (address => address) public tokenMapping; mapping (address => address) public tokenMapping;
// modifier isChief { modifier isMaster {
// require(msg.sender == instaIndex.master() || connectors.chief(msg.sender), "not-an-chief"); require(msg.sender == instaIndex.master(), "not-a-master");
// _; _;
// } }
// constructor(address _connectors) { function _addTokenMaps(address[] memory L1, address[] memory L2) internal {
// connectors = ConnectorsInterface(_connectors); 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) { function getMapping(address L1Address) external view returns (address) {
return tokenMapping[L1Address]; return tokenMapping[L1Address];
@ -49,10 +54,7 @@ abstract contract Helpers {
} }
contract InstaPolygonTokenMapping is Helpers { contract InstaPolygonTokenMapping is Helpers {
constructor(address[] memory L1, address[] memory L2) { constructor(address[] memory L1, address[] memory L2) {
for (uint256 i = 0; i < L1.length; i++) { _addTokenMaps(L1, L2);
tokenMapping[L1[i]] = L2[i];
}
} }
} }