Skip to content

Commit

Permalink
feat: add events
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChin committed Nov 15, 2024
1 parent 1187b2d commit c66534f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions script/Deploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {ERC20} from "solmate/tokens/ERC20.sol";
import {IPool, IRewardsController} from "yield-daddy/aave-v3/AaveV3ERC4626.sol";

contract Deploy is Script {
error UnsupportedChain();

struct VaultDeploymentParams {
address token;
address aToken;
Expand All @@ -24,6 +22,8 @@ contract Deploy is Script {
VaultDeploymentParams[] vaults;
}

error UnsupportedChain();

function getDeploymentParams(
uint256 chainId
) internal pure returns (DeploymentParams memory params) {
Expand Down
5 changes: 5 additions & 0 deletions src/contracts/Grateful.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ contract Grateful is IGrateful, Ownable2Step {
) external onlyOwner {
tokensWhitelisted[_token] = true;
IERC20(_token).safeIncreaseAllowance(address(aavePool), type(uint256).max);
emit TokenAdded(_token);
}

/// @inheritdoc IGrateful
function addVault(address _token, address _vault) external onlyOwner onlyWhenTokenWhitelisted(_token) {
vaults[_token] = AaveV3Vault(_vault);
IERC20(_token).safeIncreaseAllowance(address(_vault), type(uint256).max);
emit VaultAdded(_token, _vault);
}

/// @inheritdoc IGrateful
Expand Down Expand Up @@ -282,18 +284,21 @@ contract Grateful is IGrateful, Ownable2Step {
uint256 _newFee
) external onlyOwner {
fee = _newFee;
emit FeeUpdated(_newFee);
}

/// @inheritdoc IGrateful
function setCustomFee(uint256 _newFee, address _merchant) external onlyOwner {
customFees[_merchant] = CustomFee({isSet: true, fee: _newFee});
emit CustomFeeUpdated(_merchant, _newFee);
}

/// @inheritdoc IGrateful
function unsetCustomFee(
address _merchant
) external onlyOwner {
delete customFees[_merchant];
emit CustomFeeUnset(_merchant);
}

/*//////////////////////////////////////////////////////////////
Expand Down
32 changes: 32 additions & 0 deletions src/interfaces/IGrateful.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,38 @@ interface IGrateful {
*/
event Withdraw(address indexed user, address indexed token, uint256 amount);

/**
* @notice Emitted when the default fee is updated.
* @param newFee The new fee in basis points.
*/
event FeeUpdated(uint256 newFee);

/**
* @notice Emitted when a custom fee is set for a merchant.
* @param merchant Address of the merchant.
* @param newFee The new custom fee in basis points.
*/
event CustomFeeUpdated(address indexed merchant, uint256 newFee);

/**
* @notice Emitted when a custom fee is unset for a merchant.
* @param merchant Address of the merchant.
*/
event CustomFeeUnset(address indexed merchant);

/**
* @notice Emitted when a new token is added to the whitelist.
* @param token Address of the token added.
*/
event TokenAdded(address indexed token);

/**
* @notice Emitted when a new vault is added for a token.
* @param token Address of the token.
* @param vault Address of the vault added.
*/
event VaultAdded(address indexed token, address indexed vault);

/*///////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
Expand Down

0 comments on commit c66534f

Please sign in to comment.