Skip to content

Commit

Permalink
fix: radiant PoC
Browse files Browse the repository at this point in the history
  • Loading branch information
Picodes committed Mar 26, 2024
1 parent b0c8f47 commit e46326e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions contracts/coupons/RadiantCoupon.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.17;

import { ERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

import "../utils/UUPSHelper.sol";

Check warning on line 9 in contracts/coupons/RadiantCoupon.sol

View workflow job for this annotation

GitHub Actions / lint

global import of path ../utils/UUPSHelper.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

contract RadiantCoupon is UUPSHelper, ERC20Upgradeable {
using SafeERC20 for IERC20;

/// @notice `Core` contract handling access control
ICore public core;

function initialize() public initializer {
__ERC20_init("RadiantCoupon", "cpRDNT");
__UUPSUpgradeable_init();
}

function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
// Needs an approval before hand, this is how mints are done
if (to == address(DISTRIBUTOR)) {
IERC20(RADIANT).safeTransferFrom(from, address(this), amount);
_mint(from, amount); // These are then transfered to the distributor
}
if (to == address(FEE_MANAGER)) {
IERC20(RADIANT).safeTransferFrom(from, address(FEE_MANAGER), amount);
_mint(from, amount); // These are then transferred to the fee manager
}
}

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)) {
_burn(to, amount);
// HERE CALL THE VESTING CONTRACT TO STAKE ON BEHALF OF THE USER
}
}

/// @inheritdoc UUPSUpgradeable
function _authorizeUpgrade(address) internal view override onlyGovernorUpgrader(core) {}
}

0 comments on commit e46326e

Please sign in to comment.