Skip to content

Commit

Permalink
gas optimizations via constant declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
0xBrian committed May 3, 2021
1 parent d852256 commit 2dacdc3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 35 deletions.
3 changes: 1 addition & 2 deletions contracts/DAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract DAO {


uint256 public proposalCount;
uint256 public coolOffPeriod;
uint256 public constant coolOffPeriod = 1;

address public VETHER;
address public VADER;
Expand Down Expand Up @@ -90,7 +90,6 @@ contract DAO {
POOLS = _pools;
FACTORY = _factory;
UTILS = _utils;
coolOffPeriod = 1;
}
}

Expand Down
13 changes: 4 additions & 9 deletions contracts/USDV.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import "./interfaces/iROUTER.sol";

contract USDV is iERC20 {
// ERC-20 Parameters
string public override name;
string public override symbol;
uint256 public override decimals;
string public constant override name = "VADER STABLE DOLLAR";
string public constant override symbol = "USDV";
uint256 public constant override decimals = 18;
uint256 public override totalSupply;

// ERC-20 Mappings
Expand Down Expand Up @@ -45,12 +45,7 @@ contract USDV is iERC20 {

//=====================================CREATION=========================================//

constructor() {
name = "VADER STABLE DOLLAR";
symbol = "USDV";
decimals = 18;
totalSupply = 0;
}
constructor() {}

function init(address _vader) external {
if(VADER == address(0)){
Expand Down
6 changes: 3 additions & 3 deletions contracts/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import "./interfaces/iSYNTH.sol";
import "hardhat/console.sol";

contract Utils {
uint256 private one = 10**18;
uint256 private _10k = 10000;
uint256 private _year = 31536000; // One Year (in seconds)
uint256 private constant one = 10**18;
uint256 private constant _10k = 10000;
uint256 private constant _year = 31536000; // One Year (in seconds)

address public VADER;

Expand Down
22 changes: 7 additions & 15 deletions contracts/Vader.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import "./interfaces/iROUTER.sol";

contract Vader is iERC20 {
// ERC-20 Parameters
string public override name;
string public override symbol;
uint256 public override decimals;
string public constant override name = "VADER PROTOCOL TOKEN";
string public constant override symbol = "VADER";
uint256 public constant override decimals = 18;
uint256 public override totalSupply;

// ERC-20 Mappings
Expand All @@ -23,10 +23,10 @@ contract Vader is iERC20 {

bool public emitting;
bool public minting;
uint256 public conversionFactor;
uint256 public baseline;
uint256 public constant conversionFactor = 1000;
uint256 public constant baseline = 10**9 * 10**decimals; //1bn;
uint256 public constant maxSupply = 2 * baseline; //2bn
uint256 public emissionCurve;
uint256 public maxSupply;
uint256 public secondsPerEra;
uint256 public currentEra;
uint256 public nextEraTime;
Expand All @@ -35,7 +35,7 @@ contract Vader is iERC20 {
address public DAO;
address public DEPLOYER;

address public burnAddress;
address public constant burnAddress = 0x0111011001100001011011000111010101100101;

event NewEra(uint256 currentEra, uint256 nextEraTime, uint256 emission);

Expand All @@ -57,18 +57,10 @@ contract Vader is iERC20 {
//=====================================CREATION=========================================//

constructor() {
name = "VADER PROTOCOL TOKEN";
symbol = "VADER";
decimals = 18;
baseline = 10**9 * 10**decimals; //1bn;
totalSupply = 0;
maxSupply = 2 * baseline; //2bn
conversionFactor = 1000;
currentEra = 1;
secondsPerEra = 1; //86400;
nextEraTime = block.timestamp + secondsPerEra;
emissionCurve = 10;
burnAddress = 0x0111011001100001011011000111010101100101;
DEPLOYER = msg.sender;
}

Expand Down
10 changes: 4 additions & 6 deletions contracts/Vether.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import "./interfaces/iVETHER.sol";
// Token Contract
contract Vether is iVETHER {
// Coin Defaults
string public override name; // Name of Coin
string public override symbol; // Symbol of Coin
uint256 public override decimals = 18; // Decimals
uint256 public override totalSupply = 1 * 10**6 * (10**decimals); // 1,000,000 Total
string public constant override name = "Vether"; // Name of Coin
string public constant override symbol = "VETH"; // Symbol of Coin
uint256 public constant override decimals = 18; // Decimals
uint256 public constant override totalSupply = 1 * 10**6 * (10**decimals); // 1,000,000 Total

uint256 public totalFees;
mapping(address => bool) public mapAddress_Excluded;
Expand All @@ -21,8 +21,6 @@ contract Vether is iVETHER {

// Minting event
constructor() {
name = "Vether";
symbol = "VETH";
_balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
Expand Down

0 comments on commit 2dacdc3

Please sign in to comment.