-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRedeemHelper.sol
More file actions
81 lines (62 loc) · 2.36 KB
/
RedeemHelper.sol
File metadata and controls
81 lines (62 loc) · 2.36 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.7.5;
interface IOwnable {
function policy() external view returns (address);
function renounceManagement() external;
function pushManagement( address newOwner_ ) external;
function pullManagement() external;
}
contract Ownable is IOwnable {
address internal _owner;
address internal _newOwner;
event OwnershipPushed(address indexed previousOwner, address indexed newOwner);
event OwnershipPulled(address indexed previousOwner, address indexed newOwner);
constructor () {
_owner = msg.sender;
emit OwnershipPushed( address(0), _owner );
}
function policy() public view override returns (address) {
return _owner;
}
modifier onlyPolicy() {
require( _owner == msg.sender, "Ownable: caller is not the owner" );
_;
}
function renounceManagement() public virtual override onlyPolicy() {
emit OwnershipPushed( _owner, address(0) );
_owner = address(0);
}
function pushManagement( address newOwner_ ) public virtual override onlyPolicy() {
require( newOwner_ != address(0), "Ownable: new owner is the zero address");
emit OwnershipPushed( _owner, newOwner_ );
_newOwner = newOwner_;
}
function pullManagement() public virtual override {
require( msg.sender == _newOwner, "Ownable: must be new owner to pull");
emit OwnershipPulled( _owner, _newOwner );
_owner = _newOwner;
}
}
interface IBond {
function redeem( address _recipient, bool _stake ) external returns ( uint );
function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ );
}
contract RedeemHelper is Ownable {
address[] public bonds;
function redeemAll( address _recipient, bool _stake ) external {
for( uint i = 0; i < bonds.length; i++ ) {
if ( bonds[i] != address(0) ) {
if ( IBond( bonds[i] ).pendingPayoutFor( _recipient ) > 0 ) {
IBond( bonds[i] ).redeem( _recipient, _stake );
}
}
}
}
function addBondContract( address _bond ) external onlyPolicy() {
require( _bond != address(0) );
bonds.push( _bond );
}
function removeBondContract( uint _index ) external onlyPolicy() {
bonds[ _index ] = address(0);
}
}