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 {
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
) external payable returns (string memory _eventName, bytes memory _eventParam) {
require(_data.supplyTokens.length > 0, "0-length-not-allowed");
require(_data.supplyTokens.length == _data.supplyAmts.length, "invalid-length");
require(_data.targetDsa != address(0), "invalid-address");
require(supplyTokens.length > 0, "0-length-not-allowed");
require(supplyTokens.length == supplyAmts.length, "invalid-length");
require(borrowTokens.length == variableBorrowAmts.length && borrowTokens.length == stableBorrowAmts.length, "invalid-length");
require(targetDsa != address(0), "invalid-address");
AaveDataRaw memory data;
data.borrowTokens = _data.borrowTokens;
data.stableBorrowAmts = _data.stableBorrowAmts;
data.supplyAmts = _data.supplyAmts;
data.supplyTokens = _data.supplyTokens;
data.targetDsa = _data.targetDsa;
data.variableBorrowAmts = _data.variableBorrowAmts;
data.targetDsa = targetDsa;
data.supplyTokens = supplyTokens;
data.borrowTokens = borrowTokens;
data.variableBorrowAmts = variableBorrowAmts;
data.stableBorrowAmts = stableBorrowAmts;
data.supplyAmts = supplyAmts;
for (uint i = 0; i < data.supplyTokens.length; 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 settle(address[] tokens, uint[] amts);
}

View File

@ -95,4 +95,14 @@ interface AavePriceOracle {
interface ChainLinkInterface {
function latestAnswer() external view returns (int256);
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++) {
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();
}
emit settle(_tokens, _amts);
}
// TODO: emit event
}
contract MigrateResolver is LiquidityResolver {

View File

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