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

OVER token #105

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
69 changes: 69 additions & 0 deletions contracts/over_token/ExchangeThalesForOver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

// internal
import "../utils/proxy/ProxyOwned.sol";
import "../utils/proxy/ProxyPausable.sol";
import "../utils/proxy/ProxyReentrancyGuard.sol";

error AmountIsZero();

contract ExchangeThalesForOver is Initializable, ProxyOwned, ProxyPausable, ProxyReentrancyGuard {
using SafeERC20 for IERC20;
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
IERC20 public Thales;
IERC20 public Over;

function initialize(address _owner, address _thalesAddress, address _overAddress) external initializer {
setOwner(_owner);
initNonReentrant();

Thales = IERC20(_thalesAddress);
Over = IERC20(_overAddress);
}

/// @notice Exchanges Thales tokens for Over tokens at a 1:1 ratio
/// @param _amount The amount of Thales tokens to exchange for Over tokens
/// @dev Burns the Thales tokens and transfers an equal amount of Over tokens to the sender
function exchangeThalesForOver(uint _amount) external nonReentrant notPaused {
if (_amount == 0) revert AmountIsZero();
// burn Thales
Thales.safeTransferFrom(msg.sender, BURN_ADDRESS, _amount);
// send Over
Over.safeTransfer(msg.sender, _amount);

emit ThalesToOverExchanged(msg.sender, _amount);
}

/// @notice Allows the owner to withdraw any ERC20 tokens from the contract
/// @param _collateral The address of the ERC20 token to withdraw
/// @param _amount The amount of tokens to withdraw
function withdrawCollateral(address _collateral, uint _amount) external onlyOwner {
IERC20(_collateral).safeTransfer(msg.sender, _amount);
emit WithdrawnCollateral(_collateral, _amount);
}

/// @notice Updates the Thales token contract address
/// @param _thalesAddress The new Thales token contract address
function setThales(address _thalesAddress) external onlyOwner {
Thales = IERC20(_thalesAddress);
emit SetThales(_thalesAddress);
}

/// @notice Updates the Over token contract address
/// @param _overAddress The new Over token contract address
function setOver(address _overAddress) external onlyOwner {
Over = IERC20(_overAddress);
emit SetOver(_overAddress);
}

event ThalesToOverExchanged(address indexed user, uint amount);
event SetThales(address indexed thalesAddress);
event SetOver(address indexed overAddress);
event WithdrawnCollateral(address indexed collateral, uint amount);
}
29 changes: 29 additions & 0 deletions contracts/over_token/Over.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract Over is ERC20, Ownable {
string private __name = "OVERtime Token";
string private __symbol = "OVER";
uint8 private constant __decimals = 18;
uint private constant INITIAL_TOTAL_SUPPLY = 69420000;

function name() public view override returns (string memory) {
return __name;
}

function symbol() public view override returns (string memory) {
return __symbol;
}

function decimals() public pure override returns (uint8) {
return __decimals;
}

constructor(address _treasury) ERC20(__name, __symbol) Ownable(_treasury) {
_mint(_treasury, INITIAL_TOTAL_SUPPLY * 1e18);
}
}
35 changes: 35 additions & 0 deletions contracts/utils/token/ThalesToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract ThalesToken is ERC20, Ownable {
string private __name = "Thales";
string private __symbol = "THALES";
uint8 private constant __decimals = 18;
uint private constant INITIAL_TOTAL_SUPPLY = 100000000;

/// @notice Returns the name of the token
/// @return The name of the token as a string
function name() public view override returns (string memory) {
return __name;
}

/// @notice Returns the symbol of the token
/// @return The symbol of the token as a string
function symbol() public view override returns (string memory) {
return __symbol;
}

/// @notice Returns the number of decimals used by the token
/// @return The number of decimals (18)
function decimals() public pure override returns (uint8) {
return __decimals;
}

constructor(address _treasury) ERC20(__name, __symbol) Ownable(_treasury) {
_mint(_treasury, INITIAL_TOTAL_SUPPLY * 1e18);
}
}
Loading