Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
Add simple Forwarder contract for proxying payments to Distributor co…
Browse files Browse the repository at this point in the history
…ntracts
  • Loading branch information
jo-es committed Dec 11, 2019
1 parent d4c32aa commit 7b8ab85
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/ap-contracts/contracts/Tokenization/Forwarder.sol
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);
}
}

0 comments on commit 7b8ab85

Please sign in to comment.