Skip to content

Commit

Permalink
refactor: rm interface inheritances
Browse files Browse the repository at this point in the history
  • Loading branch information
pegahcarter committed Feb 16, 2024
1 parent f9655a4 commit 68bbbdb
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 144 deletions.
34 changes: 17 additions & 17 deletions src/contracts/core/FraxswapERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ pragma solidity ^0.8.0;
// ========================== FraxswapERC20 ===========================
// ====================================================================

import { IUniswapV2ERC20 } from "@uniswap/v2-core/contracts/interfaces/IUniswapV2ERC20.sol";

/// @notice Fraxswap ERC-20
/// @author Frax Finance (https://github.com/FraxFinance)
contract FraxswapERC20 is IUniswapV2ERC20 {
string public constant override name = "Fraxswap V2";
string public constant override symbol = "FS-V2";
uint8 public constant override decimals = 18;
uint256 public override totalSupply;
mapping(address => uint256) public override balanceOf;
mapping(address => mapping(address => uint256)) public override allowance;
contract FraxswapERC20 {
string public constant name = "Fraxswap V2";
string public constant symbol = "FS-V2";
uint8 public constant decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

bytes32 public override DOMAIN_SEPARATOR;
bytes32 public immutable DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant override PERMIT_TYPEHASH =
0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint256) public override nonces;
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint256) public nonces;

event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);

constructor() {
uint256 chainId = block.chainid;
Expand Down Expand Up @@ -66,17 +66,17 @@ contract FraxswapERC20 is IUniswapV2ERC20 {
emit Transfer(from, to, value);
}

function approve(address spender, uint256 value) external override returns (bool) {
function approve(address spender, uint256 value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}

function transfer(address to, uint256 value) external override returns (bool) {
function transfer(address to, uint256 value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}

function transferFrom(address from, address to, uint256 value) external override returns (bool) {
function transferFrom(address from, address to, uint256 value) external returns (bool) {
if (allowance[from][msg.sender] != type(uint256).max) {
allowance[from][msg.sender] = allowance[from][msg.sender] - value;
}
Expand All @@ -92,7 +92,7 @@ contract FraxswapERC20 is IUniswapV2ERC20 {
uint8 v,
bytes32 r,
bytes32 s
) external override {
) external {
require(deadline >= block.timestamp); // EXPIRED
bytes32 digest = keccak256(
abi.encodePacked(
Expand Down
29 changes: 15 additions & 14 deletions src/contracts/core/FraxswapFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ pragma solidity ^0.8.0;
// ========================== FraxswapFactory =========================
// ====================================================================

import { IFraxswapFactory } from "./interfaces/IFraxswapFactory.sol";
import { FraxswapPair } from "./FraxswapPair.sol";

/// @notice TWAMM LP Pair Factory
/// @author Frax Finance: https://github.com/FraxFinance
contract FraxswapFactory is IFraxswapFactory {
address public override feeTo;
address public override feeToSetter;
bool public override globalPause;
/// @author Frax Finance (https://github.com/FraxFinance)
contract FraxswapFactory {
address public feeTo;
address public feeToSetter;
bool public globalPause;

mapping(address => mapping(address => address)) public override getPair;
address[] public override allPairs;
mapping(address => mapping(address => address)) public getPair;
address[] public allPairs;

event PairCreated(address indexed token0, address indexed token1, address pair, uint256);

error IdenticalAddress();
error ZeroAddress();
Expand All @@ -39,15 +40,15 @@ contract FraxswapFactory is IFraxswapFactory {
_;
}

function allPairsLength() external view override returns (uint256) {
function allPairsLength() external view returns (uint256) {
return allPairs.length;
}

function createPair(address tokenA, address tokenB) external override returns (address pair) {
function createPair(address tokenA, address tokenB) external returns (address pair) {
return createPair(tokenA, tokenB, 30); // default fee 0.30%
}

function createPair(address tokenA, address tokenB, uint256 fee) public override returns (address pair) {
function createPair(address tokenA, address tokenB, uint256 fee) public returns (address pair) {
if (tokenA == tokenB) revert IdenticalAddress(); // IDENTICAL_ADDRESSES
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
if (token0 == address(0)) revert ZeroAddress(); // ZERO_ADDRESS
Expand All @@ -64,15 +65,15 @@ contract FraxswapFactory is IFraxswapFactory {
emit PairCreated(token0, token1, pair, allPairs.length);
}

function setFeeTo(address _feeTo) external override onlyFTS {
function setFeeTo(address _feeTo) external onlyFTS {
feeTo = _feeTo;
}

function setFeeToSetter(address _feeToSetter) external override onlyFTS {
function setFeeToSetter(address _feeToSetter) external onlyFTS {
feeToSetter = _feeToSetter;
}

function toggleGlobalPause() external override onlyFTS {
function toggleGlobalPause() external onlyFTS {
require(!globalPause);
globalPause = true;
}
Expand Down
Loading

0 comments on commit 68bbbdb

Please sign in to comment.