-
Notifications
You must be signed in to change notification settings - Fork 12
/
Stream.sol
53 lines (53 loc) · 2.95 KB
/
Stream.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
45
46
47
48
49
50
51
52
53
/////////////////////////////////////////////////////////////////////////////////////
//
// SPDX-License-Identifier: MIT
//
// ███ ███ ██████ ███ ██ ███████ ██ ██ ██████ ██ ██████ ███████
// ████ ████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
// ██ ████ ██ ██ ██ ██ ██ ██ █████ ████ ██████ ██ ██████ █████
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
// ██ ██ ██████ ██ ████ ███████ ██ ██ ██ ██ ███████
//
// ███████ ████████ ██████ ███████ █████ ███ ███
// ██ ██ ██ ██ ██ ██ ██ ████ ████
// ███████ ██ ██████ █████ ███████ ██ ████ ██
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
// ███████ ██ ██ ██ ███████ ██ ██ ██ ██
//
// https://moneypipe.xyz
//
/////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
contract Stream is Initializable {
Member[] private _members;
struct Member {
address account;
uint32 value;
uint32 total;
}
function initialize(Member[] calldata m) initializer public {
for(uint i=0; i<m.length; i++) {
_members.push(m[i]);
}
}
receive () external payable {
require(_members.length > 0, "1");
for(uint i=0; i<_members.length; i++) {
Member memory member = _members[i];
_transfer(member.account, msg.value * member.value / member.total);
}
}
function members() external view returns (Member[] memory) {
return _members;
}
// adopted from https://github.com/lexDAO/Kali/blob/main/contracts/libraries/SafeTransferLib.sol
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
bool callStatus;
assembly {
callStatus := call(gas(), to, amount, 0, 0, 0, 0)
}
if (!callStatus) revert TransferFailed();
}
}