-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPoolController.sol
40 lines (31 loc) · 982 Bytes
/
PoolController.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
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.20;
interface ILendingPlatform {
function getInvesters(address lender) external view returns (bool);
}
contract PoolController {
event Received(address indexed lender, uint256 indexed amount);
mapping(address => uint256) balances;
address owner;
ILendingPlatform lp;
constructor(address _owner, ILendingPlatform _lp) {
owner = _owner;
lp = _lp;
}
modifier onlyLP() {
require(msg.sender == address(lp));
_;
}
modifier onlyInvester() {
require(lp.getInvesters(msg.sender) == true);
_;
}
function sendLoan(address payable borrower, address payable lender, uint256 amount) external onlyLP {
balances[lender] -= amount;
borrower.transfer(amount);
}
receive() external payable onlyInvester {
balances[msg.sender] = msg.value;
emit Received(msg.sender, msg.value);
}
}