Skip to content

Commit

Permalink
feat: poc for contract
Browse files Browse the repository at this point in the history
  • Loading branch information
sogipec committed Apr 3, 2024
1 parent f3fb359 commit 1d33954
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions contracts/coupons/AaveTokenWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ contract AaveTokenWrapper is UUPSHelper, ERC20Upgradeable {

mapping(address => uint256) public isMasterClaimer;
mapping(address => address) public delegateReceiver;
mapping(address => uint256) public permissionlessClaim;

error NotGovernor();
error ZeroAddress();
error InvalidClaim();

// =================================== EVENTS ==================================

Expand Down Expand Up @@ -62,19 +67,17 @@ contract AaveTokenWrapper is UUPSHelper, ERC20Upgradeable {
IERC20(token).safeTransferFrom(from, address(this), amount);
_mint(from, amount); // These are then transfered to the distributor
}
if (to == feeManager) {
IERC20(token).safeTransferFrom(from, feeManager, amount);
_mint(from, amount); // These are then transferred to the fee manager
}
}

function _afterTokenTransfer(address from, address to, uint256 amount) internal override {
if (from == address(distributor)) {
if (tx.origin == to || isMasterClaimer[msg.sender] == 1) {
if (tx.origin == to || permissionlessClaim[to] == 1 || isMasterClaimer[tx.origin] == 1) {

Check warning on line 74 in contracts/coupons/AaveTokenWrapper.sol

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin

Check warning on line 74 in contracts/coupons/AaveTokenWrapper.sol

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin
_handleClaim(to, amount);
} else if (allowance(to, tx.origin) > amount) {

Check warning on line 76 in contracts/coupons/AaveTokenWrapper.sol

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin
_spendAllowance(to, tx.origin, amount);

Check warning on line 77 in contracts/coupons/AaveTokenWrapper.sol

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin
_handleClaim(to, amount);
} else {
revert InvalidClaim();
}
}
}
Expand All @@ -100,6 +103,11 @@ contract AaveTokenWrapper is UUPSHelper, ERC20Upgradeable {
isMasterClaimer[claimer] = claimStatus;
}

function togglePermissionlessClaim() external {
uint256 permission = 1 - permissionlessClaim[msg.sender];
permissionlessClaim[msg.sender] = permission;
}

function updateDelegateReceiver(address receiver) external {
delegateReceiver[msg.sender] = receiver;
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/coupons/RadiantCoupon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ contract RadiantCoupon is UUPSHelper, ERC20Upgradeable {
IERC20(RADIANT).safeTransferFrom(from, address(this), amount);
_mint(from, amount); // These are then transfered to the distributor
}
// TODO: check allowance issue
if (to == address(FEE_MANAGER)) {
IERC20(RADIANT).safeTransferFrom(from, address(FEE_MANAGER), amount);
_mint(from, amount); // These are then transferred to the fee manager
Expand All @@ -50,8 +51,7 @@ contract RadiantCoupon is UUPSHelper, ERC20Upgradeable {
function _afterTokenTransfer(address from, address to, uint256 amount) internal override {
if (to == address(FEE_MANAGER)) {
_burn(to, amount); // To avoid having any token aside from on the distributor
}
if (from == address(DISTRIBUTOR)) {
} else if (from == address(DISTRIBUTOR)) {
_burn(to, amount);
// HERE CALL THE VESTING CONTRACT TO STAKE ON BEHALF OF THE USER
}
Expand Down

0 comments on commit 1d33954

Please sign in to comment.