Last active
March 11, 2021 10:49
-
-
Save buendiadas/32a6c3f4b237896fd1e69fc3a510b5c0 to your computer and use it in GitHub Desktop.
LendingAutomation.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.6.12; | |
interface IComptroller { | |
function callOnExtension( | |
address, | |
uint256, | |
bytes calldata | |
) external; | |
} | |
interface IIntegrationManager { | |
function addAuthUserForFund(address _comptrollerProxy, address _who) external; | |
} | |
contract LendingAutomation { | |
address public constant integrationManager = 0x5B5100bFFFcd40A0f49cc7a01049Ab71699C3FB1; | |
address public constant compoundAdapter = 0x0551C5f061C54f231Ad45ED0C768E7024a2e96bE; | |
address public constant comptrollerProxyContract = 0x2F587dcc24b7D1f0F23BC0d20730D48713aC23d6; | |
bytes4 public constant lendSelector = bytes4(keccak256("lend(address,bytes,bytes)")); | |
constructor() public {} | |
function compoundLend( | |
address _cTokenAddress, | |
uint256 _outgoingAssetAmount, | |
uint256 _minIncomingAssetAmount | |
) public { | |
uint256 actionId = 0; | |
bytes memory compoundLendArgs = abi.encode( | |
_cTokenAddress, | |
_outgoingAssetAmount, | |
_minIncomingAssetAmount | |
); | |
bytes memory callArgs = abi.encode(compoundAdapter, lendSelector, compoundLendArgs); | |
IComptroller(comptrollerProxyContract).callOnExtension( | |
integrationManager, | |
actionId, | |
callArgs | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment