-
Notifications
You must be signed in to change notification settings - Fork 0
/
Basicbnkmode.sol
44 lines (35 loc) · 1.41 KB
/
Basicbnkmode.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pragma solidity 0.8.4;
interface cETH {
function mint() external payable;
function reedeem(uint reedemTokens) external returns (uint);
function exchangeRateStored() external view returns (uint);
function balanceOf(address owner) external view returns (uint256 balance);
}
contract bankAccount {
uint totalContractBalance = 0;
address COMPOUND_CETH_ADDRESS = 0x859e9d8a4edadfEDb5A2fF311243af80F85A91b8;
cETH ceth = cETH(COMPOUND_CETH_ADDRESS);
function getContractBalance() public view returns(uint) {
return totalContractBalance;
}
mapping(address => uint ) balances;
mapping(address => uint ) depositTimestamps;
function addBalance() public payable {
balances[msg.sender] = msg.value;
totalContractBalance = totalContractBalance + msg.value;
depositTimestamps[msg.sender] = block.timestamp;
}
function getContractBalance(address userAddress) public view returns(uint256) {
return ceth.balanceOf(userAddress);
}
function withdraw() public payable {
address payable withdrawTo = payable(msg.sender);
uint amountToTransfer = getBalance(msg.sender);
withrawTo.transfer(amountToTransfer);
totalContractBalance = totalContractBalance - amountToTransfer;
balances[msg.sender] = 0;
}
function addMoneyToContract() public payable {
totalContractBalance += msg.value;
}
}