This repository has been archived by the owner on Aug 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple Forwarder contract for proxying payments to Distributor co…
…ntracts
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/ap-contracts/contracts/Tokenization/Forwarder.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
pragma solidity ^0.5.2; | ||
|
||
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; | ||
import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
|
||
|
||
contract Forwarder is Ownable { | ||
|
||
mapping(address => address) public beneficiaries; | ||
|
||
|
||
function setBeneficiary(address token, address beneficiary) external onlyOwner { | ||
require( | ||
beneficiaries[token] == address(0), | ||
"Forwarder.setBeneficiary: Beneficary already set for token." | ||
); | ||
|
||
beneficiaries[token] = beneficiary; | ||
} | ||
|
||
function pushAccruedToBeneficiary(address token) external returns(bool) { | ||
require( | ||
beneficiaries[token] != address(0), | ||
"Forwarder.pushAccruedFundsToBeneficiary: No beneficiary set for token." | ||
); | ||
|
||
uint256 accruedFunds = IERC20(token).balanceOf(beneficiaries[token]); | ||
|
||
return IERC20(token).transfer(beneficiaries[token], accruedFunds); | ||
} | ||
} | ||
|