// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)pragmasolidity ^0.8.20;/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
function_contextSuffixLength() internalviewvirtualreturns (uint256) {
return0;
}
}
Contract Source Code
File 2 of 3: ElixirDeposit.sol
// SPDX-License-Identifier: BUSL-1.1pragmasolidity 0.8.20;import {Ownable} from"openzeppelin/access/Ownable.sol";
/// @title Elixir deposit contract/// @author The Elixir Team/// @notice This contract is used to deposit fundscontractElixirDepositisOwnable{
/*//////////////////////////////////////////////////////////////
VARIABLES
//////////////////////////////////////////////////////////////*//// @notice The address of the Elixir multisig wallet with control of fundsaddresspublic controller;
/// @notice Mapping of address to deposited amountmapping(address user =>uint256 amount) public deposits;
/// @notice The pause status of deposits. True if deposits are paused.boolpublic depositsPaused;
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*//// @notice Emitted when a deposit is made./// @param caller The caller of the deposit function, for which tokens are taken from./// @param amount The token amount deposited.eventDeposit(addressindexed caller, uint256indexed amount);
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*//// @notice Emitted when deposits are paused.errorDepositsPaused();
/// @notice Emitted when deposit fails.errorDepositFailed();
/*//////////////////////////////////////////////////////////////
MODIFIERS
//////////////////////////////////////////////////////////////*//// @notice Reverts when deposits are paused.modifierwhenDepositNotPaused() {
if (depositsPaused) revert DepositsPaused();
_;
}
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*//// @notice Constructor for the ElixirDeposit contract/// @param _owner The address of the owner of the contractconstructor(address _owner) Ownable(_owner) {}
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*//// @notice Deposit funds into the contractfunctiondeposit() externalpayablewhenDepositNotPaused{
deposits[msg.sender] +=msg.value;
(bool sent,) = controller.call{value: msg.value}("");
if (!sent) revert DepositFailed();
emit Deposit(msg.sender, msg.value);
}
/// @notice Pause deposits, callable by the owner/// @param pauseDeposits True if deposits are to be paused, false if they are to be unpausedfunctionpause(bool pauseDeposits) externalonlyOwner{
depositsPaused = pauseDeposits;
}
/// @notice Set controller address, callable by the owner/// @param _controller controller address to be setfunctionsetController(address _controller) externalonlyOwner{
controller = _controller;
}
}
Contract Source Code
File 3 of 3: Ownable.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)pragmasolidity ^0.8.20;import {Context} from"../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/abstractcontractOwnableisContext{
addressprivate _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/errorOwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/errorOwnableInvalidOwner(address owner);
eventOwnershipTransferred(addressindexed previousOwner, addressindexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/constructor(address initialOwner) {
if (initialOwner ==address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/modifieronlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/function_checkOwner() internalviewvirtual{
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
if (newOwner ==address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/function_transferOwnership(address newOwner) internalvirtual{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}