Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
SavixSupply
Compiler Version
v0.6.12+commit.27d51765
Contract Source Code (Solidity)
/**
*Submitted for verification at Etherscan.io on 2021-03-16
*/
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) public pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) public pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) public pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) public pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) public pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev savix interest and supply calculations.
*
*/
library SavixSupply {
uint256 public constant MAX_UINT256 = 2**256 - 1;
uint256 public constant MAX_UINT128 = 2**128 - 1;
uint public constant MINTIMEWIN = 7200; // 2 hours
uint public constant SECPERDAY = 3600 * 24;
uint public constant DECIMALS = 9;
struct SupplyWinBoundary
{
uint256 x1;
uint256 x2;
uint256 y1;
uint256 y2;
}
function getSupplyWindow(uint256[2][] memory map, uint256 calcTime) internal pure returns (SupplyWinBoundary memory)
{
SupplyWinBoundary memory winBound;
winBound.x1 = 0;
winBound.x2 = 0;
winBound.y1 = map[0][1];
winBound.y2 = 0;
for (uint i=0; i < map.length; i++)
{
if (map[i][0] == 0)
continue;
if (calcTime < map[i][0])
{
winBound.x2 = map[i][0];
winBound.y2 = map[i][1];
break;
}
else
{
winBound.x1 = map[i][0];
winBound.y1 = map[i][1];
}
}
if (winBound.x2 == 0) winBound.x2 = MAX_UINT128;
if (winBound.y2 == 0) winBound.y2 = MAX_UINT128;
return winBound;
}
// function to calculate new Supply with SafeMath for divisions only, shortest (cheapest) form
function getAdjustedSupply(uint256[2][] memory map, uint256 transactionTime, uint constGradient) internal pure returns (uint256)
{
if (transactionTime >= map[map.length-1][0])
{
// return (map[map.length-1][1] + constGradient * (SafeMath.sub(transactionTime, map[map.length-1][0]))); ** old version
return (map[map.length-1][1] + SafeMath.mul(constGradient, SafeMath.sub(transactionTime, map[map.length-1][0])));
}
SupplyWinBoundary memory winBound = getSupplyWindow(map, transactionTime);
// return (winBound.y1 + SafeMath.div(winBound.y2 - winBound.y1, winBound.x2 - winBound.x1) * (transactionTime - winBound.x1)); ** old version
return (winBound.y1 + SafeMath.div(SafeMath.mul(SafeMath.sub(winBound.y2, winBound.y1), SafeMath.sub(transactionTime, winBound.x1)), SafeMath.sub(winBound.x2, winBound.x1)));
}
function getDailyInterest(uint256 currentTime, uint256 lastAdjustTime, uint256 currentSupply, uint256 lastSupply) internal pure returns (uint)
{
if (currentTime <= lastAdjustTime)
{
return uint128(0);
}
// ** old version
// uint256 InterestSinceLastAdjust = SafeMath.div((currentSupply - lastSupply) * 100, lastSupply);
// return (SafeMath.div(InterestSinceLastAdjust * SECPERDAY, currentTime - lastAdjustTime));
return (SafeMath.div(SafeMath.sub(currentSupply, lastSupply) * 100 * 10**DECIMALS * SECPERDAY, SafeMath.mul(SafeMath.sub(currentTime, lastAdjustTime), lastSupply)));
}
// ** new method
// yearlyInterest rate is given in percent with 2 decimals => result has to be divede by 10**9 to get correct number with precision 2
function getYearlyInterest(uint256 currentTime, uint256 lastAdjustTime, uint256 currentSupply, uint256 lastSupply) internal pure returns (uint)
{
if (currentTime <= lastAdjustTime)
{
return uint128(0);
}
return (SafeMath.div(SafeMath.sub(currentSupply, lastSupply) * 100 * 10**DECIMALS * SECPERDAY * 360, SafeMath.mul(SafeMath.sub(currentTime, lastAdjustTime), lastSupply)));
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_UINT128","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_UINT256","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTIMEWIN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SECPERDAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
61017c610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100615760003560e01c80632e0f26251461006657806333a581d21461008457806352631aea146100a2578063587b75a3146100c0578063f472559d146100de575b600080fd5b61006e6100fc565b6040518082815260200191505060405180910390f35b61008c610101565b6040518082815260200191505060405180910390f35b6100aa610125565b6040518082815260200191505060405180910390f35b6100c8610139565b6040518082815260200191505060405180910390f35b6100e661013f565b6040518082815260200191505060405180910390f35b600981565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b6fffffffffffffffffffffffffffffffff81565b611c2081565b620151808156fea2646970667358221220e4d13c58364136971f6a15289dd99db25cf149fca970bc3cc6e4dfe57313140164736f6c634300060c0033
Deployed Bytecode
0x73cc3277446f0e0ca9b8dac67c780f68551828ad1b30146080604052600436106100615760003560e01c80632e0f26251461006657806333a581d21461008457806352631aea146100a2578063587b75a3146100c0578063f472559d146100de575b600080fd5b61006e6100fc565b6040518082815260200191505060405180910390f35b61008c610101565b6040518082815260200191505060405180910390f35b6100aa610125565b6040518082815260200191505060405180910390f35b6100c8610139565b6040518082815260200191505060405180910390f35b6100e661013f565b6040518082815260200191505060405180910390f35b600981565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b6fffffffffffffffffffffffffffffffff81565b611c2081565b620151808156fea2646970667358221220e4d13c58364136971f6a15289dd99db25cf149fca970bc3cc6e4dfe57313140164736f6c634300060c0033
Deployed Bytecode Sourcemap
5410:3619:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5659:33;;;:::i;:::-;;;;;;;;;;;;;;;;;;;5444:48;;;:::i;:::-;;;;;;;;;;;;;;;;;;;5499;;;:::i;:::-;;;;;;;;;;;;;;;;;;;5554:38;;;:::i;:::-;;;;;;;;;;;;;;;;;;;5610:42;;;:::i;:::-;;;;;;;;;;;;;;;;;;;5659:33;5691:1;5659:33;:::o;5444:48::-;5482:10;5444:48;:::o;5499:::-;5537:10;5499:48;:::o;5554:38::-;5588:4;5554:38;:::o;5610:42::-;5643:9;5610:42;:::o
Swarm Source
ipfs://e4d13c58364136971f6a15289dd99db25cf149fca970bc3cc6e4dfe573131401
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.