Finish senders

This commit is contained in:
Mubaris NK 2021-04-11 22:23:42 +05:30
parent 584bd9a98f
commit bd3ebe6ea1
No known key found for this signature in database
GPG Key ID: 9AC09AD0F8D68561
4 changed files with 28 additions and 8 deletions

View File

@ -5,13 +5,18 @@ contract Events {
event LogDeposit( event LogDeposit(
address owner, address owner,
address[] tokens, address[] tokens,
uint[] amts uint256[] amts
); );
event LogWithdraw( event LogWithdraw(
address owner, address owner,
address[] tokens, address[] tokens,
uint[] amts uint256[] amts
);
event LogSettle(
address[] tokens,
uint256[] amts
); );
event LogAaveV2Migrate( event LogAaveV2Migrate(
@ -19,9 +24,9 @@ contract Events {
address indexed targetDsa, address indexed targetDsa,
address[] supplyTokens, address[] supplyTokens,
address[] borrowTokens, address[] borrowTokens,
uint[] supplyAmts, uint256[] supplyAmts,
uint[] variableBorrowAmts, uint256[] variableBorrowAmts,
uint[] stableBorrowAmts uint256[] stableBorrowAmts
); );
event LogUpdateVariables( event LogUpdateVariables(

View File

@ -107,4 +107,8 @@ interface IndexInterface {
interface FlashloanInterface { interface FlashloanInterface {
function initiateFlashLoan(bytes memory data, uint ethAmt) external; function initiateFlashLoan(bytes memory data, uint ethAmt) external;
}
interface RootChainManagerInterface {
function depositFor(address user, address token, bytes calldata depositData) external;
} }

View File

@ -173,12 +173,16 @@ contract LiquidityResolver is Helpers, Events {
} }
} }
for (uint i = 0; i < _tokens.length; i++) { for (uint i = 0; i < _tokens.length; i++) {
address _token = _tokens[i] == ethAddr ? wethAddr : _tokens[i];
aave.withdraw(_token, _amts[i], address(this)); aave.withdraw(_token, _amts[i], address(this));
// TODO: transfer to polygon's receiver address "polygonReceiver" // TODO: Verify this
IERC20(_token).safeApprove(erc20Predicate, _amts[i]);
rootChainManager.depositFor(polygonReceiver, _token, abi.encode(_amts[i]));
isPositionSafe(); isPositionSafe();
} }
emit LogSettle(_tokens, _amts);
} }
// TODO: emit event
} }
contract MigrateResolver is LiquidityResolver { contract MigrateResolver is LiquidityResolver {

View File

@ -6,7 +6,8 @@ import {
AaveOracleInterface, AaveOracleInterface,
StateSenderInterface, StateSenderInterface,
IndexInterface, IndexInterface,
FlashloanInterface FlashloanInterface,
RootChainManagerInterface
} from "./interfaces.sol"; } from "./interfaces.sol";
contract Variables { contract Variables {
@ -35,6 +36,7 @@ contract Variables {
address constant internal polygonReceiver = address(0); // TODO: Replace this address constant internal polygonReceiver = address(0); // TODO: Replace this
FlashloanInterface constant internal flashloanContract = FlashloanInterface(address(0)); // TODO: Replace this FlashloanInterface constant internal flashloanContract = FlashloanInterface(address(0)); // TODO: Replace this
address constant internal erc20Predicate = 0x40ec5B33f54e0E8A33A975908C5BA1c14e5BbbDf;
// This will be used to have debt/collateral ratio always 20% less than liquidation // This will be used to have debt/collateral ratio always 20% less than liquidation
// TODO: Is this number correct for it? // TODO: Is this number correct for it?
@ -69,4 +71,9 @@ contract Variables {
// InstaIndex Address. // InstaIndex Address.
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723); IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
/**
* Polygon deposit bridge
*/
RootChainManagerInterface public constant rootChainManager = RootChainManagerInterface(0xA0c68C638235ee32657e8f720a23ceC1bFc77C77);
} }