connector update & settle transfer

This commit is contained in:
Samyak Jain 2021-04-14 04:13:51 +05:30
parent 127ebebd8e
commit 20a9e4fc6d
5 changed files with 34 additions and 13 deletions

View File

@ -9,21 +9,27 @@ import { Events } from "./events.sol";
contract AaveMigrateResolver is Helpers, Events { contract AaveMigrateResolver is Helpers, Events {
function migrate( function migrate(
AaveDataRaw calldata _data, address targetDsa,
address[] memory supplyTokens,
address[] memory borrowTokens,
uint[] memory variableBorrowAmts,
uint[] memory stableBorrowAmts,
uint[] memory supplyAmts,
uint ethAmt // if ethAmt is > 0 then use migrateWithflash uint ethAmt // if ethAmt is > 0 then use migrateWithflash
) external payable returns (string memory _eventName, bytes memory _eventParam) { ) external payable returns (string memory _eventName, bytes memory _eventParam) {
require(_data.supplyTokens.length > 0, "0-length-not-allowed"); require(supplyTokens.length > 0, "0-length-not-allowed");
require(_data.supplyTokens.length == _data.supplyAmts.length, "invalid-length"); require(supplyTokens.length == supplyAmts.length, "invalid-length");
require(_data.targetDsa != address(0), "invalid-address"); require(borrowTokens.length == variableBorrowAmts.length && borrowTokens.length == stableBorrowAmts.length, "invalid-length");
require(targetDsa != address(0), "invalid-address");
AaveDataRaw memory data; AaveDataRaw memory data;
data.borrowTokens = _data.borrowTokens; data.targetDsa = targetDsa;
data.stableBorrowAmts = _data.stableBorrowAmts; data.supplyTokens = supplyTokens;
data.supplyAmts = _data.supplyAmts; data.borrowTokens = borrowTokens;
data.supplyTokens = _data.supplyTokens; data.variableBorrowAmts = variableBorrowAmts;
data.targetDsa = _data.targetDsa; data.stableBorrowAmts = stableBorrowAmts;
data.variableBorrowAmts = _data.variableBorrowAmts; data.supplyAmts = supplyAmts;
for (uint i = 0; i < data.supplyTokens.length; i++) { for (uint i = 0; i < data.supplyTokens.length; i++) {
address _token = data.supplyTokens[i] == ethAddr ? wethAddr : data.supplyTokens[i]; address _token = data.supplyTokens[i] == ethAddr ? wethAddr : data.supplyTokens[i];

View File

@ -28,4 +28,6 @@ contract Events {
event variablesUpdate(uint _safeRatioGap, uint _fee, bool _depositEnable); event variablesUpdate(uint _safeRatioGap, uint _fee, bool _depositEnable);
event settle(address[] tokens, uint[] amts);
} }

View File

@ -96,3 +96,13 @@ interface ChainLinkInterface {
function latestAnswer() external view returns (int256); function latestAnswer() external view returns (int256);
function decimals() external view returns (uint256); function decimals() external view returns (uint256);
} }
interface RootChainManagerInterface {
function depositEtherFor(address user) external payable;
function depositFor(
address user,
address rootToken,
bytes calldata depositData
) external;
function exit(bytes calldata inputData) external;
}

View File

@ -166,11 +166,11 @@ contract LiquidityResolver is Helpers, Events {
} }
for (uint i = 0; i < _tokens.length; i++) { for (uint i = 0; i < _tokens.length; i++) {
aave.withdraw(_tokens[i], _amts[i], address(this)); aave.withdraw(_tokens[i], _amts[i], address(this));
// TODO: transfer to polygon's receiver address "polygonReceiver" migrator.depositFor(polygonReceiver, _tokens[i], abi.encode(_amts[i]));
isPositionSafe(); isPositionSafe();
} }
emit settle(_tokens, _amts);
} }
// TODO: emit event
} }
contract MigrateResolver is LiquidityResolver { contract MigrateResolver is LiquidityResolver {

View File

@ -5,7 +5,8 @@ import {
AaveDataProviderInterface, AaveDataProviderInterface,
StateSenderInterface, StateSenderInterface,
IndexInterface, IndexInterface,
FlashloanInterface FlashloanInterface,
RootChainManagerInterface
} from "./interfaces.sol"; } from "./interfaces.sol";
contract Variables { contract Variables {
@ -69,4 +70,6 @@ contract Variables {
// InstaIndex Address. // InstaIndex Address.
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723); IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
RootChainManagerInterface internal constant migrator = RootChainManagerInterface(0xA0c68C638235ee32657e8f720a23ceC1bFc77C77);
} }