Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"new.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
interface ILendingPool {
function setUserUseReserveAsCollateral(address reserve, bool useAsCollateral) external;
}
interface IAToken {
function redeem(uint256 amount) external;
function balanceOf(address account) external view returns (uint256);
}
interface IERC20 {
function transfer(address recipient, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
interface IDSProxy {
function owner() external view returns (address);
}
contract UpdateAndRedeem {
function execute() external {
address dai = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
ILendingPool lendingPool = ILendingPool(0x398eC7346DcD622eDc5ae82352F02bE94C62d119);
lendingPool.setUserUseReserveAsCollateral(dai, true); // Poke/update user state
IAToken aDAI = IAToken(0xfC1E690f61EFd961294b3e1Ce3313fBD8aa4f85d);
uint256 balance = aDAI.balanceOf(address(this));
if (balance > 0) {
aDAI.redeem(uint256(-1)); // Full redeem (max uint256)
}
IERC20 underlying = IERC20(dai);
uint256 underlyingBalance = underlying.balanceOf(address(this));
if (underlyingBalance > 0) {
underlying.transfer(IDSProxy(address(this)).owner(), underlyingBalance); // To your wallet
}
lendingPool.setUserUseReserveAsCollateral(dai, false); // Reset to original
}
}"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-10-30 14:08:33
Comments
Log in to comment.
No comments yet.