文件 1 的 5:Context.sol
pragma solidity ^0.6.0;
contract Context {
constructor () internal { }
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this;
return msg.data;
}
}
文件 2 的 5:ERC20.sol
pragma solidity ^0.6.0;
import "./Context.sol";
import "./SafeMath.sol";
contract ERC20 is Context {
using SafeMath for uint256;
mapping (address => uint256) public _balances;
mapping (address => mapping (address => uint256)) public _allowances;
uint256 public _totalSupply;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) virtual internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
}
文件 3 的 5:SafeMath.sol
pragma solidity ^0.6.0;
library SafeMath{
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
文件 4 的 5:Steam.sol
pragma solidity ^0.6.0;
import "./ERC20.sol";
contract Steam is ERC20 {
using SafeMath for uint256;
modifier onlyUPS() {
require(_UPS == _msgSender(), "onlyUPS: Only the UPStkn contract may call this function");
_;
}
string private _name;
address public _UPS;
string private _symbol;
uint8 private _decimals;
uint256 private _maxSupply;
uint256 private _steamMinted = 0;
event SteamGenerated(address account, uint amount);
constructor(uint256 STEAM_maxTokens) public {
_name = "STEAM";
_symbol = "STEAM";
_decimals = 18;
_maxSupply = STEAM_maxTokens.mul(1e18);
ERC20._mint(_msgSender(), 1e18);
_UPS = _msgSender();
}
function generateSteam(address account, uint256 amount) external onlyUPS {
require((_totalSupply + amount) < _maxSupply, "STEAM token: cannot generate more steam than the max supply");
ERC20._mint(account, amount);
_steamMinted = _steamMinted.add(amount);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view returns (uint256) {
return ERC20._totalSupply;
}
function mySteam(address _address) public view returns(uint256){
return balanceOf(_address);
}
function getSteamTotalSupply() public view returns(uint256){
return _totalSupply;
}
function getSteamMaxSupply() public view returns(uint256){
return _maxSupply;
}
function getSteamMinted() public view returns(uint256){
return _steamMinted;
}
}
文件 5 的 5:UpSwing.sol
pragma solidity ^0.6.0;
import "./Steam.sol";
import "./ERC20.sol";
interface IUNIv2 {
function sync() external;
}
contract UpSwing is ERC20 {
using SafeMath for uint256;
address private UNIv2;
mapping(address => bool) public allowed;
mapping(address => bool) public pauser;
modifier onlyAllowed() {
require(allowed[_msgSender()], "onlyAllowed");
_;
}
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _initialSupply;
uint256 private _UPSBurned = 0;
uint8 public leverage;
bool public paused = true;
mapping(address => uint256) sellPressure;
mapping(address => uint256) steamToGenerate;
mapping(address => uint256) txCount;
address _STEAM;
event BurnedFromLiquidityPool(address burnerAddress, uint amount);
event SteamGenerated(address steamRecipientddress, uint amount);
constructor(uint256 UPS_totalSupply) public {
_name = "UpSwing";
_symbol = "UPS";
_decimals = 18;
_initialSupply = UPS_totalSupply.mul(1e18);
ERC20._mint(_msgSender(), UPS_totalSupply.mul(1e18));
leverage = 200;
_STEAM = address(new Steam(UPS_totalSupply));
allowed[_msgSender()] = true;
pauser[_msgSender()] = true;
}
modifier onlyPauser() {
require(pauser[_msgSender()], "onlyPauser");
_;
}
function setPauser(address _address, bool _bool) public onlyAllowed {
pauser[_address] = _bool;
}
function togglePause(bool _bool) public onlyPauser {
paused = _bool;
}
modifier canSteam(address _address){
require(steamToGenerate[_address] > 0, "no Steam to generate");
_;
}
function _generateSteamFromUPSBurn(address _address) internal canSteam(_address){
uint256 _steam = steamToGenerate[_address];
steamToGenerate[_address] = 0;
Steam(_STEAM).generateSteam(_address, _steam);
}
function addToSteam(address _address, uint256 _amount) internal {
steamToGenerate[_address] = steamToGenerate[_address].add(_amount);
}
function amountPressure(uint256 amount) internal view returns(uint256){
uint256 UNI_SupplyRatio = (getUNIV2Liq().mul(1e18)).div(totalSupply());
UNI_SupplyRatio = UNI_SupplyRatio.mul(leverage).div(100);
return amount.mul(UNI_SupplyRatio).div(1e18);
}
function setAllowed(address _address, bool _bool) public onlyAllowed {
allowed[_address] = _bool;
}
function setUNIv2(address _address) public onlyAllowed {
UNIv2 = _address;
}
function setLeverage(uint8 _leverage) public onlyAllowed {
require(_leverage <= 1000 && _leverage >= 0);
leverage = _leverage;
}
function myPressure(address _address) public view returns(uint256){
return amountPressure(sellPressure[_address]);
}
function releasePressure(address _address) internal {
uint256 amount = myPressure(_address);
if(amount < balanceOf(UNIv2)) {
require(_totalSupply.sub(amount) >= _initialSupply.div(1000), "There is less than 0.1% of the Maximum Supply remaining, unfortunately, kabooming is over");
sellPressure[_address] = 0;
addToSteam(_address, amount);
ERC20._burn(UNIv2, amount);
_UPSBurned = _UPSBurned.add(amount);
emit BurnedFromLiquidityPool(_address, amount);
_generateSteamFromUPSBurn(_address);
emit SteamGenerated(_address, amount);
txCount[_address] = 0;
} else if (amount > 0) {
sellPressure[_address] = sellPressure[_address].div(2);
}
IUNIv2(UNIv2).sync();
}
function UPSMath(uint256 n) internal pure returns(uint256){
uint _t = n*n + 1;
_t = 1e10/(_t);
return (92*_t)/100;
}
function _transfer(address sender, address recipient, uint256 amount) internal override{
require(!paused || pauser[sender], "UPStkn: You must wait until UniSwap listing to transfer");
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
ERC20._balances[sender] = ERC20._balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
ERC20._balances[recipient] = ERC20._balances[recipient].add(amount);
if(recipient == UNIv2){
txCount[sender] = txCount[sender]+1;
amount = amount.mul(UPSMath(txCount[sender])).div(1e10);
sellPressure[sender] = sellPressure[sender].add(amount);
}
if(sender == recipient && amount == 0){releasePressure(sender);}
emit Transfer(sender, recipient, amount);
}
function burn(uint256 amount) public {
_burn(_msgSender(), amount);
}
function mySteam(address _address) public view returns(uint256){
return steamToGenerate[_address];
}
function getUNIV2Address() public view returns (address) {
return UNIv2;
}
function getUNIV2Liq() public view returns (uint256) {
return balanceOf(UNIv2);
}
function getUPSTotalSupply() public view returns(uint256){
return _totalSupply;
}
function getUPSBurned() public view returns(uint256){
return _UPSBurned;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view returns (uint256) {
return ERC20._totalSupply;
}
}
{
"compilationTarget": {
"browser/UpSwing.sol": "UpSwing"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"UPS_totalSupply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"burnerAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BurnedFromLiquidityPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"steamRecipientddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SteamGenerated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"_allowances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getUNIV2Address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUNIV2Liq","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUPSBurned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUPSTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"leverage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"myPressure","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"mySteam","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pauser","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"_bool","type":"bool"}],"name":"setAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_leverage","type":"uint8"}],"name":"setLeverage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"_bool","type":"bool"}],"name":"setPauser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"setUNIv2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_bool","type":"bool"}],"name":"togglePause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]