Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Giver contract #403

Merged
merged 9 commits into from
May 16, 2022
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions contracts/utils/Giver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.6;

import "@yield-protocol/vault-interfaces/src/ICauldron.sol";
import "@yield-protocol/vault-interfaces/src/DataTypes.sol";
import "@yield-protocol/utils-v2/contracts/access/AccessControl.sol";

/// @title A contract that allows owner of a vault to give the vault
contract Giver is AccessControl {
ICauldron public immutable cauldron;
iamsahu marked this conversation as resolved.
Show resolved Hide resolved
mapping(bytes6 => bool) public bannedIlks;

/// @notice Event emitted after an ilk is banned
/// @param ilkId Ilkid to be banned
event IlkBanned(bytes6 ilkId);

constructor(ICauldron cauldron_) {
cauldron = cauldron_;
}

/// @notice Function to ban
/// @param ilkId the ilkId to be banned
/// @param set bool value to ban/unban an ilk
function banIlk(bytes6 ilkId, bool set) external auth {
bannedIlks[ilkId] = set;
emit IlkBanned(ilkId);
}

/// @notice A give function which allows the owner of vault to give the vault to another address
/// @param vaultId The vaultId of the vault to be given
/// @param receiver The address to which the vault is being given to
/// @return vault The vault which has been given
function give(bytes12 vaultId, address receiver) external returns (DataTypes.Vault memory vault) {
vault = cauldron.vaults(vaultId);
require(vault.owner == msg.sender, "msg.sender is not the owner");
require(!bannedIlks[vault.ilkId], "ilk is banned");
vault = cauldron.give(vaultId, receiver);
}
}